Added support for colored nicknames protocol5

Fri, 15 May 2015 22:46:53 +0300

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Fri, 15 May 2015 22:46:53 +0300
branch
protocol5
changeset 78
c1d43ade656e
parent 77
32ef969adeed
child 79
62cfb7b97fc0

Added support for colored nicknames

sources/coloredline.cpp file | annotate | diff | comparison | revisions
sources/coloredline.h file | annotate | diff | comparison | revisions
sources/interface.cpp file | annotate | diff | comparison | revisions
sources/interface.h file | annotate | diff | comparison | revisions
sources/network/rconsession.cpp file | annotate | diff | comparison | revisions
sources/network/rconsession.h file | annotate | diff | comparison | revisions
--- a/sources/coloredline.cpp	Fri May 15 21:43:21 2015 +0300
+++ b/sources/coloredline.cpp	Fri May 15 22:46:53 2015 +0300
@@ -125,6 +125,14 @@
 
 // -------------------------------------------------------------------------------------------------
 //
+void ColoredLine::add_string (const String& text)
+{
+	for (char a : text)
+		add_char (a);
+}
+
+// -------------------------------------------------------------------------------------------------
+//
 void ColoredLine::set_color (Color a, bool on)
 {
 	switch (a)
--- a/sources/coloredline.h	Fri May 15 21:43:21 2015 +0300
+++ b/sources/coloredline.h	Fri May 15 22:46:53 2015 +0300
@@ -65,6 +65,7 @@
 	const Vector<int>& data() const { return m_data; }
 	int length() const { return m_length; }
 	void add_char (char ch);
+	void add_string (const String& msg);
 	void finalize();
 	int rows (int cols) const;
 
--- a/sources/interface.cpp	Fri May 15 21:43:21 2015 +0300
+++ b/sources/interface.cpp	Fri May 15 22:46:53 2015 +0300
@@ -378,17 +378,7 @@
 		mvhline (y, x, ' ', width);
 
 		if (i < PlayerNames.size())
-		{
-			String displaynick = PlayerNames[i];
-
-			if (displaynick.length() > width)
-			{
-				displaynick = displaynick.mid (0, width - 3);
-				displaynick += "...";
-			}
-
-			mvprintw (y, x, "%s", displaynick.chars());
-		}
+			render_colorline (y, x, width, PlayerNames[i], false);
 
 		y++;
 	}
@@ -936,7 +926,16 @@
 //
 void Interface::set_player_names (const StringList& names)
 {
-	PlayerNames = names;
+	PlayerNames.clear();
+
+	for (const String& name : names)
+	{
+		ColoredLine coloredname;
+		coloredname.add_string (name);
+		coloredname.finalize();
+		PlayerNames.append (coloredname);
+	}
+
 	NeedNicklistRender = true;
 }
 
--- a/sources/interface.h	Fri May 15 21:43:21 2015 +0300
+++ b/sources/interface.h	Fri May 15 22:46:53 2015 +0300
@@ -93,7 +93,7 @@
 	Function<void (void)> DisconnectConfirmFunction = nullptr;
 	IPAddress CurrentAddress;
 	String StatusBarText;
-	StringList PlayerNames;
+	List<ColoredLine> PlayerNames;
 	String PasteBuffer;
 	RCONSession Session;
 
--- a/sources/network/rconsession.cpp	Fri May 15 21:43:21 2015 +0300
+++ b/sources/network/rconsession.cpp	Fri May 15 22:46:53 2015 +0300
@@ -375,4 +375,4 @@
 	}
 	else
 		m_interface->print ("Server protocol is %1, cannot tab-complete\n", m_serverProtocol);
-}
\ No newline at end of file
+}
--- a/sources/network/rconsession.h	Fri May 15 21:43:21 2015 +0300
+++ b/sources/network/rconsession.h	Fri May 15 22:46:53 2015 +0300
@@ -37,7 +37,7 @@
 //
 enum
 {
-	RCON_PROTOCOL_VERSION = 4
+	RCON_PROTOCOL_VERSION = 5
 };
 
 // -------------------------------------------------------------------------------------------------

mercurial