From 2c3bacbd3b0c936ff562805e1cc92baec49d6739 Mon Sep 17 00:00:00 2001 From: Eknous-P Date: Sat, 29 Jul 2023 11:07:20 +0400 Subject: [PATCH] colored text, arrays instead of many vars --- src/gui/effectList.cpp | 56 ++++++++++++------------------------------ src/gui/gui.cpp | 12 ++------- src/gui/gui.h | 2 +- src/gui/guiConst.cpp | 26 ++++++++++++++++++++ src/gui/guiConst.h | 4 ++- 5 files changed, 48 insertions(+), 52 deletions(-) diff --git a/src/gui/effectList.cpp b/src/gui/effectList.cpp index 8dd0b327a..4da92c29d 100644 --- a/src/gui/effectList.cpp +++ b/src/gui/effectList.cpp @@ -14,39 +14,15 @@ void FurnaceGUI::drawEffectList() { ImGui::Text("Chip at cursor: %s",e->getSystemName(e->sysOfChan[cursor.xCoarse])); if (ImGui::Button("Sort Effects")) ImGui::OpenPopup("effectSort"); if (ImGui::BeginPopupContextItem("effectSort")) { - ImGui::Checkbox("Pitch",&effectShowPitch); - ImGui::Checkbox("Song",&effectShowSong); - ImGui::Checkbox("Time",&effectShowTime); - ImGui::Checkbox("Speed",&effectShowSpeed); - ImGui::Checkbox("Panning",&effectShowPanning); - ImGui::Checkbox("Volume",&effectShowVolume); - ImGui::Checkbox("System (primary)",&effectShowSysPrimary); - ImGui::Checkbox("System (secondary)",&effectShowSysSecondary); - ImGui::Checkbox("Miscellaneous",&effectShowMisc); + for (int i=0; i<9; i++) { + ImGui::PushStyleColor(ImGuiCol_Text,uiColors[fxColorsSort[i]]); + ImGui::Checkbox(fxColorsNames[i],&effectsShow[i]); + ImGui::PopStyleColor(); + } - if (ImGui::Button("All")) { - effectShowMisc = true; - effectShowPanning = true; - effectShowPitch = true; - effectShowVolume = true; - effectShowSong = true; - effectShowTime = true; - effectShowSpeed = true; - effectShowSysPrimary = true; - effectShowSysSecondary = true; - } + if (ImGui::Button("All")) memset(effectsShow,1,sizeof(bool)*10); ImGui::SameLine(); - if (ImGui::Button("None")) { - effectShowMisc = false; - effectShowPanning = false; - effectShowPitch = false; - effectShowVolume = false; - effectShowSong = false; - effectShowTime = false; - effectShowSpeed = false; - effectShowSysPrimary = false; - effectShowSysSecondary = false; - } + if (ImGui::Button("None")) memset(effectsShow,0,sizeof(bool)*10); ImGui::EndPopup(); } @@ -70,15 +46,15 @@ void FurnaceGUI::drawEffectList() { } prevName=name; switch (fxColors[i]) { - case GUI_COLOR_PATTERN_EFFECT_MISC: effectShow = effectShowMisc; break; - case GUI_COLOR_PATTERN_EFFECT_SONG: effectShow = effectShowSong; break; - case GUI_COLOR_PATTERN_EFFECT_SPEED: effectShow = effectShowSpeed; break; - case GUI_COLOR_PATTERN_EFFECT_TIME: effectShow = effectShowTime; break; - case GUI_COLOR_PATTERN_EFFECT_PITCH: effectShow = effectShowPitch; break; - case GUI_COLOR_PATTERN_EFFECT_PANNING: effectShow = effectShowPanning; break; - case GUI_COLOR_PATTERN_EFFECT_VOLUME: effectShow = effectShowVolume; break; - case GUI_COLOR_PATTERN_EFFECT_SYS_PRIMARY: effectShow = effectShowSysPrimary; break; - case GUI_COLOR_PATTERN_EFFECT_SYS_SECONDARY: effectShow = effectShowSysSecondary; break; + case GUI_COLOR_PATTERN_EFFECT_MISC: effectShow = effectsShow[8]; break; + case GUI_COLOR_PATTERN_EFFECT_SONG: effectShow = effectsShow[1]; break; + case GUI_COLOR_PATTERN_EFFECT_SPEED: effectShow = effectsShow[3]; break; + case GUI_COLOR_PATTERN_EFFECT_TIME: effectShow = effectsShow[2]; break; + case GUI_COLOR_PATTERN_EFFECT_PITCH: effectShow = effectsShow[0]; break; + case GUI_COLOR_PATTERN_EFFECT_PANNING: effectShow = effectsShow[4]; break; + case GUI_COLOR_PATTERN_EFFECT_VOLUME: effectShow = effectsShow[5]; break; + case GUI_COLOR_PATTERN_EFFECT_SYS_PRIMARY: effectShow = effectsShow[6]; break; + case GUI_COLOR_PATTERN_EFFECT_SYS_SECONDARY: effectShow = effectsShow[7]; break; default: effectShow = true; break; } if (name!=NULL && effectShow) { diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 0883dce3f..4986cdfb4 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -7134,16 +7134,6 @@ FurnaceGUI::FurnaceGUI(): pianoView(PIANO_LAYOUT_STANDARD), pianoInputPadMode(PIANO_INPUT_PAD_DISABLE), #endif - //effect sorting - effectShowPitch(true), - effectShowVolume(true), - effectShowPanning(true), - effectShowSong(true), - effectShowTime(true), - effectShowSpeed(true), - effectShowSysPrimary(true), - effectShowSysSecondary(true), - effectShowMisc(true), hasACED(false), waveGenBaseShape(0), waveInterpolation(0), @@ -7279,6 +7269,8 @@ FurnaceGUI::FurnaceGUI(): memset(macroRelLabel,0,32); memset(emptyLabel,0,32); memset(emptyLabel2,0,32); + //effect sorting + memset(effectsShow,1,sizeof(bool)*10); strncpy(noteOffLabel,"OFF",32); strncpy(noteRelLabel,"===",32); diff --git a/src/gui/gui.h b/src/gui/gui.h index 65b1cc293..7d3e4cb5b 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -2031,7 +2031,7 @@ class FurnaceGUI { int pianoView, pianoInputPadMode; //effect sorting - bool effectShowPitch, effectShowVolume, effectShowPanning, effectShowSong, effectShowTime, effectShowSpeed, effectShowSysPrimary, effectShowSysSecondary, effectShowMisc; + bool effectsShow[10]; // TX81Z bool hasACED; diff --git a/src/gui/guiConst.cpp b/src/gui/guiConst.cpp index 09fe601d4..c1446ac6f 100644 --- a/src/gui/guiConst.cpp +++ b/src/gui/guiConst.cpp @@ -208,6 +208,32 @@ const char* resampleStrats[]={ "best possible" }; +const FurnaceGUIColors fxColorsSort[]={//used for sorting + GUI_COLOR_PATTERN_EFFECT_PITCH, + GUI_COLOR_PATTERN_EFFECT_SONG, + GUI_COLOR_PATTERN_EFFECT_TIME, + GUI_COLOR_PATTERN_EFFECT_SPEED, + GUI_COLOR_PATTERN_EFFECT_PANNING, + GUI_COLOR_PATTERN_EFFECT_VOLUME, + GUI_COLOR_PATTERN_EFFECT_SYS_PRIMARY, + GUI_COLOR_PATTERN_EFFECT_SYS_SECONDARY, + GUI_COLOR_PATTERN_EFFECT_MISC, + GUI_COLOR_PATTERN_EFFECT_INVALID +}; + +const char* fxColorsNames[]={ + "Pitch", + "Song", + "Time", + "Speed", + "Panning", + "Volume", + "System Primary", + "System Secondary", + "Miscellaneous", + "Invalid" +}; + const FurnaceGUIColors fxColors[256]={ GUI_COLOR_PATTERN_EFFECT_MISC, // 00 GUI_COLOR_PATTERN_EFFECT_PITCH, // 01 diff --git a/src/gui/guiConst.h b/src/gui/guiConst.h index 494ba58dc..616692de5 100644 --- a/src/gui/guiConst.h +++ b/src/gui/guiConst.h @@ -57,4 +57,6 @@ extern const FurnaceGUIActionDef guiActions[]; extern const FurnaceGUIColorDef guiColors[]; extern const int altValues[24]; extern const int vgmVersions[7]; -extern const FurnaceGUIColors fxColors[256]; \ No newline at end of file +extern const FurnaceGUIColors fxColors[256]; +extern const FurnaceGUIColors fxColorsSort[10]; +extern const char* fxColorsNames[10]; \ No newline at end of file