summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/initfile.cc
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-03-16 15:48:28 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-03-16 15:48:28 +0000
commit54bfc8f5f26243e68353eeedb959864e6565de4c (patch)
treec7b82c5f497ab9f3bbfc5da435f60305738863ee /crawl-ref/source/initfile.cc
parenteff8860c8c5cf24ffb3ff64e4b44af416d72b3d4 (diff)
downloadcrawl-ref-54bfc8f5f26243e68353eeedb959864e6565de4c.tar.gz
crawl-ref-54bfc8f5f26243e68353eeedb959864e6565de4c.zip
Added message_colour option to allow custom-colouring individual messages. This
does not affect formatted_mpr. Moved low magic warning to the danger channel and added a message_colour option to colour it lightcyan in the stock init.txt. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1050 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/initfile.cc')
-rw-r--r--crawl-ref/source/initfile.cc55
1 files changed, 51 insertions, 4 deletions
diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc
index 84ac50bb1f..78da3c3519 100644
--- a/crawl-ref/source/initfile.cc
+++ b/crawl-ref/source/initfile.cc
@@ -148,8 +148,7 @@ static const std::string message_channel_names[ NUM_MESSAGE_CHANNELS ] =
"plain", "prompt", "god", "pray", "duration", "danger", "warning", "food",
"recovery", "sound", "talk", "intrinsic_gain", "mutation", "monster_spell",
"monster_enchant", "monster_damage", "monster_target",
- "rotten_meat", "equipment", "floor", "multiturn", "diagnostic","tutorial",
- "magic_warning",
+ "rotten_meat", "equipment", "floor", "multiturn", "diagnostic","tutorial"
};
// returns -1 if unmatched else returns 0--(NUM_MESSAGE_CHANNELS-1)
@@ -758,6 +757,7 @@ void game_options::reset_options()
travel_stop_message.clear();
sound_mappings.clear();
menu_colour_mappings.clear();
+ message_colour_mappings.clear();
drop_filter.clear();
map_file_name.clear();
named_options.clear();
@@ -1257,6 +1257,46 @@ std::string game_options::unalias(const std::string &key) const
return (i == aliases.end()? key : i->second);
}
+void game_options::add_message_colour_mappings(const std::string &field)
+{
+ std::vector<std::string> fragments = split_string(",", field);
+ for (int i = 0, count = fragments.size(); i < count; ++i)
+ add_message_colour_mapping(fragments[i]);
+}
+
+message_filter game_options::parse_message_filter(const std::string &filter)
+{
+ std::string::size_type pos = filter.find(":");
+ if (pos && pos != std::string::npos)
+ {
+ std::string prefix = filter.substr(0, pos);
+ int channel = str_to_channel( prefix );
+ if (channel != -1 || prefix == "any")
+ {
+ std::string s = filter.substr( pos + 1 );
+ trim_string( s );
+ return message_filter( channel, s );
+ }
+ }
+
+ return message_filter( filter );
+}
+
+void game_options::add_message_colour_mapping(const std::string &field)
+{
+ std::vector<std::string> cmap = split_string(":", field, true, true, 1);
+
+ if (cmap.size() != 2)
+ return;
+
+ const int col = str_to_colour( cmap[0] );
+ if (col == -1)
+ return;
+
+ message_colour_mapping m = { parse_message_filter( cmap[1] ), col };
+ message_colour_mappings.push_back( m );
+}
+
void game_options::read_option_line(const std::string &str, bool runscript)
{
std::string key = "";
@@ -1333,6 +1373,7 @@ void game_options::read_option_line(const std::string &str, bool runscript)
&& key.find("cset") != 0 && key != "dungeon"
&& key != "feature" && key != "fire_items_start"
&& key != "menu_colour" && key != "menu_color"
+ && key != "message_colour" && key != "message_color"
&& key != "levels" && key != "level" && key != "entries")
{
tolower_string( field );
@@ -2158,10 +2199,12 @@ void game_options::read_option_line(const std::string &str, bool runscript)
else if (key == "menu_colour" || key == "menu_color")
{
std::vector<std::string> seg = split_string(",", field);
- for (int i = 0, count = seg.size(); i < count; ++i) {
+ for (int i = 0, count = seg.size(); i < count; ++i)
+ {
const std::string &sub = seg[i];
std::string::size_type cpos = sub.find(":", 0);
- if (cpos != std::string::npos) {
+ if (cpos != std::string::npos)
+ {
colour_mapping mapping;
mapping.pattern = sub.substr(cpos + 1);
mapping.colour = str_to_colour(sub.substr(0, cpos));
@@ -2170,6 +2213,10 @@ void game_options::read_option_line(const std::string &str, bool runscript)
}
}
}
+ else if (key == "message_colour" || key == "message_color")
+ {
+ add_message_colour_mappings(field);
+ }
else if (key == "dump_order")
{
if (!plus_equal)