mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
added tab completion to the console. works for local and remote
This commit is contained in:
parent
1a1af65b96
commit
9d51d47cea
|
@ -1945,21 +1945,36 @@ static void con_stoprecord(void *result, void *user_data)
|
|||
demorec_record_stop();
|
||||
}
|
||||
|
||||
static void con_serverdummy(void *result, void *user_data)
|
||||
{
|
||||
dbg_msg("client", "this command is not available on the client");
|
||||
}
|
||||
|
||||
static void client_register_commands()
|
||||
{
|
||||
MACRO_REGISTER_COMMAND("quit", "", con_quit, 0x0);
|
||||
MACRO_REGISTER_COMMAND("connect", "s", con_connect, 0x0);
|
||||
MACRO_REGISTER_COMMAND("disconnect", "", con_disconnect, 0x0);
|
||||
MACRO_REGISTER_COMMAND("ping", "", con_ping, 0x0);
|
||||
MACRO_REGISTER_COMMAND("screenshot", "", con_screenshot, 0x0);
|
||||
MACRO_REGISTER_COMMAND("rcon", "r", con_rcon, 0x0);
|
||||
MACRO_REGISTER_COMMAND("rcon_auth", "s", con_rcon_auth, 0x0);
|
||||
MACRO_REGISTER_COMMAND("quit", "", CFGFLAG_CLIENT, con_quit, 0x0);
|
||||
MACRO_REGISTER_COMMAND("connect", "s", CFGFLAG_CLIENT, con_connect, 0x0);
|
||||
MACRO_REGISTER_COMMAND("disconnect", "", CFGFLAG_CLIENT, con_disconnect, 0x0);
|
||||
MACRO_REGISTER_COMMAND("ping", "", CFGFLAG_CLIENT, con_ping, 0x0);
|
||||
MACRO_REGISTER_COMMAND("screenshot", "", CFGFLAG_CLIENT, con_screenshot, 0x0);
|
||||
MACRO_REGISTER_COMMAND("rcon", "r", CFGFLAG_CLIENT, con_rcon, 0x0);
|
||||
MACRO_REGISTER_COMMAND("rcon_auth", "s", CFGFLAG_CLIENT, con_rcon_auth, 0x0);
|
||||
|
||||
MACRO_REGISTER_COMMAND("play", "r", con_play, 0x0);
|
||||
MACRO_REGISTER_COMMAND("record", "s", con_record, 0);
|
||||
MACRO_REGISTER_COMMAND("stoprecord", "", con_stoprecord, 0);
|
||||
MACRO_REGISTER_COMMAND("play", "r", CFGFLAG_CLIENT, con_play, 0x0);
|
||||
MACRO_REGISTER_COMMAND("record", "s", CFGFLAG_CLIENT, con_record, 0);
|
||||
MACRO_REGISTER_COMMAND("stoprecord", "", CFGFLAG_CLIENT, con_stoprecord, 0);
|
||||
|
||||
MACRO_REGISTER_COMMAND("add_favorite", "s", con_addfavorite, 0x0);
|
||||
MACRO_REGISTER_COMMAND("add_favorite", "s", CFGFLAG_CLIENT, con_addfavorite, 0x0);
|
||||
|
||||
/* register server dummy commands for tab completion */
|
||||
MACRO_REGISTER_COMMAND("kick", "", CFGFLAG_SERVER, con_serverdummy, 0);
|
||||
MACRO_REGISTER_COMMAND("ban", "", CFGFLAG_SERVER, con_serverdummy, 0);
|
||||
MACRO_REGISTER_COMMAND("unban", "", CFGFLAG_SERVER, con_serverdummy, 0);
|
||||
MACRO_REGISTER_COMMAND("bans", "", CFGFLAG_SERVER, con_serverdummy, 0);
|
||||
MACRO_REGISTER_COMMAND("status", "", CFGFLAG_SERVER, con_serverdummy, 0);
|
||||
MACRO_REGISTER_COMMAND("shutdown", "", CFGFLAG_SERVER, con_serverdummy, 0);
|
||||
/*MACRO_REGISTER_COMMAND("record", "", CFGFLAG_SERVER, con_serverdummy, 0);
|
||||
MACRO_REGISTER_COMMAND("stoprecord", "", CFGFLAG_SERVER, con_serverdummy, 0);*/
|
||||
}
|
||||
|
||||
void client_save_line(const char *line)
|
||||
|
|
|
@ -292,6 +292,19 @@ void console_execute_line_stroked(int stroke, const char *str)
|
|||
}
|
||||
}
|
||||
|
||||
void console_possible_commands(const char *str, int flagmask, void (*callback)(const char *cmd, void *user), void *user)
|
||||
{
|
||||
COMMAND *cmd;
|
||||
for (cmd = first_command; cmd; cmd = cmd->next)
|
||||
{
|
||||
if(cmd->flags&flagmask)
|
||||
{
|
||||
if(str_find_nocase(cmd->name, str))
|
||||
callback(cmd->name, user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void console_execute_line(const char *str)
|
||||
{
|
||||
console_execute_line_stroked(1, str);
|
||||
|
@ -319,18 +332,18 @@ static void console_execute_file_real(const char *filename)
|
|||
dbg_msg("console", "failed to open '%s'", filename);
|
||||
}
|
||||
|
||||
struct exec_file
|
||||
struct EXECFILE
|
||||
{
|
||||
const char *filename;
|
||||
struct exec_file *next;
|
||||
struct EXECFILE *next;
|
||||
};
|
||||
|
||||
void console_execute_file(const char *filename)
|
||||
{
|
||||
static struct exec_file *first = 0;
|
||||
struct exec_file this;
|
||||
struct exec_file *cur;
|
||||
struct exec_file *prev;
|
||||
static struct EXECFILE *first = 0;
|
||||
struct EXECFILE this;
|
||||
struct EXECFILE *cur;
|
||||
struct EXECFILE *prev;
|
||||
|
||||
/* make sure that this isn't being executed already */
|
||||
for(cur = first; cur; cur = cur->next)
|
||||
|
@ -404,11 +417,11 @@ static void str_variable_command(void *result, void *user_data)
|
|||
|
||||
void console_init()
|
||||
{
|
||||
MACRO_REGISTER_COMMAND("echo", "r", con_echo, 0x0);
|
||||
MACRO_REGISTER_COMMAND("exec", "r", con_exec, 0x0);
|
||||
MACRO_REGISTER_COMMAND("echo", "r", CFGFLAG_SERVER|CFGFLAG_CLIENT, con_echo, 0x0);
|
||||
MACRO_REGISTER_COMMAND("exec", "r", CFGFLAG_SERVER|CFGFLAG_CLIENT, con_exec, 0x0);
|
||||
|
||||
#define MACRO_CONFIG_INT(name,def,min,max,flags,desc) { static INT_VARIABLE_DATA data = { &config_get_ ## name, &config_set_ ## name }; MACRO_REGISTER_COMMAND(#name, "?i", int_variable_command, &data) }
|
||||
#define MACRO_CONFIG_STR(name,len,def,flags,desc) { static STR_VARIABLE_DATA data = { &config_get_ ## name, &config_set_ ## name }; MACRO_REGISTER_COMMAND(#name, "?r", str_variable_command, &data) }
|
||||
#define MACRO_CONFIG_INT(name,def,min,max,flags,desc) { static INT_VARIABLE_DATA data = { &config_get_ ## name, &config_set_ ## name }; MACRO_REGISTER_COMMAND(#name, "?i", flags, int_variable_command, &data) }
|
||||
#define MACRO_CONFIG_STR(name,len,def,flags,desc) { static STR_VARIABLE_DATA data = { &config_get_ ## name, &config_set_ ## name }; MACRO_REGISTER_COMMAND(#name, "?r", flags, str_variable_command, &data) }
|
||||
|
||||
#include "e_config_variables.h"
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ typedef struct COMMAND_t
|
|||
{
|
||||
const char *name;
|
||||
const char *params;
|
||||
int flags;
|
||||
CONSOLE_CALLBACK callback;
|
||||
void *user_data;
|
||||
struct COMMAND_t *next;
|
||||
|
@ -21,6 +22,7 @@ void console_register(COMMAND *cmd);
|
|||
void console_execute_line(const char *str);
|
||||
void console_execute_line_stroked(int stroke, const char *str);
|
||||
void console_execute_file(const char *filename);
|
||||
void console_possible_commands(const char *str, int flagmask, void (*callback)(const char *cmd, void *user), void *user);
|
||||
void console_print(const char *str);
|
||||
void console_register_print_callback(void (*callback)(const char *, void *user_data), void *user_data);
|
||||
|
||||
|
@ -33,7 +35,7 @@ int console_arg_int(void *result, int index);
|
|||
float console_arg_float(void *result, int index);
|
||||
int console_arg_num(void *result);
|
||||
|
||||
#define MACRO_REGISTER_COMMAND(name, params, func, ptr) { static COMMAND cmd = { name, params, func, ptr, 0x0 }; console_register(&cmd); }
|
||||
#define MACRO_REGISTER_COMMAND(name, params, flags, func, ptr) { static COMMAND cmd = { name, params, flags, func, ptr, 0x0 }; console_register(&cmd); }
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -83,8 +83,8 @@ void engine_init(const char *appname)
|
|||
|
||||
jobs_initpool(&hostlookuppool, 1);
|
||||
|
||||
MACRO_REGISTER_COMMAND("dbg_dumpmem", "", con_dbg_dumpmem, 0x0);
|
||||
MACRO_REGISTER_COMMAND("dbg_lognetwork", "", con_dbg_lognetwork, 0x0);
|
||||
MACRO_REGISTER_COMMAND("dbg_dumpmem", "", CFGFLAG_SERVER|CFGFLAG_CLIENT, con_dbg_dumpmem, 0x0);
|
||||
MACRO_REGISTER_COMMAND("dbg_lognetwork", "", CFGFLAG_SERVER|CFGFLAG_CLIENT, con_dbg_lognetwork, 0x0);
|
||||
|
||||
/* reset the config */
|
||||
config_reset();
|
||||
|
|
|
@ -94,6 +94,7 @@ typedef struct
|
|||
int snap_rate;
|
||||
|
||||
int last_acked_snapshot;
|
||||
int last_input_tick;
|
||||
SNAPSTORAGE snapshots;
|
||||
|
||||
CLIENT_INPUT latestinput;
|
||||
|
@ -535,8 +536,10 @@ static void reset_client(int cid)
|
|||
|
||||
snapstorage_purge_all(&clients[cid].snapshots);
|
||||
clients[cid].last_acked_snapshot = -1;
|
||||
clients[cid].last_input_tick = -1;
|
||||
clients[cid].snap_rate = SRVCLIENT_SNAPRATE_INIT;
|
||||
clients[cid].score = 0;
|
||||
|
||||
}
|
||||
|
||||
static int new_client_callback(int cid, void *user)
|
||||
|
@ -710,11 +713,18 @@ static void server_process_client_packet(NETCHUNK *packet)
|
|||
clients[cid].latency = (int)(((time_get()-tagtime)*1000)/time_freq());
|
||||
|
||||
/* add message to report the input timing */
|
||||
msg_pack_start_system(NETMSG_INPUTTIMING, 0);
|
||||
msg_pack_int(tick);
|
||||
msg_pack_int(((server_tick_start_time(tick)-time_get())*1000) / time_freq());
|
||||
msg_pack_end();
|
||||
server_send_msg(cid);
|
||||
/* skip packets that are old */
|
||||
if(tick > clients[cid].last_input_tick)
|
||||
{
|
||||
int time_left = ((server_tick_start_time(tick)-time_get())*1000) / time_freq();
|
||||
msg_pack_start_system(NETMSG_INPUTTIMING, 0);
|
||||
msg_pack_int(tick);
|
||||
msg_pack_int(time_left);
|
||||
msg_pack_end();
|
||||
server_send_msg(cid);
|
||||
}
|
||||
|
||||
clients[cid].last_input_tick = tick;
|
||||
|
||||
input = &clients[cid].inputs[clients[cid].current_input];
|
||||
|
||||
|
@ -1278,15 +1288,15 @@ static void con_stoprecord(void *result, void *user_data)
|
|||
|
||||
static void server_register_commands()
|
||||
{
|
||||
MACRO_REGISTER_COMMAND("kick", "i", con_kick, 0);
|
||||
MACRO_REGISTER_COMMAND("ban", "s?i", con_ban, 0);
|
||||
MACRO_REGISTER_COMMAND("unban", "s", con_unban, 0);
|
||||
MACRO_REGISTER_COMMAND("bans", "", con_bans, 0);
|
||||
MACRO_REGISTER_COMMAND("status", "", con_status, 0);
|
||||
MACRO_REGISTER_COMMAND("shutdown", "", con_shutdown, 0);
|
||||
MACRO_REGISTER_COMMAND("kick", "i", CFGFLAG_SERVER, con_kick, 0);
|
||||
MACRO_REGISTER_COMMAND("ban", "s?i", CFGFLAG_SERVER, con_ban, 0);
|
||||
MACRO_REGISTER_COMMAND("unban", "s", CFGFLAG_SERVER, con_unban, 0);
|
||||
MACRO_REGISTER_COMMAND("bans", "", CFGFLAG_SERVER, con_bans, 0);
|
||||
MACRO_REGISTER_COMMAND("status", "", CFGFLAG_SERVER, con_status, 0);
|
||||
MACRO_REGISTER_COMMAND("shutdown", "", CFGFLAG_SERVER, con_shutdown, 0);
|
||||
|
||||
MACRO_REGISTER_COMMAND("record", "s", con_record, 0);
|
||||
MACRO_REGISTER_COMMAND("stoprecord", "", con_stoprecord, 0);
|
||||
MACRO_REGISTER_COMMAND("record", "s", CFGFLAG_SERVER, con_record, 0);
|
||||
MACRO_REGISTER_COMMAND("stoprecord", "", CFGFLAG_SERVER, con_stoprecord, 0);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
|
|
|
@ -114,10 +114,10 @@ void BINDS::set_defaults()
|
|||
void BINDS::on_console_init()
|
||||
{
|
||||
// bindings
|
||||
MACRO_REGISTER_COMMAND("bind", "sr", con_bind, this);
|
||||
MACRO_REGISTER_COMMAND("unbind", "s", con_unbind, this);
|
||||
MACRO_REGISTER_COMMAND("unbindall", "", con_unbindall, this);
|
||||
MACRO_REGISTER_COMMAND("dump_binds", "", 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();
|
||||
|
|
|
@ -41,9 +41,9 @@ void CHAT::con_chat(void *result, void *user_data)
|
|||
|
||||
void CHAT::on_console_init()
|
||||
{
|
||||
MACRO_REGISTER_COMMAND("say", "r", con_say, this);
|
||||
MACRO_REGISTER_COMMAND("say_team", "r", con_sayteam, this);
|
||||
MACRO_REGISTER_COMMAND("chat", "s", 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)
|
||||
|
|
|
@ -20,6 +20,7 @@ extern "C" {
|
|||
#include <game/version.hpp>
|
||||
|
||||
#include <game/client/lineinput.hpp>
|
||||
#include <game/client/render.hpp>
|
||||
|
||||
#include "console.hpp"
|
||||
|
||||
|
@ -40,6 +41,14 @@ CONSOLE::INSTANCE::INSTANCE(int t)
|
|||
history_entry = 0x0;
|
||||
|
||||
type = t;
|
||||
|
||||
if(t == 0)
|
||||
completion_flagmask = CFGFLAG_CLIENT;
|
||||
else
|
||||
completion_flagmask = CFGFLAG_SERVER;
|
||||
|
||||
completion_buffer[0] = 0;
|
||||
completion_chosen = -1;
|
||||
}
|
||||
|
||||
void CONSOLE::INSTANCE::execute_line(const char *line)
|
||||
|
@ -55,6 +64,14 @@ void CONSOLE::INSTANCE::execute_line(const char *line)
|
|||
}
|
||||
}
|
||||
|
||||
void CONSOLE::INSTANCE::possible_commands_complete_callback(const char *str, void *user)
|
||||
{
|
||||
CONSOLE::INSTANCE *instance = (CONSOLE::INSTANCE *)user;
|
||||
if(instance->completion_chosen == instance->completion_enumeration_count)
|
||||
instance->input.set(str);
|
||||
instance->completion_enumeration_count++;
|
||||
}
|
||||
|
||||
void CONSOLE::INSTANCE::on_input(INPUT_EVENT e)
|
||||
{
|
||||
bool handled = false;
|
||||
|
@ -110,6 +127,26 @@ void CONSOLE::INSTANCE::on_input(INPUT_EVENT e)
|
|||
input.clear();
|
||||
handled = true;
|
||||
}
|
||||
else if(e.key == KEY_TAB)
|
||||
{
|
||||
completion_chosen++;
|
||||
completion_enumeration_count = 0;
|
||||
console_possible_commands(completion_buffer, completion_flagmask, possible_commands_complete_callback, this);
|
||||
|
||||
// handle wrapping
|
||||
if(completion_chosen >= completion_enumeration_count)
|
||||
{
|
||||
completion_chosen %= completion_enumeration_count;
|
||||
completion_enumeration_count = 0;
|
||||
console_possible_commands(completion_buffer, completion_flagmask, possible_commands_complete_callback, this);
|
||||
}
|
||||
}
|
||||
|
||||
if(e.key != KEY_TAB)
|
||||
{
|
||||
completion_chosen = -1;
|
||||
str_copy(completion_buffer, input.get_string(), sizeof(completion_buffer));
|
||||
}
|
||||
}
|
||||
|
||||
if(!handled)
|
||||
|
@ -160,6 +197,54 @@ static float console_scale_func(float t)
|
|||
return sinf(acosf(1.0f-t));
|
||||
}
|
||||
|
||||
struct RENDERINFO
|
||||
{
|
||||
TEXT_CURSOR cursor;
|
||||
const char *current_cmd;
|
||||
int wanted_completion;
|
||||
int enum_count;
|
||||
};
|
||||
|
||||
void CONSOLE::possible_commands_render_callback(const char *str, void *user)
|
||||
{
|
||||
RENDERINFO *info = (RENDERINFO *)user;
|
||||
|
||||
if(info->enum_count == info->wanted_completion)
|
||||
{
|
||||
float tw = gfx_text_width(info->cursor.font_set, info->cursor.font_size, str, -1);
|
||||
gfx_texture_set(-1);
|
||||
gfx_quads_begin();
|
||||
gfx_setcolor(229.0f/255.0f,185.0f/255.0f,4.0f/255.0f,0.85f);
|
||||
draw_round_rect(info->cursor.x-3, info->cursor.y, tw+5, info->cursor.font_size+4, info->cursor.font_size/3);
|
||||
gfx_quads_end();
|
||||
|
||||
gfx_text_color(0.05f, 0.05f, 0.05f,1);
|
||||
gfx_text_ex(&info->cursor, str, -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *match_start = str_find_nocase(str, info->current_cmd);
|
||||
|
||||
if(match_start)
|
||||
{
|
||||
gfx_text_color(0.5f,0.5f,0.5f,1);
|
||||
gfx_text_ex(&info->cursor, str, match_start-str);
|
||||
gfx_text_color(229.0f/255.0f,185.0f/255.0f,4.0f/255.0f,1);
|
||||
gfx_text_ex(&info->cursor, match_start, strlen(info->current_cmd));
|
||||
gfx_text_color(0.5f,0.5f,0.5f,1);
|
||||
gfx_text_ex(&info->cursor, match_start+strlen(info->current_cmd), -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
gfx_text_color(0.75f,0.75f,0.75f,1);
|
||||
gfx_text_ex(&info->cursor, str, -1);
|
||||
}
|
||||
}
|
||||
|
||||
info->enum_count++;
|
||||
info->cursor.x += 7.0f;
|
||||
}
|
||||
|
||||
void CONSOLE::on_render()
|
||||
{
|
||||
RECT screen = *ui_screen();
|
||||
|
@ -235,7 +320,7 @@ void CONSOLE::on_render()
|
|||
gfx_quads_drawTL(0,console_height-10.0f,screen.w,10.0f);
|
||||
gfx_quads_end();
|
||||
|
||||
console_height -= 10.0f;
|
||||
console_height -= 20.0f;
|
||||
|
||||
INSTANCE *console = current_console();
|
||||
|
||||
|
@ -249,6 +334,12 @@ void CONSOLE::on_render()
|
|||
TEXT_CURSOR cursor;
|
||||
gfx_text_set_cursor(&cursor, x, y, font_size, TEXTFLAG_RENDER);
|
||||
|
||||
RENDERINFO info;
|
||||
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);
|
||||
|
||||
const char *prompt = "> ";
|
||||
if(console_type)
|
||||
{
|
||||
|
@ -277,6 +368,13 @@ void CONSOLE::on_render()
|
|||
float version_width = gfx_text_width(0, font_size, buf, -1);
|
||||
gfx_text(0, screen.w-version_width-5, y, font_size, buf, -1);
|
||||
|
||||
// render possible commands
|
||||
if(console->input.get_string()[0] == 0)
|
||||
gfx_text_ex(&info.cursor, "No matching possible", -1);
|
||||
else
|
||||
console_possible_commands(console->completion_buffer, console->completion_flagmask, possible_commands_render_callback, &info);
|
||||
gfx_text_color(1,1,1,1);
|
||||
|
||||
// render log
|
||||
y -= row_height;
|
||||
char *entry = (char *)ringbuf_last(console->backlog);
|
||||
|
@ -372,8 +470,8 @@ void CONSOLE::on_console_init()
|
|||
//
|
||||
console_register_print_callback(client_console_print_callback, this);
|
||||
|
||||
MACRO_REGISTER_COMMAND("toggle_local_console", "", con_toggle_local_console, this);
|
||||
MACRO_REGISTER_COMMAND("toggle_remote_console", "", 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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -17,14 +17,23 @@ class CONSOLE : public COMPONENT
|
|||
LINEINPUT input;
|
||||
|
||||
int type;
|
||||
int completion_enumeration_count;
|
||||
|
||||
public:
|
||||
char completion_buffer[128];
|
||||
int completion_chosen;
|
||||
int completion_flagmask;
|
||||
|
||||
INSTANCE(int t);
|
||||
|
||||
void execute_line(const char *line);
|
||||
|
||||
void on_input(INPUT_EVENT e);
|
||||
void print_line(const char *line);
|
||||
|
||||
const char *get_string() const { return input.get_string(); }
|
||||
|
||||
static void possible_commands_complete_callback(const char *str, void *user);
|
||||
};
|
||||
|
||||
INSTANCE local_console;
|
||||
|
@ -41,6 +50,7 @@ class CONSOLE : public COMPONENT
|
|||
|
||||
void toggle(int type);
|
||||
|
||||
static void possible_commands_render_callback(const char *str, void *user);
|
||||
static void client_console_print_callback(const char *str, void *user_data);
|
||||
static void con_toggle_local_console(void *result, void *user_data);
|
||||
static void con_toggle_remote_console(void *result, void *user_data);
|
||||
|
|
|
@ -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", "", con_key_input_state, &input_direction_left);
|
||||
MACRO_REGISTER_COMMAND("+right", "", con_key_input_state, &input_direction_right);
|
||||
MACRO_REGISTER_COMMAND("+jump", "", con_key_input_state, &input_data.jump);
|
||||
MACRO_REGISTER_COMMAND("+hook", "", con_key_input_state, &input_data.hook);
|
||||
MACRO_REGISTER_COMMAND("+fire", "", con_key_input_counter, &input_data.fire);
|
||||
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", "", con_key_input_set, (void *)&set); }
|
||||
{ static INPUTSET set = {this, &input_data.wanted_weapon, 2}; MACRO_REGISTER_COMMAND("+weapon2", "", con_key_input_set, (void *)&set); }
|
||||
{ static INPUTSET set = {this, &input_data.wanted_weapon, 3}; MACRO_REGISTER_COMMAND("+weapon3", "", con_key_input_set, (void *)&set); }
|
||||
{ static INPUTSET set = {this, &input_data.wanted_weapon, 4}; MACRO_REGISTER_COMMAND("+weapon4", "", con_key_input_set, (void *)&set); }
|
||||
{ static INPUTSET set = {this, &input_data.wanted_weapon, 5}; MACRO_REGISTER_COMMAND("+weapon5", "", con_key_input_set, (void *)&set); }
|
||||
{ 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", "", con_key_input_nextprev_weapon, (void *)&set); }
|
||||
{ static INPUTSET set = {this, &input_data.prev_weapon, 0}; MACRO_REGISTER_COMMAND("+prevweapon", "", con_key_input_nextprev_weapon, (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)
|
||||
|
|
|
@ -25,8 +25,8 @@ void EMOTICON::con_emote(void *result, void *user_data)
|
|||
|
||||
void EMOTICON::on_console_init()
|
||||
{
|
||||
MACRO_REGISTER_COMMAND("+emote", "", con_key_emoticon, this);
|
||||
MACRO_REGISTER_COMMAND("emote", "i", 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()
|
||||
|
|
|
@ -26,7 +26,7 @@ void SCOREBOARD::on_reset()
|
|||
|
||||
void SCOREBOARD::on_console_init()
|
||||
{
|
||||
MACRO_REGISTER_COMMAND("+scoreboard", "", con_key_scoreboard, this);
|
||||
MACRO_REGISTER_COMMAND("+scoreboard", "", CFGFLAG_CLIENT, con_key_scoreboard, this);
|
||||
}
|
||||
|
||||
void SCOREBOARD::render_goals(float x, float y, float w)
|
||||
|
|
|
@ -88,8 +88,8 @@ void VOTING::on_reset()
|
|||
|
||||
void VOTING::on_console_init()
|
||||
{
|
||||
MACRO_REGISTER_COMMAND("callvote", "sr", con_callvote, this);
|
||||
MACRO_REGISTER_COMMAND("vote", "r", 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)
|
||||
|
|
|
@ -92,6 +92,11 @@ static void load_sounds_thread(void *do_render)
|
|||
}
|
||||
}
|
||||
|
||||
static void con_serverdummy(void *result, void *user_data)
|
||||
{
|
||||
dbg_msg("client", "this command is not available on the client");
|
||||
}
|
||||
|
||||
void GAMECLIENT::on_console_init()
|
||||
{
|
||||
// setup pointers
|
||||
|
@ -155,8 +160,20 @@ void GAMECLIENT::on_console_init()
|
|||
input.add(binds);
|
||||
|
||||
// add the some console commands
|
||||
MACRO_REGISTER_COMMAND("team", "i", con_team, this);
|
||||
MACRO_REGISTER_COMMAND("kill", "", con_kill, this);
|
||||
MACRO_REGISTER_COMMAND("team", "i", CFGFLAG_CLIENT, con_team, this);
|
||||
MACRO_REGISTER_COMMAND("kill", "", CFGFLAG_CLIENT, con_kill, this);
|
||||
|
||||
// register server dummy commands for tab completion
|
||||
MACRO_REGISTER_COMMAND("tune", "", CFGFLAG_SERVER, con_serverdummy, 0);
|
||||
MACRO_REGISTER_COMMAND("tune_reset", "", CFGFLAG_SERVER, con_serverdummy, 0);
|
||||
MACRO_REGISTER_COMMAND("tune_dump", "", CFGFLAG_SERVER, con_serverdummy, 0);
|
||||
MACRO_REGISTER_COMMAND("change_map", "", CFGFLAG_SERVER, con_serverdummy, 0);
|
||||
MACRO_REGISTER_COMMAND("restart", "", CFGFLAG_SERVER, con_serverdummy, 0);
|
||||
MACRO_REGISTER_COMMAND("broadcast", "", CFGFLAG_SERVER, con_serverdummy, 0);
|
||||
/*MACRO_REGISTER_COMMAND("say", "r", CFGFLAG_SERVER, con_serverdummy, 0);*/
|
||||
MACRO_REGISTER_COMMAND("set_team", "", CFGFLAG_SERVER, con_serverdummy, 0);
|
||||
MACRO_REGISTER_COMMAND("addvote", "", CFGFLAG_SERVER, con_serverdummy, 0);
|
||||
/*MACRO_REGISTER_COMMAND("vote", "", CFGFLAG_SERVER, con_serverdummy, 0);*/
|
||||
|
||||
// let all the other components register their console commands
|
||||
for(int i = 0; i < all.num; i++)
|
||||
|
|
|
@ -501,18 +501,18 @@ static void con_vote(void *result, void *user_data)
|
|||
|
||||
void mods_console_init()
|
||||
{
|
||||
MACRO_REGISTER_COMMAND("tune", "si", con_tune_param, 0);
|
||||
MACRO_REGISTER_COMMAND("tune_reset", "", con_tune_reset, 0);
|
||||
MACRO_REGISTER_COMMAND("tune_dump", "", con_tune_dump, 0);
|
||||
MACRO_REGISTER_COMMAND("tune", "si", CFGFLAG_SERVER, con_tune_param, 0);
|
||||
MACRO_REGISTER_COMMAND("tune_reset", "", CFGFLAG_SERVER, con_tune_reset, 0);
|
||||
MACRO_REGISTER_COMMAND("tune_dump", "", CFGFLAG_SERVER, con_tune_dump, 0);
|
||||
|
||||
MACRO_REGISTER_COMMAND("change_map", "r", con_change_map, 0);
|
||||
MACRO_REGISTER_COMMAND("restart", "?i", con_restart, 0);
|
||||
MACRO_REGISTER_COMMAND("broadcast", "r", con_broadcast, 0);
|
||||
MACRO_REGISTER_COMMAND("say", "r", con_say, 0);
|
||||
MACRO_REGISTER_COMMAND("set_team", "ii", con_set_team, 0);
|
||||
MACRO_REGISTER_COMMAND("change_map", "r", CFGFLAG_SERVER, con_change_map, 0);
|
||||
MACRO_REGISTER_COMMAND("restart", "?i", CFGFLAG_SERVER, con_restart, 0);
|
||||
MACRO_REGISTER_COMMAND("broadcast", "r", CFGFLAG_SERVER, con_broadcast, 0);
|
||||
MACRO_REGISTER_COMMAND("say", "r", CFGFLAG_SERVER, con_say, 0);
|
||||
MACRO_REGISTER_COMMAND("set_team", "ii", CFGFLAG_SERVER, con_set_team, 0);
|
||||
|
||||
MACRO_REGISTER_COMMAND("addvote", "r", con_addvote, 0);
|
||||
MACRO_REGISTER_COMMAND("vote", "r", con_vote, 0);
|
||||
MACRO_REGISTER_COMMAND("addvote", "r", CFGFLAG_SERVER, con_addvote, 0);
|
||||
MACRO_REGISTER_COMMAND("vote", "r", CFGFLAG_SERVER, con_vote, 0);
|
||||
}
|
||||
|
||||
void mods_init()
|
||||
|
|
Loading…
Reference in a new issue