mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-04-28 13:43:20 +00:00
dialog:: lists in help extensions
This commit is contained in:
parent
42f96b768c
commit
2e9ee75dc3
24
help.cpp
24
help.cpp
@ -14,7 +14,7 @@ EX function<void()> help_delegate;
|
|||||||
|
|
||||||
#if HDR
|
#if HDR
|
||||||
struct help_extension {
|
struct help_extension {
|
||||||
char key;
|
int key;
|
||||||
string text;
|
string text;
|
||||||
string subtext;
|
string subtext;
|
||||||
color_t color;
|
color_t color;
|
||||||
@ -1102,28 +1102,32 @@ EX void showHelp() {
|
|||||||
dialog::addHelp(help);
|
dialog::addHelp(help);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool in_list = false;
|
||||||
|
|
||||||
for(auto& he: help_extensions) {
|
for(auto& he: help_extensions) {
|
||||||
|
if(!in_list && he.key == dialog::first_list_fake_key) {
|
||||||
|
dialog::start_list(1000, 1000, 'a');
|
||||||
|
in_list = true;
|
||||||
|
}
|
||||||
|
if(in_list && (he.key < dialog::first_list_fake_key || he.key > dialog::first_list_fake_key + 1000)) {
|
||||||
|
in_list = false;
|
||||||
|
dialog::end_list();
|
||||||
|
}
|
||||||
|
|
||||||
if(he.subtext != "")
|
if(he.subtext != "")
|
||||||
dialog::addSelItem(he.text, he.subtext, he.key);
|
dialog::addSelItem(he.text, he.subtext, he.key);
|
||||||
else
|
else
|
||||||
dialog::addItem(he.text, he.key);
|
dialog::addItem(he.text, he.key);
|
||||||
|
dialog::add_action(he.action);
|
||||||
dialog::lastItem().color = he.color;
|
dialog::lastItem().color = he.color;
|
||||||
}
|
}
|
||||||
|
if(in_list) dialog::end_list();
|
||||||
|
|
||||||
dialog::display();
|
dialog::display();
|
||||||
|
|
||||||
keyhandler = [] (int sym, int uni) {
|
keyhandler = [] (int sym, int uni) {
|
||||||
dialog::handleNavigation(sym, uni);
|
dialog::handleNavigation(sym, uni);
|
||||||
|
|
||||||
for(auto& he: help_extensions)
|
|
||||||
if(uni == he.key) {
|
|
||||||
// we need to copy he.action
|
|
||||||
// as otherwise it could clear the extensions,
|
|
||||||
// leading to errors
|
|
||||||
auto act = he.action;
|
|
||||||
act();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(sym == SDLK_F1) {
|
if(sym == SDLK_F1) {
|
||||||
auto i = help;
|
auto i = help;
|
||||||
buildHelpText();
|
buildHelpText();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user