command palette: improve checks on item selection

This commit is contained in:
YohananDiamond 2023-07-01 15:15:41 -03:00
parent 869e5d7be9
commit 55d791f852

View file

@ -121,10 +121,7 @@ void FurnaceGUI::drawPalette() {
if (curPaletteChoice>=(int)paletteSearchResults.size()) { if (curPaletteChoice>=(int)paletteSearchResults.size()) {
curPaletteChoice=paletteSearchResults.size()-1; curPaletteChoice=paletteSearchResults.size()-1;
} }
if (ImGui::IsKeyPressed(ImGuiKey_Enter)) { accepted=ImGui::IsKeyPressed(ImGuiKey_Enter);
// TODO: properly test this - what happens when enter is pressed and the list is empty?
accepted=true;
}
} }
if (ImGui::Button("Cancel") || ImGui::IsKeyPressed(ImGuiKey_Escape)) { if (ImGui::Button("Cancel") || ImGui::IsKeyPressed(ImGuiKey_Escape)) {
@ -132,8 +129,10 @@ void FurnaceGUI::drawPalette() {
} }
if (accepted) { if (accepted) {
if (paletteSearchResults.size()==0) {
ImGui::CloseCurrentPopup();
} else {
int i=paletteSearchResults[curPaletteChoice]; int i=paletteSearchResults[curPaletteChoice];
switch (curPaletteType) { switch (curPaletteType) {
case CMDPAL_TYPE_MAIN: case CMDPAL_TYPE_MAIN:
resetPalette(this); resetPalette(this);
@ -153,7 +152,8 @@ void FurnaceGUI::drawPalette() {
// TODO: PANIC! DIE! PERISH! // TODO: PANIC! DIE! PERISH!
break; break;
}; };
} else { }
}
paletteFirstFrame=false; paletteFirstFrame=false;
} }
}