From ad19a69f279cf9ed5ef53a5d98473d4b4a42f254 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Tue, 8 Mar 2022 13:12:20 -0500 Subject: [PATCH 1/6] GUI: improvements to OPL ins edit --- src/gui/insEdit.cpp | 46 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/src/gui/insEdit.cpp b/src/gui/insEdit.cpp index d51db3edf..4bb9ce543 100644 --- a/src/gui/insEdit.cpp +++ b/src/gui/insEdit.cpp @@ -84,6 +84,10 @@ const char* opllInsNames[17]={ "Drums" }; +const char* oplWaveforms[8]={ + "Sine", "Half Sine", "Absolute Sine", "Quarter Sine", "Squished Sine", "Squished AbsSine", "Square", "Derived Square" +}; + enum FMParams { FM_ALG=0, FM_FB=1, @@ -819,13 +823,19 @@ void FurnaceGUI::drawInsEdit() { break; case DIV_INS_OPL: { bool fourOp=(ins->fm.ops==4); + bool drums=ins->fm.opllPreset==16; + int algMax=fourOp?3:1; ImGui::TableNextColumn(); + ins->fm.alg&=algMax; P(ImGui::SliderScalar(FM_NAME(FM_FB),ImGuiDataType_U8,&ins->fm.fb,&_ZERO,&_SEVEN)); rightClickable if (ImGui::Checkbox("4-op",&fourOp)) { PARAMETER ins->fm.ops=fourOp?4:2; } ImGui::TableNextColumn(); - P(ImGui::SliderScalar(FM_NAME(FM_ALG),ImGuiDataType_U8,&ins->fm.alg,&_ZERO,&_SEVEN)); rightClickable + P(ImGui::SliderScalar(FM_NAME(FM_ALG),ImGuiDataType_U8,&ins->fm.alg,&_ZERO,&algMax)); rightClickable + if (ImGui::Checkbox("Drums",&drums)) { PARAMETER + ins->fm.opllPreset=drums?16:0; + } ImGui::TableNextColumn(); drawAlgorithm(ins->fm.alg&1,FM_ALGS_2OP_OPL,ImVec2(ImGui::GetContentRegionAvail().x,48.0*dpiScale)); break; @@ -977,18 +987,30 @@ void FurnaceGUI::drawInsEdit() { maxTl=63; } } + if (ins->type==DIV_INS_OPL) { + maxTl=63; + } int maxArDr=(ins->type==DIV_INS_FM || ins->type==DIV_INS_OPZ)?31:15; bool ssgOn=op.ssgEnv&8; bool ksrOn=op.ksr; bool vibOn=op.vib; + bool susOn=op.sus; // don't you make fun of this one unsigned char ssgEnv=op.ssgEnv&7; - if (ImGui::Checkbox((ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPLL)?FM_NAME(FM_EGS):"SSG On",&ssgOn)) { PARAMETER - op.ssgEnv=(op.ssgEnv&7)|(ssgOn<<3); + if (ins->type!=DIV_INS_OPL && ins->type!=DIV_INS_OPZ) { + if (ImGui::Checkbox((ins->type==DIV_INS_OPLL)?FM_NAME(FM_EGS):"SSG On",&ssgOn)) { PARAMETER + op.ssgEnv=(op.ssgEnv&7)|(ssgOn<<3); + } + if (ins->type==DIV_INS_FM) { + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("Only for Genesis and Neo Geo systems"); + } + } } - if (ins->type==DIV_INS_FM) { - if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("Only for Genesis and Neo Geo systems"); + + if (ins->type==DIV_INS_OPL) { + if (ImGui::Checkbox(FM_NAME(FM_SUS),&susOn)) { PARAMETER + op.sus=susOn; } } @@ -1102,6 +1124,18 @@ void FurnaceGUI::drawInsEdit() { ImGui::TableNextColumn(); ImGui::Text("%s",FM_NAME(FM_SSG)); } + + if (ins->type==DIV_INS_OPL) { + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + P(ImGui::SliderScalar("##WS",ImGuiDataType_U8,&op.ws,&_ZERO,&_SEVEN,oplWaveforms[op.ws&7])); rightClickable + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("OPL2/3 only (last 4 waveforms are OPL3 only)"); + } + ImGui::TableNextColumn(); + ImGui::Text("%s",FM_NAME(FM_WS)); + } ImGui::EndTable(); } From 42a3391574dd7365692df7c5d381d46512c43735 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Tue, 8 Mar 2022 13:46:48 -0500 Subject: [PATCH 2/6] GUI: add OPZ waveforms --- src/gui/insEdit.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/gui/insEdit.cpp b/src/gui/insEdit.cpp index 4bb9ce543..274fed360 100644 --- a/src/gui/insEdit.cpp +++ b/src/gui/insEdit.cpp @@ -88,6 +88,10 @@ const char* oplWaveforms[8]={ "Sine", "Half Sine", "Absolute Sine", "Quarter Sine", "Squished Sine", "Squished AbsSine", "Square", "Derived Square" }; +const char* opzWaveforms[8]={ + "Sine", "Triangle", "Cut Sine", "Cut Triangle", "Squished Sine", "Squished Triangle" "Squished AbsSine", "Squished AbsTriangle" +}; + enum FMParams { FM_ALG=0, FM_FB=1, @@ -1125,12 +1129,12 @@ void FurnaceGUI::drawInsEdit() { ImGui::Text("%s",FM_NAME(FM_SSG)); } - if (ins->type==DIV_INS_OPL) { + if (ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPZ) { ImGui::TableNextRow(); ImGui::TableNextColumn(); ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); - P(ImGui::SliderScalar("##WS",ImGuiDataType_U8,&op.ws,&_ZERO,&_SEVEN,oplWaveforms[op.ws&7])); rightClickable - if (ImGui::IsItemHovered()) { + P(ImGui::SliderScalar("##WS",ImGuiDataType_U8,&op.ws,&_ZERO,&_SEVEN,(ins->type==DIV_INS_OPZ)?opzWaveforms[op.ws&7]:oplWaveforms[op.ws&7])); rightClickable + if (ins->type==DIV_INS_OPL && ImGui::IsItemHovered()) { ImGui::SetTooltip("OPL2/3 only (last 4 waveforms are OPL3 only)"); } ImGui::TableNextColumn(); From 698b8e960fa21e0b3e9b743ba507efa53b391ae7 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Tue, 8 Mar 2022 14:20:21 -0500 Subject: [PATCH 3/6] I must be blind --- src/gui/insEdit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/insEdit.cpp b/src/gui/insEdit.cpp index 274fed360..aaab3f644 100644 --- a/src/gui/insEdit.cpp +++ b/src/gui/insEdit.cpp @@ -89,7 +89,7 @@ const char* oplWaveforms[8]={ }; const char* opzWaveforms[8]={ - "Sine", "Triangle", "Cut Sine", "Cut Triangle", "Squished Sine", "Squished Triangle" "Squished AbsSine", "Squished AbsTriangle" + "Sine", "Triangle", "Cut Sine", "Cut Triangle", "Squished Sine", "Squished Triangle", "Squished AbsSine", "Squished AbsTriangle" }; enum FMParams { From 9e080956ec692aa7685feb7b0d06ea7a26666e21 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Tue, 8 Mar 2022 18:26:41 -0500 Subject: [PATCH 4/6] prepare to add a right click menu to pattern DO NOT USE IF YOU WANT TO SOLO CHANNELS - I'LL FIX IT when I come back --- src/gui/pattern.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/gui/pattern.cpp b/src/gui/pattern.cpp index 2eabcd04b..20f8975f5 100644 --- a/src/gui/pattern.cpp +++ b/src/gui/pattern.cpp @@ -807,6 +807,24 @@ void FurnaceGUI::drawPattern() { ImGui::PopFont(); } ImGui::PopStyleVar(); + if (patternOpen) if (ImGui::BeginPopupContextItem("furnace quit unexpectedly.")) { + char id[4096]; + ImGui::Selectable("cut"); + ImGui::Selectable("copy"); + ImGui::Selectable("paste"); + if (ImGui::BeginMenu("change instrument...")) { + if (e->song.ins.empty()) { + ImGui::Text("no instruments available"); + } + for (size_t i=0; isong.ins.size(); i++) { + snprintf(id,4095,"%.2lX: %s",i,e->song.ins[i]->name.c_str()); + if (ImGui::Selectable(id)) { // TODO + } + } + ImGui::EndMenu(); + } + ImGui::EndPopup(); + } if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_PATTERN; ImGui::End(); } From 1a3eed7830e5f32eb534562d3737ac884cefb31c Mon Sep 17 00:00:00 2001 From: tildearrow Date: Wed, 9 Mar 2022 02:30:36 -0500 Subject: [PATCH 5/6] fix MinGW build --- src/gui/pattern.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/pattern.cpp b/src/gui/pattern.cpp index 20f8975f5..8b124bfc0 100644 --- a/src/gui/pattern.cpp +++ b/src/gui/pattern.cpp @@ -817,7 +817,7 @@ void FurnaceGUI::drawPattern() { ImGui::Text("no instruments available"); } for (size_t i=0; isong.ins.size(); i++) { - snprintf(id,4095,"%.2lX: %s",i,e->song.ins[i]->name.c_str()); + snprintf(id,4095,"%.2X: %s",(int)i,e->song.ins[i]->name.c_str()); if (ImGui::Selectable(id)) { // TODO } } From 372f2a20a2d46dfd76c7c1c4b8b44105c35cd760 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Wed, 9 Mar 2022 03:40:24 -0500 Subject: [PATCH 6/6] GUI: much better --- src/gui/pattern.cpp | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/gui/pattern.cpp b/src/gui/pattern.cpp index 8b124bfc0..9bf6eee59 100644 --- a/src/gui/pattern.cpp +++ b/src/gui/pattern.cpp @@ -332,6 +332,7 @@ void FurnaceGUI::drawPattern() { } if (!patternOpen) return; + bool inhibitMenu=false; float scrollX=0; if (e->isPlaying() && followPattern) cursor.y=oldRow; @@ -411,6 +412,7 @@ void FurnaceGUI::drawPattern() { } if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) { fancyPattern=!fancyPattern; + inhibitMenu=true; e->enableCommandStream(fancyPattern); e->getCommandStream(cmdStream); cmdStream.clear(); @@ -481,6 +483,7 @@ void FurnaceGUI::drawPattern() { if (muted) ImGui::PopStyleColor(); ImGui::PopStyleColor(3); if (settings.soloAction!=2) if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) { + inhibitMenu=true; e->toggleSolo(i); } if (extraChannelButtons==2) { @@ -807,23 +810,26 @@ void FurnaceGUI::drawPattern() { ImGui::PopFont(); } ImGui::PopStyleVar(); - if (patternOpen) if (ImGui::BeginPopupContextItem("furnace quit unexpectedly.")) { - char id[4096]; - ImGui::Selectable("cut"); - ImGui::Selectable("copy"); - ImGui::Selectable("paste"); - if (ImGui::BeginMenu("change instrument...")) { - if (e->song.ins.empty()) { - ImGui::Text("no instruments available"); - } - for (size_t i=0; isong.ins.size(); i++) { - snprintf(id,4095,"%.2X: %s",(int)i,e->song.ins[i]->name.c_str()); - if (ImGui::Selectable(id)) { // TODO + if (patternOpen) { + if (!inhibitMenu && ImGui::IsItemClicked(ImGuiMouseButton_Right)) ImGui::OpenPopup("patternActionMenu"); + if (ImGui::BeginPopup("patternActionMenu",ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings)) { + char id[4096]; + ImGui::Selectable("cut"); + ImGui::Selectable("copy"); + ImGui::Selectable("paste"); + if (ImGui::BeginMenu("change instrument...")) { + if (e->song.ins.empty()) { + ImGui::Text("no instruments available"); } + for (size_t i=0; isong.ins.size(); i++) { + snprintf(id,4095,"%.2X: %s",(int)i,e->song.ins[i]->name.c_str()); + if (ImGui::Selectable(id)) { // TODO + } + } + ImGui::EndMenu(); } - ImGui::EndMenu(); + ImGui::EndPopup(); } - ImGui::EndPopup(); } if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_PATTERN; ImGui::End();