From 0a4efdf86b33220269f7439aeb5952a88d50efa7 Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Mon, 2 Jun 2008 16:52:40 +0000 Subject: Fix a stupid bug I'd introduced when fixing another one. Fix 1939901: Weapon listing not updated right away after being cursed. Put the code to colour arbitrary substrings of a message according to the menu_colour settings into a function of its own, and use it for pick up and eating prompts (currently from floor only) as well as for the "Things that are here" listing. Could be overly spammy, thus needs testing. If all works well, we can remove the "msg =" settings in food_colouring.txt that currently don't do anything anyway, or reuse them for non-prompt messages like "You see here a green rat corpse." git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5436 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/itemname.cc | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'crawl-ref/source/itemname.cc') diff --git a/crawl-ref/source/itemname.cc b/crawl-ref/source/itemname.cc index 947937e859..96069237a5 100644 --- a/crawl-ref/source/itemname.cc +++ b/crawl-ref/source/itemname.cc @@ -29,6 +29,7 @@ #include "decks.h" #include "food.h" +#include "initfile.h" #include "invent.h" #include "it_use2.h" #include "itemprop.h" @@ -2244,6 +2245,30 @@ const std::string menu_colour_item_prefix(const item_def &item) return result; } +const std::string get_menu_colour_prefix_tags(item_def &item, + description_level_type desc) +{ + std::string cprf = menu_colour_item_prefix(item); + std::string colour = ""; + std::string colour_off = ""; + std::string item_name = item.name(desc); + int col = menu_colour(item_name, cprf, "pickup"); + + if (col != LIGHTGRAY) + colour = colour_to_str( col ); + + if (!colour.empty()) + { + // Order is important here. + colour_off = ""; + colour = "<" + colour + ">"; + item_name = colour + item_name + colour_off; + } + + return (item_name); +} + + typedef std::map item_names_map; static item_names_map item_names_cache; -- cgit v1.2.3-54-g00ecf