diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2009-01-24 13:12:04 +0000 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2009-01-24 13:12:04 +0000 |
| commit | 5f186c89062ddd9caeb8f105e748af62dc254f00 (patch) | |
| tree | 3fda7ee1a49db59af6a9983b1adc5d351cf48030 /src/game/client/components | |
| parent | ae5b47a26686e452cbc52981a6d617382f70dfba (diff) | |
| download | zcatch-5f186c89062ddd9caeb8f105e748af62dc254f00.tar.gz zcatch-5f186c89062ddd9caeb8f105e748af62dc254f00.zip | |
fixed so the console show help for each command. not all commands have descriptions however
Diffstat (limited to 'src/game/client/components')
| -rw-r--r-- | src/game/client/components/binds.cpp | 8 | ||||
| -rw-r--r-- | src/game/client/components/chat.cpp | 6 | ||||
| -rw-r--r-- | src/game/client/components/console.cpp | 33 | ||||
| -rw-r--r-- | src/game/client/components/console.hpp | 2 | ||||
| -rw-r--r-- | src/game/client/components/controls.cpp | 28 | ||||
| -rw-r--r-- | src/game/client/components/emoticon.cpp | 4 | ||||
| -rw-r--r-- | src/game/client/components/scoreboard.cpp | 2 | ||||
| -rw-r--r-- | src/game/client/components/voting.cpp | 4 |
8 files changed, 57 insertions, 30 deletions
diff --git a/src/game/client/components/binds.cpp b/src/game/client/components/binds.cpp index a2e30eaa..a48ad187 100644 --- a/src/game/client/components/binds.cpp +++ b/src/game/client/components/binds.cpp @@ -114,10 +114,10 @@ void BINDS::set_defaults() void BINDS::on_console_init() { // bindings - MACRO_REGISTER_COMMAND("bind", "sr", CFGFLAG_CLIENT, con_bind, this); - MACRO_REGISTER_COMMAND("unbind", "s", CFGFLAG_CLIENT, con_unbind, this); - MACRO_REGISTER_COMMAND("unbindall", "", CFGFLAG_CLIENT, con_unbindall, this); - MACRO_REGISTER_COMMAND("dump_binds", "", CFGFLAG_CLIENT, con_dump_binds, this); + MACRO_REGISTER_COMMAND("bind", "sr", CFGFLAG_CLIENT, con_bind, this, ""); + MACRO_REGISTER_COMMAND("unbind", "s", CFGFLAG_CLIENT, con_unbind, this, ""); + MACRO_REGISTER_COMMAND("unbindall", "", CFGFLAG_CLIENT, con_unbindall, this, ""); + MACRO_REGISTER_COMMAND("dump_binds", "", CFGFLAG_CLIENT, con_dump_binds, this, ""); // default bindings set_defaults(); diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index 2bd4511d..55097e58 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -41,9 +41,9 @@ void CHAT::con_chat(void *result, void *user_data) void CHAT::on_console_init() { - MACRO_REGISTER_COMMAND("say", "r", CFGFLAG_CLIENT, con_say, this); - MACRO_REGISTER_COMMAND("say_team", "r", CFGFLAG_CLIENT, con_sayteam, this); - MACRO_REGISTER_COMMAND("chat", "s", CFGFLAG_CLIENT, con_chat, this); + MACRO_REGISTER_COMMAND("say", "r", CFGFLAG_CLIENT, con_say, this, ""); + MACRO_REGISTER_COMMAND("say_team", "r", CFGFLAG_CLIENT, con_sayteam, this, ""); + MACRO_REGISTER_COMMAND("chat", "s", CFGFLAG_CLIENT, con_chat, this, ""); } bool CHAT::on_input(INPUT_EVENT e) diff --git a/src/game/client/components/console.cpp b/src/game/client/components/console.cpp index 201f145f..fe43507c 100644 --- a/src/game/client/components/console.cpp +++ b/src/game/client/components/console.cpp @@ -49,6 +49,8 @@ CONSOLE::INSTANCE::INSTANCE(int t) completion_buffer[0] = 0; completion_chosen = -1; + + command = 0x0; } void CONSOLE::INSTANCE::execute_line(const char *line) @@ -147,6 +149,18 @@ void CONSOLE::INSTANCE::on_input(INPUT_EVENT e) completion_chosen = -1; str_copy(completion_buffer, input.get_string(), sizeof(completion_buffer)); } + + // find the current command + { + char buf[64] = {0}; + const char *src = get_string(); + int i = 0; + for(; i < (int)sizeof(buf) && *src && *src != ' ' && *src != ' '; i++, src++) + buf[i] = *src; + buf[i] = 0; + + command = console_get_command(buf); + } } if(!handled) @@ -320,7 +334,7 @@ void CONSOLE::on_render() gfx_quads_drawTL(0,console_height-10.0f,screen.w,10.0f); gfx_quads_end(); - console_height -= 20.0f; + console_height -= 22.0f; INSTANCE *console = current_console(); @@ -338,7 +352,7 @@ void CONSOLE::on_render() info.wanted_completion = console->completion_chosen; info.enum_count = 0; info.current_cmd = console->completion_buffer; - gfx_text_set_cursor(&info.cursor, x, y+10.0f, font_size, TEXTFLAG_RENDER); + gfx_text_set_cursor(&info.cursor, x, y+12.0f, font_size, TEXTFLAG_RENDER); const char *prompt = "> "; if(console_type) @@ -370,7 +384,18 @@ void CONSOLE::on_render() // render possible commands if(console->input.get_string()[0] != 0) + { console_possible_commands(console->completion_buffer, console->completion_flagmask, possible_commands_render_callback, &info); + + if(info.enum_count <= 0) + { + if(console->command) + { + gfx_text_ex(&info.cursor, "Help: ", -1); + gfx_text_ex(&info.cursor, console->command->help, -1); + } + } + } gfx_text_color(1,1,1,1); // render log @@ -468,8 +493,8 @@ void CONSOLE::on_console_init() // console_register_print_callback(client_console_print_callback, this); - MACRO_REGISTER_COMMAND("toggle_local_console", "", CFGFLAG_CLIENT, con_toggle_local_console, this); - MACRO_REGISTER_COMMAND("toggle_remote_console", "", CFGFLAG_CLIENT, con_toggle_remote_console, this); + MACRO_REGISTER_COMMAND("toggle_local_console", "", CFGFLAG_CLIENT, con_toggle_local_console, this, ""); + MACRO_REGISTER_COMMAND("toggle_remote_console", "", CFGFLAG_CLIENT, con_toggle_remote_console, this, ""); } /* diff --git a/src/game/client/components/console.hpp b/src/game/client/components/console.hpp index 5a37b664..0a4adbda 100644 --- a/src/game/client/components/console.hpp +++ b/src/game/client/components/console.hpp @@ -23,6 +23,8 @@ class CONSOLE : public COMPONENT char completion_buffer[128]; int completion_chosen; int completion_flagmask; + + COMMAND *command; INSTANCE(int t); diff --git a/src/game/client/components/controls.cpp b/src/game/client/components/controls.cpp index e0ba7d96..63d4fd16 100644 --- a/src/game/client/components/controls.cpp +++ b/src/game/client/components/controls.cpp @@ -49,20 +49,20 @@ static void con_key_input_nextprev_weapon(void *result, void *user_data) void CONTROLS::on_console_init() { // game commands - MACRO_REGISTER_COMMAND("+left", "", CFGFLAG_CLIENT, con_key_input_state, &input_direction_left); - MACRO_REGISTER_COMMAND("+right", "", CFGFLAG_CLIENT, con_key_input_state, &input_direction_right); - MACRO_REGISTER_COMMAND("+jump", "", CFGFLAG_CLIENT, con_key_input_state, &input_data.jump); - MACRO_REGISTER_COMMAND("+hook", "", CFGFLAG_CLIENT, con_key_input_state, &input_data.hook); - MACRO_REGISTER_COMMAND("+fire", "", CFGFLAG_CLIENT, con_key_input_counter, &input_data.fire); - - { static INPUTSET set = {this, &input_data.wanted_weapon, 1}; MACRO_REGISTER_COMMAND("+weapon1", "", CFGFLAG_CLIENT, con_key_input_set, (void *)&set); } - { static INPUTSET set = {this, &input_data.wanted_weapon, 2}; MACRO_REGISTER_COMMAND("+weapon2", "", CFGFLAG_CLIENT, con_key_input_set, (void *)&set); } - { static INPUTSET set = {this, &input_data.wanted_weapon, 3}; MACRO_REGISTER_COMMAND("+weapon3", "", CFGFLAG_CLIENT, con_key_input_set, (void *)&set); } - { static INPUTSET set = {this, &input_data.wanted_weapon, 4}; MACRO_REGISTER_COMMAND("+weapon4", "", CFGFLAG_CLIENT, con_key_input_set, (void *)&set); } - { static INPUTSET set = {this, &input_data.wanted_weapon, 5}; MACRO_REGISTER_COMMAND("+weapon5", "", CFGFLAG_CLIENT, con_key_input_set, (void *)&set); } - - { static INPUTSET set = {this, &input_data.next_weapon, 0}; MACRO_REGISTER_COMMAND("+nextweapon", "", CFGFLAG_CLIENT, con_key_input_nextprev_weapon, (void *)&set); } - { static INPUTSET set = {this, &input_data.prev_weapon, 0}; MACRO_REGISTER_COMMAND("+prevweapon", "", CFGFLAG_CLIENT, con_key_input_nextprev_weapon, (void *)&set); } + MACRO_REGISTER_COMMAND("+left", "", CFGFLAG_CLIENT, con_key_input_state, &input_direction_left, ""); + MACRO_REGISTER_COMMAND("+right", "", CFGFLAG_CLIENT, con_key_input_state, &input_direction_right, ""); + MACRO_REGISTER_COMMAND("+jump", "", CFGFLAG_CLIENT, con_key_input_state, &input_data.jump, ""); + MACRO_REGISTER_COMMAND("+hook", "", CFGFLAG_CLIENT, con_key_input_state, &input_data.hook, ""); + MACRO_REGISTER_COMMAND("+fire", "", CFGFLAG_CLIENT, con_key_input_counter, &input_data.fire, ""); + + { static INPUTSET set = {this, &input_data.wanted_weapon, 1}; MACRO_REGISTER_COMMAND("+weapon1", "", CFGFLAG_CLIENT, con_key_input_set, (void *)&set, ""); } + { static INPUTSET set = {this, &input_data.wanted_weapon, 2}; MACRO_REGISTER_COMMAND("+weapon2", "", CFGFLAG_CLIENT, con_key_input_set, (void *)&set, ""); } + { static INPUTSET set = {this, &input_data.wanted_weapon, 3}; MACRO_REGISTER_COMMAND("+weapon3", "", CFGFLAG_CLIENT, con_key_input_set, (void *)&set, ""); } + { static INPUTSET set = {this, &input_data.wanted_weapon, 4}; MACRO_REGISTER_COMMAND("+weapon4", "", CFGFLAG_CLIENT, con_key_input_set, (void *)&set, ""); } + { static INPUTSET set = {this, &input_data.wanted_weapon, 5}; MACRO_REGISTER_COMMAND("+weapon5", "", CFGFLAG_CLIENT, con_key_input_set, (void *)&set, ""); } + + { static INPUTSET set = {this, &input_data.next_weapon, 0}; MACRO_REGISTER_COMMAND("+nextweapon", "", CFGFLAG_CLIENT, con_key_input_nextprev_weapon, (void *)&set, ""); } + { static INPUTSET set = {this, &input_data.prev_weapon, 0}; MACRO_REGISTER_COMMAND("+prevweapon", "", CFGFLAG_CLIENT, con_key_input_nextprev_weapon, (void *)&set, ""); } } void CONTROLS::on_message(int msg, void *rawmsg) diff --git a/src/game/client/components/emoticon.cpp b/src/game/client/components/emoticon.cpp index 8ca01ee3..c9b086cd 100644 --- a/src/game/client/components/emoticon.cpp +++ b/src/game/client/components/emoticon.cpp @@ -25,8 +25,8 @@ void EMOTICON::con_emote(void *result, void *user_data) void EMOTICON::on_console_init() { - MACRO_REGISTER_COMMAND("+emote", "", CFGFLAG_CLIENT, con_key_emoticon, this); - MACRO_REGISTER_COMMAND("emote", "i", CFGFLAG_CLIENT, con_emote, this); + MACRO_REGISTER_COMMAND("+emote", "", CFGFLAG_CLIENT, con_key_emoticon, this, ""); + MACRO_REGISTER_COMMAND("emote", "i", CFGFLAG_CLIENT, con_emote, this, ""); } void EMOTICON::on_reset() diff --git a/src/game/client/components/scoreboard.cpp b/src/game/client/components/scoreboard.cpp index 5fdc8721..bdeec3c1 100644 --- a/src/game/client/components/scoreboard.cpp +++ b/src/game/client/components/scoreboard.cpp @@ -26,7 +26,7 @@ void SCOREBOARD::on_reset() void SCOREBOARD::on_console_init() { - MACRO_REGISTER_COMMAND("+scoreboard", "", CFGFLAG_CLIENT, con_key_scoreboard, this); + MACRO_REGISTER_COMMAND("+scoreboard", "", CFGFLAG_CLIENT, con_key_scoreboard, this, ""); } void SCOREBOARD::render_goals(float x, float y, float w) diff --git a/src/game/client/components/voting.cpp b/src/game/client/components/voting.cpp index 68a4d42b..09fd1930 100644 --- a/src/game/client/components/voting.cpp +++ b/src/game/client/components/voting.cpp @@ -88,8 +88,8 @@ void VOTING::on_reset() void VOTING::on_console_init() { - MACRO_REGISTER_COMMAND("callvote", "sr", CFGFLAG_CLIENT, con_callvote, this); - MACRO_REGISTER_COMMAND("vote", "r", CFGFLAG_CLIENT, con_vote, this); + MACRO_REGISTER_COMMAND("callvote", "sr", CFGFLAG_CLIENT, con_callvote, this, ""); + MACRO_REGISTER_COMMAND("vote", "r", CFGFLAG_CLIENT, con_vote, this, ""); } void VOTING::on_message(int msgtype, void *rawmsg) |