summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-04-17 13:43:42 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-04-17 13:43:42 +0000
commitf672c6472dfa1ac6fa64f1d77e5701589576ca6c (patch)
tree96309e9add139ef71e0ba3f529f7502ebb2e1530 /crawl-ref
parent7a0cf4fa055dbebc676db78dde82881be8a6e6af (diff)
downloadcrawl-ref-f672c6472dfa1ac6fa64f1d77e5701589576ca6c.tar.gz
crawl-ref-f672c6472dfa1ac6fa64f1d77e5701589576ca6c.zip
Allow specific colouring of pickup menu (as opposed to general
inventory). To do so, use "pickup:colour:pattern". git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@4287 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/docs/options_guide.txt26
-rw-r--r--crawl-ref/source/initfile.cc4
-rw-r--r--crawl-ref/source/invent.cc11
-rw-r--r--crawl-ref/source/invent.h14
-rw-r--r--crawl-ref/source/items.cc1
-rw-r--r--crawl-ref/source/menu.cc5
-rw-r--r--crawl-ref/source/menu.h33
7 files changed, 52 insertions, 42 deletions
diff --git a/crawl-ref/docs/options_guide.txt b/crawl-ref/docs/options_guide.txt
index 6e5cd36731..a6f697f108 100644
--- a/crawl-ref/docs/options_guide.txt
+++ b/crawl-ref/docs/options_guide.txt
@@ -897,8 +897,9 @@ sort_menus = [menu:](true | false | auto:X)[:sort_order]
will be ordered by inventory letter (or in the order they're
stacked for items on the floor).
- When sort_menus = true, items are sorted by base name, qualified
- name, curse status and quantity.
+ When sort_menus = true, items are sorted according to the specified
+ sort_order, with the default being:
+ equipped, basename, qualname, curse, qty
If sort_menus = auto:X, items are sorted if there are at least
X items in the same category. For instance:
@@ -909,14 +910,16 @@ sort_menus = [menu:](true | false | auto:X)[:sort_order]
You can explicitly specify sort criteria in the sort_menus
option as:
- sort_menus = true : basename, qualname, curse, qty
+ sort_menus = true : art, basename, qualname, curse, qty
Two items will be compared based on the first sort criteria
where they differ. So with the sort_menus line given above,
- if the basenames of two different items are different they
- will be alphabetically compared using their basenames; if
- the basenames are the same but the qualified names different
- it will compare their qualified names, and so on.
+ if only one of two different items is a known artefact, it will be
+ listed first, else (if both or neither are artefacts) if their
+ basenames are different they will be alphabetically compared
+ using their basenames; if the basenames are the same but the
+ qualified names different it will compare their qualified
+ names, and so on.
The available sort criteria are:
@@ -970,9 +973,6 @@ sort_menus = [menu:](true | false | auto:X)[:sort_order]
basename and qualname, then non-chunk food items will be
sorted between the non-rotting and rotting chunks.
- The default sort criteria are:
- "equipped, basename, qualname, curse, qty".
-
You can ask for a descending order sort by prefixing one or more
sort criteria with > as:
sort_menus = true : basename, >qty
@@ -984,6 +984,10 @@ sort_menus = [menu:](true | false | auto:X)[:sort_order]
(Menu types must be specified as name:, with no space between
name and colon.)
+ By default only pickup menus are sorted, and the sort criteria are:
+ "basename, qualname, curse, qty".
+ All other menus (drop, inv) will be sorted by inventory letter.
+
The menu selectors available are:
pickup: All pickup menus, stash-search menus, etc. for items not
@@ -1114,7 +1118,7 @@ menu_colour = <match>:<colour>:<regex>
To quickly check what potions were trashed by a mummy curse, use
menu_colour = inventory:lightred:potions? of (degeneration|decay)
- If you like to see rotten chunks and corpses at a glance, use
+ If you'd like to see rotten chunks and corpses at a glance, use
menu_colour = inventory:red: rotting
menu_colour can also be applied to colour the in-game notes (to
diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc
index d9a8d3603e..0fb15ea644 100644
--- a/crawl-ref/source/initfile.cc
+++ b/crawl-ref/source/initfile.cc
@@ -2445,9 +2445,9 @@ void game_options::read_option_line(const std::string &str, bool runscript)
}
colour_mapping mapping;
- mapping.tag = tagname;
+ mapping.tag = tagname;
mapping.pattern = patname;
- mapping.colour = str_to_colour(colname);
+ mapping.colour = str_to_colour(colname);
if (mapping.colour != -1)
menu_colour_mappings.push_back(mapping);
diff --git a/crawl-ref/source/invent.cc b/crawl-ref/source/invent.cc
index 71850082ba..01e5bd5543 100644
--- a/crawl-ref/source/invent.cc
+++ b/crawl-ref/source/invent.cc
@@ -558,19 +558,20 @@ void InvMenu::load_items(const std::vector<const item_def*> &mitems,
menu_letter ckey;
std::vector<InvEntry*> items_in_class;
-
const menu_sort_condition *cond = find_menu_sort_condition();
for (int i = 0; i < NUM_OBJECT_CLASSES; ++i)
{
- if (!inv_class[i]) continue;
+ if (!inv_class[i])
+ continue;
add_entry( new MenuEntry( item_class_name(i), MEL_SUBTITLE ) );
items_in_class.clear();
for (int j = 0, count = mitems.size(); j < count; ++j)
{
- if (mitems[j]->base_type != i) continue;
+ if (mitems[j]->base_type != i)
+ continue;
items_in_class.push_back( new InvEntry(*mitems[j]) );
}
@@ -579,6 +580,8 @@ void InvMenu::load_items(const std::vector<const item_def*> &mitems,
for (unsigned int j = 0; j < items_in_class.size(); ++j)
{
InvEntry *ie = items_in_class[j];
+ if (this->tag == "pickup")
+ ie->tag = "pickup";
// If there's no hotkey, provide one.
if (ie->hotkeys[0] == ' ')
ie->hotkeys[0] = ckey++;
@@ -738,6 +741,8 @@ std::vector<SelItem> select_items( const std::vector<const item_def*> &items,
InvMenu menu;
menu.set_type(mtype);
menu.set_title(title);
+ if (mtype == MT_PICKUP)
+ menu.set_tag("pickup");
menu.load_items(items);
menu.set_flags(noselect ? MF_NOSELECT | MF_SHOW_PAGENUMBERS :
MF_MULTISELECT | MF_ALLOW_FILTER | MF_SHOW_PAGENUMBERS);
diff --git a/crawl-ref/source/invent.h b/crawl-ref/source/invent.h
index 804a034a64..74ac810a85 100644
--- a/crawl-ref/source/invent.h
+++ b/crawl-ref/source/invent.h
@@ -43,7 +43,7 @@ struct SelItem
SelItem() : slot(0), quantity(0), item(NULL) { }
SelItem( int s, int q, const item_def *it = NULL )
- : slot(s), quantity(q), item(it)
+ : slot(s), quantity(q), item(it)
{
}
};
@@ -55,7 +55,7 @@ struct InvTitle : public MenuEntry
{
Menu *m;
invtitle_annotator titlefn;
-
+
InvTitle( Menu *mn, const std::string &title,
invtitle_annotator tfn );
@@ -71,7 +71,7 @@ private:
mutable std::string basename;
mutable std::string qualname;
-
+
friend class InvShowPrices;
public:
@@ -112,7 +112,7 @@ public:
class InvMenu : public Menu
{
public:
- InvMenu(int mflags = MF_MULTISELECT)
+ InvMenu(int mflags = MF_MULTISELECT)
: Menu(mflags, "inventory"), type(MT_INVLIST), pre_select(NULL),
title_annotate(NULL)
{
@@ -169,15 +169,15 @@ protected:
int prompt_invent_item( const char *prompt,
menu_type type,
int type_expect,
- bool must_exist = true,
- bool allow_auto_list = true,
+ bool must_exist = true,
+ bool allow_auto_list = true,
bool allow_easy_quit = true,
const char other_valid_char = '\0',
int *const count = NULL,
operation_types oper = OPER_ANY );
std::vector<SelItem> select_items(
- const std::vector<const item_def*> &items,
+ const std::vector<const item_def*> &items,
const char *title, bool noselect = false,
menu_type mtype = MT_PICKUP );
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc
index 04e20be1eb..4a082d92fb 100644
--- a/crawl-ref/source/items.cc
+++ b/crawl-ref/source/items.cc
@@ -664,7 +664,6 @@ static int count_nonsquelched_items( int obj )
static void _item_list_on_square( std::vector<const item_def*>& items,
int obj, bool force_squelch )
{
-
const bool have_nonsquelched = (force_squelch ||
count_nonsquelched_items(obj));
diff --git a/crawl-ref/source/menu.cc b/crawl-ref/source/menu.cc
index 2e6e291001..6d004e968d 100644
--- a/crawl-ref/source/menu.cc
+++ b/crawl-ref/source/menu.cc
@@ -1169,8 +1169,9 @@ int menu_colour(const std::string &text, const std::string &prefix,
for (unsigned int i = 0; i < Options.menu_colour_mappings.size(); ++i)
{
const colour_mapping &cm = Options.menu_colour_mappings[i];
- if ( (cm.tag.empty() || cm.tag == "any" || cm.tag == tag) &&
- cm.pattern.matches(tmp_text) )
+ if ( (cm.tag.empty() || cm.tag == "any" || cm.tag == tag
+ || cm.tag == "inventory" && tag == "pickup")
+ && cm.pattern.matches(tmp_text) )
{
return (cm.colour);
}
diff --git a/crawl-ref/source/menu.h b/crawl-ref/source/menu.h
index e1af2f760e..652a68cd87 100644
--- a/crawl-ref/source/menu.h
+++ b/crawl-ref/source/menu.h
@@ -37,7 +37,7 @@ struct menu_letter
menu_letter(char c) : letter(c) { }
operator char () const { return letter; }
-
+
const menu_letter &operator ++ ()
{
letter = letter == 'z'? 'A' :
@@ -79,15 +79,16 @@ struct MenuEntry
text(txt), quantity(qty), selected_qty(0), colour(-1),
hotkeys(), level(lev), data(NULL)
{
- colour = lev == MEL_ITEM? LIGHTGREY :
- lev == MEL_SUBTITLE? BLUE :
- WHITE;
+ colour = (lev == MEL_ITEM ? LIGHTGREY :
+ lev == MEL_SUBTITLE ? BLUE :
+ WHITE);
if (hotk)
hotkeys.push_back( hotk );
}
virtual ~MenuEntry() { }
- bool operator<( const MenuEntry& rhs ) const {
+ bool operator<( const MenuEntry& rhs ) const
+ {
return text < rhs.text;
}
@@ -96,7 +97,7 @@ struct MenuEntry
if (key && !is_hotkey(key))
hotkeys.push_back( key );
}
-
+
bool is_hotkey( int key ) const
{
return find( hotkeys.begin(), hotkeys.end(), key ) != hotkeys.end();
@@ -106,7 +107,7 @@ struct MenuEntry
{
return hotkeys.size()? hotkeys[0] == key : false;
}
-
+
virtual std::string get_text() const
{
if (level == MEL_ITEM && hotkeys.size())
@@ -165,7 +166,7 @@ enum MenuFlag
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
+ MF_ANYPRINTABLE = 0x0008, // Any printable character is valid, and
// closes the menu.
MF_SELECT_BY_PAGE = 0x0010, // Allow selections to occur only on
// currently visible page.
@@ -197,7 +198,7 @@ public:
Menu( int flags = MF_MULTISELECT, const std::string& tagname = "" );
// Initializes a Menu from a formatted_string as follows:
- //
+ //
// 1) Splits the formatted_string on EOL (this is not necessarily \n).
// 2) Picks the most recently used non-whitespace colour as the colour
// for the next line (so it can't do multiple colours on one line).
@@ -206,7 +207,7 @@ public:
// These are limitations that should be fixed eventually.
//
Menu( const formatted_string &fs );
-
+
virtual ~Menu();
// Remove all items from the Menu, leave title intact.
@@ -218,14 +219,14 @@ public:
int get_flags() const { return flags; }
virtual bool is_set( int flag ) const;
void set_tag(const std::string& t) { tag = t; }
-
+
bool draw_title_suffix( const std::string &s, bool titlefirst = true );
bool draw_title_suffix( const formatted_string &fs, 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 );
void add_entry( MenuEntry *entry );
@@ -262,7 +263,7 @@ protected:
MenuEntry *title;
int flags;
std::string tag;
-
+
int first_entry, y_offset;
int pagesize, max_pagesize;
@@ -313,7 +314,7 @@ protected:
bool is_selectable(int index) const;
virtual int item_colour(int index, const MenuEntry *me) const;
-
+
virtual bool process_key( int keyin );
};
@@ -390,7 +391,7 @@ public:
column_composer(int ncols, ...);
void clear();
- void add_formatted(int ncol,
+ void add_formatted(int ncol,
const std::string &tagged_text,
bool add_separator = true,
bool eol_ends_format = true,
@@ -425,7 +426,7 @@ private:
// This class is for when (some of) your items are formatted, and
// you want mostly a browser.
-//
+//
// If MF_NOSELECT, hotkeys jump to menu items.
// If MF_SINGLESELECT, hotkeys end the menu immediately.
// MF_MULTISELECT is not supported.