← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/fh1-chatoverlay into lp:widelands

 

GunChleoc has proposed merging lp:~widelands-dev/widelands/fh1-chatoverlay into lp:widelands.

Commit message:
Removed formatting for old renderer from chat overlay.

Requested reviews:
  Widelands Developers (widelands-dev)

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/fh1-chatoverlay/+merge/342029
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/fh1-chatoverlay into lp:widelands.
=== modified file 'src/wui/chat_msg_layout.cc'
--- src/wui/chat_msg_layout.cc	2017-01-25 18:55:59 +0000
+++ src/wui/chat_msg_layout.cc	2018-03-24 11:47:13 +0000
@@ -41,66 +41,6 @@
 
 }  // namespace
 
-// TODO(sirver): remove as soon as old text renderer is gone.
-std::string format_as_old_richtext(const ChatMessage& chat_message) {
-	const std::string& font_face = "serif";
-	std::string message = "<p font-color=#33ff33 font-size=9>";
-
-	std::string sanitized = sanitize_message(chat_message);
-
-	// time calculation
-	char ts[13];
-	strftime(ts, sizeof(ts), "[%H:%M] </p>", localtime(&chat_message.time));
-	message += ts;
-
-	message = (boost::format("%s<p font-size=14 font-face=%s font-color=#%s") % message % font_face %
-	           color(chat_message.playern))
-	             .str();
-
-	std::string sender_escaped = richtext_escape(chat_message.sender);
-	std::string recipient_escaped = richtext_escape(chat_message.recipient);
-
-	if (chat_message.recipient.size() && chat_message.sender.size()) {
-		// Personal message handling
-		if (sanitized.compare(0, 3, "/me")) {
-
-			message =
-			   (boost::format(
-			       "%s font-decoration=underline>%s @ %s:</p><p font-size=14 font-face=%s> %s") %
-			    message % sender_escaped % recipient_escaped % font_face % sanitized)
-			      .str();
-		} else {
-
-			message =
-			   (boost::format("%s>@%s &gt;&gt; </p>"
-			                  "<p font-size=14 font-face=%s font-color=#%s font-style=italic> %s%s") %
-			    message % recipient_escaped % font_face % color(chat_message.playern) %
-			    sender_escaped % sanitized.substr(3))
-			      .str();
-		}
-	} else {
-		// Normal messages handling
-		if (!sanitized.compare(0, 3, "/me")) {
-			message = (boost::format("%s font-style=italic>-&gt; %s%s") % message %
-			           (chat_message.sender.size() ? chat_message.sender.c_str() : "***") %
-			           sanitized.substr(3))
-			             .str();
-
-		} else if (chat_message.sender.size()) {
-			message =
-			   (boost::format("%s font-decoration=underline>%s:</p><p font-size=14 font-face=%s> %s") %
-			    message % sender_escaped % font_face % sanitized)
-			      .str();
-		} else {
-			message += " font-weight=bold>*** ";
-			message += sanitized;
-		}
-	}
-
-	// return the formated message
-	return message + "<br></p>";
-}
-
 // Returns a richtext string that can be displayed to the user.
 std::string format_as_richtext(const ChatMessage& chat_message) {
 	const std::string& font_face = "serif";

=== modified file 'src/wui/chat_msg_layout.h'
--- src/wui/chat_msg_layout.h	2017-01-25 18:55:59 +0000
+++ src/wui/chat_msg_layout.h	2018-03-24 11:47:13 +0000
@@ -20,12 +20,7 @@
 #ifndef WL_WUI_CHAT_MSG_LAYOUT_H
 #define WL_WUI_CHAT_MSG_LAYOUT_H
 
-#include <string>
-
-struct ChatMessage;
-
-// Formats 'chat_message' as old richtext.
-std::string format_as_old_richtext(const ChatMessage& chat_message);
+#include "chat/chat.h"
 
 // Formats 'chat_message' as richtext.
 std::string format_as_richtext(const ChatMessage& chat_message);

=== modified file 'src/wui/gamechatpanel.cc'
--- src/wui/gamechatpanel.cc	2017-02-23 17:58:25 +0000
+++ src/wui/gamechatpanel.cc	2018-03-24 11:47:13 +0000
@@ -49,6 +49,7 @@
 	editbox.ok.connect(boost::bind(&GameChatPanel::key_enter, this));
 	editbox.cancel.connect(boost::bind(&GameChatPanel::key_escape, this));
 	editbox.activate_history(true);
+	chatbox.force_new_renderer(true);
 
 	set_handle_mouse(true);
 	set_can_focus(true);
@@ -66,8 +67,7 @@
 
 	std::string str = "<rt>";
 	for (uint32_t i = 0; i < msgs.size(); ++i) {
-		str += format_as_old_richtext(msgs[i]);
-		str += '\n';
+		str += format_as_richtext(msgs[i]);
 	}
 	str += "</rt>";
 


Follow ups