From 40f62aa13e611c6e5ceee905ce8f227b95230eb4 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Tue, 9 Apr 2024 14:34:13 -0500 Subject: [PATCH] GUI: re-enable user presets option --- TODO.md | 1 - src/gui/editControls.cpp | 4 ++++ src/gui/gui.cpp | 2 -- src/gui/gui.h | 3 +++ src/gui/presets.cpp | 22 ++++++++++++++++++++-- 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/TODO.md b/TODO.md index fec70c993..f8a0e67de 100644 --- a/TODO.md +++ b/TODO.md @@ -1,6 +1,5 @@ # to-do for 0.6.3 -- compress fonts further if possible - 9xxx for more chips - user presets diff --git a/src/gui/editControls.cpp b/src/gui/editControls.cpp index e17061d37..b86f1f983 100644 --- a/src/gui/editControls.cpp +++ b/src/gui/editControls.cpp @@ -595,6 +595,10 @@ void FurnaceGUI::drawMobileControls() { if (ImGui::Button("CV")) { cvOpen=!cvOpen; } + ImGui::SameLine(); + if (ImGui::Button("Presets")) { + userPresetsOpen=!userPresetsOpen; + } ImGui::Separator(); diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index b9fc71043..1a24bccba 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -4391,11 +4391,9 @@ bool FurnaceGUI::loop() { toggleMobileUI(!mobileUI); } #endif - /* if (ImGui::MenuItem("manage presets...",BIND_FOR(GUI_ACTION_WINDOW_USER_PRESETS))) { userPresetsOpen=true; } - */ if (ImGui::MenuItem("settings...",BIND_FOR(GUI_ACTION_WINDOW_SETTINGS))) { syncSettings(); settingsOpen=true; diff --git a/src/gui/gui.h b/src/gui/gui.h index bd286e6c9..ebd9660e0 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -2527,6 +2527,8 @@ class FurnaceGUI { // user presets window int selectedUserPreset; + std::vector selectedUserPresetSub; + std::vector randomDemoSong; void drawExportAudio(bool onWindow=false); @@ -2610,6 +2612,7 @@ class FurnaceGUI { void sampleListItem(int index, int dir, int asset); void drawSysDefs(std::vector& category, bool& accepted, std::vector& sysDefStack); + void printPresets(std::vector& items, int depth); void toggleMobileUI(bool enable, bool force=false); diff --git a/src/gui/presets.cpp b/src/gui/presets.cpp index 9849e0ec6..aa4f98b19 100644 --- a/src/gui/presets.cpp +++ b/src/gui/presets.cpp @@ -2430,10 +2430,8 @@ void FurnaceGUI::initSystemPresets() { ); CATEGORY_END; - /* CATEGORY_BEGIN("User","system presets that you have saved."); CATEGORY_END; - */ CATEGORY_BEGIN("FM","chips which use frequency modulation (FM) to generate sound.\nsome of these also pack more (like square and sample channels)."); ENTRY( @@ -3398,6 +3396,19 @@ bool FurnaceGUI::saveUserPresets(bool redundancy) { } // user presets management +void FurnaceGUI::printPresets(std::vector& items, int depth) { + if (depth>0) ImGui::Indent(); + for (FurnaceGUISysDef& i: items) { + if (ImGui::Selectable(i.name.c_str())) { + // TODO + } + if (!i.subDefs.empty()) { + printPresets(i.subDefs,depth+1); + } + } + if (depth>0) ImGui::Unindent(); +} + void FurnaceGUI::drawUserPresets() { if (nextWindow==GUI_WINDOW_USER_PRESETS) { userPresetsOpen=true; @@ -3414,16 +3425,23 @@ void FurnaceGUI::drawUserPresets() { } } + //std::vector depthStack; + if (userCategory==NULL) { ImGui::Text("Error! User category does not exist!"); } else if (ImGui::BeginTable("UserPresets",2,ImGuiTableFlags_BordersInnerV)) { + // preset list ImGui::TableNextRow(); ImGui::TableNextColumn(); ImGui::Text("Presets..."); + printPresets(userCategory->systems,0); + + // editor ImGui::TableNextColumn(); if (selectedUserPreset<0 || selectedUserPreset>=(int)userCategory->systems.size()) { ImGui::Text("select a preset"); } else { + ImGui::Text("Edit..."); }