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();
auto spoilerPath = Ship::Context::GetPathRelativeToAppDirectory("Randomizer");
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());
}
}
}
}
void PlandomizerItemImageCorrection(Rando::Item randoItem) {
textureID = 0;
@ -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");