From b417df720584c101f3799874a0c836a543a8d0a8 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 12 Oct 2008 14:55:10 +0000 Subject: user interface updates, work-in-progress --- src/client/input.cc | 61 +++++++++++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 28 deletions(-) (limited to 'src/client/input.cc') diff --git a/src/client/input.cc b/src/client/input.cc index d2a53e1..d2c290b 100644 --- a/src/client/input.cc +++ b/src/client/input.cc @@ -108,7 +108,7 @@ float joystick_lastmoved_time() void func_screenshot(std::string const & args) { - video::screenshot(); + render::screenshot(); } void func_ui_control(std::string const &args) @@ -138,13 +138,6 @@ void func_ui_console(std::string const &args) console()->toggle(); } -void func_ui_chat(std::string const &args) -{ - if (core::application()->connected()) { - chat::toggle(); - } -} - void func_view_next(std::string const &args) { if (core::application()->connected() && core::localcontrol()) { @@ -256,8 +249,6 @@ void init() keyboard = new Keyboard(); - client::setkeyboardmode(false); - SDL_ShowCursor(SDL_DISABLE); SDL_WM_GrabInput(SDL_GRAB_ON); // SDL_EnableUNICODE(1); @@ -280,8 +271,8 @@ void init() func = core::Func::add("ui_console", func_ui_console); func->set_info("toggle console on or off"); - func = core::Func::add("ui_chat", func_ui_chat); - func->set_info("toggle chatbox on or of"); + //func = core::Func::add("ui_chat", func_ui_chat); + //func->set_info("toggle chatbox on or of"); func = core::Func::add("ui_control",func_ui_control); func->set_info("toggle mouse control"); @@ -333,8 +324,8 @@ void shutdown() core::Func::remove("screenshot"); core::Func::remove("ui_console"); - core::Func::remove("ui_control"); - core::Func::remove("ui_chat"); + //core::Func::remove("ui_control"); + //core::Func::remove("ui_chat"); core::Func::remove("ui_view"); keyboard->save_binds(); @@ -498,21 +489,37 @@ Key::Modifier convert_SDL_modifier(int const sdlmodifier) void key_pressed(Key *key) { + ui::root()->input_key(true, Keyboard::translate_keysym(key->sym(), keyboard_modifiers), keyboard_modifiers); if (key->sym() == SDLK_ESCAPE) { - if (chat::visible()) { - chat::toggle(); - } else { + + if (console()->visible()) { + console()->toggle(); local_direction = 0.0f; local_pitch = 0.0f; local_roll = 0.0f; - + render::Camera::set_direction(0.0f); render::Camera::set_pitch(0.0f); - console()->toggle(); + } else { + if (ui::root()->active()) { + ui::root()->hide_window(); + local_direction = 0.0f; + local_pitch = 0.0f; + local_roll = 0.0f; + + render::Camera::set_direction(0.0f); + render::Camera::set_pitch(0.0f); + } else { + if (core::application()->connected()) { + ui::root()->show_window("game"); + } else { + ui::root()->show_window("main"); + } + } } - + } else if (key->bind(Key::None).compare("ui_console") == 0) { local_direction = 0.0f; local_pitch = 0.0f; @@ -526,16 +533,16 @@ void key_pressed(Key *key) } else if (console()->visible()) { // send key events to the console if (key->sym() < 512) - console()->keypressed(translate_keysym(key->sym(), keyboard_modifiers)); + console()->keypressed(Keyboard::translate_keysym(key->sym(), keyboard_modifiers)); } else if (ui::root()->active()) { - ui::root()->input_key(true, key->sym(), keyboard_modifiers); - - } else if (chat::visible()) { +/* ui::root()->input_key(true, key->sym(), keyboard_modifiers); +*/ +/* } else if (chat::visible()) { // send key events to the chat box if (key->sym() < 512) chat::keypressed(translate_keysym(key->sym(), keyboard_modifiers)); - +*/ } else if (core::application()->connected() && core::localcontrol()) { char c = key->bind(convert_SDL_modifier(keyboard_modifiers)).c_str()[0]; @@ -559,9 +566,7 @@ void key_pressed(Key *key) void key_released(Key *key) { - if (ui::root()->active()) { - ui::root()->input_key(false, key->sym(), keyboard_modifiers); - } + ui::root()->input_key(false, Keyboard::translate_keysym(key->sym(), keyboard_modifiers), keyboard_modifiers); if (core::application()->connected() && core::localcontrol()) { -- cgit v1.2.3