mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-18 06:50:27 +00:00
duplicate keys in dialogs are now fixed correctly
This commit is contained in:
parent
3d813e83b9
commit
d8d32d19b0
15
dialogs.cpp
15
dialogs.cpp
@ -22,7 +22,6 @@ EX namespace dialog {
|
|||||||
tDialogItem type;
|
tDialogItem type;
|
||||||
string body;
|
string body;
|
||||||
string value;
|
string value;
|
||||||
string keycaption;
|
|
||||||
int key;
|
int key;
|
||||||
color_t color, colorv, colork, colors, colorc;
|
color_t color, colorv, colork, colors, colorc;
|
||||||
int scale;
|
int scale;
|
||||||
@ -122,12 +121,16 @@ EX namespace dialog {
|
|||||||
EX map<int, reaction_t> key_actions;
|
EX map<int, reaction_t> key_actions;
|
||||||
|
|
||||||
EX void add_key_action(int key, const reaction_t& action) {
|
EX void add_key_action(int key, const reaction_t& action) {
|
||||||
while(key_actions.count(key)) key++;
|
|
||||||
key_actions[key] = action;
|
key_actions[key] = action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EX void add_key_action_adjust(int& key, const reaction_t& action) {
|
||||||
|
while(key_actions.count(key)) key++;
|
||||||
|
add_key_action(key, action);
|
||||||
|
}
|
||||||
|
|
||||||
EX void add_action(const reaction_t& action) {
|
EX void add_action(const reaction_t& action) {
|
||||||
add_key_action(lastItem().key, action);
|
add_key_action_adjust(lastItem().key, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
EX void add_action_push(const reaction_t& action) { add_action([action] { pushScreen(action); }); }
|
EX void add_action_push(const reaction_t& action) { add_action([action] { pushScreen(action); }); }
|
||||||
@ -184,7 +187,6 @@ EX namespace dialog {
|
|||||||
it.type = diItem;
|
it.type = diItem;
|
||||||
it.body = body;
|
it.body = body;
|
||||||
it.value = value;
|
it.value = value;
|
||||||
it.keycaption = keyname(key);
|
|
||||||
it.key = key;
|
it.key = key;
|
||||||
it.color = dialogcolor;
|
it.color = dialogcolor;
|
||||||
it.colork = 0x808080;
|
it.colork = 0x808080;
|
||||||
@ -222,7 +224,6 @@ EX namespace dialog {
|
|||||||
it.type = diItem;
|
it.type = diItem;
|
||||||
it.body = body;
|
it.body = body;
|
||||||
it.value = COLORBAR;
|
it.value = COLORBAR;
|
||||||
it.keycaption = keyname(key);
|
|
||||||
it.key = key;
|
it.key = key;
|
||||||
it.color = it.colorv = displaycolor(value);
|
it.color = it.colorv = displaycolor(value);
|
||||||
it.colors = it.color ^ 0x404040;
|
it.colors = it.color ^ 0x404040;
|
||||||
@ -256,7 +257,6 @@ EX namespace dialog {
|
|||||||
item it;
|
item it;
|
||||||
it.type = diItem;
|
it.type = diItem;
|
||||||
it.body = body;
|
it.body = body;
|
||||||
it.keycaption = keyname(key);
|
|
||||||
it.key = key;
|
it.key = key;
|
||||||
it.color = dialogcolor;
|
it.color = dialogcolor;
|
||||||
it.colork = 0x808080;
|
it.colork = 0x808080;
|
||||||
@ -270,7 +270,6 @@ EX namespace dialog {
|
|||||||
item it;
|
item it;
|
||||||
it.type = diBigItem;
|
it.type = diBigItem;
|
||||||
it.body = body;
|
it.body = body;
|
||||||
it.keycaption = keyname(key);
|
|
||||||
it.key = key;
|
it.key = key;
|
||||||
it.color = 0xC06000;
|
it.color = 0xC06000;
|
||||||
it.colors = 0xFFD500;
|
it.colors = 0xFFD500;
|
||||||
@ -440,7 +439,7 @@ EX namespace dialog {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(!mousing)
|
if(!mousing)
|
||||||
displayfr(keyx, mid, 2, dfsize * I.scale/100, I.keycaption, I.colork, 16);
|
displayfr(keyx, mid, 2, dfsize * I.scale/100, keyname(I.key), I.colork, 16);
|
||||||
displayfr(itemx, mid, 2, dfsize * I.scale/100, I.body, I.color, 0);
|
displayfr(itemx, mid, 2, dfsize * I.scale/100, I.body, I.color, 0);
|
||||||
displayfr(valuex, mid, 2, dfsize * I.scale/100, I.value, I.colorv, 0);
|
displayfr(valuex, mid, 2, dfsize * I.scale/100, I.value, I.colorv, 0);
|
||||||
}
|
}
|
||||||
|
@ -225,7 +225,7 @@ EX void showMainMenu() {
|
|||||||
if(cheater)
|
if(cheater)
|
||||||
dialog::addItem(XLAT("cheats"), 'c');
|
dialog::addItem(XLAT("cheats"), 'c');
|
||||||
else dialog::addBreak(100);
|
else dialog::addBreak(100);
|
||||||
dialog::addItem(XLAT("restart game"), 'r'); dialog::lastItem().keycaption += " / F5";
|
dialog::addItem(XLAT("restart game"), 'r');
|
||||||
|
|
||||||
dialog::addItem(XLAT(inSpecialMode() ? "reset special modes" : "back to the start menu"), 'R');
|
dialog::addItem(XLAT(inSpecialMode() ? "reset special modes" : "back to the start menu"), 'R');
|
||||||
|
|
||||||
@ -235,7 +235,7 @@ EX void showMainMenu() {
|
|||||||
#else
|
#else
|
||||||
q = quitsaves() ? "save" : "quit";
|
q = quitsaves() ? "save" : "quit";
|
||||||
q = q + " the game";
|
q = q + " the game";
|
||||||
dialog::addItem(XLAT(q), 'q'); dialog::lastItem().keycaption += " / F10";
|
dialog::addItem(XLAT(q), 'q');
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(canmove)
|
if(canmove)
|
||||||
|
Loading…
Reference in New Issue
Block a user