diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-08-30 08:20:06 +0000 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-08-30 08:20:06 +0000 |
| commit | 71fa35606c268594f8cf4c52626057f86861c3de (patch) | |
| tree | bbb67479ab1b89a0e18af6cd4dc9c3a3cca5d0ba /src/game | |
| parent | b4cef60d62e24d3c0c0451e94adf99254a259a3d (diff) | |
| download | zcatch-71fa35606c268594f8cf4c52626057f86861c3de.tar.gz zcatch-71fa35606c268594f8cf4c52626057f86861c3de.zip | |
fixed emoticons
Diffstat (limited to 'src/game')
| -rw-r--r-- | src/game/client/components/emoticon.cpp | 41 | ||||
| -rw-r--r-- | src/game/client/components/emoticon.hpp | 9 | ||||
| -rw-r--r-- | src/game/client/gameclient.cpp | 4 |
3 files changed, 46 insertions, 8 deletions
diff --git a/src/game/client/components/emoticon.cpp b/src/game/client/components/emoticon.cpp index f359530a..75859f60 100644 --- a/src/game/client/components/emoticon.cpp +++ b/src/game/client/components/emoticon.cpp @@ -3,6 +3,7 @@ #include <game/generated/gc_data.hpp> #include <game/gamecore.hpp> // get_angle +#include <game/client/gameclient.hpp> #include <game/client/gc_ui.hpp> #include <game/client/gc_render.hpp> #include "emoticon.hpp" @@ -12,22 +13,42 @@ EMOTICON::EMOTICON() on_reset(); } +void EMOTICON::con_key_emoticon(void *result, void *user_data) +{ + ((EMOTICON *)user_data)->active = console_arg_int(result, 0) != 0; +} + +void EMOTICON::on_init() +{ + MACRO_REGISTER_COMMAND("+emote", "", con_key_emoticon, this); +} + void EMOTICON::on_reset() { - selector_active = 0; + was_active = false; + active = false; selected_emote = -1; } void EMOTICON::on_message(int msgtype, void *rawmsg) { + if(msgtype == NETMSGTYPE_SV_EMOTICON) + { + NETMSG_SV_EMOTICON *msg = (NETMSG_SV_EMOTICON *)rawmsg; + gameclient.clients[msg->cid].emoticon = msg->emoticon; + gameclient.clients[msg->cid].emoticon_start = client_tick(); + } } -bool EMOTICON::on_input(INPUT_EVENT e) +bool EMOTICON::on_mousemove(float x, float y) { - return false; + if(!active) + return false; + + selector_mouse += vec2(x,y); + return true; } - void EMOTICON::draw_circle(float x, float y, float r, int segments) { float f_segments = (float)segments; @@ -54,6 +75,16 @@ void EMOTICON::draw_circle(float x, float y, float r, int segments) void EMOTICON::on_render() { + if(!active) + { + if(was_active && selected_emote) + emote(selected_emote); + was_active = false; + return; + } + + was_active = true; + int x, y; inp_mouse_relative(&x, &y); @@ -110,8 +141,6 @@ void EMOTICON::on_render() gfx_quads_end(); } - - void EMOTICON::emote(int emoticon) { NETMSG_CL_EMOTICON msg; diff --git a/src/game/client/components/emoticon.hpp b/src/game/client/components/emoticon.hpp index 17e977ab..1acb741d 100644 --- a/src/game/client/components/emoticon.hpp +++ b/src/game/client/components/emoticon.hpp @@ -5,17 +5,22 @@ class EMOTICON : public COMPONENT { void draw_circle(float x, float y, float r, int segments); + bool was_active; + bool active; + vec2 selector_mouse; - int selector_active; int selected_emote; + + static void con_key_emoticon(void *result, void *user_data); public: EMOTICON(); virtual void on_reset(); + virtual void on_init(); virtual void on_render(); virtual void on_message(int msgtype, void *rawmsg); - virtual bool on_input(INPUT_EVENT e); + virtual bool on_mousemove(float x, float y); void emote(int emoticon); }; diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index 9ae01634..ba7e4b37 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -23,6 +23,7 @@ #include "components/effects.hpp" #include "components/scoreboard.hpp" #include "components/sounds.hpp" +#include "components/emoticon.hpp" GAMECLIENT gameclient; @@ -44,6 +45,7 @@ static CONTROLS controls; static EFFECTS effects; static SCOREBOARD scoreboard; static SOUNDS sounds; +static EMOTICON emoticon; static PLAYERS players; static ITEMS items; @@ -87,6 +89,7 @@ void GAMECLIENT::on_init() all.add(&maplayers_foreground); all.add(&particles->render_general); all.add(&hud); + all.add(&emoticon); all.add(&killmessages); all.add(chat); all.add(&broadcast); @@ -100,6 +103,7 @@ void GAMECLIENT::on_init() input.add(console); input.add(menus); input.add(chat); + input.add(&emoticon); input.add(controls); input.add(binds); |