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.
This commit is contained in:
Malkierian 2024-11-19 15:39:30 -07:00 committed by GitHub
parent 9bed5af33b
commit 5dd3b39a83
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -361,12 +361,14 @@ void PlandomizerPopulateSeedList() {
existingSeedList.clear(); existingSeedList.clear();
auto spoilerPath = Ship::Context::GetPathRelativeToAppDirectory("Randomizer"); auto spoilerPath = Ship::Context::GetPathRelativeToAppDirectory("Randomizer");
if (std::filesystem::exists(spoilerPath)) {
for (const auto& entry : std::filesystem::directory_iterator(spoilerPath)) { for (const auto& entry : std::filesystem::directory_iterator(spoilerPath)) {
if (entry.is_regular_file() && entry.path().extension() == ".json") { if (entry.is_regular_file() && entry.path().extension() == ".json") {
existingSeedList.push_back(entry.path().stem().string()); existingSeedList.push_back(entry.path().stem().string());
} }
} }
} }
}
void PlandomizerItemImageCorrection(Rando::Item randoItem) { void PlandomizerItemImageCorrection(Rando::Item randoItem) {
textureID = 0; textureID = 0;
@ -875,15 +877,18 @@ void PlandomizerDrawOptions() {
} else { } else {
ImGui::Text("No Spoiler Logs found."); ImGui::Text("No Spoiler Logs found.");
} }
ImGui::BeginDisabled(existingSeedList.empty());
if (ImGui::Button("Load")) { if (ImGui::Button("Load")) {
logTemp = existingSeedList[selectedList].c_str(); logTemp = existingSeedList[selectedList].c_str();
PlandomizerLoadSpoilerLog(logTemp.c_str()); PlandomizerLoadSpoilerLog(logTemp.c_str());
} }
ImGui::EndDisabled();
ImGui::BeginDisabled(spoilerLogData.empty());
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button("Save")) { if (ImGui::Button("Save")) {
PlandomizerSaveSpoilerLog(); PlandomizerSaveSpoilerLog();
} }
ImGui::EndDisabled();
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::SeparatorText("Current Seed Hash"); ImGui::SeparatorText("Current Seed Hash");