From dbc52ec28f42875d3b99a7501c0ef3bcdd68b997 Mon Sep 17 00:00:00 2001 From: William JCM Date: Sat, 2 Apr 2022 21:34:45 +0200 Subject: [PATCH] SaveTool: allow changing the equipped accessory. --- src/SaveTool/SaveTool_MassViewer.cpp | 77 ++++++++++++++++++++++++++-- 1 file changed, 73 insertions(+), 4 deletions(-) diff --git a/src/SaveTool/SaveTool_MassViewer.cpp b/src/SaveTool/SaveTool_MassViewer.cpp index 5c0d335..d80ad74 100644 --- a/src/SaveTool/SaveTool_MassViewer.cpp +++ b/src/SaveTool/SaveTool_MassViewer.cpp @@ -502,10 +502,79 @@ void SaveTool::drawAccessoryEditor(Accessory& accessory, Containers::ArrayView= 3000) { + tab = 3; + } + else if(accessory.id >= 2000) { + tab = 2; + } + else if(accessory.id >= 1000) { + tab = 1; + } + } + if(ImGui::BeginPopup("##AccessoryPopup")) { + Float selectable_width = 90.0f; + + ImGui::PushStyleVar(ImGuiStyleVar_SelectableTextAlign, {0.5f, 0.0f}); + if(ImGui::Selectable("Primitives", tab == 0, ImGuiSelectableFlags_DontClosePopups, {selectable_width, 0.0f})) { + tab = 0; + } + ImGui::SameLine(); + ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical); + ImGui::SameLine(); + if(ImGui::Selectable("Armours", tab == 1, ImGuiSelectableFlags_DontClosePopups, {selectable_width, 0.0f})) { + tab = 1; + } + ImGui::SameLine(); + ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical); + ImGui::SameLine(); + if(ImGui::Selectable("Components", tab == 2, ImGuiSelectableFlags_DontClosePopups, {selectable_width, 0.0f})) { + tab = 2; + } + ImGui::SameLine(); + ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical); + ImGui::SameLine(); + if(ImGui::Selectable("Connectors", tab == 3, ImGuiSelectableFlags_DontClosePopups, {selectable_width, 0.0f})) { + tab = 3; + } + ImGui::PopStyleVar(); + + ImGui::Separator(); + + if(ImGui::BeginListBox("##AccessoryListbox", {-1.0f, 0.0f})) { + for(const auto& acc : accessories) { + if(acc.first >= tab * 1000 && acc.first < ((tab + 1) * 1000)) { + if(ImGui::Selectable(acc.second.data(), acc.first == accessory.id)) { + accessory.id = acc.first; + accessory.attachIndex = 0; + } + if(acc.first == accessory.id) { + ImGui::SetItemDefaultFocus(); + } + } + } + + ImGui::EndListBox(); + } + + ImGui::EndPopup(); + } + + if(accessory.id > 0) { + ImGui::SameLine(); + if(ImGui::SmallButton("Unequip")) { + accessory.id = 0; + accessory.attachIndex = -1; + } + } ImGui::BeginGroup(); drawAlignedText("Styles:");