diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-08-30 08:26:36 +0000 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-08-30 08:26:36 +0000 |
| commit | 2e2d31ccc359228f0031b9fa507b33f8ba935722 (patch) | |
| tree | 90f7270a696e7f47238c2945f91381af485c5ac4 /src/game | |
| parent | 71fa35606c268594f8cf4c52626057f86861c3de (diff) | |
| download | zcatch-2e2d31ccc359228f0031b9fa507b33f8ba935722.tar.gz zcatch-2e2d31ccc359228f0031b9fa507b33f8ba935722.zip | |
fixed the motd correctly
Diffstat (limited to 'src/game')
| -rw-r--r-- | src/game/client/components/motd.cpp | 48 | ||||
| -rw-r--r-- | src/game/client/components/motd.hpp | 4 | ||||
| -rw-r--r-- | src/game/client/components/scoreboard.cpp | 4 | ||||
| -rw-r--r-- | src/game/client/gameclient.cpp | 12 | ||||
| -rw-r--r-- | src/game/client/gameclient.hpp | 1 |
5 files changed, 42 insertions, 27 deletions
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 @@ -11,33 +11,42 @@ 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 <game/client/gameclient.hpp> #include <game/client/animstate.hpp> #include <game/client/gc_render.hpp> +#include <game/client/components/motd.hpp> #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 /* diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index ba7e4b37..a209eef8 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -70,6 +70,7 @@ void GAMECLIENT::on_init() controls = &::controls; effects = &::effects; sounds = &::sounds; + motd = &::motd; // make a list of all the systems, make sure to add them in the corrent render order all.add(skins); @@ -95,12 +96,13 @@ void GAMECLIENT::on_init() all.add(&broadcast); all.add(&debughud); all.add(&scoreboard); - all.add(&motd); + all.add(motd); all.add(menus); all.add(console); // build the input stack input.add(console); + input.add(motd); // for pressing esc to remove it input.add(menus); input.add(chat); input.add(&emoticon); @@ -110,14 +112,6 @@ void GAMECLIENT::on_init() // init all components for(int i = 0; i < all.num; i++) all.components[i]->on_init(); - - /* - input_stack.add_handler(console_input_special_binds, 0); // F1-Fx binds - input_stack.add_handler(console_input_cli, 0); // console - input_stack.add_handler(chat_input_handle, 0); // chat - //input_stack.add_handler() // ui - input_stack.add_handler(console_input_normal_binds, 0); // binds - */ } void GAMECLIENT::dispatch_input() diff --git a/src/game/client/gameclient.hpp b/src/game/client/gameclient.hpp index 6ff05d9b..0e6547d9 100644 --- a/src/game/client/gameclient.hpp +++ b/src/game/client/gameclient.hpp @@ -107,6 +107,7 @@ public: class CONTROLS *controls; class EFFECTS *effects; class SOUNDS *sounds; + class MOTD *motd; }; extern GAMECLIENT gameclient; |