summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-03 00:20:30 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-03 00:20:30 +0000
commit4d1ed355a8b118242938be2c79fb74173b37f5a1 (patch)
tree9188247228f9dc9436959528a49e89f3350c32f1 /crawl-ref
parent3a61889e9e926b7b49a074bba327b694905623ff (diff)
downloadcrawl-ref-4d1ed355a8b118242938be2c79fb74173b37f5a1.tar.gz
crawl-ref-4d1ed355a8b118242938be2c79fb74173b37f5a1.zip
Allow tiles in 'V' menu, at least for items - the menu structure can't
handle monster information (yet?) This means that the two parts (monsters/items) are differently formatted but for Tiles this looks much better this way than it did before. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8143 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/directn.cc30
-rw-r--r--crawl-ref/source/invent.cc23
-rw-r--r--crawl-ref/source/invent.h2
-rw-r--r--crawl-ref/source/menu.cc11
-rw-r--r--crawl-ref/source/tilereg.cc3
5 files changed, 53 insertions, 16 deletions
diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc
index 53d4a25c4e..0fd8bb5d03 100644
--- a/crawl-ref/source/directn.cc
+++ b/crawl-ref/source/directn.cc
@@ -30,6 +30,7 @@
#include "describe.h"
#include "dungeon.h"
#include "initfile.h"
+#include "invent.h"
#include "itemname.h"
#include "items.h"
#include "mapmark.h"
@@ -490,9 +491,13 @@ void full_describe_view()
mprf("Neither monsters nor items are visible.");
return;
}
-
- Menu desc_menu(MF_SINGLESELECT | MF_ANYPRINTABLE |
- /*MF_ALWAYS_SHOW_MORE |*/ MF_ALLOW_FORMATTING);
+/*
+ InvMenu desc_menu(MF_SINGLESELECT | MF_ANYPRINTABLE |
+ MF_ALLOW_FORMATTING,
+ "description", false);
+*/
+ InvMenu desc_menu(MF_SINGLESELECT | MF_ANYPRINTABLE |
+ /*MF_ALWAYS_SHOW_MORE |*/ MF_ALLOW_FORMATTING);
desc_menu.set_highlighter(NULL);
desc_menu.set_title(
@@ -573,10 +578,10 @@ void full_describe_view()
{
++menu_index;
const char letter = index_to_letter(menu_index);
-
+ const item_def &item = list_items[i];
+/*
unsigned glyph_char;
unsigned short glyph_col;
- const item_def &item = list_items[i];
get_item_glyph( &item, &glyph_char, &glyph_col );
const std::string col_string = colour_to_str(glyph_col);
@@ -586,11 +591,18 @@ void full_describe_view()
const std::string str = prefix +
uppercase_first(item.name(DESC_PLAIN));
-
- MenuEntry *me = new MenuEntry(str, MEL_ITEM, 1, letter);
- me->data = reinterpret_cast<void*>(
- const_cast<item_def*>(&item));
+*/
+ InvEntry *me = new InvEntry(item);
+// MenuEntry *me = new MenuEntry(str, MEL_ITEM, 1, letter);
+// me->item = item;
+// me->data = reinterpret_cast<void*>(
+// const_cast<item_def*>(&item));
+#ifndef USE_TILE
+ // Show glyphs only for ASCII.
+ me->set_show_glyph(true);
+#endif
me->tag = "i";
+ me->hotkeys[0] = letter;
me->quantity = 2; // Hack to make items selectable.
desc_menu.add_entry(me);
}
diff --git a/crawl-ref/source/invent.cc b/crawl-ref/source/invent.cc
index fa03f8b291..ac1e6f5b86 100644
--- a/crawl-ref/source/invent.cc
+++ b/crawl-ref/source/invent.cc
@@ -189,7 +189,21 @@ std::string InvEntry::get_text() const
tstr << '#';
else
tstr << '+';
+
+ if (InvEntry::show_glyph)
+ {
+ unsigned glyph_char;
+ unsigned short glyph_col;
+ get_item_glyph( item, &glyph_char, &glyph_col );
+
+ const std::string col_string = colour_to_str(glyph_col);
+ const std::string prefix = " (<" + col_string + ">"
+ + static_cast<char>(glyph_char)
+ + "</" + col_string + ">)";
+ tstr << prefix;
+ }
tstr << ' ' << text;
+
if (InvEntry::show_prices)
{
const int value = item_value(*item, show_prices);
@@ -274,6 +288,13 @@ InvShowPrices::~InvShowPrices()
InvEntry::set_show_prices(false);
}
+bool InvEntry::show_glyph = false;
+
+void InvEntry::set_show_glyph(bool doshow)
+{
+ show_glyph = doshow;
+}
+
InvMenu::InvMenu(int mflags)
: Menu(mflags, "inventory", false), type(MT_INVLIST), pre_select(NULL),
title_annotate(NULL)
@@ -399,7 +420,7 @@ void InvMenu::load_inv_items(int item_selector, int excluded_slot,
bool InvEntry::tile(int &idx, TextureID &tex) const
{
if (quantity <= 0)
- return false;
+ return (false);
idx = tileidx_item(*item);
tex = TEX_DEFAULT;
diff --git a/crawl-ref/source/invent.h b/crawl-ref/source/invent.h
index 079d15ff1e..25dcb6aa7c 100644
--- a/crawl-ref/source/invent.h
+++ b/crawl-ref/source/invent.h
@@ -67,6 +67,7 @@ class InvEntry : public MenuEntry
{
private:
static bool show_prices;
+ static bool show_glyph;
static void set_show_prices(bool doshow);
mutable std::string basename;
@@ -79,6 +80,7 @@ public:
InvEntry( const item_def &i );
std::string get_text() const;
+ void set_show_glyph(bool doshow);
const std::string &get_basename() const;
const std::string &get_qualname() const;
diff --git a/crawl-ref/source/menu.cc b/crawl-ref/source/menu.cc
index 6daa92f940..6b282bd849 100644
--- a/crawl-ref/source/menu.cc
+++ b/crawl-ref/source/menu.cc
@@ -564,9 +564,10 @@ void Menu::draw_select_count(int count, bool force)
{
char buf[100] = "";
if (count)
+ {
snprintf(buf, sizeof buf, " (%d item%s) ", count,
(count > 1? "s" : ""));
-
+ }
draw_title_suffix(buf);
}
}
@@ -1741,18 +1742,20 @@ int ToggleableMenu::pre_process(int key)
toggle_keys.end() )
{
// Toggle all menu entries
- for ( unsigned int i = 0; i < items.size(); ++i )
+ for (unsigned int i = 0; i < items.size(); ++i)
{
ToggleableMenuEntry* const p =
dynamic_cast<ToggleableMenuEntry*>(items[i]);
- if ( p )
+
+ if (p)
p->toggle();
}
// Toggle title
ToggleableMenuEntry* const pt =
dynamic_cast<ToggleableMenuEntry*>(title);
- if ( pt )
+
+ if (pt)
pt->toggle();
// Redraw
diff --git a/crawl-ref/source/tilereg.cc b/crawl-ref/source/tilereg.cc
index d185c2be4b..b895815e63 100644
--- a/crawl-ref/source/tilereg.cc
+++ b/crawl-ref/source/tilereg.cc
@@ -2660,9 +2660,8 @@ void MenuRegion::clear()
m_more.clear();
for (unsigned int i = 0; i < m_entries.size(); i++)
- {
m_entries[i].valid = false;
- }
+
m_mouse_idx = -1;
}