command palette: improve checks on item selection
This commit is contained in:
parent
869e5d7be9
commit
55d791f852
|
|
@ -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,28 +129,31 @@ void FurnaceGUI::drawPalette() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (accepted) {
|
if (accepted) {
|
||||||
int i=paletteSearchResults[curPaletteChoice];
|
if (paletteSearchResults.size()==0) {
|
||||||
|
|
||||||
switch (curPaletteType) {
|
|
||||||
case CMDPAL_TYPE_MAIN:
|
|
||||||
resetPalette(this);
|
|
||||||
doAction(i);
|
|
||||||
if (i<GUI_ACTION_CMDPAL_MIN || GUI_ACTION_CMDPAL_MAX<i) {
|
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
}
|
} else {
|
||||||
break;
|
int i=paletteSearchResults[curPaletteChoice];
|
||||||
|
switch (curPaletteType) {
|
||||||
|
case CMDPAL_TYPE_MAIN:
|
||||||
|
resetPalette(this);
|
||||||
|
doAction(i);
|
||||||
|
if (i<GUI_ACTION_CMDPAL_MIN || GUI_ACTION_CMDPAL_MAX<i) {
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case CMDPAL_TYPE_RECENT:
|
case CMDPAL_TYPE_RECENT:
|
||||||
resetPalette(this);
|
resetPalette(this);
|
||||||
openRecentFile(recentFile[i]);
|
openRecentFile(recentFile[i]);
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// TODO: PANIC! DIE! PERISH!
|
// TODO: PANIC! DIE! PERISH!
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
} else {
|
}
|
||||||
paletteFirstFrame=false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
paletteFirstFrame=false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue