diff options
Diffstat (limited to 'src/ui/ui.cc')
-rw-r--r-- | src/ui/ui.cc | 242 |
1 files changed, 0 insertions, 242 deletions
diff --git a/src/ui/ui.cc b/src/ui/ui.cc index 93b5e16..4977d03 100644 --- a/src/ui/ui.cc +++ b/src/ui/ui.cc @@ -16,7 +16,6 @@ #include "sys/sys.h" #include "ui/button.h" #include "ui/label.h" -#include "ui/menu.h" #include "ui/paint.h" #include "ui/ui.h" #include "ui/widget.h" @@ -100,17 +99,8 @@ UI::~UI() void UI::load_settings() { - ui_active_menu = 0; ui_mouse_focus = this; - // clear any existing menus - Menus::iterator it; - for (it = ui_menus.begin(); it != ui_menus.end(); it++) { - Window *menu = (*it); - remove_child(menu); - } - ui_menus.clear(); - // open ui.ini std::string filename("ini/ui"); filesystem::IniFile ini; @@ -124,10 +114,6 @@ void UI::load_settings() std::string strval; math::Color color; - Button *button = 0; - Label *label = 0; - Menu *menu = 0; - float w = elementsize.width(); float h = elementsize.height(); float m = elementmargin; @@ -138,51 +124,20 @@ void UI::load_settings() if (ini.got_section()) { if (ini.got_section("ui")) { - menu = 0; continue; // section default colors } else if (ini.got_section("colors")) { - menu = 0; continue; // section hud configuration } else if (ini.got_section("hud")) { - menu = 0; continue; // section text colors } else if (ini.got_section("text")) { - menu = 0; - continue; - - // section menu - } else if (ini.got_section("menu")) { - label = 0; - button = 0; - menu = new Menu(this); - add_menu(menu); continue; - - // menu button - } else if (ini.got_section("button")) { - - if (!menu) { - ini.unknown_error("button section outside menu defintion"); - } else { - button = menu->add_button(); - } - - // menu label - } else if (ini.got_section("label")) { - - if (!menu) { - ini.unknown_error("label section outside menu defintion"); - } else { - label = menu->add_label(); - } - } else { ini.unknown_section(); continue; @@ -264,69 +219,6 @@ void UI::load_settings() ui_palette->set_error(color); } - // menu definitions - - } else if (menu) { - - if (ini.in_section("menu")) { - - if (ini.got_key_string("label", strval)) { - aux::to_label(strval); - menu->set_label(strval); - } else if (ini.got_key_string("background", strval)) { - menu->set_background_texture(strval); - } else { - ini.unknown_key(); - } - - } else if (ini.in_section("button")) { - - if (ini.got_key_string("text", strval)) { - aux::strip_quotes(strval); - button->set_text(strval); - - } else if (ini.got_key_string("command", strval)) { - for (size_t i = 0; i <= strval.size(); i++) { - if (strval[i] == ',') strval[i] = ';'; - } - aux::strip_quotes(strval); - button->set_command(strval); - - } else if (ini.got_key_string("align", strval)) { - aux::to_label(strval); - if (strval.compare("left") == 0) { - button->set_alignment(AlignLeft | AlignVCenter); - } else if (strval.compare("center") == 0) { - button->set_alignment(AlignCenter); - } else if (strval.compare("right") == 0) { - button->set_alignment(AlignRight | AlignVCenter); - } else { - ini.unknown_value(); - } - } else { - ini.unknown_key(); - } - - } else if (ini.in_section("label")) { - - if (ini.got_key_string("text", strval)) { - label->set_text(strval); - } else if (ini.got_key_string("align", strval)) { - aux::to_label(strval); - if (strval.compare("left") == 0) { - label->set_alignment(AlignLeft | AlignHCenter); - } else if (strval.compare("center") == 0) { - label->set_alignment(AlignCenter); - } else if (strval.compare("right") == 0) { - label->set_alignment(AlignRight | AlignHCenter); - } else { - ini.unknown_value(); - } - } else { - ini.unknown_key(); - } - } - } } } @@ -339,35 +231,6 @@ void UI::load_settings() Paint::assign_system_color('W', palette()->warning()); Paint::assign_system_color('E', palette()->error()); - con_debug << " " << ini.name() << " " << ui_menus.size() << " menus" << std::endl; - - // fallback main menu - if (!find_menu("main")) { - con_warn << "menu 'main' not found, using default" << std::endl; - Menu *menu = new Menu(this, "main"); - menu->add_label("Main Menu"); - menu->add_button("Connect", "connect"); - menu->add_button("Quit", "quit"); - } - - // fallback game menu - if (!find_menu("game")) { - con_warn << "menu 'game' not found, using default" << std::endl; - Menu *menu = new Menu(this, "game"); - menu->add_label("Game Menu"); - menu->add_button("Disconnect", "disconnect"); - menu->add_button("Quit", "quit"); - } - - // fallback join menu - if (!find_menu("join")) { - con_warn << "menu 'join' not found, using default" << std::endl; - Menu *menu = new Menu(this, "join"); - menu->add_label("Join Menu"); - menu->add_button("Join", "join; menu hide"); - menu->add_button("Game menu", "menu game"); - } - ini.close(); } @@ -383,100 +246,8 @@ void UI::list_visible() const con_print << n << " visible user interface widgets" << std::endl; } -UI::Menus::iterator UI::find_menu(Window *menu) -{ - Menus::iterator it; - for (it = ui_menus.begin(); it != ui_menus.end(); it++) { - if ((*it) == menu) - return it; - } - - return it; -} - -Window *UI::find_menu(const char *label) -{ - for (Menus::const_iterator it = ui_menus.begin(); it != ui_menus.end(); it++) { - if ((*it)->label().compare(label) == 0) { - return (*it); - } - } - - return 0; -} - -void UI::list_menus() const -{ - for (Menus::const_iterator it = ui_menus.begin(); it != ui_menus.end(); it++) { - const Window *menu = (*it); - con_print << " " << menu->label() << std::endl; - } - con_print << ui_menus.size() << " menus" << std::endl; -} - -void UI::add_menu(Window *menu) -{ - Menus::iterator it = find_menu(menu); - if (it == ui_menus.end()) { - ui_menus.push_back(menu); - } - -} - -void UI::show_menu(const char *label) -{ - Window *menu = find_menu(label); - - if (menu) { - if (ui_active_menu) { - ui_active_menu->hide(); - menu->set_previous(ui_active_menu); - } else { - menu->clear_previous(); - } - ui_mouse_focus = this; - ui_input_focus = this; - - ui_active_menu = menu; - ui_active_menu->event_resize(); - ui_active_menu->show(); - - set_pointer("pointer"); - - // raise console if it is visible - if (ui_console->visible()) - ui_console->show(); - - } else { - con_warn << "Unknown window '" << label << "'" << std::endl; - } -} - -void UI::hide_menu() -{ - if (ui_active_menu) { - ui_active_menu->hide(); - ui_active_menu = 0; - } -} - -void UI::previous_menu() -{ - if (ui_active_menu) { - if (ui_active_menu->previous().size()) { - show_menu(ui_active_menu->previous().c_str()); - } else { - hide_menu(); - } - } -} - void UI::frame() { - if (ui_active_menu && !ui_active_menu->visible()) { - ui_active_menu = 0; - } - ui_input_focus = find_input_focus(); Widget *f = find_mouse_focus(mouse_cursor); if (f) { @@ -532,19 +303,6 @@ bool UI::input_key(const bool pressed, const int key, const unsigned int modifie bool UI::on_keypress(const int key, const unsigned int modifier) { - switch (key) { - - case SDLK_ESCAPE: - if (active()) { - hide_menu(); - //audio::play("ui/menu"); - } - return true; - break; - default: - break; - } - return false; } |