diff options
Diffstat (limited to 'crawl-ref/source/menu.h')
-rw-r--r-- | crawl-ref/source/menu.h | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/crawl-ref/source/menu.h b/crawl-ref/source/menu.h index a788b92ebc..57b90b33b0 100644 --- a/crawl-ref/source/menu.h +++ b/crawl-ref/source/menu.h @@ -5,6 +5,7 @@ #include <vector> #include <algorithm> #include "AppHdr.h" +#include "externs.h" #include "defines.h" #include "libutil.h" @@ -123,15 +124,18 @@ public: enum MenuFlag { - MF_NOSELECT = 0, // No selection is permitted - MF_SINGLESELECT = 1, // Select just one item - MF_MULTISELECT = 2, // Select multiple items - MF_NO_SELECT_QTY = 4, // Disallow partial selections - MF_ANYPRINTABLE = 8, // Any printable character is valid, and - // closes the menu. - MF_SELECT_ANY_PAGE = 16, // Allow selections to occur on any page. - - MF_EASY_EXIT = 64 + MF_NOSELECT = 0x0000, // No selection is permitted + MF_SINGLESELECT = 0x0001, // Select just one item + MF_MULTISELECT = 0x0002, // Select multiple items + MF_NO_SELECT_QTY = 0x0004, // Disallow partial selections + MF_ANYPRINTABLE = 0x0008, // Any printable character is valid, and + // closes the menu. + MF_SELECT_ANY_PAGE = 0x0010, // Allow selections to occur on any page. + + MF_ALWAYS_SHOW_MORE = 0x0020, // Always show the -more- footer + MF_NOWRAP = 0x0040, // Paging past the end will not wrap back. + + MF_EASY_EXIT = 0x1000 }; /////////////////////////////////////////////////////////////////////// @@ -147,12 +151,17 @@ public: Menu( int flags = MF_MULTISELECT ); virtual ~Menu(); - void set_flags( int new_flags ) { this->flags = new_flags; } + // Sets menu flags to new_flags. If use_options is true, game options may + // override options. + void set_flags(int new_flags, bool use_options = true); int get_flags() const { return flags; } bool is_set( int flag ) const; bool draw_title_suffix( const std::string &s, bool titlefirst = true ); void update_title(); + + // Sets a replacement for the --more-- string. + void set_more(const formatted_string &more); void set_highlighter( MenuHighlighter *h ); void set_title( MenuEntry *e ); @@ -171,8 +180,12 @@ public: public: typedef std::string (*selitem_tfn)( const std::vector<MenuEntry*> *sel ); + typedef void (*drawitem_tfn)(int index, const MenuEntry *me); + typedef int (*keyfilter_tfn)(int keyin); - selitem_tfn selitem_text; + selitem_tfn f_selitem; + drawitem_tfn f_drawitem; + keyfilter_tfn f_keyfilter; protected: MenuEntry *title; @@ -181,6 +194,8 @@ protected: int first_entry, y_offset; int pagesize; + formatted_string more; + std::vector<MenuEntry*> items; std::vector<MenuEntry*> *sel; std::vector<text_pattern> select_filter; @@ -196,7 +211,9 @@ protected: void do_menu( std::vector<MenuEntry*> *selected ); virtual void draw_select_count( int count ); - void draw_item( int index ) const; + virtual void draw_item( int index ) const; + virtual void draw_item(int index, const MenuEntry *me) const; + virtual void draw_title(); void draw_menu( std::vector<MenuEntry*> *selected ); bool page_down(); @@ -204,6 +221,8 @@ protected: bool page_up(); bool line_up(); + bool in_page(int index) const; + void deselect_all(bool update_view = true); void select_items( int key, int qty = -1 ); void select_index( int index, int qty = -1 ); |