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();
}
if (ImGui::Button("Cancel")) {
ImGui::CloseCurrentPopup();
if (ImGui::Button("I'm feeling lucky")) {
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();
if (ImGui::Button("I'm feeling lucky")) {
FurnaceGUISysCategory* newSystemCat=&sysCategories[rand()%sysCategories.size()];
nextDesc=newSystemCat->systems[rand()%newSystemCat->systems.size()].definition.data();
accepted=true;
if (ImGui::Button("Cancel")) {
ImGui::CloseCurrentPopup();
}
if (accepted) {
@ -95,4 +103,4 @@ void FurnaceGUI::drawNewSong() {
updateWindowTitle();
ImGui::CloseCurrentPopup();
}
}
}