From 0eee085981c88a392c6eb8119d6a7902497241b6 Mon Sep 17 00:00:00 2001 From: briaguya Date: Fri, 19 Aug 2022 09:30:17 -0400 Subject: [PATCH] save/load locations to a string cvar --- .../Enhancements/randomizer/randomizer.cpp | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index 7025db172a..7e0264b569 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -17,6 +17,7 @@ #include #include #include "randomizer_check_objects.h" +#include using json = nlohmann::json; using namespace std::literals::string_literals; @@ -3735,6 +3736,13 @@ void DrawRandoEditor(bool& open) { if (!locationsTabOpen) { locationsTabOpen = true; RandomizerCheckObjects::UpdateImGuiVisibility(); + // todo: this efficently when we build out cvar array support + std::stringstream excludedLocationStringStream(CVar_GetString("gRandomizeExcludedLocations", "")); + std::string excludedLocationString; + excludedLocations.clear(); + while(getline(excludedLocationStringStream, excludedLocationString, ',')) { + excludedLocations.insert((RandomizerCheck)std::stoi(excludedLocationString)); + } } if (ImGui::BeginTable("tableRandoLocations", 2, @@ -3776,6 +3784,14 @@ void DrawRandoEditor(bool& open) { if (ImGui::ArrowButton(std::to_string(locationIt.rc).c_str(), ImGuiDir_Right)) { excludedLocations.insert(locationIt.rc); + // todo: this efficently when we build out cvar array support + std::string excludedLocationString = ""; + for (auto excludedLocationIt : excludedLocations) { + excludedLocationString += std::to_string(excludedLocationIt); + excludedLocationString += ","; + } + CVar_SetString("gRandomizeExcludedLocations", excludedLocationString.c_str()); + SohImGui::needs_save = true; } ImGui::SameLine(); ImGui::Text(locationIt.rcShortName.c_str()); @@ -3809,6 +3825,14 @@ void DrawRandoEditor(bool& open) { if (locationIt.visibleInImgui && elfound != excludedLocations.end()) { if (ImGui::ArrowButton(std::to_string(locationIt.rc).c_str(), ImGuiDir_Left)) { excludedLocations.erase(elfound); + // todo: this efficently when we build out cvar array support + std::string excludedLocationString = ""; + for (auto excludedLocationIt : excludedLocations) { + excludedLocationString += std::to_string(excludedLocationIt); + excludedLocationString += ","; + } + CVar_SetString("gRandomizeExcludedLocations", excludedLocationString.c_str()); + SohImGui::needs_save = true; } ImGui::SameLine(); ImGui::Text(locationIt.rcShortName.c_str());