summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-06-06 19:19:35 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-06-06 19:19:35 +0000
commitc7116e761c1805b3991509f50f87b89eaad3a857 (patch)
tree06aec90cff3983dff786681477bd62e44eec6ba3
parentd73eb4aaefb38e2aac5a8b20ed5da7619526c034 (diff)
downloadcrawl-ref-c7116e761c1805b3991509f50f87b89eaad3a857.tar.gz
crawl-ref-c7116e761c1805b3991509f50f87b89eaad3a857.zip
Apply r9904 to trunk.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@9905 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/docs/options_guide.txt5
-rw-r--r--crawl-ref/source/invent.cc20
-rw-r--r--crawl-ref/source/invent.h2
-rw-r--r--crawl-ref/source/it_use3.cc2
-rw-r--r--crawl-ref/source/menu.cc24
-rw-r--r--crawl-ref/source/tilereg.cc19
6 files changed, 47 insertions, 25 deletions
diff --git a/crawl-ref/docs/options_guide.txt b/crawl-ref/docs/options_guide.txt
index 982f01ff40..eb80df825d 100644
--- a/crawl-ref/docs/options_guide.txt
+++ b/crawl-ref/docs/options_guide.txt
@@ -1152,6 +1152,11 @@ 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.
+ * charged:
+ Makes wands known or assumed to have some charges left appear
+ before wands known to be empty; irrelevant for all other item
+ types.
+
You can ask for a descending order sort by prefixing one or more
sort criteria with > as:
sort_menus = true : basename, >qty
diff --git a/crawl-ref/source/invent.cc b/crawl-ref/source/invent.cc
index 363fe1a48a..4d7d7f0e35 100644
--- a/crawl-ref/source/invent.cc
+++ b/crawl-ref/source/invent.cc
@@ -326,7 +326,8 @@ InvMenu::InvMenu(int mflags)
: Menu(mflags, "inventory", false), type(MT_INVLIST), pre_select(NULL),
title_annotate(NULL)
{
- mdisplay->set_num_columns(2);
+ if (Options.tile_menu_icons)
+ mdisplay->set_num_columns(2);
}
// Returns vector of item_def pointers to each item_def in the given
@@ -645,8 +646,14 @@ bool sort_item_identified(const InvEntry *a)
return !item_type_known(*(a->item));
}
+bool sort_item_charged(const InvEntry *a)
+{
+ return (a->item->base_type != OBJ_WANDS
+ || !item_is_evokable(*(a->item), true));
+}
+
static bool _compare_invmenu_items(const InvEntry *a, const InvEntry *b,
- const item_sort_comparators *cmps)
+ const item_sort_comparators *cmps)
{
for (item_sort_comparators::const_iterator i = cmps->begin();
i != cmps->end(); ++i)
@@ -693,6 +700,7 @@ void init_item_sort_comparators(item_sort_comparators &list,
{ "art", compare_item<bool, sort_item_art> },
{ "equipped", compare_item<bool, sort_item_equipped> },
{ "identified",compare_item<bool, sort_item_identified> },
+ { "charged", compare_item<bool, sort_item_charged>},
{ "qty", compare_item<int, sort_item_qty> },
{ "slot", compare_item<int, sort_item_slot> },
{ "freshness", compare_item<int, sort_item_freshness> }
@@ -1023,7 +1031,7 @@ static bool _item_class_selected(const item_def &i, int selector)
return (item_is_rechargeable(i, true));
case OSEL_EVOKABLE:
- return (item_is_evokable(i, true));
+ return (item_is_evokable(i, true, true));
case OSEL_ENCH_ARM:
return (is_enchantable_armour(i, true, true));
@@ -1709,13 +1717,17 @@ bool prompt_failed(int retval, std::string msg)
return (true);
}
-bool item_is_evokable(const item_def &item, bool known, bool msg)
+bool item_is_evokable(const item_def &item, bool known, bool all_wands,
+ bool msg)
{
const bool wielded = (you.equip[EQ_WEAPON] == item.link);
switch (item.base_type)
{
case OBJ_WANDS:
+ if (all_wands)
+ return (true);
+
if (item.plus2 == ZAPCOUNT_EMPTY)
{
if (msg)
diff --git a/crawl-ref/source/invent.h b/crawl-ref/source/invent.h
index 2f64cf9d59..8f94ef26a7 100644
--- a/crawl-ref/source/invent.h
+++ b/crawl-ref/source/invent.h
@@ -235,6 +235,6 @@ void init_item_sort_comparators(item_sort_comparators &list,
bool prompt_failed(int retval, std::string msg = "");
bool item_is_evokable(const item_def &item, bool known = false,
- bool msg = false);
+ bool all_wands = false, bool msg = false);
#endif
diff --git a/crawl-ref/source/it_use3.cc b/crawl-ref/source/it_use3.cc
index b1723620c9..77c91e5554 100644
--- a/crawl-ref/source/it_use3.cc
+++ b/crawl-ref/source/it_use3.cc
@@ -814,7 +814,7 @@ bool evoke_item(int slot)
item_def& item = you.inv[slot];
// Also handles messages.
- if (!item_is_evokable(item, false, true))
+ if (!item_is_evokable(item, false, false, true))
return (false);
// Check inscriptions.
diff --git a/crawl-ref/source/menu.cc b/crawl-ref/source/menu.cc
index e4c5a6dc6a..e2a907f5f0 100644
--- a/crawl-ref/source/menu.cc
+++ b/crawl-ref/source/menu.cc
@@ -1347,7 +1347,7 @@ void slider_menu::new_selection(int nsel)
{
if (nsel < 0)
{
- if ( !is_set(MF_NOWRAP) )
+ if (!is_set(MF_NOWRAP))
{
do
{
@@ -1360,7 +1360,7 @@ void slider_menu::new_selection(int nsel)
}
if (nsel >= static_cast<int>(items.size()))
{
- if ( !is_set(MF_NOWRAP) )
+ if (!is_set(MF_NOWRAP))
{
do
{
@@ -1620,12 +1620,12 @@ int linebreak_string( std::string& s, int wrapcol, int maxcol )
size_t loc = 0;
int xpos = 0;
int breakcount = 0;
- while ( loc < s.size() )
+ while (loc < s.size())
{
- if ( s[loc] == '<' ) // tag
+ if (s[loc] == '<') // tag
{
// << escape
- if ( loc + 1 < s.size() && s[loc+1] == '<' )
+ if (loc + 1 < s.size() && s[loc+1] == '<')
{
++xpos;
loc += 2;
@@ -1633,24 +1633,24 @@ int linebreak_string( std::string& s, int wrapcol, int maxcol )
continue;
}
// skip tag
- while ( loc < s.size() && s[loc] != '>' )
+ while (loc < s.size() && s[loc] != '>')
++loc;
++loc;
}
else
{
// user-forced newline
- if ( s[loc] == '\n' )
+ if (s[loc] == '\n')
xpos = 0;
// soft linebreak
- else if ( s[loc] == ' ' && xpos > wrapcol )
+ else if (s[loc] == ' ' && xpos > wrapcol)
{
s.replace(loc, 1, "\n");
xpos = 0;
++breakcount;
}
// hard linebreak
- else if ( xpos > maxcol )
+ else if (xpos > maxcol)
{
s.insert(loc, "\n");
xpos = 0;
@@ -1691,7 +1691,7 @@ int linebreak_string2( std::string& s, int maxcol )
else
{
// user-forced newline, or one we just stuffed in
- if ( s[loc] == '\n' )
+ if (s[loc] == '\n')
{
xpos = 0;
spaceloc = 0;
@@ -1700,7 +1700,7 @@ int linebreak_string2( std::string& s, int maxcol )
}
// force a wrap?
- if ( xpos >= maxcol )
+ if (xpos >= maxcol)
{
if (spaceloc)
{
@@ -1717,7 +1717,7 @@ int linebreak_string2( std::string& s, int maxcol )
}
// save possible linebreak location
- if ( s[loc] == ' ' && xpos > 0)
+ if (s[loc] == ' ' && xpos > 0)
{
spaceloc = loc;
}
diff --git a/crawl-ref/source/tilereg.cc b/crawl-ref/source/tilereg.cc
index 3bb15874ae..0188f20de0 100644
--- a/crawl-ref/source/tilereg.cc
+++ b/crawl-ref/source/tilereg.cc
@@ -2625,8 +2625,8 @@ void MenuRegion::place_entries()
const int heading_indent = 10;
const int tile_indent = 20;
const int text_indent = (Options.tile_menu_icons ? 58 : 20);
- const int max_tile_height = 32;
- const int entry_buffer = 1;
+ const int max_tile_height = (Options.tile_menu_icons ? 32 : 0);
+ const int entry_buffer = 1;
const VColour selected_colour(50, 50, 10, 255);
m_font_buf.clear();
@@ -2668,7 +2668,7 @@ void MenuRegion::place_entries()
column++;
}
- int text_width = m_font_entry->string_width(m_entries[i].text);
+ int text_width = m_font_entry->string_width(m_entries[i].text);
int text_height = m_font_entry->char_height();
if (m_entries[i].heading)
@@ -2714,7 +2714,8 @@ void MenuRegion::place_entries()
int text_sy = m_entries[i].sy;
text_sy += (entry_height - m_font_entry->char_height()) / 2;
- if (text_sx + text_width > entry_start + column_width)
+ if (Options.tile_menu_icons
+ && text_sx + text_width > entry_start + column_width)
{
// [enne] - Ugh, hack. Maybe MenuEntry could specify the
// presence and length of this substring?
@@ -2841,10 +2842,14 @@ int MenuRegion::maxpagesize() const
// It would be better to make menus use a dynamic number of items per page,
// but it'd require a lot more refactoring of menu.cc to handle that.
- int lines = count_linebreaks(m_more);
- int more_height = (lines + 1) * m_font_entry->char_height();
+ const int lines = count_linebreaks(m_more);
+ const int more_height = (lines + 1) * m_font_entry->char_height();
+
+ // Similar to the definition of max_entry_height in place_entries().
+ const int div = (Options.tile_menu_icons ? 32
+ : m_font_entry->char_height());
- int pagesize = ((my - more_height) / 32) * m_max_columns;
+ const int pagesize = ((my - more_height) / div) * m_max_columns;
// Upper limit for inventory menus. (jpeg)
// Non-inventory menus only have one column and need