summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/menu.cc
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-10-19 22:30:42 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-10-19 22:30:42 +0000
commitd67f41ebf91d23eabe1640a2910cdae40358b77c (patch)
treeba68939920e514731ce118cf697e51357480d140 /crawl-ref/source/menu.cc
parent55901dbf5e38817170440cae2f80df7b468d52f5 (diff)
downloadcrawl-ref-d67f41ebf91d23eabe1640a2910cdae40358b77c.tar.gz
crawl-ref-d67f41ebf91d23eabe1640a2910cdae40358b77c.zip
Menus are now tagged. Menu colours now only apply to a menu with a matching
tag, unless the menu colour tag is empty or "any". Menu colours are specified as tag:colour:pattern, where the "tag:" part is optional (default is empty tag, i.e., all menus.) The following menu tags exist: ability, description, equip, help, inventory, notes, resists, spell, stash. Default .crawlrc should probably be changed (and the docs, too...) git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2493 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/menu.cc')
-rw-r--r--crawl-ref/source/menu.cc20
1 files changed, 13 insertions, 7 deletions
diff --git a/crawl-ref/source/menu.cc b/crawl-ref/source/menu.cc
index 6b368433cb..f9afedac4c 100644
--- a/crawl-ref/source/menu.cc
+++ b/crawl-ref/source/menu.cc
@@ -16,12 +16,13 @@
#include "view.h"
#include "initfile.h"
-Menu::Menu( int _flags )
+Menu::Menu( int _flags, const std::string& tagname )
: f_selitem(NULL),
f_drawitem(NULL),
f_keyfilter(NULL),
title(NULL),
flags(_flags),
+ tag(tagname),
first_entry(0),
y_offset(0),
pagesize(0),
@@ -92,6 +93,7 @@ void Menu::set_title( MenuEntry *e )
void Menu::add_entry( MenuEntry *entry )
{
+ entry->tag = tag;
items.push_back( entry );
}
@@ -1028,15 +1030,19 @@ bool slider_menu::line_up()
// Menu colouring
//
-int menu_colour(const std::string &text, const std::string &prefix)
+int menu_colour(const std::string &text, const std::string &prefix,
+ const std::string &tag)
{
- std::string tmp_text = prefix + text;
+ const std::string tmp_text = prefix + text;
- for (int i = 0, size = Options.menu_colour_mappings.size(); i < size; ++i)
+ for (unsigned int i = 0; i < Options.menu_colour_mappings.size(); ++i)
{
- colour_mapping &cm = Options.menu_colour_mappings[i];
- if (cm.pattern.matches(tmp_text))
+ const colour_mapping &cm = Options.menu_colour_mappings[i];
+ if ( (cm.tag.empty() || cm.tag == "any" || cm.tag == tag) &&
+ cm.pattern.matches(tmp_text) )
+ {
return (cm.colour);
+ }
}
return (-1);
}
@@ -1411,7 +1417,7 @@ bool formatted_scroller::page_up()
bool formatted_scroller::line_down()
{
- if (first_entry + pagesize < (int) items.size() &&
+ if (first_entry + pagesize < static_cast<int>(items.size()) &&
items[first_entry + pagesize]->level != MEL_TITLE )
{
++first_entry;