mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-08-28 08:22:18 +00:00
fixed the dialog navigation keys
This commit is contained in:
parent
f2fcbf4b81
commit
f5eff4e225
34
dialogs.cpp
34
dialogs.cpp
@ -526,20 +526,37 @@ EX namespace dialog {
|
|||||||
return it.type == diItem || it.type == diBigItem;
|
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) {
|
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++)
|
for(int i=0; i<isize(items); i++)
|
||||||
if(isitem(items[i]))
|
if(isitem(items[i]))
|
||||||
if(items[i].body == highlight_text) {
|
if(items[i].body == highlight_text) {
|
||||||
uni = sym = items[i].key;
|
uni = sym = items[i].key;
|
||||||
|
handle_actions(sym, uni);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if(DKEY == SDLK_PAGEDOWN) {
|
if(DKEY == SDLK_PAGEDOWN) {
|
||||||
|
uni = sym = 0;
|
||||||
for(int i=0; i<isize(items); i++)
|
for(int i=0; i<isize(items); i++)
|
||||||
if(isitem(items[i]))
|
if(isitem(items[i]))
|
||||||
highlight_text = items[i].body;
|
highlight_text = items[i].body;
|
||||||
}
|
}
|
||||||
if(DKEY == SDLK_PAGEUP) {
|
if(DKEY == SDLK_PAGEUP) {
|
||||||
|
uni = sym = 0;
|
||||||
for(int i=0; i<isize(items); i++)
|
for(int i=0; i<isize(items); i++)
|
||||||
if(isitem(items[i])) {
|
if(isitem(items[i])) {
|
||||||
highlight_text = items[i].body;
|
highlight_text = items[i].body;
|
||||||
@ -547,11 +564,11 @@ EX namespace dialog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(DKEY == SDLK_UP) {
|
if(DKEY == SDLK_UP) {
|
||||||
|
uni = sym = 0;
|
||||||
string last = "";
|
string last = "";
|
||||||
for(int i=0; i<isize(items); i++)
|
for(int i=0; i<isize(items); i++)
|
||||||
if(isitem(items[i]))
|
if(isitem(items[i]))
|
||||||
last = items[i].body;
|
last = items[i].body;
|
||||||
uni = sym = 0;
|
|
||||||
for(int i=0; i<isize(items); i++)
|
for(int i=0; i<isize(items); i++)
|
||||||
if(isitem(items[i])) {
|
if(isitem(items[i])) {
|
||||||
if(items[i].body == highlight_text) {
|
if(items[i].body == highlight_text) {
|
||||||
@ -562,6 +579,7 @@ EX namespace dialog {
|
|||||||
highlight_text = last;
|
highlight_text = last;
|
||||||
}
|
}
|
||||||
if(DKEY == SDLK_DOWN) {
|
if(DKEY == SDLK_DOWN) {
|
||||||
|
uni = sym = 0;
|
||||||
int state = 0;
|
int state = 0;
|
||||||
for(int i=0; i<isize(items); i++)
|
for(int i=0; i<isize(items); i++)
|
||||||
if(isitem(items[i])) {
|
if(isitem(items[i])) {
|
||||||
@ -573,18 +591,8 @@ EX namespace dialog {
|
|||||||
highlight_text = items[i].body;
|
highlight_text = items[i].body;
|
||||||
break;
|
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] = {
|
color_t colorhistory[10] = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user