GUI: prevent division by zero

This commit is contained in:
tildearrow 2022-04-29 04:42:18 -05:00
parent dbf4635646
commit aeea8a4912
1 changed files with 15 additions and 7 deletions

View File

@ -66,16 +66,24 @@ void FurnaceGUI::drawNewSong() {
ImGui::EndTable(); ImGui::EndTable();
} }
if (ImGui::Button("Cancel")) { if (ImGui::Button("I'm feeling lucky")) {
ImGui::CloseCurrentPopup(); if (sysCategories.size()==0) {
ImGui::CloseCurrentPopup();
} else {
FurnaceGUISysCategory* newSystemCat=&sysCategories[rand()%sysCategories.size()];
if (newSystemCat->systems.size()==0) {
ImGui::CloseCurrentPopup();
} else {
nextDesc=newSystemCat->systems[rand()%newSystemCat->systems.size()].definition.data();
accepted=true;
}
}
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button("I'm feeling lucky")) { if (ImGui::Button("Cancel")) {
FurnaceGUISysCategory* newSystemCat=&sysCategories[rand()%sysCategories.size()]; ImGui::CloseCurrentPopup();
nextDesc=newSystemCat->systems[rand()%newSystemCat->systems.size()].definition.data();
accepted=true;
} }
if (accepted) { if (accepted) {
@ -95,4 +103,4 @@ void FurnaceGUI::drawNewSong() {
updateWindowTitle(); updateWindowTitle();
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
} }
} }