summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/spl-cast.cc
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2008-10-10 00:52:11 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2008-10-10 00:52:11 +0000
commitbbddaa28b4d5221142ce49db6aca94691f2c6054 (patch)
tree482dc55bff5014d2202ffc2d2cce6e2cfcdd5b73 /crawl-ref/source/spl-cast.cc
parent5cd65ca8c6e1dd6ab026524171f857a0fd7ffdca (diff)
downloadcrawl-ref-bbddaa28b4d5221142ce49db6aca94691f2c6054.tar.gz
crawl-ref-bbddaa28b4d5221142ce49db6aca94691f2c6054.zip
Colours, pretty colours...
Potential range now in darkgrey. Spell power coloured red/green/yellow/white. (This might have been there in the past and removed as fruit salad; if so sorry and I'll remove it again.) git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7206 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/spl-cast.cc')
-rw-r--r--crawl-ref/source/spl-cast.cc47
1 files changed, 44 insertions, 3 deletions
diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc
index 518dfb8456..1f81c690b8 100644
--- a/crawl-ref/source/spl-cast.cc
+++ b/crawl-ref/source/spl-cast.cc
@@ -168,6 +168,41 @@ static std::string _spell_base_description(spell_type spell)
return desc.str();
}
+static int _string_tag_length(const std::string& s)
+{
+ int taglen = 0;
+ bool in_tag = false;
+ int last_taglen = 0;
+ for (std::string::const_iterator ci = s.begin(); ci != s.end(); ++ci)
+ {
+ if (in_tag)
+ {
+ if (*ci == '<' && last_taglen == 1)
+ {
+ in_tag = false;
+ --taglen;
+ }
+ else if (*ci == '>')
+ {
+ in_tag = false;
+ ++taglen;
+ }
+ else
+ {
+ ++last_taglen;
+ ++taglen;
+ }
+ }
+ else if (*ci == '<')
+ {
+ in_tag = true;
+ last_taglen = 1;
+ ++taglen;
+ }
+ }
+ return (taglen);
+}
+
static std::string _spell_extra_description(spell_type spell)
{
std::ostringstream desc;
@@ -178,8 +213,13 @@ static std::string _spell_extra_description(spell_type spell)
desc << std::setw(30) << spell_title(spell);
// spell power, spell range, hunger level, level
- desc << std::setw(14) << spell_power_string(spell)
- << std::setw(16) << spell_range_string(spell)
+ const std::string power_colour = colour_to_str(spell_power_colour(spell));
+ const std::string rangestring = spell_range_string(spell);
+
+ desc << '<' << power_colour << '>'
+ << std::setw(14) << spell_power_string(spell)
+ << "</" << power_colour << '>'
+ << std::setw(16 + _string_tag_length(rangestring)) << rangestring
<< std::setw(12) << spell_hunger_string(spell)
<< spell_difficulty(spell);
@@ -4581,5 +4621,6 @@ std::string spell_range_string(spell_type spell)
return "N/A";
else
return std::string("@") + std::string(range, '.')
- + std::string(maxrange - range, ',');
+ + "<darkgrey>" + std::string(maxrange - range, '.')
+ + "</dargrey>";
}