diff options
author | Stijn Buys <ingar@osirion.org> | 2011-09-04 17:54:51 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2011-09-04 17:54:51 +0000 |
commit | 69eed715f80c24c2435c82bb9fa1954697bf3af0 (patch) | |
tree | a21aa14d2ecfa86b94d3b122c2c972d758425782 /src/client | |
parent | edd5dfcd15198f5d5d277835fdf75108eb67472d (diff) |
Moved main menu infrastructure into client namespace,
removed ui::Container and ui::Menu classes.
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/buttonmenu.cc | 36 | ||||
-rw-r--r-- | src/client/buttonmenu.h | 10 | ||||
-rw-r--r-- | src/client/buymenu.h | 1 | ||||
-rw-r--r-- | src/client/client.cc | 91 | ||||
-rw-r--r-- | src/client/client.h | 2 | ||||
-rw-r--r-- | src/client/entitymenu.cc | 3 | ||||
-rw-r--r-- | src/client/hud.cc | 3 | ||||
-rw-r--r-- | src/client/input.cc | 2 | ||||
-rw-r--r-- | src/client/mainmenu.cc | 314 | ||||
-rw-r--r-- | src/client/mainmenu.h | 54 | ||||
-rw-r--r-- | src/client/mainwindow.cc | 23 | ||||
-rw-r--r-- | src/client/mapwindow.cc | 169 | ||||
-rw-r--r-- | src/client/mapwindow.h | 2 |
13 files changed, 434 insertions, 276 deletions
diff --git a/src/client/buttonmenu.cc b/src/client/buttonmenu.cc index ed15223..18139d0 100644 --- a/src/client/buttonmenu.cc +++ b/src/client/buttonmenu.cc @@ -19,6 +19,7 @@ ButtonMenu::ButtonMenu(ui::Widget *parent, const char *label) : ui::Window(paren set_background(false); buttonmenu_container = new ui::Window(this); + buttonmenu_compact = false; hide(); } @@ -44,11 +45,10 @@ ui::Button *ButtonMenu::add_button(char const *text, char const *command) void ButtonMenu::resize() { - // resize container widget - buttonmenu_container->set_geometry(0, 0, ui::UI::elementsize.width() * 1.5f, height()); - + const float padding = ui::UI::elementsize.height(); + // reposition all children within the container - const float x = ui::UI::elementsize.width() * 0.25f; + const float x = padding; float y = ui::UI::elementsize.height() * 0.5f; for (Children::iterator it = buttonmenu_container->children().begin(); it != buttonmenu_container->children().end(); it++) { @@ -60,6 +60,15 @@ void ButtonMenu::resize() y += ui::UI::elementsize.height() + ui::UI::elementmargin; } + // resize container widget + if (!buttonmenu_compact) { + buttonmenu_container->set_geometry(0, 0, ui::UI::elementsize.width() + 2.0f * padding, height()); + } else { + y += ui::UI::elementsize.height() * 0.5f; + buttonmenu_container->set_geometry(0, (height() - y) * 0.5f, ui::UI::elementsize.width() + 2.0f * padding, y); + } + + } void ButtonMenu::clear() @@ -70,23 +79,4 @@ void ButtonMenu::clear() } -bool ButtonMenu::on_keypress(const int key, const unsigned int modifier) -{ - switch (key) { - - case SDLK_ESCAPE: - // close window on ESC - if (visible()) { - this->hide(); - return true; - } - break; - - default: - break; - } - - return Window::on_keypress(key, modifier); -} - } diff --git a/src/client/buttonmenu.h b/src/client/buttonmenu.h index 2c3dd87..fbd7797 100644 --- a/src/client/buttonmenu.h +++ b/src/client/buttonmenu.h @@ -28,6 +28,11 @@ public: /// add a button with a command ui::Button *add_button(char const *text = 0, char const *command = 0); + + /// set compact mode + inline void set_compact(const bool compact = true) { + buttonmenu_compact = compact; + } protected: /// remove container children @@ -36,11 +41,10 @@ protected: /// resize event virtual void resize(); - /// keypress event - virtual bool on_keypress(const int key, const unsigned int modifier); - private: ui::Window *buttonmenu_container; + + bool buttonmenu_compact; }; } diff --git a/src/client/buymenu.h b/src/client/buymenu.h index 7f19ebf..d4bc45c 100644 --- a/src/client/buymenu.h +++ b/src/client/buymenu.h @@ -8,7 +8,6 @@ #define __INCLUDED_CLIENT_BUYMENU_H__ #include "core/info.h" -#include "ui/container.h" #include "ui/button.h" #include "ui/label.h" #include "ui/modelview.h" diff --git a/src/client/client.cc b/src/client/client.cc index 69f36b6..706634a 100644 --- a/src/client/client.cc +++ b/src/client/client.cc @@ -224,44 +224,34 @@ void Client::frame() core::Application::frame(); if (!connected()) { + const std::string module_label(core::Loader::label()); + + if (!ui::console()->visible()) { - // load the intro if nothing is running - if (load("intro")) { - connect(""); - if (module_label.size()) - load(module_label); + // load the intro if nothing is running + if (load("intro")) { + connect(""); + if (module_label.size()) + load(module_label); + } else { + ui::console()->toggle(); + } } - // show the console if everything fails - if (!connected() && !ui::console()->visible()) { - ui::console()->toggle(); + + if (client_mainwindow->visible()) { + client_mainwindow->hide(); } - } else if (!ui::root()->active()) { - - // show the main menu on non-interactive modules - if (!core::game()->interactive()) { - ui::root()->show_menu("main"); - - // show the join menu when player does not control an entity - } else if (core::game()->time() && !core::localcontrol()) { - ui::root()->show_menu("join"); + + } else { + if (client_mainwindow->hidden()) { + client_mainwindow->show(); } - if (testmodelwindow()->visible()) { - testmodelwindow()->raise(); - } if (ui::console()->visible()) { ui::console()->raise(); ui::console()->set_focus(); } - } else { - if (core::localcontrol()) { - - // hide join menu - if (ui::root()->active()->label().compare("join") == 0) { - ui::root()->hide_menu(); - } - } } const float now = timestamp(); @@ -310,9 +300,6 @@ void Client::notify_connect() video::frame_loader(); mainwindow()->clear(); - ui::root()->hide_menu(); - - //video::set_caption(); } void Client::notify_disconnect() @@ -322,8 +309,6 @@ void Client::notify_disconnect() input::reset(); mainwindow()->clear(); - - //video::set_caption(); } void Client::notify_zonechange() @@ -444,7 +429,7 @@ void Client::func_ui_restart(std::string const &args) void Client::func_list_menu(std::string const &args) { if (ui::root()) { - ui::root()->list_menus(); + // FIXME ui::root()->list_menus(); } } @@ -500,14 +485,12 @@ void Client::func_ui(std::string const &args) void Client::func_menu_help() { con_print << "^Bmenu functions" << std::endl; - con_print << " menu help show this help" << std::endl; - con_print << " menu list list available menus" << std::endl; - con_print << " menu [name] show a menu" << std::endl; - con_print << " menu back return to the previous menu" << std::endl; - con_print << " menu previous return to the previous menu" << std::endl; - con_print << " menu close close the current menu" << std::endl; - con_print << " menu hide hide the current menu" << std::endl; - ui::root()->list_menus(); + con_print << "^RTODO" << std::endl; +} + +void Client::show_menu(const char *menu) +{ + client()->client_mainwindow->mainmenu()->show_menu(menu); } // global menu fuctions @@ -528,28 +511,24 @@ void Client::func_menu(std::string const &args) argstr >> command; aux::to_label(command); - if (command.compare("help") == 0) { func_menu_help(); } else if (command.compare("hide") == 0) { - ui::root()->hide_menu(); + client()->client_mainwindow->mainmenu()->hide(); } else if (command.compare("close") == 0) { - ui::root()->hide_menu(); - - } else if (command.compare("back") == 0) { - ui::root()->previous_menu(); + client()->client_mainwindow->mainmenu()->hide(); - } else if (command.compare("previous") == 0) { - ui::root()->previous_menu(); + } else if (command.compare("default") == 0) { + client()->client_mainwindow->mainmenu()->show_default(); } else if (command.compare("list") == 0) { - ui::root()->list_menus(); + // TODO client_mainwindow->mainmenu()->list(); } else { - ui::root()->show_menu(command.c_str()); + show_menu(command.c_str()); } } @@ -557,14 +536,14 @@ void Client::func_menu(std::string const &args) void Client::func_ui_menu(std::string const &args) { if (client()->connected()) { - if (ui::root()->active()) { - ui::root()->hide_menu(); + if (client()->client_mainwindow->mainmenu()->visible()) { + client()->client_mainwindow->mainmenu()->hide(); } else { // show the main menu on non-interactive modules if (!core::game()->interactive()) { - ui::root()->show_menu("main"); + show_menu("main"); } else { - ui::root()->show_menu("game"); + show_menu("game"); } } } else { diff --git a/src/client/client.h b/src/client/client.h index ff7ac98..e89abfa 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -75,6 +75,8 @@ public: func_say(text); } + static void show_menu(const char *menu); + protected: /// run a client frame virtual void frame(); diff --git a/src/client/entitymenu.cc b/src/client/entitymenu.cc index ee1d373..f9a5edc 100644 --- a/src/client/entitymenu.cc +++ b/src/client/entitymenu.cc @@ -6,6 +6,7 @@ #include "client/entitymenu.h" +#include "client/client.h" #include "ui/ui.h" #include "ui/paint.h" @@ -171,7 +172,7 @@ bool EntityMenu::on_keypress(const int key, const unsigned int modifier) generate(menu_generated_entity, "main"); } else { this->hide(); - ui::root()->show_menu("game"); + Client::show_menu("game"); } return true; } diff --git a/src/client/hud.cc b/src/client/hud.cc index 423bf58..c3a6a71 100644 --- a/src/client/hud.cc +++ b/src/client/hud.cc @@ -6,6 +6,7 @@ #include "core/core.h" +#include "client/client.h" #include "client/hud.h" #include "client/input.h" #include "client/targets.h" @@ -224,7 +225,7 @@ bool HUD::on_keypress(const int key, const unsigned int modifier) if (targets::current()) { targets::reset(); } else { - ui::root()->show_menu("game"); + Client::show_menu("game"); } return true; } diff --git a/src/client/input.cc b/src/client/input.cc index 8672284..69be2ab 100644 --- a/src/client/input.cc +++ b/src/client/input.cc @@ -851,7 +851,7 @@ void frame() mouse_control = false; if (core::application()->connected() && core::localcontrol()) { - mouse_control = ui::console()->hidden() && !ui::root()->active() && ((input_mousecontrol->value() > 0) || (mouse_control_override && (mouse_control_override_time + (input_mousedelay->value() / 1000.0f) < core::application()->time()))); + mouse_control = ui::console()->hidden() && ((input_mousecontrol->value() > 0) || (mouse_control_override && (mouse_control_override_time + (input_mousedelay->value() / 1000.0f) < core::application()->time()))); if (mouse_control && joystick_control && ((render::Camera::mode() == render::Camera::Track) || (render::Camera::mode() == render::Camera::Cockpit))) { if (!(mouse_control_override && (mouse_control_override_time + (input_mousedelay->value() / 1000.0f) < core::application()->time()))) { diff --git a/src/client/mainmenu.cc b/src/client/mainmenu.cc index 6a4f97a..cfebade 100644 --- a/src/client/mainmenu.cc +++ b/src/client/mainmenu.cc @@ -4,15 +4,27 @@ the terms and conditions of the GNU General Public License version 2 */ +#include "client/buttonmenu.h" #include "client/mainmenu.h" +#include "core/core.h" +#include "core/gameinterface.h" +#include "core/application.h" +#include "filesystem/inifile.h" #include "ui/paint.h" #include "ui/ui.h" +#include "ui/label.h" +#include "ui/button.h" namespace client { -MainMenu::MainMenu(ui::Widget *parent) : ui::Window(parent) +MainMenu::MainMenu(ui::Widget *parent) : + ui::Window(parent), + mainmenu_background("bitmaps/banner") { + // acive menu + mainmenu_activemenu = 0; + // default main menus mainmenu_mainmenu = 0; mainmenu_gamemenu = 0; @@ -23,31 +35,273 @@ MainMenu::MainMenu(ui::Widget *parent) : ui::Window(parent) mainmenu_loadmenu = 0; mainmenu_savemenu = 0; mainmenu_connectmenu = 0; - + + set_border(false); set_background(true); set_label("mainmenu"); + + load(); } MainMenu::~MainMenu() { } +void MainMenu::load_definitions() +{ + // load custom menu definitions from ini/menu.ini + std::string filename("ini/menu"); + filesystem::IniFile ini; + ini.open(filename); + + if (!ini.is_open()) { + con_error << "Could not open " << ini.name() << std::endl; + return; + } + + con_debug << " Loading menu definitions..." << std::endl; + + ui::Label *label = 0; + ui::Button *button = 0; + ButtonMenu *menu = 0; + std::string strval; + + while (ini.getline()) { + + if (ini.got_section()) { + + if (ini.got_section("menu")) { + menu = 0; + continue; + + // menu button + } else if (ini.got_section("button")) { + + if (!menu) { + ini.unknown_error("button section without menu defintion"); + } else { + button = menu->add_button(); + } + + // menu label + } else if (ini.got_section("label")) { + + if (!menu) { + ini.unknown_error("label section without menu defintion"); + } else { + label = menu->add_label(); + } + + } else { + ini.unknown_section(); + continue; + } + + } else if (ini.got_key()) { + + if (ini.in_section("menu")) { + + if (ini.got_key_string("label", strval)) { + aux::to_label(strval); + + for (ui::Widget::Children::iterator child = children().begin(); child != children().end(); ++child) { + if ((*child)->label().compare(strval) == 0) { + menu = static_cast<ButtonMenu*>((*child)); + } + } + + if (!menu) { + menu = new ButtonMenu(this, strval.c_str()); + } + } else { + ini.unknown_key(); + } + + } else if (menu) { + + 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(ui::AlignLeft | ui::AlignVCenter); + } else if (strval.compare("center") == 0) { + button->set_alignment(ui::AlignCenter); + } else if (strval.compare("right") == 0) { + button->set_alignment(ui::AlignRight | ui::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(ui::AlignLeft | ui::AlignHCenter); + } else if (strval.compare("center") == 0) { + label->set_alignment(ui::AlignCenter); + } else if (strval.compare("right") == 0) { + label->set_alignment(ui::AlignRight | ui::AlignHCenter); + } else { + ini.unknown_value(); + } + } else { + ini.unknown_key(); + } + } + } + } + } + + ini.close(); +} + +void MainMenu::load() +{ + remove_children(); + + // main menu when not connected + mainmenu_mainmenu = (ui::Widget *) new ButtonMenu(this, "main"); + static_cast<ButtonMenu *>(mainmenu_mainmenu)->set_compact(); + + // main menu when connected + mainmenu_gamemenu = (ui::Widget *) new ButtonMenu(this, "game"); + static_cast<ButtonMenu *>(mainmenu_gamemenu)->set_compact(); + + // menu to join a game + mainmenu_joinmenu = (ui::Widget *) new ButtonMenu(this, "join"); + static_cast<ButtonMenu *>(mainmenu_joinmenu)->set_compact(); + + // load custom menus, this needs to be done before the + // non-buttonmenu child widgets are created + load_definitions(); + + // options menu + mainmenu_optionsmenu = 0; + + // menu to connect to remote servers + mainmenu_connectmenu = 0; + + // load game menu + mainmenu_loadmenu = 0; + + // save game menu + mainmenu_savemenu = 0; + + show_menu(); +} + +void MainMenu::show_menu() +{ + mainmenu_activemenu = 0; + + if (core::application()->connected()) { + + // show the main menu on non-interactive modules + if (!core::game()->interactive()) { + mainmenu_activemenu = mainmenu_mainmenu; + + // show the join menu if player does not control an entity + } else if (!core::localcontrol()) { + mainmenu_activemenu = mainmenu_joinmenu; + + } else { + mainmenu_activemenu = mainmenu_gamemenu; + } + + } else { + mainmenu_activemenu = mainmenu_mainmenu; + } + + // show the requested menu and hide all other children + for (ui::Widget::Children::iterator child = children().begin(); child != children().end(); child++) { + if ((*child) == mainmenu_activemenu) { + (*child)->show(); + } else { + (*child)->hide(); + } + } +} + +void MainMenu::show_default() +{ + if (core::application()->connected() && core::game()->interactive()) { + show_menu(mainmenu_gamemenu); + } else { + show_menu(mainmenu_mainmenu); + } + +} +void MainMenu::show_menu(const Widget *widget) +{ + mainmenu_activemenu = 0; + + // show the requested menu and hide all other children + for (ui::Widget::Children::iterator child = children().begin(); child != children().end(); child++) { + if ((*child)== widget) { + (*child)->show(); + mainmenu_activemenu = (*child); + } else { + (*child)->hide(); + } + } + + show(); +} + +void MainMenu::show_menu(const char * label) +{ + mainmenu_activemenu = 0; + + for (ui::Widget::Children::iterator child = children().begin(); child != children().end(); ++child) { + if ((*child)->label().compare(label) == 0) { + (*child)->show(); + mainmenu_activemenu = (*child); + } else { + (*child)->hide(); + } + } + + show(); +} + void MainMenu::show() { - ui::Widget::show(); + if (!mainmenu_activemenu) + show_menu(); + ui::Window::show(); } void MainMenu::hide() { - ui::Widget::hide(); + ui::Window::hide(); + mainmenu_activemenu = 0; } void MainMenu::resize() -{ +{ // resize and reposition all child windows const float smallmargin = ui::UI::elementsize.height(); + for (ui::Widget::Children::iterator child = children().begin(); child != children().end(); ++child) { - (*child)->set_size(width() - smallmargin * 2, height() - smallmargin * 4); + (*child)->set_size(width() - smallmargin * 2, height() - smallmargin * 4); (*child)->set_location(smallmargin, smallmargin * 2); } } @@ -61,4 +315,52 @@ void MainMenu::draw_background() } } +void MainMenu::draw() +{ + if (mainmenu_activemenu == mainmenu_mainmenu) { + if (core::game()->interactive()) { + hide(); + return; + } + + } else if (mainmenu_activemenu == mainmenu_joinmenu) { + if (core::localcontrol()) { + hide(); + return; + } + + } else if (mainmenu_activemenu == mainmenu_gamemenu) { + if (!core::game()->interactive()) { + hide(); + return; + } + } + + ui::Window::draw(); +} + +bool MainMenu::on_keypress(const int key, const unsigned int modifier) +{ + if (key == SDLK_ESCAPE) { + if (mainmenu_activemenu == mainmenu_mainmenu) { + return true; + + } else if (mainmenu_activemenu == mainmenu_joinmenu) { + show_menu(mainmenu_gamemenu); + return true; + + } else if (mainmenu_activemenu == mainmenu_gamemenu) { + if (core::localcontrol()) { + hide(); + } else { + show_menu(mainmenu_joinmenu); + } + } else { + show_menu(); + } + } + + return true; +} + } // namespace client diff --git a/src/client/mainmenu.h b/src/client/mainmenu.h index 9320668..0a0354c 100644 --- a/src/client/mainmenu.h +++ b/src/client/mainmenu.h @@ -27,27 +27,65 @@ public: virtual void show(); virtual void hide(); + + /** + * @brief show the main or game menu, depending on the application state + * */ + void show_default(); + + /// show a submenu + void show_menu(const char * label); + + inline void show_menu(const std::string & label) { + show_menu(label.c_str()); + } + + /// load menu definitions + void load(); + protected: + + virtual void draw(); + virtual void draw_background(); virtual void resize(); - + + virtual bool on_keypress(const int key, const unsigned int modifier); + private: + /// load menu definitions + void load_definitions(); + + /// show the main, game or join menu + void show_menu(); + + void show_menu(const Widget *widget); + + /// the current active menu + ui::Widget *mainmenu_activemenu; + /// the menu to show if the application is not connected - ui::Window *mainmenu_mainmenu; + ui::Widget *mainmenu_mainmenu; + /// the menu to show if the application is connected but the player has not joined yet - ui::Window *mainmenu_joinmenu; + ui::Widget *mainmenu_joinmenu; + /// the menu the show if the application is connected and the player has joined - ui::Window *mainmenu_gamemenu; + ui::Widget *mainmenu_gamemenu; + /// the options menu - ui::Window *mainmenu_optionsmenu; + ui::Widget *mainmenu_optionsmenu; + /// the load game menu - ui::Window *mainmenu_loadmenu; + ui::Widget *mainmenu_loadmenu; + /// the save game menu - ui::Window *mainmenu_savemenu; + ui::Widget *mainmenu_savemenu; + /// the connect to server menu - ui::Window *mainmenu_connectmenu; + ui::Widget *mainmenu_connectmenu; std::string mainmenu_background; }; diff --git a/src/client/mainwindow.cc b/src/client/mainwindow.cc index 607e503..8e7b2af 100644 --- a/src/client/mainwindow.cc +++ b/src/client/mainwindow.cc @@ -79,6 +79,9 @@ void MainWindow::resize() // resize game window mainwindow_gamewindow->set_size(size()); + + // resize mainmenu window + mainwindow_mainmenu->set_size(size()); } void MainWindow::clear() @@ -114,14 +117,20 @@ void MainWindow::draw() } else { mainwindow_clockwidget->set_mode(ClockInfoWidget::Clock24Hours); } - - // FIXME - either draw one of the menus or draw the playerview - if (ui::root()->active() || !core::game()->interactive() || !core::localcontrol() || (core::localplayer()->view() && !core::localplayer()->view()->menus().size())) { - if (mainwindow_gamewindow->visible()) - mainwindow_gamewindow->hide(); - } else { - if (!mainwindow_gamewindow->visible()) + + if (!mainwindow_mainmenu->visible()) { + + if (!core::game()->interactive() || !core::localcontrol()) { + mainwindow_mainmenu->show(); + + } else if (mainwindow_gamewindow->hidden()) { mainwindow_gamewindow->show(); + } + + } else { + if (mainwindow_gamewindow->visible()) { + mainwindow_gamewindow->hide(); + } } } diff --git a/src/client/mapwindow.cc b/src/client/mapwindow.cc index f1de585..244056b 100644 --- a/src/client/mapwindow.cc +++ b/src/client/mapwindow.cc @@ -151,173 +151,6 @@ void MapWindow::draw() set_target(mapwindow_target); } } - - /* - const float fontmargin = mapwindow_targetlabel->font()->height(); - const float s = ui::UI::elementsize.width() * 1.5f; - - const float blue = 0.8f; - const float gridsize = 16; - - const core::Entity *entity; - const core::Entity *current_target = mapwindow_target; - mapwindow_target = 0; - - math::Color color; - - math::Vector2f v(global_location()); - math::Vector2f l; - - v[0] += fontmargin; - v[1] += fontmargin + (height() - s) * 0.5f; - mapwindow_hover = 0; - - gl::color(0, 0, blue); - - gl::begin(gl::Lines); - for (int i = 0; i <= gridsize; i++) { - gl::vertex(v.x(), v.y() + s / gridsize * i); - gl::vertex(v.x() + s, v.y() + s / gridsize * i); - - gl::vertex(v.x() + s / gridsize * i, v.y()); - gl::vertex(v.x() + s / gridsize * i, v.y() + s); - } - gl::end(); - - const size_t texture_entity = render::Textures::load("bitmaps/icons/entity_default"); - const size_t texture_globe = render::Textures::load("bitmaps/icons/entity_globe"); - const size_t texture_bright = render::Textures::load("bitmaps/icons/entity_bright"); - - size_t texture_current = render::Textures::bind(texture_entity); - - v[0] += s * 0.5f; - v[1] += s * 0.5f; - - core::Zone *zone = core::localplayer()->zone(); - - mapwindow_maplabel->set_text(zone->name()); - - const math::Vector2f cursor(input::mouse_position_x(), input::mouse_position_y()); - - const float r = 12.0f; - float scale = 2048.0f; - scale *= 2; - - gl::enable(GL_TEXTURE_2D); - gl::begin(gl::Quads); - - // draw map icons - for (core::Zone::Content::iterator it = zone->content().begin(); it != zone->content().end(); it++) { - entity = (*it); - - bool draw_icon = false; - l.assign(v); - - if (targets::is_valid_map_target(entity)) { - draw_icon = true; - l[0] -= s / scale * entity->location().y(); - l[1] -= s / scale * entity->location().x(); - - if (math::distancesquared(cursor, l) < (r*r)) { - mapwindow_hover = entity->id(); - } - - if (entity == current_target) { - mapwindow_target = entity; - if (core::application()->time() - floorf(core::application()->time()) < 0.5f) { - draw_icon = false; - } - } - } - - if (draw_icon) { - if (entity->type() == core::Entity::Globe) { - if (entity->flag_is_set(core::Entity::Bright)) { - if (texture_current != texture_bright) { - gl::end(); - texture_current = render::Textures::bind(texture_bright); - gl::begin(gl::Quads); - } - } else { - if (texture_current != texture_globe) { - gl::end(); - texture_current = render::Textures::bind(texture_globe); - gl::begin(gl::Quads); - } - } - } else { - if (texture_current != texture_entity) { - gl::end(); - texture_current = render::Textures::bind(texture_entity); - gl::begin(gl::Quads); - } - } - - if (entity == core::localplayer()->mission_target()) { - color.assign(palette()->mission()); - } else { - color.assign(entity->color()); - } - color.a = 1.0f; - - gl::color(color); - glTexCoord2f(0.0f, 0.0f); - gl::vertex(l.x() - r, l.y() - r); - - glTexCoord2f(1.0f, 0.0f); - gl::vertex(l.x() + r, l.y() - r); - - glTexCoord2f(1.0f, 1.0f); - gl::vertex(l.x() + r, l.y() + r); - - glTexCoord2f(0.0f, 1.0f); - gl::vertex(l.x() - r, l.y() + r); - } - - } - - // draw localcontrol icon - entity = core::localcontrol(); - - //if (core::localcontrol()->state() != core::Entity::Docked) { - l.assign(v); - l[0] -= s / scale * entity->location().y(); - l[1] -= s / scale * entity->location().x(); - if (core::application()->time() - floorf(core::application()->time()) < 0.5f) { - if (texture_current != texture_entity) { - gl::end(); - texture_current = render::Textures::bind(texture_entity); - gl::begin(gl::Quads); - } - - math::Color color(entity->color()); - color.a = 1.0f; - gl::color(color); - glTexCoord2f(0.0f, 0.0f); - gl::vertex(l.x() - r, l.y() - r); - - glTexCoord2f(1.0f, 0.0f); - gl::vertex(l.x() + r, l.y() - r); - - glTexCoord2f(1.0f, 1.0f); - gl::vertex(l.x() + r, l.y() + r); - - glTexCoord2f(0.0f, 1.0f); - gl::vertex(l.x() - r, l.y() + r); - } - //} - - gl::end(); - gl::disable(GL_TEXTURE_2D); - - if (mapwindow_target != current_target ) { - // this makes sure the map target exists - set_target(current_target); - - } else if (mapwindow_inforecord && (mapwindow_infotimestamp != mapwindow_inforecord->timestamp())) { - set_target(mapwindow_target); - } - */ } void MapWindow::set_target(const core::Entity *entity) { @@ -385,7 +218,7 @@ bool MapWindow::on_keypress(const int key, const unsigned int modifier) return false; } -bool MapWindow::on_emit(Widget *sender, const Event event, void *data) +bool MapWindow::on_emit(ui::Widget *sender, const ui::Widget::Event event, void *data) { if (sender == mapwindow_closebutton) { if (event == ui::Widget::EventButtonClicked) { diff --git a/src/client/mapwindow.h b/src/client/mapwindow.h index 46fd8b1..66f8f45 100644 --- a/src/client/mapwindow.h +++ b/src/client/mapwindow.h @@ -40,7 +40,7 @@ protected: virtual bool on_keypress(const int key, const unsigned int modifier); /// called if the widget receives an emit evet - virtual bool on_emit(Widget *sender, const Event event, void *data); + virtual bool on_emit(ui::Widget *sender, const ui::Widget::Event event, void *data); virtual void resize(); |