SaveTool: allow changing the equipped accessory.

This commit is contained in:
Guillaume Jacquemin 2022-04-02 21:34:45 +02:00
parent 11c089d408
commit dbc52ec28f

View file

@ -502,10 +502,79 @@ void SaveTool::drawAccessoryEditor(Accessory& accessory, Containers::ArrayView<C
drawTooltip("WARNING: accessory mapping is a WIP."); drawTooltip("WARNING: accessory mapping is a WIP.");
} }
#ifdef SAVETOOL_DEBUG_BUILD ImGui::SameLine();
ImGui::SameLine(0.0f, ImGui::GetStyle().FramePadding.x * 5.0f);
ImGui::Text("Attach index: %i", accessory.attachIndex); static Int tab = 0;
#endif if(ImGui::SmallButton("Change")) {
ImGui::OpenPopup("##AccessoryPopup");
if(accessory.id < 1000) {
tab = 0;
}
else if(accessory.id >= 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(); ImGui::BeginGroup();
drawAlignedText("Styles:"); drawAlignedText("Styles:");