From 2b2a5958399c551e7643237bc6b519d299bad164 Mon Sep 17 00:00:00 2001 From: haranp Date: Fri, 29 Jun 2007 16:55:20 +0000 Subject: Implemented 1715578: pressing '!' in the Z? screen toggles between showing schools/success and hunger/power. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1693 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/menu.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'crawl-ref/source/menu.h') diff --git a/crawl-ref/source/menu.h b/crawl-ref/source/menu.h index 834946d820..2607a02702 100644 --- a/crawl-ref/source/menu.h +++ b/crawl-ref/source/menu.h @@ -117,6 +117,20 @@ struct MenuEntry } }; +struct ToggleableMenuEntry : public MenuEntry +{ +public: + std::string alt_text; + + ToggleableMenuEntry( const std::string &txt = std::string(), + const std::string &alt_txt = std::string(), + MenuEntryLevel lev = MEL_ITEM, + int qty = 0, int hotk = 0 ) : + MenuEntry(txt, lev, qty, hotk), alt_text(alt_txt) {} + + void toggle() { text.swap(alt_text); } +}; + class MenuHighlighter { public: @@ -252,6 +266,19 @@ protected: virtual bool process_key( int keyin ); }; +// Allows toggling by specific keys. +class ToggleableMenu : public Menu +{ +public: + ToggleableMenu( int _flags = MF_MULTISELECT ) : Menu(_flags) {} + void add_toggle_key(int newkey) { toggle_keys.push_back(newkey); } +protected: + virtual int pre_process(int key); + + std::vector toggle_keys; +}; + + // Uses a sliding selector rather than hotkeyed selection. class slider_menu : public Menu { -- cgit v1.2.3-54-g00ecf