From 1e0df536c2fae85c317ce9c3cc17603d5f98c911 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Wed, 15 Oct 2008 20:33:15 +0000 Subject: moved client console into a Widget --- src/ui/ui.cc | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) (limited to 'src/ui/ui.cc') diff --git a/src/ui/ui.cc b/src/ui/ui.cc index 2cadd8b..baedd38 100644 --- a/src/ui/ui.cc +++ b/src/ui/ui.cc @@ -381,13 +381,12 @@ void UI::show_menu(const char *label) } else { menu->clear_previous(); } - ui_active_menu = menu; - ui_active_menu->event_resize(); - ui_active_menu->raise(); - ui_active_menu->show(); - ui_active_menu->set_focus(); ui_mouse_focus = this; ui_input_focus = this; + + ui_active_menu = menu; + ui_active_menu->event_resize(); + ui_active_menu->show(); } else { con_warn << "Unknown window '" << label << "'" << std::endl; } @@ -436,20 +435,22 @@ void UI::input_mouse(const float x, const float y) ui_mouse_focus = f; } -void UI::input_key(const bool pressed, const int key, const unsigned int modifier) +bool UI::input_key(const bool pressed, const int key, const unsigned int modifier) { + bool handled = false; if (key < 512) { // keyboard keys Widget *f = find_input_focus(); if (f) { - f->event_key(pressed, key, modifier); + handled = f->event_key(pressed, key, modifier); } ui_input_focus = f; } else { // mosue buttons if (ui_mouse_focus) - ui_mouse_focus->event_key(pressed, key, modifier); + handled = ui_mouse_focus->event_key(pressed, key, modifier); } + return handled; } /* -- event handlers ----------------------------------------------- */ @@ -459,12 +460,28 @@ void UI::input_key(const bool pressed, const int key, const unsigned int modifie */ bool UI::on_keypress(const int key, const unsigned int modifier) { - return true; + switch( key ) { + + case SDLK_ESCAPE: + if (active()) { + previous_menu(); + } else { + if (core::application()->connected()) { + show_menu("game"); + } + } + return true; + break; + default: + break; + } + + return false; } bool UI::on_keyrelease(const int key, const unsigned int modifier) { - return true; + return false; } } -- cgit v1.2.3