summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorMatthew Cline <zelgadis@sourceforge.net>2009-11-27 01:40:34 -0800
committerMatthew Cline <zelgadis@sourceforge.net>2009-11-27 01:40:34 -0800
commit0f8cd49c9c18260156782afc65bbea7b30a92804 (patch)
tree47f6395d1ccb9269f3b8e269a0bb22b72230e348 /crawl-ref
parent3e6a77f46bac1b303645b7391f72e86c882986c9 (diff)
downloadcrawl-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')
-rw-r--r--crawl-ref/source/abl-show.cc2
-rw-r--r--crawl-ref/source/directn.cc2
-rw-r--r--crawl-ref/source/menu.cc34
-rw-r--r--crawl-ref/source/menu.h4
-rw-r--r--crawl-ref/source/shopping.cc2
-rw-r--r--crawl-ref/source/stash.cc2
6 files changed, 30 insertions, 16 deletions
diff --git a/crawl-ref/source/abl-show.cc b/crawl-ref/source/abl-show.cc
index cb8c2fbd6c..4bda429d91 100644
--- a/crawl-ref/source/abl-show.cc
+++ b/crawl-ref/source/abl-show.cc
@@ -2169,7 +2169,7 @@ int choose_ability_menu(const std::vector<talent>& talents)
"between ability selection and description."));
}
- abil_menu.allow_toggle = true;
+ abil_menu.action_cycle = Menu::CYCLE_TOGGLE;
abil_menu.menu_action = Menu::ACT_EXECUTE;
int numbers[52];
diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc
index f478cb7130..11e887c728 100644
--- a/crawl-ref/source/directn.cc
+++ b/crawl-ref/source/directn.cc
@@ -604,7 +604,7 @@ void full_describe_view()
desc_menu.set_tag("pickup");
desc_menu.set_type(MT_PICKUP); // necessary for sorting of the item submenu
- desc_menu.allow_toggle = true;
+ desc_menu.action_cycle = Menu::CYCLE_TOGGLE;
// Don't make a menu so tall that we recycle hotkeys on the same page.
if (list_mons.size() + list_items.size() + list_features.size() > 52
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);
diff --git a/crawl-ref/source/menu.h b/crawl-ref/source/menu.h
index 4b93916447..fb822388ed 100644
--- a/crawl-ref/source/menu.h
+++ b/crawl-ref/source/menu.h
@@ -349,8 +349,8 @@ public:
drawitem_tfn f_drawitem;
keyfilter_tfn f_keyfilter;
- bool allow_toggle;
- enum action { ACT_EXECUTE, ACT_EXAMINE, ACT_NUM } menu_action;
+ enum cycle { CYCLE_NONE, CYCLE_TOGGLE, CYCLE_CYCLE } action_cycle;
+ enum action { ACT_EXECUTE, ACT_EXAMINE, ACT_MISC, ACT_NUM } menu_action;
protected:
MenuEntry *title;
diff --git a/crawl-ref/source/shopping.cc b/crawl-ref/source/shopping.cc
index c9ecd853be..8b5d04529e 100644
--- a/crawl-ref/source/shopping.cc
+++ b/crawl-ref/source/shopping.cc
@@ -2509,7 +2509,7 @@ void ShoppingList::display()
ShoppingListMenu shopmenu;
shopmenu.set_tag("shop");
shopmenu.menu_action = travelable ? Menu::ACT_EXECUTE : Menu::ACT_EXAMINE;
- shopmenu.allow_toggle = travelable;
+ shopmenu.action_cycle = Menu::CYCLE_TOGGLE;
std::string title = "thing";
MenuEntry *mtitle = new MenuEntry(title, MEL_TITLE);
diff --git a/crawl-ref/source/stash.cc b/crawl-ref/source/stash.cc
index 7c403a1a98..1c4bddfbc9 100644
--- a/crawl-ref/source/stash.cc
+++ b/crawl-ref/source/stash.cc
@@ -1863,7 +1863,7 @@ bool StashTracker::display_search_results(
StashSearchMenu stashmenu(sort_style);
stashmenu.set_tag("stash");
stashmenu.can_travel = travelable;
- stashmenu.allow_toggle = true;
+ stashmenu.action_cycle = Menu::CYCLE_TOGGLE;
stashmenu.menu_action = Menu::ACT_EXECUTE;
std::string title = "match";