summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/menu.cc
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2007-03-20 12:12:03 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2007-03-20 12:12:03 +0000
commitbc1869c1a3334676d5cc99df90f7f9b24426274d (patch)
treede15184d6e9328c8d2b50f6c201af5fa306db2eb /crawl-ref/source/menu.cc
parent73efec90ba10a76ae5d4663461781f840b110d9d (diff)
downloadcrawl-ref-bc1869c1a3334676d5cc99df90f7f9b24426274d.tar.gz
crawl-ref-bc1869c1a3334676d5cc99df90f7f9b24426274d.zip
Added a funtion for formatted message history, and, while I was at it,
moved some overlapping parts of base_mpr and formatted_mpr into separate functions. This makes them more readable and avoids code duplication. I'm uncertain as to whether translating every string in replay_messages into a formatted string (just in case) would be overkill - so for now that only happens for messages of MSGCH_TUTORIAL. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1071 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/menu.cc')
-rw-r--r--crawl-ref/source/menu.cc28
1 files changed, 15 insertions, 13 deletions
diff --git a/crawl-ref/source/menu.cc b/crawl-ref/source/menu.cc
index bc7ee61821..35e054f0d9 100644
--- a/crawl-ref/source/menu.cc
+++ b/crawl-ref/source/menu.cc
@@ -1180,13 +1180,13 @@ int linebreak_string2( std::string& s, int maxcol )
// hard linebreak
else if ( xpos >= maxcol )
{
- if (spacepos >= xpos-maxcol)
+ if (spacepos >= xpos-maxcol)
{
- loc = spacepos;
- s.replace(loc, 1, "\n");
- }
- else
- s.insert(loc, "\n");
+ loc = spacepos;
+ s.replace(loc, 1, "\n");
+ }
+ else
+ s.insert(loc, "\n");
xpos = 0;
++breakcount;
}
@@ -1212,19 +1212,21 @@ void print_formatted_paragraph(std::string &s, int maxcol, int channel)
{
linebreak_string2(s,maxcol);
std::string text;
-
+
size_t loc = 0, oldloc = 0;
while ( loc < s.size() )
{
if (s[loc] == '\n') {
- text = s.substr(oldloc, loc-oldloc);
- formatted_mpr( formatted_string::parse_string(text), channel );
- oldloc = ++loc;
- }
+ text = s.substr(oldloc, loc-oldloc);
+// formatted_mpr( formatted_string::parse_string(text), channel );
+ formatted_message_history( text, channel );
+ oldloc = ++loc;
+ }
loc++;
}
- formatted_mpr( formatted_string::parse_string( s.substr(oldloc, loc-oldloc) ), channel );
-}
+// formatted_mpr( formatted_string::parse_string( s.substr(oldloc, loc-oldloc) ), channel );
+ formatted_message_history( s.substr(oldloc, loc-oldloc), channel );
+}
bool formatted_scroller::jump_to( int i )
{