From 2e2d31ccc359228f0031b9fa507b33f8ba935722 Mon Sep 17 00:00:00 2001 From: Magnus Auvinen Date: Sat, 30 Aug 2008 08:26:36 +0000 Subject: fixed the motd correctly --- src/game/client/components/motd.cpp | 48 ++++++++++++++++++++----------- src/game/client/components/motd.hpp | 4 ++- src/game/client/components/scoreboard.cpp | 4 +++ 3 files changed, 38 insertions(+), 18 deletions(-) (limited to 'src/game/client/components') diff --git a/src/game/client/components/motd.cpp b/src/game/client/components/motd.cpp index bd04d089..9e1013b6 100644 --- a/src/game/client/components/motd.cpp +++ b/src/game/client/components/motd.cpp @@ -10,34 +10,43 @@ #include "motd.hpp" void MOTD::on_reset() +{ + clear(); +} + +void MOTD::clear() { server_motd_time = 0; } +bool MOTD::is_active() +{ + return time_get() < server_motd_time; +} + void MOTD::on_render() { + if(!is_active()) + return; + float width = 400*3.0f*gfx_screenaspect(); float height = 400*3.0f; + + gfx_mapscreen(0, 0, width, height); - // 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; + 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_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)); - } + 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) @@ -70,6 +79,11 @@ void MOTD::on_message(int msgtype, void *rawmsg) bool MOTD::on_input(INPUT_EVENT e) { + if(is_active() && e.flags&INPFLAG_PRESS && e.key == KEY_ESC) + { + clear(); + return true; + } return false; } diff --git a/src/game/client/components/motd.hpp b/src/game/client/components/motd.hpp index e26dff9b..bc2c962e 100644 --- a/src/game/client/components/motd.hpp +++ b/src/game/client/components/motd.hpp @@ -2,10 +2,12 @@ class MOTD : public COMPONENT { -public: // motd int64 server_motd_time; char server_motd[900]; // FUGLY +public: + void clear(); + bool is_active(); virtual void on_reset(); virtual void on_render(); diff --git a/src/game/client/components/scoreboard.cpp b/src/game/client/components/scoreboard.cpp index 8891b12d..bd8c7ea9 100644 --- a/src/game/client/components/scoreboard.cpp +++ b/src/game/client/components/scoreboard.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include "scoreboard.hpp" @@ -226,6 +227,9 @@ void SCOREBOARD::on_render() { if(!active) return; + + // if the score board is active, then we should clear the motd message aswell + gameclient.motd->clear(); // TODO: repair me /* -- cgit 1.4.1