From 5dd3b39a8301a0a204288eba0f0d4d183e6a92f0 Mon Sep 17 00:00:00 2001 From: Malkierian Date: Tue, 19 Nov 2024 15:39:30 -0700 Subject: [PATCH] Fix Plando Window Crash on new installs (#4557) * Add check for Randomizer folder existing, and creating it if not, to plando window. * Changed seed list population to just bail if the Randomizer folder doesn't exist. Added button disabling to prevent crashes loading or saving empty structures. --- soh/soh/Enhancements/randomizer/Plandomizer.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/Plandomizer.cpp b/soh/soh/Enhancements/randomizer/Plandomizer.cpp index 732ef700b..fcec76887 100644 --- a/soh/soh/Enhancements/randomizer/Plandomizer.cpp +++ b/soh/soh/Enhancements/randomizer/Plandomizer.cpp @@ -361,9 +361,11 @@ void PlandomizerPopulateSeedList() { existingSeedList.clear(); auto spoilerPath = Ship::Context::GetPathRelativeToAppDirectory("Randomizer"); - for (const auto& entry : std::filesystem::directory_iterator(spoilerPath)) { - if (entry.is_regular_file() && entry.path().extension() == ".json") { - existingSeedList.push_back(entry.path().stem().string()); + if (std::filesystem::exists(spoilerPath)) { + for (const auto& entry : std::filesystem::directory_iterator(spoilerPath)) { + if (entry.is_regular_file() && entry.path().extension() == ".json") { + existingSeedList.push_back(entry.path().stem().string()); + } } } } @@ -875,15 +877,18 @@ void PlandomizerDrawOptions() { } else { ImGui::Text("No Spoiler Logs found."); } - + ImGui::BeginDisabled(existingSeedList.empty()); if (ImGui::Button("Load")) { logTemp = existingSeedList[selectedList].c_str(); PlandomizerLoadSpoilerLog(logTemp.c_str()); } + ImGui::EndDisabled(); + ImGui::BeginDisabled(spoilerLogData.empty()); ImGui::SameLine(); if (ImGui::Button("Save")) { PlandomizerSaveSpoilerLog(); } + ImGui::EndDisabled(); ImGui::TableNextColumn(); ImGui::SeparatorText("Current Seed Hash");