From edceb2d460c2c24b578a496688d8fa9418ca7dfb Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Thu, 19 Jan 2023 03:32:05 -0500 Subject: [PATCH] Adds lock/unlock all buttons to Cosmetics Editor. (#2225) * Adds lock/unlock all buttons to Cosmetics Editor. Adds Lock All and Unlock All, which locks all visible cosmetics options (i.e. does not lock the advanced options if Advanced isn't checked, just like the existing randomize all buttons), and a Lock All Advanced and Unlock All Advanced button that is only visible while the Advanced Options are enabled. * Updates latest develop and CVar API Changes. --- .../cosmetics/CosmeticsEditor.cpp | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp index 141f0da7e..ebfca5df8 100644 --- a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp +++ b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp @@ -1669,6 +1669,25 @@ void DrawCosmeticsEditor(bool& open) { ImGui::SameLine(); UIWidgets::EnhancementCombobox("gCosmetics.DefaultColorScheme", colorSchemes, 2, 0); UIWidgets::EnhancementCheckbox("Advanced Mode", "gCosmetics.AdvancedMode"); + if (CVarGetInteger("gCosmetics.AdvancedMode", 0)) { + if (ImGui::Button("Lock All Advanced", ImVec2(ImGui::GetContentRegionAvail().x / 2, 30.0f))) { + for (auto& [id, cosmeticOption] : cosmeticOptions) { + if (cosmeticOption.advancedOption) { + CVarSetInteger(cosmeticOption.lockedCvar, 1); + } + } + SohImGui::RequestCvarSaveOnNextTick(); + } + ImGui::SameLine(); + if (ImGui::Button("Unlock All Advanced", ImVec2(ImGui::GetContentRegionAvail().x, 30.0f))) { + for (auto& [id, cosmeticOption] : cosmeticOptions) { + if (cosmeticOption.advancedOption) { + CVarSetInteger(cosmeticOption.lockedCvar, 0); + } + } + SohImGui::RequestCvarSaveOnNextTick(); + } + } UIWidgets::EnhancementCheckbox("Sync Rainbow colors", "gCosmetics.RainbowSync"); UIWidgets::EnhancementSliderFloat("Rainbow Speed: %f", "##rainbowSpeed", "gCosmetics.RainbowSpeed", 0.03f, 1.0f, "", 0.6f, false); if (ImGui::Button("Randomize All", ImVec2(ImGui::GetContentRegionAvail().x / 2, 30.0f))) { @@ -1691,6 +1710,24 @@ void DrawCosmeticsEditor(bool& open) { SohImGui::RequestCvarSaveOnNextTick(); } + if (ImGui::Button("Lock All", ImVec2(ImGui::GetContentRegionAvail().x / 2, 30.0f))) { + for (auto& [id, cosmeticOption] : cosmeticOptions) { + if (!cosmeticOption.advancedOption || CVarGetInteger("gCosmetics.AdvancedMode", 0)) { + CVarSetInteger(cosmeticOption.lockedCvar, 1); + } + } + SohImGui::RequestCvarSaveOnNextTick(); + } + ImGui::SameLine(); + if (ImGui::Button("Unlock All", ImVec2(ImGui::GetContentRegionAvail().x, 30.0f))) { + for (auto& [id, cosmeticOption] : cosmeticOptions) { + if (!cosmeticOption.advancedOption || CVarGetInteger("gCosmetics.AdvancedMode", 0)) { + CVarSetInteger(cosmeticOption.lockedCvar, 0); + } + } + SohImGui::RequestCvarSaveOnNextTick(); + } + if (ImGui::BeginTabBar("CosmeticsContextTabBar", ImGuiTabBarFlags_NoCloseWithMiddleMouseButton)) { if (ImGui::BeginTabItem("Link & Items")) { DrawCosmeticGroup(GROUP_LINK);