From 68c52dd5efca7ed66b083b70439337b8f1205c15 Mon Sep 17 00:00:00 2001 From: Magnus Auvinen Date: Wed, 27 Aug 2008 16:23:15 +0000 Subject: repaired the local console --- src/game/client/components/console.cpp | 66 ++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 2 deletions(-) (limited to 'src/game/client/components/console.cpp') diff --git a/src/game/client/components/console.cpp b/src/game/client/components/console.cpp index 6437b718..a67a1138 100644 --- a/src/game/client/components/console.cpp +++ b/src/game/client/components/console.cpp @@ -162,7 +162,6 @@ static float console_scale_func(float t) void CONSOLE::on_render() { - RECT screen = *ui_screen(); float console_max_height = screen.h*3/5.0f; float console_height; @@ -294,7 +293,70 @@ void CONSOLE::on_message(int msgtype, void *rawmsg) bool CONSOLE::on_input(INPUT_EVENT e) { - return false; + if(console_state == CONSOLE_CLOSED) + return false; + if(e.key >= KEY_F1 && e.key <= KEY_F25) + return false; + + if(e.key == KEY_ESC && (e.flags&INPFLAG_PRESS)) + toggle(console_type); + else + current_console()->on_input(e); + + return true; +} + +void CONSOLE::toggle(int type) +{ + if(console_type != type && (console_state == CONSOLE_OPEN || console_state == CONSOLE_OPENING)) + { + // don't toggle console, just switch what console to use + } + else + { + if (console_state == CONSOLE_CLOSED || console_state == CONSOLE_OPEN) + { + state_change_end = time_now()+state_change_duration; + } + else + { + float progress = state_change_end-time_now(); + float reversed_progress = state_change_duration-progress; + + state_change_end = time_now()+reversed_progress; + } + + if (console_state == CONSOLE_CLOSED || console_state == CONSOLE_CLOSING) + console_state = CONSOLE_OPENING; + else + console_state = CONSOLE_CLOSING; + } + + console_type = type; +} + +void CONSOLE::con_toggle_local_console(void *result, void *user_data) +{ + ((CONSOLE *)user_data)->toggle(0); +} + +void CONSOLE::con_toggle_remote_console(void *result, void *user_data) +{ + ((CONSOLE *)user_data)->toggle(1); +} + +void CONSOLE::client_console_print_callback(const char *str, void *user_data) +{ + ((CONSOLE *)user_data)->local_console.print_line(str); +} + +void CONSOLE::on_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); } -- cgit 1.4.1