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.
This commit is contained in:
Christopher Leggett 2023-01-19 03:32:05 -05:00 committed by GitHub
parent 7c8be2153c
commit edceb2d460
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1669,6 +1669,25 @@ void DrawCosmeticsEditor(bool& open) {
ImGui::SameLine(); ImGui::SameLine();
UIWidgets::EnhancementCombobox("gCosmetics.DefaultColorScheme", colorSchemes, 2, 0); UIWidgets::EnhancementCombobox("gCosmetics.DefaultColorScheme", colorSchemes, 2, 0);
UIWidgets::EnhancementCheckbox("Advanced Mode", "gCosmetics.AdvancedMode"); 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::EnhancementCheckbox("Sync Rainbow colors", "gCosmetics.RainbowSync");
UIWidgets::EnhancementSliderFloat("Rainbow Speed: %f", "##rainbowSpeed", "gCosmetics.RainbowSpeed", 0.03f, 1.0f, "", 0.6f, false); 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))) { if (ImGui::Button("Randomize All", ImVec2(ImGui::GetContentRegionAvail().x / 2, 30.0f))) {
@ -1691,6 +1710,24 @@ void DrawCosmeticsEditor(bool& open) {
SohImGui::RequestCvarSaveOnNextTick(); 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::BeginTabBar("CosmeticsContextTabBar", ImGuiTabBarFlags_NoCloseWithMiddleMouseButton)) {
if (ImGui::BeginTabItem("Link & Items")) { if (ImGui::BeginTabItem("Link & Items")) {
DrawCosmeticGroup(GROUP_LINK); DrawCosmeticGroup(GROUP_LINK);