summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/delay.cc8
-rw-r--r--crawl-ref/source/describe.cc4
-rw-r--r--crawl-ref/source/menu.cc47
-rw-r--r--crawl-ref/source/menu.h8
-rw-r--r--crawl-ref/source/message.cc4
-rw-r--r--crawl-ref/source/message.h2
-rw-r--r--crawl-ref/source/view.cc52
-rw-r--r--crawl-ref/source/view.h5
8 files changed, 101 insertions, 29 deletions
diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc
index 1ff6f0e3d4..2279e4fb68 100644
--- a/crawl-ref/source/delay.cc
+++ b/crawl-ref/source/delay.cc
@@ -944,11 +944,13 @@ inline static void monster_warning(activity_interrupt_type ai,
#ifndef DEBUG_DIAGNOSTICS
mprf(MSGCH_WARN, "%s comes into view.", ptr_monam(mon, DESC_CAP_A));
#else
- mprf(MSGCH_WARN,
- "%s in view: (%d,%d), see_grid: %s",
- ptr_monam(mon, DESC_PLAIN),
+ formatted_string fs( channel_to_colour(MSGCH_WARN) );
+ fs.cprintf("%s (", ptr_monam(mon, DESC_PLAIN));
+ fs.add_glyph( mon );
+ fs.cprintf(") in view: (%d,%d), see_grid: %s",
mon->x, mon->y,
see_grid(mon->x, mon->y)? "yes" : "no");
+ formatted_mpr(fs, MSGCH_WARN);
#endif
}
}
diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc
index 17cb25705d..bbe50df91e 100644
--- a/crawl-ref/source/describe.cc
+++ b/crawl-ref/source/describe.cc
@@ -85,11 +85,7 @@ static void print_description( const std::string &d )
unsigned int nextLine = std::string::npos;
unsigned int currentPos = 0;
-#ifdef DOS
- const unsigned int lineWidth = 52;
-#else
const unsigned int lineWidth = 70;
-#endif
bool nlSearch = true; // efficiency
diff --git a/crawl-ref/source/menu.cc b/crawl-ref/source/menu.cc
index d40564fad1..7420d543b2 100644
--- a/crawl-ref/source/menu.cc
+++ b/crawl-ref/source/menu.cc
@@ -930,12 +930,19 @@ int MenuHighlighter::entry_colour(const MenuEntry *entry) const
// formatted_string
//
+formatted_string::formatted_string(int init_colour)
+ : ops()
+{
+ if (init_colour)
+ textcolor(init_colour);
+}
+
formatted_string::formatted_string(const std::string &s, int init_colour)
: ops()
{
if (init_colour)
- ops.push_back(init_colour);
- ops.push_back(s);
+ textcolor(init_colour);
+ cprintf(s);
}
int formatted_string::get_colour(const std::string &tag)
@@ -1116,8 +1123,44 @@ void formatted_string::movexy(int x, int y)
ops.push_back( fs_op(x, y, true) );
}
+int formatted_string::find_last_colour() const
+{
+ if (!ops.empty())
+ {
+ for (int i = ops.size() - 1; i >= 0; --i)
+ {
+ if (ops[i].type == FSOP_COLOUR)
+ return (ops[i].x);
+ }
+ }
+ return (LIGHTGREY);
+}
+
+void formatted_string::add_glyph(const item_def *item)
+{
+ const int last_col = find_last_colour();
+ unsigned short ch, col;
+ get_item_glyph(item, &ch, &col);
+ this->textcolor(col);
+ this->cprintf("%c", ch);
+ this->textcolor(last_col);
+}
+
+void formatted_string::add_glyph(const monsters *mons)
+{
+ const int last_col = find_last_colour();
+ unsigned short ch, col;
+ get_mons_glyph(mons, &ch, &col);
+ this->textcolor(col);
+ this->cprintf("%c", ch);
+ this->textcolor(last_col);
+}
+
void formatted_string::textcolor(int color)
{
+ if (!ops.empty() && ops[ ops.size() - 1 ].type == FSOP_COLOUR)
+ ops.erase( ops.end() - 1 );
+
ops.push_back(color);
}
diff --git a/crawl-ref/source/menu.h b/crawl-ref/source/menu.h
index 2fe96eda3a..29b3d6351b 100644
--- a/crawl-ref/source/menu.h
+++ b/crawl-ref/source/menu.h
@@ -54,7 +54,7 @@ enum fs_op_type
class formatted_string
{
public:
- formatted_string() : ops() { }
+ formatted_string(int init_colour = 0);
formatted_string(const std::string &s, int init_colour = 0);
operator std::string() const;
@@ -65,6 +65,8 @@ public:
void cprintf(const std::string &s);
void gotoxy(int x, int y);
void movexy(int delta_x, int delta_y);
+ void add_glyph(const monsters *mons);
+ void add_glyph(const item_def *item);
void textcolor(int color);
void clear();
@@ -79,9 +81,11 @@ public:
bool eol_ends_format = true,
bool (*process_tag)(const std::string &tag) = NULL );
-public:
static int get_colour(const std::string &tag);
+private:
+ int find_last_colour() const;
+
public:
struct fs_op
{
diff --git a/crawl-ref/source/message.cc b/crawl-ref/source/message.cc
index d5c35fb9c3..9040a2d2ea 100644
--- a/crawl-ref/source/message.cc
+++ b/crawl-ref/source/message.cc
@@ -114,7 +114,7 @@ static char god_message_altar_colour( char god )
#ifdef USE_COLOUR_MESSAGES
// returns a colour or MSGCOL_MUTED
-static char channel_to_colour( int channel, int param )
+int channel_to_colour( int channel, int param )
{
char ret;
@@ -229,7 +229,7 @@ static char channel_to_colour( int channel, int param )
#else // don't use colour messages
-static char channel_to_colour( int channel, int param )
+int channel_to_colour( int channel, int param )
{
return (LIGHTGREY);
}
diff --git a/crawl-ref/source/message.h b/crawl-ref/source/message.h
index b0ff6a93c0..ec6e4258af 100644
--- a/crawl-ref/source/message.h
+++ b/crawl-ref/source/message.h
@@ -99,4 +99,6 @@ bool any_messages(void);
* *********************************************************************** */
std::string get_last_messages(int mcount);
+int channel_to_colour( int channel, int param = 0 );
+
#endif
diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc
index b9d8916114..5a9c49b10c 100644
--- a/crawl-ref/source/view.cc
+++ b/crawl-ref/source/view.cc
@@ -501,6 +501,28 @@ void clear_map()
}
}
+static int get_mons_colour(const monsters *mons)
+{
+ int col = mons->colour;
+
+ if (mons_friendly(mons))
+ {
+ col |= COLFLAG_FRIENDLY_MONSTER;
+ }
+ else if (Options.stab_brand != CHATTR_NORMAL
+ && mons_looks_stabbable(mons))
+ {
+ col |= COLFLAG_WILLSTAB;
+ }
+ else if (Options.may_stab_brand != CHATTR_NORMAL
+ && mons_looks_distracted(mons))
+ {
+ col |= COLFLAG_MAYSTAB;
+ }
+
+ return (col);
+}
+
void monster_grid(bool do_updates)
{
struct monsters *monster = 0; // NULL {dlb}
@@ -638,22 +660,7 @@ void monster_grid(bool do_updates)
set_show_backup(ex, ey);
env.show[ex][ey] = monster->type + DNGN_START_OF_MONSTERS;
- env.show_col[ex][ey] = monster->colour;
-
- if (mons_friendly(monster))
- {
- env.show_col[ex][ey] |= COLFLAG_FRIENDLY_MONSTER;
- }
- else if (Options.stab_brand != CHATTR_NORMAL
- && mons_looks_stabbable(monster))
- {
- env.show_col[ex][ey] |= COLFLAG_WILLSTAB;
- }
- else if (Options.may_stab_brand != CHATTR_NORMAL
- && mons_looks_distracted(monster))
- {
- env.show_col[ex][ey] |= COLFLAG_MAYSTAB;
- }
+ env.show_col[ex][ey] = get_mons_colour( monster );
} // end "if (monster->type != -1 && mons_ner)"
} // end "for s"
} // end monster_grid()
@@ -799,6 +806,19 @@ void item_grid()
}
} // end item()
+void get_item_glyph( const item_def *item, unsigned short *glych,
+ unsigned short *glycol )
+{
+ *glycol = item->colour;
+ get_symbol( 0, 0, get_item_dngn_code( *item ), glych, glycol );
+}
+
+void get_mons_glyph( const monsters *mons, unsigned short *glych,
+ unsigned short *glycol )
+{
+ *glycol = get_mons_colour( mons );
+ get_symbol( 0, 0, mons->type + DNGN_START_OF_MONSTERS, glych, glycol );
+}
void cloud_grid(void)
{
diff --git a/crawl-ref/source/view.h b/crawl-ref/source/view.h
index f655bb1ce9..22f3b5bdf2 100644
--- a/crawl-ref/source/view.h
+++ b/crawl-ref/source/view.h
@@ -112,6 +112,11 @@ void clear_map();
bool is_feature(int feature, int x, int y);
+void get_item_glyph(const item_def *item, unsigned short *glych,
+ unsigned short *glycol);
+void get_mons_glyph(const monsters *mons, unsigned short *glych,
+ unsigned short *glycol);
+
void set_envmap_char( int x, int y, unsigned char chr );
unsigned get_envmap_char(int x, int y);
void set_envmap_detected_item(int x, int y, bool detected = true);