From 2e9ee75dc3266b0e850a956f6a9066119165a9e5 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sun, 4 Dec 2022 14:49:06 +0100 Subject: [PATCH] dialog:: lists in help extensions --- help.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/help.cpp b/help.cpp index 8cf13b51..e9719269 100644 --- a/help.cpp +++ b/help.cpp @@ -14,7 +14,7 @@ EX function help_delegate; #if HDR struct help_extension { - char key; + int key; string text; string subtext; color_t color; @@ -1102,28 +1102,32 @@ EX void showHelp() { dialog::addHelp(help); } + bool in_list = false; + 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 != "") dialog::addSelItem(he.text, he.subtext, he.key); else dialog::addItem(he.text, he.key); + dialog::add_action(he.action); dialog::lastItem().color = he.color; } + if(in_list) dialog::end_list(); dialog::display(); keyhandler = [] (int sym, int 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) { auto i = help; buildHelpText();