GUI: user presets, part 1
This commit is contained in:
parent
ce4432175d
commit
6d8e6a9a55
|
|
@ -7876,8 +7876,7 @@ FurnaceGUI::FurnaceGUI():
|
||||||
curTutorialStep(0),
|
curTutorialStep(0),
|
||||||
audioExportType(0),
|
audioExportType(0),
|
||||||
dmfExportVersion(0),
|
dmfExportVersion(0),
|
||||||
curExportType(GUI_EXPORT_NONE),
|
curExportType(GUI_EXPORT_NONE) {
|
||||||
selectedUserPreset(-1) {
|
|
||||||
// value keys
|
// value keys
|
||||||
valueKeys[SDLK_0]=0;
|
valueKeys[SDLK_0]=0;
|
||||||
valueKeys[SDLK_1]=1;
|
valueKeys[SDLK_1]=1;
|
||||||
|
|
|
||||||
|
|
@ -2526,8 +2526,7 @@ class FurnaceGUI {
|
||||||
FurnaceGUIExportTypes curExportType;
|
FurnaceGUIExportTypes curExportType;
|
||||||
|
|
||||||
// user presets window
|
// user presets window
|
||||||
int selectedUserPreset;
|
std::vector<int> selectedUserPreset;
|
||||||
std::vector<int> selectedUserPresetSub;
|
|
||||||
|
|
||||||
std::vector<String> randomDemoSong;
|
std::vector<String> randomDemoSong;
|
||||||
|
|
||||||
|
|
@ -2612,7 +2611,8 @@ class FurnaceGUI {
|
||||||
void sampleListItem(int index, int dir, int asset);
|
void sampleListItem(int index, int dir, int asset);
|
||||||
|
|
||||||
void drawSysDefs(std::vector<FurnaceGUISysDef>& category, bool& accepted, std::vector<int>& sysDefStack);
|
void drawSysDefs(std::vector<FurnaceGUISysDef>& category, bool& accepted, std::vector<int>& sysDefStack);
|
||||||
void printPresets(std::vector<FurnaceGUISysDef>& items, int depth);
|
void printPresets(std::vector<FurnaceGUISysDef>& items, size_t depth, std::vector<int>& depthStack);
|
||||||
|
FurnaceGUISysDef* selectPreset(std::vector<FurnaceGUISysDef>& items);
|
||||||
|
|
||||||
void toggleMobileUI(bool enable, bool force=false);
|
void toggleMobileUI(bool enable, bool force=false);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,9 @@
|
||||||
#include "../baseutils.h"
|
#include "../baseutils.h"
|
||||||
#include "../fileutils.h"
|
#include "../fileutils.h"
|
||||||
#include <fmt/printf.h>
|
#include <fmt/printf.h>
|
||||||
|
#include "IconsFontAwesome4.h"
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
|
#include "misc/cpp/imgui_stdlib.h"
|
||||||
|
|
||||||
// add system configurations here.
|
// add system configurations here.
|
||||||
// every entry is written in the following format:
|
// every entry is written in the following format:
|
||||||
|
|
@ -3396,19 +3398,56 @@ bool FurnaceGUI::saveUserPresets(bool redundancy) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// user presets management
|
// user presets management
|
||||||
void FurnaceGUI::printPresets(std::vector<FurnaceGUISysDef>& items, int depth) {
|
void FurnaceGUI::printPresets(std::vector<FurnaceGUISysDef>& items, size_t depth, std::vector<int>& depthStack) {
|
||||||
if (depth>0) ImGui::Indent();
|
if (depth>0) ImGui::Indent();
|
||||||
|
int index=0;
|
||||||
for (FurnaceGUISysDef& i: items) {
|
for (FurnaceGUISysDef& i: items) {
|
||||||
if (ImGui::Selectable(i.name.c_str())) {
|
bool isSelected=(selectedUserPreset.size()==(depth+1));
|
||||||
// TODO
|
if (isSelected) {
|
||||||
|
for (size_t j=0; j<=depth; j++) {
|
||||||
|
int item=-1;
|
||||||
|
if (j>=depthStack.size()) {
|
||||||
|
item=index;
|
||||||
|
} else {
|
||||||
|
item=depthStack[j];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selectedUserPreset[j]!=item) {
|
||||||
|
isSelected=false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
ImGui::PushID(index+1);
|
||||||
|
if (ImGui::Selectable(i.name.c_str(),isSelected)) {
|
||||||
|
selectedUserPreset=depthStack;
|
||||||
|
selectedUserPreset.push_back(index);
|
||||||
|
}
|
||||||
|
ImGui::PopID();
|
||||||
if (!i.subDefs.empty()) {
|
if (!i.subDefs.empty()) {
|
||||||
printPresets(i.subDefs,depth+1);
|
depthStack.push_back(index);
|
||||||
|
ImGui::PushID(index);
|
||||||
|
printPresets(i.subDefs,depth+1,depthStack);
|
||||||
|
ImGui::PopID();
|
||||||
|
depthStack.pop_back();
|
||||||
}
|
}
|
||||||
|
index++;
|
||||||
}
|
}
|
||||||
if (depth>0) ImGui::Unindent();
|
if (depth>0) ImGui::Unindent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FurnaceGUISysDef* FurnaceGUI::selectPreset(std::vector<FurnaceGUISysDef>& items) {
|
||||||
|
FurnaceGUISysDef* ret=NULL;
|
||||||
|
for (size_t i=0; i<selectedUserPreset.size(); i++) {
|
||||||
|
if (selectedUserPreset[i]<0 || selectedUserPreset[i]>(int)items.size()) return NULL;
|
||||||
|
ret=&items[selectedUserPreset[i]];
|
||||||
|
if (i<selectedUserPreset.size()-1) {
|
||||||
|
items=ret->subDefs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void FurnaceGUI::drawUserPresets() {
|
void FurnaceGUI::drawUserPresets() {
|
||||||
if (nextWindow==GUI_WINDOW_USER_PRESETS) {
|
if (nextWindow==GUI_WINDOW_USER_PRESETS) {
|
||||||
userPresetsOpen=true;
|
userPresetsOpen=true;
|
||||||
|
|
@ -3425,7 +3464,7 @@ void FurnaceGUI::drawUserPresets() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//std::vector<int> depthStack;
|
std::vector<int> depthStack;
|
||||||
|
|
||||||
if (userCategory==NULL) {
|
if (userCategory==NULL) {
|
||||||
ImGui::Text("Error! User category does not exist!");
|
ImGui::Text("Error! User category does not exist!");
|
||||||
|
|
@ -3433,16 +3472,29 @@ void FurnaceGUI::drawUserPresets() {
|
||||||
// preset list
|
// preset list
|
||||||
ImGui::TableNextRow();
|
ImGui::TableNextRow();
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::Text("Presets...");
|
if (ImGui::Button(ICON_FA_PLUS "##AddPreset")) {
|
||||||
printPresets(userCategory->systems,0);
|
userCategory->systems.push_back(FurnaceGUISysDef("New Preset",{}));
|
||||||
|
selectedUserPreset.clear();
|
||||||
|
selectedUserPreset.push_back(userCategory->systems.size()-1);
|
||||||
|
}
|
||||||
|
printPresets(userCategory->systems,0,depthStack);
|
||||||
|
|
||||||
// editor
|
// editor
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
if (selectedUserPreset<0 || selectedUserPreset>=(int)userCategory->systems.size()) {
|
if (selectedUserPreset.empty()) {
|
||||||
ImGui::Text("select a preset");
|
ImGui::Text("select a preset");
|
||||||
} else {
|
} else {
|
||||||
|
FurnaceGUISysDef* preset=selectPreset(userCategory->systems);
|
||||||
ImGui::Text("Edit...");
|
|
||||||
|
if (preset!=NULL) {
|
||||||
|
ImGui::AlignTextToFramePadding();
|
||||||
|
ImGui::Text("Name");
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
|
||||||
|
ImGui::InputText("##PName",&preset->name);
|
||||||
|
ImGui::Separator();
|
||||||
|
ImGui::Text("the rest...");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue