GUI: user presets, part 6
This commit is contained in:
parent
801e0e4b21
commit
8743ea9a6e
|
@ -335,32 +335,47 @@ 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::BeginChild("UList",ImVec2(ImGui::GetContentRegionAvail().x,ImGui::GetContentRegionAvail().y-ImGui::GetFrameHeightWithSpacing()))) {
|
||||||
|
ImGui::AlignTextToFramePadding();
|
||||||
|
ImGui::Text("Systems");
|
||||||
|
ImGui::SameLine();
|
||||||
if (ImGui::Button(ICON_FA_PLUS "##AddPreset")) {
|
if (ImGui::Button(ICON_FA_PLUS "##AddPreset")) {
|
||||||
userCategory->systems.push_back(FurnaceGUISysDef("New Preset",{}));
|
userCategory->systems.push_back(FurnaceGUISysDef("New Preset",{}));
|
||||||
selectedUserPreset.clear();
|
selectedUserPreset.clear();
|
||||||
selectedUserPreset.push_back(userCategory->systems.size()-1);
|
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 (ImGui::BeginChild("UEdit",ImVec2(ImGui::GetContentRegionAvail().x,ImGui::GetContentRegionAvail().y-ImGui::GetFrameHeightWithSpacing()))) {
|
||||||
if (selectedUserPreset.empty()) {
|
if (selectedUserPreset.empty()) {
|
||||||
ImGui::Text("select a preset");
|
ImGui::Text("select a preset");
|
||||||
} else {
|
} else {
|
||||||
FurnaceGUISysDef* preset=selectPreset(userCategory->systems);
|
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::SameLine();
|
||||||
|
pushDestColor();
|
||||||
|
if (ImGui::Button("Remove##UPresetRemove")) {
|
||||||
|
doRemovePreset=true;
|
||||||
|
}
|
||||||
|
popDestColor();
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
int doRemove=-1;
|
int doRemove=-1;
|
||||||
|
@ -450,10 +465,36 @@ void FurnaceGUI::drawUserPresets() {
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui::Separator();
|
||||||
|
|
||||||
|
if (ImGui::InputTextMultiline("##UExtra",&preset->extra,ImVec2(ImGui::GetContentRegionAvail().x,120.0f*dpiScale),ImGuiInputTextFlags_UndoRedo)) {
|
||||||
|
mustBake=true;
|
||||||
|
}
|
||||||
|
|
||||||
if (mustBake) preset->bake();
|
if (mustBake) preset->bake();
|
||||||
|
} else {
|
||||||
|
selectedUserPreset.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doRemovePreset) {
|
||||||
|
std::vector<FurnaceGUISysDef>& items=userCategory->systems;
|
||||||
|
FurnaceGUISysDef* target=NULL;
|
||||||
|
for (size_t i=0; i<selectedUserPreset.size(); i++) {
|
||||||
|
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]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
selectedUserPreset.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImGui::EndChild();
|
||||||
|
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue