1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-06-25 22:53:19 +00:00

fixed the dialog navigation keys

This commit is contained in:
Zeno Rogue 2020-10-06 21:07:34 +02:00
parent f2fcbf4b81
commit f5eff4e225

View File

@ -525,21 +525,38 @@ EX namespace dialog {
bool isitem(item& it) {
return it.type == diItem || it.type == diBigItem;
}
EX void handle_actions(int &sym, int &uni) {
if(key_actions.count(uni)) {
key_actions[uni]();
sym = uni = 0;
return;
}
if(key_actions.count(sym)) {
key_actions[sym]();
sym = uni = 0;
return;
}
}
EX void handleNavigation(int &sym, int &uni) {
if(uni == '\n' || uni == '\r' || DIRECTIONKEY == SDLK_KP5)
if(uni == '\n' || uni == '\r' || DIRECTIONKEY == SDLK_KP5) {
for(int i=0; i<isize(items); i++)
if(isitem(items[i]))
if(items[i].body == highlight_text) {
uni = sym = items[i].key;
handle_actions(sym, uni);
return;
}
}
if(DKEY == SDLK_PAGEDOWN) {
uni = sym = 0;
for(int i=0; i<isize(items); i++)
if(isitem(items[i]))
highlight_text = items[i].body;
}
if(DKEY == SDLK_PAGEUP) {
uni = sym = 0;
for(int i=0; i<isize(items); i++)
if(isitem(items[i])) {
highlight_text = items[i].body;
@ -547,11 +564,11 @@ EX namespace dialog {
}
}
if(DKEY == SDLK_UP) {
uni = sym = 0;
string last = "";
for(int i=0; i<isize(items); i++)
if(isitem(items[i]))
last = items[i].body;
uni = sym = 0;
for(int i=0; i<isize(items); i++)
if(isitem(items[i])) {
if(items[i].body == highlight_text) {
@ -562,6 +579,7 @@ EX namespace dialog {
highlight_text = last;
}
if(DKEY == SDLK_DOWN) {
uni = sym = 0;
int state = 0;
for(int i=0; i<isize(items); i++)
if(isitem(items[i])) {
@ -573,18 +591,8 @@ EX namespace dialog {
highlight_text = items[i].body;
break;
}
uni = sym = 0;
}
if(key_actions.count(uni)) {
key_actions[uni]();
sym = uni = 0;
return;
}
if(key_actions.count(sym)) {
key_actions[sym]();
sym = uni = 0;
return;
}
handle_actions(sym, uni);
}
color_t colorhistory[10] = {