diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-09-24 14:47:03 +0000 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-09-24 14:47:03 +0000 |
| commit | 917ebc17c617dfd27e4e997dce713cb1dfb6cfdc (patch) | |
| tree | 11d85f18ef289de3de322bed5274dc616c23ac45 /src/game/client | |
| parent | 2f28978237f0ead749a39229f1c683df63d34871 (diff) | |
| download | zcatch-917ebc17c617dfd27e4e997dce713cb1dfb6cfdc.tar.gz zcatch-917ebc17c617dfd27e4e997dce713cb1dfb6cfdc.zip | |
begun the work on voting
Diffstat (limited to 'src/game/client')
| -rw-r--r-- | src/game/client/components/menus.cpp | 22 | ||||
| -rw-r--r-- | src/game/client/components/voting.cpp | 61 | ||||
| -rw-r--r-- | src/game/client/components/voting.hpp | 39 | ||||
| -rw-r--r-- | src/game/client/gameclient.cpp | 4 | ||||
| -rw-r--r-- | src/game/client/gameclient.hpp | 1 |
5 files changed, 125 insertions, 2 deletions
diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 36bf6378..6c28138d 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -23,6 +23,7 @@ extern "C" { #include <game/generated/gc_data.hpp> #include <game/client/components/binds.hpp> #include <game/client/components/motd.hpp> +#include <game/client/components/voting.hpp> #include <game/client/gameclient.hpp> #include <game/client/animstate.hpp> #include <game/client/gc_render.hpp> @@ -620,8 +621,8 @@ void MENUS::render_news(RECT main_view) void MENUS::render_game(RECT main_view) { - RECT button; - ui_hsplit_t(&main_view, 45.0f, &main_view, 0); + RECT button, votearea; + ui_hsplit_t(&main_view, 45.0f, &main_view, &votearea); ui_draw_rect(&main_view, color_tabbar_active, CORNER_ALL, 10.0f); ui_hsplit_t(&main_view, 10.0f, 0, &main_view); @@ -688,6 +689,23 @@ void MENUS::render_game(RECT main_view) } } } + + ui_hsplit_t(&votearea, 10.0f, 0, &votearea); + ui_hsplit_t(&votearea, 25.0f+10.0f*2, &votearea, 0); + + ui_draw_rect(&votearea, color_tabbar_active, CORNER_ALL, 10.0f); + + ui_vmargin(&votearea, 10.0f, &votearea); + ui_hmargin(&votearea, 10.0f, &votearea); + if(gameclient.voting->is_voting()) + { + + } + else + { + ui_do_label(&votearea, "No vote in progress", 18.0f, -1); + } + } void MENUS::render_serverinfo(RECT main_view) diff --git a/src/game/client/components/voting.cpp b/src/game/client/components/voting.cpp new file mode 100644 index 00000000..b81cfb97 --- /dev/null +++ b/src/game/client/components/voting.cpp @@ -0,0 +1,61 @@ +#include <engine/e_client_interface.h> +#include <game/generated/g_protocol.hpp> +#include "voting.hpp" + +void VOTING::con_callvote(void *result, void *user_data) +{ +} + +void VOTING::con_vote(void *result, void *user_data) +{ +} + +VOTING::VOTING() +{ + on_reset(); +} + +void VOTING::on_reset() +{ + closetime = 0; + description[0] = 0; + command[0] = 0; + yes = no = pass = total = 0; + voted = 0; +} + +void VOTING::on_console_init() +{ + MACRO_REGISTER_COMMAND("callvote", "r", con_callvote, this); + MACRO_REGISTER_COMMAND("vote", "r", con_vote, this); +} + +void VOTING::on_message(int msgtype, void *rawmsg) +{ + if(msgtype == NETMSGTYPE_SV_VOTE_SET) + { + NETMSG_SV_VOTE_SET *msg = (NETMSG_SV_VOTE_SET *)rawmsg; + if(msg->timeout) + { + on_reset(); + str_copy(description, msg->description, sizeof(description)); + str_copy(command, msg->command, sizeof(description)); + closetime = time_get() + time_freq() * msg->timeout; + } + else + on_reset(); + } + else if(msgtype == NETMSGTYPE_SV_VOTE_STATUS) + { + NETMSG_SV_VOTE_STATUS *msg = (NETMSG_SV_VOTE_STATUS *)rawmsg; + yes = msg->yes; + no = msg->no; + pass = msg->pass; + total = msg->total; + } +} + +void VOTING::on_render() +{ +} + diff --git a/src/game/client/components/voting.hpp b/src/game/client/components/voting.hpp new file mode 100644 index 00000000..6f518d10 --- /dev/null +++ b/src/game/client/components/voting.hpp @@ -0,0 +1,39 @@ +#include <game/client/component.hpp> + +class VOTING : public COMPONENT +{ + /* + void render_goals(float x, float y, float w); + void render_spectators(float x, float y, float w); + void render_scoreboard(float x, float y, float w, int team, const char *title); + + static void con_key_scoreboard(void *result, void *user_data); + + bool active; + */ + + static void con_callvote(void *result, void *user_data); + static void con_vote(void *result, void *user_data); + + int64 closetime; + char description[512]; + char command[512]; + int voted; + +public: + VOTING(); + virtual void on_reset(); + virtual void on_console_init(); + virtual void on_message(int msgtype, void *rawmsg); + virtual void on_render(); + + void vote(int v); // -1 = no, 1 = yes + + bool is_voting() { return closetime != 0; } + int taken_choice() const { return voted; } + const char *vote_description() const { return description; } + const char *vote_command() const { return command; } + + int yes, no, pass, total; +}; + diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index 5ae98ced..e1634706 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -32,6 +32,7 @@ #include "components/scoreboard.hpp" #include "components/skins.hpp" #include "components/sounds.hpp" +#include "components/voting.hpp" GAMECLIENT gameclient; @@ -55,6 +56,7 @@ static SCOREBOARD scoreboard; static SOUNDS sounds; static EMOTICON emoticon; static DAMAGEIND damageind; +static VOTING voting; static PLAYERS players; static NAMEPLATES nameplates; @@ -105,6 +107,7 @@ void GAMECLIENT::on_console_init() motd = &::motd; damageind = &::damageind; mapimages = &::mapimages; + voting = &::voting; // make a list of all the systems, make sure to add them in the corrent render order all.add(skins); @@ -115,6 +118,7 @@ void GAMECLIENT::on_console_init() all.add(controls); all.add(camera); all.add(sounds); + all.add(voting); all.add(particles); // doesn't render anything, just updates all the particles all.add(&maplayers_background); // first to render diff --git a/src/game/client/gameclient.hpp b/src/game/client/gameclient.hpp index 4b397e86..c1e60c2c 100644 --- a/src/game/client/gameclient.hpp +++ b/src/game/client/gameclient.hpp @@ -137,6 +137,7 @@ public: class SOUNDS *sounds; class MOTD *motd; class MAPIMAGES *mapimages; + class VOTING *voting; }; extern GAMECLIENT gameclient; |