about summary refs log tree commit diff
path: root/src/game/client/components/motd.cpp
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2008-08-27 15:48:50 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2008-08-27 15:48:50 +0000
commitdfe499248f1b1236487156b28e4a535d7963fe35 (patch)
treea750b0f28cfd3f3e252602681412ac1adc6d29c7 /src/game/client/components/motd.cpp
parentd711dd190cac809a9bd278fba03ed974812bb863 (diff)
downloadzcatch-dfe499248f1b1236487156b28e4a535d7963fe35.tar.gz
zcatch-dfe499248f1b1236487156b28e4a535d7963fe35.zip
major commit. game client restructure. not complete, loads of stuff not working, but the structure is there
Diffstat (limited to 'src/game/client/components/motd.cpp')
-rw-r--r--src/game/client/components/motd.cpp75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/game/client/components/motd.cpp b/src/game/client/components/motd.cpp
new file mode 100644
index 00000000..bd04d089
--- /dev/null
+++ b/src/game/client/components/motd.cpp
@@ -0,0 +1,75 @@
+#include <engine/e_client_interface.h>
+#include <engine/e_config.h>
+#include <game/generated/g_protocol.hpp>
+#include <game/generated/gc_data.hpp>
+
+#include <game/client/gameclient.hpp>
+//#include <game/client/gc_anim.hpp>
+#include <game/client/gc_client.hpp>
+
+#include "motd.hpp"
+	
+void MOTD::on_reset()
+{
+	server_motd_time = 0;
+}
+
+void MOTD::on_render()
+{
+	float width = 400*3.0f*gfx_screenaspect();
+	float height = 400*3.0f;
+	
+	// TODO: repair me
+	if(/* !do_scoreboard && */ time_get() < server_motd_time)
+	{
+		gfx_mapscreen(0, 0, width, height);
+		
+		float h = 800.0f;
+		float w = 650.0f;
+		float x = width/2 - w/2;
+		float y = 150.0f;
+
+		gfx_blend_normal();
+		gfx_texture_set(-1);
+		gfx_quads_begin();
+		gfx_setcolor(0,0,0,0.5f);
+		draw_round_rect(x, y, w, h, 40.0f);
+		gfx_quads_end();
+
+		gfx_text(0, x+40.0f, y+40.0f, 32.0f, server_motd, (int)(w-80.0f));
+	}
+}
+
+void MOTD::on_message(int msgtype, void *rawmsg)
+{
+	if(msgtype == NETMSGTYPE_SV_MOTD)
+	{
+		NETMSG_SV_MOTD *msg = (NETMSG_SV_MOTD *)rawmsg;
+
+		// process escaping			
+		str_copy(server_motd, msg->message, sizeof(server_motd));
+		for(int i = 0; server_motd[i]; i++)
+		{
+			if(server_motd[i] == '\\')
+			{
+				if(server_motd[i+1] == 'n')
+				{
+					server_motd[i] = ' ';
+					server_motd[i+1] = '\n';
+					i++;
+				}
+			}
+		}
+
+		if(server_motd[0] && config.cl_motd_time)
+			server_motd_time = time_get()+time_freq()*config.cl_motd_time;
+		else
+			server_motd_time = 0;
+	}
+}
+
+bool MOTD::on_input(INPUT_EVENT e)
+{
+	return false;
+}
+