GUI: user presets, part 6
This commit is contained in:
parent
801e0e4b21
commit
8743ea9a6e
|
@ -335,124 +335,165 @@ void FurnaceGUI::drawUserPresets() {
|
||||||
|
|
||||||
if (userCategory==NULL) {
|
if (userCategory==NULL) {
|
||||||
ImGui::Text("Error! User category does not exist!");
|
ImGui::Text("Error! User category does not exist!");
|
||||||
} else if (ImGui::BeginTable("UserPresets",2,ImGuiTableFlags_BordersInnerV)) {
|
} else if (ImGui::BeginTable("UserPresets",2,ImGuiTableFlags_BordersInnerV,ImVec2(ImGui::GetContentRegionAvail().x,ImGui::GetContentRegionAvail().y-ImGui::GetFrameHeightWithSpacing()))) {
|
||||||
ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthStretch,0.25f);
|
ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthStretch,0.25f);
|
||||||
ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthStretch,0.75f);
|
ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthStretch,0.75f);
|
||||||
// preset list
|
// preset list
|
||||||
ImGui::TableNextRow();
|
ImGui::TableNextRow();
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
if (ImGui::Button(ICON_FA_PLUS "##AddPreset")) {
|
if (ImGui::BeginChild("UList",ImVec2(ImGui::GetContentRegionAvail().x,ImGui::GetContentRegionAvail().y-ImGui::GetFrameHeightWithSpacing()))) {
|
||||||
userCategory->systems.push_back(FurnaceGUISysDef("New Preset",{}));
|
ImGui::AlignTextToFramePadding();
|
||||||
selectedUserPreset.clear();
|
ImGui::Text("Systems");
|
||||||
selectedUserPreset.push_back(userCategory->systems.size()-1);
|
ImGui::SameLine();
|
||||||
|
if (ImGui::Button(ICON_FA_PLUS "##AddPreset")) {
|
||||||
|
userCategory->systems.push_back(FurnaceGUISysDef("New Preset",{}));
|
||||||
|
selectedUserPreset.clear();
|
||||||
|
selectedUserPreset.push_back(userCategory->systems.size()-1);
|
||||||
|
}
|
||||||
|
printPresets(userCategory->systems,0,depthStack);
|
||||||
}
|
}
|
||||||
printPresets(userCategory->systems,0,depthStack);
|
ImGui::EndChild();
|
||||||
|
|
||||||
// editor
|
// editor
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
if (selectedUserPreset.empty()) {
|
if (ImGui::BeginChild("UEdit",ImVec2(ImGui::GetContentRegionAvail().x,ImGui::GetContentRegionAvail().y-ImGui::GetFrameHeightWithSpacing()))) {
|
||||||
ImGui::Text("select a preset");
|
if (selectedUserPreset.empty()) {
|
||||||
} else {
|
ImGui::Text("select a preset");
|
||||||
FurnaceGUISysDef* preset=selectPreset(userCategory->systems);
|
} else {
|
||||||
|
FurnaceGUISysDef* preset=selectPreset(userCategory->systems);
|
||||||
|
bool doRemovePreset=false;
|
||||||
|
|
||||||
if (preset!=NULL) {
|
if (preset!=NULL) {
|
||||||
ImGui::AlignTextToFramePadding();
|
ImGui::AlignTextToFramePadding();
|
||||||
ImGui::Text("Name");
|
ImGui::Text("Name");
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
|
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x-ImGui::CalcTextSize("Remove").x-ImGui::GetStyle().ItemSpacing.x*2.0-ImGui::GetStyle().ItemInnerSpacing.x*2.0);
|
||||||
ImGui::InputText("##PName",&preset->name);
|
ImGui::InputText("##PName",&preset->name);
|
||||||
ImGui::Separator();
|
ImGui::SameLine();
|
||||||
|
pushDestColor();
|
||||||
|
if (ImGui::Button("Remove##UPresetRemove")) {
|
||||||
|
doRemovePreset=true;
|
||||||
|
}
|
||||||
|
popDestColor();
|
||||||
|
|
||||||
int doRemove=-1;
|
ImGui::Separator();
|
||||||
bool mustBake=false;
|
|
||||||
|
|
||||||
for (size_t i=0; i<preset->orig.size(); i++) {
|
int doRemove=-1;
|
||||||
String tempID;
|
bool mustBake=false;
|
||||||
FurnaceGUISysDefChip& chip=preset->orig[i];
|
|
||||||
|
|
||||||
bool doInvert=(chip.vol<0);
|
for (size_t i=0; i<preset->orig.size(); i++) {
|
||||||
float vol=fabs(chip.vol);
|
String tempID;
|
||||||
ImGui::PushID(i);
|
FurnaceGUISysDefChip& chip=preset->orig[i];
|
||||||
|
|
||||||
tempID=fmt::sprintf("%s##USystem",getSystemName(chip.sys));
|
bool doInvert=(chip.vol<0);
|
||||||
ImGui::Button(tempID.c_str(),ImVec2(ImGui::GetContentRegionAvail().x-ImGui::CalcTextSize("Invert").x-ImGui::GetFrameHeightWithSpacing()*2.0-ImGui::GetStyle().ItemSpacing.x*2.0,0));
|
float vol=fabs(chip.vol);
|
||||||
if (ImGui::BeginPopupContextItem("SysPickerCU",ImGuiPopupFlags_MouseButtonLeft)) {
|
ImGui::PushID(i);
|
||||||
|
|
||||||
|
tempID=fmt::sprintf("%s##USystem",getSystemName(chip.sys));
|
||||||
|
ImGui::Button(tempID.c_str(),ImVec2(ImGui::GetContentRegionAvail().x-ImGui::CalcTextSize("Invert").x-ImGui::GetFrameHeightWithSpacing()*2.0-ImGui::GetStyle().ItemSpacing.x*2.0,0));
|
||||||
|
if (ImGui::BeginPopupContextItem("SysPickerCU",ImGuiPopupFlags_MouseButtonLeft)) {
|
||||||
|
DivSystem picked=systemPicker();
|
||||||
|
if (picked!=DIV_SYSTEM_NULL) {
|
||||||
|
chip.sys=picked;
|
||||||
|
mustBake=true;
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
}
|
||||||
|
ImGui::EndPopup();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::SameLine();
|
||||||
|
if (ImGui::Checkbox("Invert",&doInvert)) {
|
||||||
|
chip.vol=-chip.vol;
|
||||||
|
mustBake=true;
|
||||||
|
}
|
||||||
|
ImGui::SameLine();
|
||||||
|
pushDestColor();
|
||||||
|
if (ImGui::Button(ICON_FA_MINUS "##USysRemove")) {
|
||||||
|
doRemove=i;
|
||||||
|
mustBake=true;
|
||||||
|
}
|
||||||
|
popDestColor();
|
||||||
|
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x-ImGui::GetFrameHeightWithSpacing()*2.0-ImGui::GetStyle().ItemSpacing.x*2.0);
|
||||||
|
if (CWSliderFloat("Volume",&vol,0.0f,3.0f)) {
|
||||||
|
if (doInvert) {
|
||||||
|
if (vol<0.0001) vol=0.0001;
|
||||||
|
}
|
||||||
|
if (vol<0) vol=0;
|
||||||
|
if (vol>10) vol=10;
|
||||||
|
chip.vol=doInvert?-vol:vol;
|
||||||
|
mustBake=true;
|
||||||
|
} rightClickable
|
||||||
|
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x-ImGui::GetFrameHeightWithSpacing()*2.0-ImGui::GetStyle().ItemSpacing.x*2.0);
|
||||||
|
if (CWSliderFloat("Panning",&chip.pan,-1.0f,1.0f)) {
|
||||||
|
if (chip.pan<-1.0f) chip.pan=-1.0f;
|
||||||
|
if (chip.pan>1.0f) chip.pan=1.0f;
|
||||||
|
mustBake=true;
|
||||||
|
} rightClickable
|
||||||
|
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x-ImGui::GetFrameHeightWithSpacing()*2.0-ImGui::GetStyle().ItemSpacing.x*2.0);
|
||||||
|
if (CWSliderFloat("Front/Rear",&chip.panFR,-1.0f,1.0f)) {
|
||||||
|
if (chip.panFR<-1.0f) chip.panFR=-1.0f;
|
||||||
|
if (chip.panFR>1.0f) chip.panFR=1.0f;
|
||||||
|
mustBake=true;
|
||||||
|
} rightClickable
|
||||||
|
|
||||||
|
if (ImGui::TreeNode("Configure")) {
|
||||||
|
DivConfig sysFlags;
|
||||||
|
sysFlags.loadFromBase64(chip.flags.c_str());
|
||||||
|
if (drawSysConf(-1,i,chip.sys,sysFlags,false)) {
|
||||||
|
chip.flags=sysFlags.toBase64();
|
||||||
|
mustBake=true;
|
||||||
|
}
|
||||||
|
ImGui::TreePop();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::PopID();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doRemove>=0) {
|
||||||
|
preset->orig.erase(preset->orig.begin()+doRemove);
|
||||||
|
mustBake=true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::Button(ICON_FA_PLUS "##SysAddU");
|
||||||
|
if (ImGui::BeginPopupContextItem("SysPickerU",ImGuiPopupFlags_MouseButtonLeft)) {
|
||||||
DivSystem picked=systemPicker();
|
DivSystem picked=systemPicker();
|
||||||
if (picked!=DIV_SYSTEM_NULL) {
|
if (picked!=DIV_SYSTEM_NULL) {
|
||||||
chip.sys=picked;
|
preset->orig.push_back(FurnaceGUISysDefChip(picked,1.0f,0.0f,""));
|
||||||
mustBake=true;
|
mustBake=true;
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
}
|
}
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::Separator();
|
||||||
if (ImGui::Checkbox("Invert",&doInvert)) {
|
|
||||||
chip.vol=-chip.vol;
|
if (ImGui::InputTextMultiline("##UExtra",&preset->extra,ImVec2(ImGui::GetContentRegionAvail().x,120.0f*dpiScale),ImGuiInputTextFlags_UndoRedo)) {
|
||||||
mustBake=true;
|
mustBake=true;
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
|
||||||
pushDestColor();
|
if (mustBake) preset->bake();
|
||||||
if (ImGui::Button(ICON_FA_MINUS "##USysRemove")) {
|
} else {
|
||||||
doRemove=i;
|
selectedUserPreset.clear();
|
||||||
mustBake=true;
|
}
|
||||||
}
|
|
||||||
popDestColor();
|
if (doRemovePreset) {
|
||||||
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x-ImGui::GetFrameHeightWithSpacing()*2.0-ImGui::GetStyle().ItemSpacing.x*2.0);
|
std::vector<FurnaceGUISysDef>& items=userCategory->systems;
|
||||||
if (CWSliderFloat("Volume",&vol,0.0f,3.0f)) {
|
FurnaceGUISysDef* target=NULL;
|
||||||
if (doInvert) {
|
for (size_t i=0; i<selectedUserPreset.size(); i++) {
|
||||||
if (vol<0.0001) vol=0.0001;
|
if (selectedUserPreset[i]<0 || selectedUserPreset[i]>(int)items.size()) break;
|
||||||
|
target=&items[selectedUserPreset[i]];
|
||||||
|
if (i<selectedUserPreset.size()-1) {
|
||||||
|
items=target->subDefs;
|
||||||
|
} else {
|
||||||
|
items.erase(items.begin()+selectedUserPreset[i]);
|
||||||
}
|
}
|
||||||
if (vol<0) vol=0;
|
|
||||||
if (vol>10) vol=10;
|
|
||||||
chip.vol=doInvert?-vol:vol;
|
|
||||||
mustBake=true;
|
|
||||||
} rightClickable
|
|
||||||
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x-ImGui::GetFrameHeightWithSpacing()*2.0-ImGui::GetStyle().ItemSpacing.x*2.0);
|
|
||||||
if (CWSliderFloat("Panning",&chip.pan,-1.0f,1.0f)) {
|
|
||||||
if (chip.pan<-1.0f) chip.pan=-1.0f;
|
|
||||||
if (chip.pan>1.0f) chip.pan=1.0f;
|
|
||||||
mustBake=true;
|
|
||||||
} rightClickable
|
|
||||||
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x-ImGui::GetFrameHeightWithSpacing()*2.0-ImGui::GetStyle().ItemSpacing.x*2.0);
|
|
||||||
if (CWSliderFloat("Front/Rear",&chip.panFR,-1.0f,1.0f)) {
|
|
||||||
if (chip.panFR<-1.0f) chip.panFR=-1.0f;
|
|
||||||
if (chip.panFR>1.0f) chip.panFR=1.0f;
|
|
||||||
mustBake=true;
|
|
||||||
} rightClickable
|
|
||||||
|
|
||||||
if (ImGui::TreeNode("Configure")) {
|
|
||||||
DivConfig sysFlags;
|
|
||||||
sysFlags.loadFromBase64(chip.flags.c_str());
|
|
||||||
if (drawSysConf(-1,i,chip.sys,sysFlags,false)) {
|
|
||||||
chip.flags=sysFlags.toBase64();
|
|
||||||
mustBake=true;
|
|
||||||
}
|
|
||||||
ImGui::TreePop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::PopID();
|
selectedUserPreset.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doRemove>=0) {
|
|
||||||
preset->orig.erase(preset->orig.begin()+doRemove);
|
|
||||||
mustBake=true;
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::Button(ICON_FA_PLUS "##SysAddU");
|
|
||||||
if (ImGui::BeginPopupContextItem("SysPickerU",ImGuiPopupFlags_MouseButtonLeft)) {
|
|
||||||
DivSystem picked=systemPicker();
|
|
||||||
if (picked!=DIV_SYSTEM_NULL) {
|
|
||||||
preset->orig.push_back(FurnaceGUISysDefChip(picked,1.0f,0.0f,""));
|
|
||||||
mustBake=true;
|
|
||||||
ImGui::CloseCurrentPopup();
|
|
||||||
}
|
|
||||||
ImGui::EndPopup();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mustBake) preset->bake();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ImGui::EndChild();
|
||||||
|
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue