From ea4340cab5f8b19f0843e935daa4806f86f2a3b3 Mon Sep 17 00:00:00 2001 From: Pepe20129 <72659707+Pepe20129@users.noreply.github.com> Date: Mon, 27 Jan 2025 21:33:41 +0100 Subject: [PATCH] Small cleanup --- soh/soh/Enhancements/ExtraTraps.cpp | 2 +- soh/soh/Enhancements/mod_menu.cpp | 65 ++++++++++++++++------------- 2 files changed, 38 insertions(+), 29 deletions(-) diff --git a/soh/soh/Enhancements/ExtraTraps.cpp b/soh/soh/Enhancements/ExtraTraps.cpp index 27d64d1c7..196fc63f4 100644 --- a/soh/soh/Enhancements/ExtraTraps.cpp +++ b/soh/soh/Enhancements/ExtraTraps.cpp @@ -65,7 +65,7 @@ std::vector getEnabledAddTraps () { }; static void RollRandomTrap(uint32_t seed) { - uint32_t finalSeed = seed + (IS_RANDO ? Rando::Context::GetInstance()->GetSettings()->GetSeed() : gSaveContext.ship.stats.fileCreatedAt); + uint32_t finalSeed = seed + (IS_RANDO ? Rando::Context::GetInstance()->GetSeed() : gSaveContext.ship.stats.fileCreatedAt); Random_Init(finalSeed); roll = RandomElement(getEnabledAddTraps()); diff --git a/soh/soh/Enhancements/mod_menu.cpp b/soh/soh/Enhancements/mod_menu.cpp index b4f415ab1..82b05ba9f 100644 --- a/soh/soh/Enhancements/mod_menu.cpp +++ b/soh/soh/Enhancements/mod_menu.cpp @@ -117,9 +117,44 @@ void AfterModChange() { } void DrawModInfo(std::string file) { + ImGui::SameLine(); ImGui::Text(file.c_str()); } +void DrawEnabledMods() { + std::vector enabledMods = GetEnabledModFiles(); + if (enabledMods.empty()) { + ImGui::Text(""); + return; + } + + for (std::string file : enabledMods) { + if (ImGui::ArrowButton(file.c_str(), ImGuiDir_Left)) { + modFiles[file] = false; + GetArchiveManager()->RemoveArchive(file); + AfterModChange(); + } + DrawModInfo(file); + } +} + +void DrawDisabledMods() { + std::vector disabledMods = GetDisabledModFiles(); + if (disabledMods.empty()) { + ImGui::Text(""); + return; + } + + for (std::string file : disabledMods) { + if (ImGui::ArrowButton(file.c_str(), ImGuiDir_Right)) { + modFiles[file] = true; + GetArchiveManager()->AddArchive(file); + AfterModChange(); + } + DrawModInfo(file); + } +} + void ModMenuWindow::DrawElement() { if (ImGui::Button("Update")) { UpdateModFiles(); @@ -136,20 +171,7 @@ void ModMenuWindow::DrawElement() { ImGui::TableNextColumn(); if (ImGui::BeginChild("Disabled Mods", ImVec2(0, -8))) { - std::vector disabledMods = GetDisabledModFiles(); - if (!disabledMods.empty()) { - for (std::string file : disabledMods) { - if (ImGui::ArrowButton(file.c_str(), ImGuiDir_Right)) { - modFiles[file] = true; - GetArchiveManager()->AddArchive(file); - AfterModChange(); - } - ImGui::SameLine(); - DrawModInfo(file); - } - } else { - ImGui::Text(""); - } + DrawDisabledMods(); ImGui::EndChild(); } @@ -157,20 +179,7 @@ void ModMenuWindow::DrawElement() { ImGui::TableNextColumn(); if (ImGui::BeginChild("Enabled Mods", ImVec2(0, -8))) { - std::vector enabledMods = GetEnabledModFiles(); - if (!enabledMods.empty()) { - for (std::string file : enabledMods) { - if (ImGui::ArrowButton(file.c_str(), ImGuiDir_Left)) { - modFiles[file] = false; - GetArchiveManager()->RemoveArchive(file); - AfterModChange(); - } - ImGui::SameLine(); - DrawModInfo(file); - } - } else { - ImGui::Text(""); - } + DrawEnabledMods(); ImGui::EndChild(); }