diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2009-06-15 14:01:36 +0000 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2009-06-15 14:01:36 +0000 |
| commit | 7b68ff42773976cafe39b59dc026350cda5c05fd (patch) | |
| tree | a64ff77b56d62f3860e82513df4874436c353621 /src/game/client | |
| parent | 0160f2651448c2c2df332d2447629e23d5bd4a9a (diff) | |
| download | zcatch-7b68ff42773976cafe39b59dc026350cda5c05fd.tar.gz zcatch-7b68ff42773976cafe39b59dc026350cda5c05fd.zip | |
fixed chaining of console commands, allows snatching updates of console variables. cleaned up some code
Diffstat (limited to 'src/game/client')
| -rw-r--r-- | src/game/client/components/menus_demo.cpp | 63 | ||||
| -rw-r--r-- | src/game/client/gameclient.cpp | 20 | ||||
| -rw-r--r-- | src/game/client/gameclient.hpp | 3 |
3 files changed, 45 insertions, 41 deletions
diff --git a/src/game/client/components/menus_demo.cpp b/src/game/client/components/menus_demo.cpp index efcf05b8..594ee3df 100644 --- a/src/game/client/components/menus_demo.cpp +++ b/src/game/client/components/menus_demo.cpp @@ -178,6 +178,8 @@ static float listbox_rowheight; static int listbox_itemindex; static int listbox_selected_index; static int listbox_new_selected; +static int listbox_doneevents; +static int listbox_numitems; void MENUS::ui_do_listbox_start(void *id, const RECT *rect, float row_height, const char *title, int num_items, int selected_index) { @@ -207,6 +209,8 @@ void MENUS::ui_do_listbox_start(void *id, const RECT *rect, float row_height, co listbox_new_selected = selected_index; listbox_itemindex = 0; listbox_rowheight = row_height; + listbox_numitems = num_items; + listbox_doneevents = 0; //int num_servers = client_serverbrowse_sorted_num(); @@ -270,6 +274,25 @@ MENUS::LISTBOXITEM MENUS::ui_do_listbox_nextitem(void *id) if(listbox_selected_index==listbox_itemindex) { + if(!listbox_doneevents) + { + listbox_doneevents = 1; + + for(int i = 0; i < num_inputevents; i++) + { + if(inputevents[i].flags&INPFLAG_PRESS) + { + if(inputevents[i].key == KEY_DOWN) listbox_new_selected++; + if(inputevents[i].key == KEY_UP) listbox_new_selected--; + } + } + + if(listbox_new_selected >= listbox_numitems) + listbox_new_selected = listbox_numitems-1; + if(listbox_new_selected < 0) + listbox_new_selected = 0; + } + //selected_index = i; RECT r = row; ui_margin(&r, 1.5f, &r); @@ -289,28 +312,6 @@ int MENUS::ui_do_listbox_end() return listbox_new_selected; } -/* -void MENUS::demolist_listdir_callback(const char *name, int is_dir, void *user) -{ - - (*count)++; - LISTBOXITEM item = ui_do_listbox_nextitem((void*)(10+*count)); - if(item.visible) - ui_do_label(&item.rect, name, item.rect.h*fontmod_height, -1); -} - - - DEMOITEM *demos; - int num_demos; - */ - -/*void MENUS::demolist_count_callback(const char *name, int is_dir, void *user) -{ - if(is_dir || name[0] == '.') - return; - (*(int *)user)++; -}*/ - struct FETCH_CALLBACKINFO { MENUS *self; @@ -329,32 +330,14 @@ void MENUS::demolist_fetch_callback(const char *name, int is_dir, void *user) str_format(item.filename, sizeof(item.filename), "%s/%s", info->prefix, name); str_copy(item.name, name, sizeof(item.name)); info->self->demos.add(item); - - /* - if(info->count == info->self->num_demos) - return; - - info->count++; - */ } - void MENUS::demolist_populate() { demos.clear(); - /*if(demos) - mem_free(demos); - demos = 0; - num_demos = 0;*/ - char buf[512]; str_format(buf, sizeof(buf), "%s/demos", client_user_directory()); - //fs_listdir(buf, demolist_count_callback, &num_demos); - //fs_listdir("demos", demolist_count_callback, &num_demos); - - //demos = (DEMOITEM *)mem_alloc(sizeof(DEMOITEM)*num_demos, 1); - //mem_zero(demos, sizeof(DEMOITEM)*num_demos); FETCH_CALLBACKINFO info = {this, buf, 0}; fs_listdir(buf, demolist_fetch_callback, &info); diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index fc17b94f..fa2f4de0 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -248,7 +248,18 @@ void GAMECLIENT::on_console_init() // let all the other components register their console commands for(int i = 0; i < all.num; i++) all.components[i]->on_console_init(); - + + + // + { static COMMANDCHAIN chain; console_chain_command("player_name", &chain, conchain_special_infoupdate, this); } + { static COMMANDCHAIN chain; console_chain_command("player_use_custom_color", &chain, conchain_special_infoupdate, this); } + { static COMMANDCHAIN chain; console_chain_command("player_color_body", &chain, conchain_special_infoupdate, this); } + { static COMMANDCHAIN chain; console_chain_command("player_color_feet", &chain, conchain_special_infoupdate, this); } + { static COMMANDCHAIN chain; console_chain_command("player_skin", &chain, conchain_special_infoupdate, this); } + + + + // suppress_events = false; } @@ -954,3 +965,10 @@ void GAMECLIENT::con_kill(void *result, void *user_data) { ((GAMECLIENT*)user_data)->send_kill(-1); } + +void GAMECLIENT::conchain_special_infoupdate(void *result, void *user_data, CONSOLE_CALLBACK cb, void *cbuser) +{ + cb(result, cbuser); + if(console_arg_num(result)) + ((GAMECLIENT*)user_data)->send_info(false); +} diff --git a/src/game/client/gameclient.hpp b/src/game/client/gameclient.hpp index 35b95f27..e354430d 100644 --- a/src/game/client/gameclient.hpp +++ b/src/game/client/gameclient.hpp @@ -1,5 +1,6 @@ #include <base/vmath.hpp> +#include <engine/e_console.h> #include <game/gamecore.hpp> #include "render.hpp" @@ -34,6 +35,8 @@ class GAMECLIENT static void con_team(void *result, void *user_data); static void con_kill(void *result, void *user_data); + static void conchain_special_infoupdate(void *result, void *user_data, CONSOLE_CALLBACK cb, void *cbuser); + public: bool suppress_events; bool new_tick; |