diff options
author | Matthew Cline <zelgadis@sourceforge.net> | 2009-11-27 01:40:34 -0800 |
---|---|---|
committer | Matthew Cline <zelgadis@sourceforge.net> | 2009-11-27 01:40:34 -0800 |
commit | 0f8cd49c9c18260156782afc65bbea7b30a92804 (patch) | |
tree | 47f6395d1ccb9269f3b8e269a0bb22b72230e348 /crawl-ref/source/menu.cc | |
parent | 3e6a77f46bac1b303645b7391f72e86c882986c9 (diff) | |
download | crawl-ref-0f8cd49c9c18260156782afc65bbea7b30a92804.tar.gz crawl-ref-0f8cd49c9c18260156782afc65bbea7b30a92804.zip |
Add third menu action type ACT_MISC
To the menu actions ACT_EXECUTE and ACT_EXAMINE add the third action
type ACT_MISC, for things like deleting menu entries. The member
"allow_toggle" has been changed to "action_cycle", with the possible
values CYCLE_NONE (default) , CYCLE_TOGGLE (allow_toggle == true), and
CYCLE_CYCLE (cycle through all three possible action types).
Diffstat (limited to 'crawl-ref/source/menu.cc')
-rw-r--r-- | crawl-ref/source/menu.cc | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/crawl-ref/source/menu.cc b/crawl-ref/source/menu.cc index 897ccd14b1..846f5fc0fa 100644 --- a/crawl-ref/source/menu.cc +++ b/crawl-ref/source/menu.cc @@ -95,12 +95,12 @@ void MenuDisplayTile::set_num_columns(int columns) #endif Menu::Menu( int _flags, const std::string& tagname, bool text_only ) - : f_selitem(NULL), f_drawitem(NULL), f_keyfilter(NULL), allow_toggle(false), - menu_action(ACT_EXAMINE), title(NULL), title2(NULL), flags(_flags), - tag(tagname), first_entry(0), y_offset(0), pagesize(0), max_pagesize(0), - more("-more-", true), items(), sel(), select_filter(), - highlighter(new MenuHighlighter), num(-1), lastch(0), alive(false), - last_selected(-1) + : f_selitem(NULL), f_drawitem(NULL), f_keyfilter(NULL), + action_cycle(CYCLE_NONE), menu_action(ACT_EXAMINE), title(NULL), + title2(NULL), flags(_flags), tag(tagname), first_entry(0), y_offset(0), + pagesize(0), max_pagesize(0), more("-more-", true), items(), sel(), + select_filter(), highlighter(new MenuHighlighter), num(-1), lastch(0), + alive(false), last_selected(-1) { #ifdef USE_TILE if (text_only) @@ -115,8 +115,9 @@ Menu::Menu( int _flags, const std::string& tagname, bool text_only ) } Menu::Menu( const formatted_string &fs ) - : f_selitem(NULL), f_drawitem(NULL), f_keyfilter(NULL), allow_toggle(false), - menu_action(ACT_EXAMINE), title(NULL), title2(NULL), + : f_selitem(NULL), f_drawitem(NULL), f_keyfilter(NULL), + action_cycle(CYCLE_NONE), menu_action(ACT_EXAMINE), title(NULL), + title2(NULL), // This is a text-viewer menu, init flags to be easy on the user. flags(MF_NOSELECT | MF_EASY_EXIT), @@ -348,10 +349,22 @@ bool Menu::process_key( int keyin ) lastch = keyin; return (false); } - else if (allow_toggle && (keyin == '!' || keyin == '?')) + else if (action_cycle == CYCLE_TOGGLE && (keyin == '!' || keyin == '?')) { + ASSERT(menu_action != ACT_MISC); + if (menu_action == ACT_EXECUTE) + menu_action = ACT_EXAMINE; + else + menu_action = ACT_EXECUTE; + sel.clear(); + update_title(); + return (true); + } + else if (action_cycle == CYCLE_CYCLE && (keyin == '!' || keyin == '?')) + { menu_action = (action)((menu_action+1) % ACT_NUM); + sel.clear(); update_title(); return (true); } @@ -1102,7 +1115,8 @@ void Menu::draw_title() void Menu::write_title() { - const bool first = (!allow_toggle || menu_action == ACT_EXECUTE); + const bool first = (action_cycle == CYCLE_NONE + || menu_action == ACT_EXECUTE); if (!first) ASSERT(title2); |