summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-04-29 11:24:06 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-04-29 11:24:06 +0000
commitc5eb6a75b02e59b8821c9244f7abd549fa10ebff (patch)
treee1cf7479c1b3dbe21d6236a15c1753901e5b8130 /crawl-ref/source
parentb51817cbfd4a52f6d66ed5e7580ad3b0c75ffef2 (diff)
downloadcrawl-ref-c5eb6a75b02e59b8821c9244f7abd549fa10ebff.tar.gz
crawl-ref-c5eb6a75b02e59b8821c9244f7abd549fa10ebff.zip
Added a show_inventory_weights option (defaults to false), following
1629320. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1393 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/externs.h1
-rw-r--r--crawl-ref/source/initfile.cc6
-rw-r--r--crawl-ref/source/invent.cc29
3 files changed, 25 insertions, 11 deletions
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h
index 4ae9f482c7..99be5026e2 100644
--- a/crawl-ref/source/externs.h
+++ b/crawl-ref/source/externs.h
@@ -1279,6 +1279,7 @@ public:
bool show_turns; // Show turns used in HUD.
long autopickups; // items to autopickup
+ bool show_inventory_weights; // show weights in inventory listings
bool verbose_dump; // make character dumps contain more detail
bool detailed_stat_dump; // add detailed stat and resist dump
bool colour_map; // add colour to the map
diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc
index f712195036..9e2e079e1e 100644
--- a/crawl-ref/source/initfile.cc
+++ b/crawl-ref/source/initfile.cc
@@ -583,6 +583,7 @@ void game_options::reset_options()
(1L << 7) | // jewellery
(1L << 3) | // wands
(1L << 4)); // food
+ show_inventory_weights = false;
verbose_dump = false;
detailed_stat_dump = true;
colour_map = true;
@@ -1475,6 +1476,11 @@ void game_options::read_option_line(const std::string &str, bool runscript)
// should autoprayer default to on or off?
autoprayer_on = read_bool( field, autoprayer_on );
}
+ else if (key == "show_inventory_weights")
+ {
+ // should weights be shown on inventory items?
+ show_inventory_weights = read_bool( field, show_inventory_weights );
+ }
else if (key == "detailed_stat_dump")
{
detailed_stat_dump =
diff --git a/crawl-ref/source/invent.cc b/crawl-ref/source/invent.cc
index a7192a5eaa..5096365115 100644
--- a/crawl-ref/source/invent.cc
+++ b/crawl-ref/source/invent.cc
@@ -20,6 +20,7 @@
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
+#include <sstream>
#ifdef DOS
#include <conio.h>
@@ -94,23 +95,29 @@ InvEntry::InvEntry( const item_def &i ) : MenuEntry( "", MEL_ITEM ), item( &i )
std::string InvEntry::get_text() const
{
- char buf[ITEMNAME_SIZE];
- char suffix[ITEMNAME_SIZE] = "";
+ std::ostringstream tstr;
+ tstr << ' ' << static_cast<char>(hotkeys[0]) << ' ';
+ if ( !selected_qty )
+ tstr << '-';
+ else if ( selected_qty < quantity )
+ tstr << '#';
+ else
+ tstr << '+';
+ tstr << ' ' << text;
if (InvEntry::show_prices)
{
const int value = item_value(*item, show_prices);
if (value > 0)
- snprintf(suffix, sizeof suffix,
- " (%d gold)", value);
+ tstr << " (" << value << " gold)";
+ }
+
+ if ( Options.show_inventory_weights )
+ {
+ const int mass = item_mass(*item);
+ tstr << " [" << (mass/10) << '.' << (mass%10) << " aum]";
}
- snprintf( buf, sizeof buf,
- " %c %c %s%s",
- hotkeys[0],
- (!selected_qty? '-' : selected_qty < quantity? '#' : '+'),
- text.c_str(),
- suffix );
- return (buf);
+ return tstr.str();
}
void InvEntry::add_class_hotkeys(const item_def &i)