diff options
author | Stijn Buys <ingar@osirion.org> | 2013-11-08 21:01:05 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2013-11-08 21:01:05 +0000 |
commit | dd2162af7727c0f30d77cc7ae33ccbb346611b20 (patch) | |
tree | 0cb7d2ab453c8f82864853780cdb9c56270a1fb2 /src/client | |
parent | c8336c0fb110f8b23707c755e7ebaabdde62c8ea (diff) |
Code cleanups, removed unnecessary functions,
added star coronas to the map.
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/chat.cc | 8 | ||||
-rw-r--r-- | src/client/chat.h | 1 | ||||
-rw-r--r-- | src/client/gamewindow.cc | 121 | ||||
-rw-r--r-- | src/client/gamewindow.h | 32 | ||||
-rw-r--r-- | src/client/inventorywindow.cc | 8 | ||||
-rw-r--r-- | src/client/inventorywindow.h | 4 | ||||
-rw-r--r-- | src/client/mapwidget.cc | 58 | ||||
-rw-r--r-- | src/client/mapwindow.cc | 8 | ||||
-rw-r--r-- | src/client/mapwindow.h | 3 | ||||
-rw-r--r-- | src/client/reputationwindow.h | 12 |
10 files changed, 131 insertions, 124 deletions
diff --git a/src/client/chat.cc b/src/client/chat.cc index 21fe698..dd71d57 100644 --- a/src/client/chat.cc +++ b/src/client/chat.cc @@ -106,14 +106,6 @@ void Chat::show() chat_scrollpane->set_scroll(0); } -void Chat::toggle() -{ - if (visible()) - hide(); - else - show(); -} - bool Chat::on_emit(ui::Widget *sender, const ui::Widget::Event event, void *data) { if (sender == chat_closebutton) { diff --git a/src/client/chat.h b/src/client/chat.h index 39b1a1a..0633a0f 100644 --- a/src/client/chat.h +++ b/src/client/chat.h @@ -26,7 +26,6 @@ public: ~Chat(); virtual void show(); - void toggle(); void event_text(const std::string & text); diff --git a/src/client/gamewindow.cc b/src/client/gamewindow.cc index 01e1e81..71a2171 100644 --- a/src/client/gamewindow.cc +++ b/src/client/gamewindow.cc @@ -9,7 +9,9 @@ #include "core/info.h" #include "core/application.h" + #include "ui/ui.h" +#include "ui/iconbutton.h" #include "client/targeticonbutton.h" @@ -93,13 +95,13 @@ void GameWindow::event_text(const std::string & text) void GameWindow::toggle_map() { - if (!map()->visible()) { - if (chat()->visible() && !chat()->small_view()) { - chat()->hide(); + if (!gamewindow_map->visible()) { + if (gamewindow_chat->visible() && !gamewindow_chat->small_view()) { + gamewindow_chat->hide(); } - if (inventory()->visible()) { - inventory()->hide(); + if (gamewindow_inventory->visible()) { + gamewindow_inventory->hide(); } if (gamewindow_entitymenu->visible()) { @@ -117,26 +119,23 @@ void GameWindow::toggle_map() if (gamewindow_reputation->visible()) { gamewindow_reputation->hide(); } + + gamewindow_map->show(); + } else { + gamewindow_map->hide(); } - - map()->toggle(); - -/* if (map()->visible() && chat()->visible() && chat()->small_view()) { - chat()->raise(); - } -*/ } void GameWindow::toggle_inventory() { - if (!inventory()->visible()) { - if (chat()->visible() && !chat()->small_view()) { - chat()->hide(); + if (!gamewindow_inventory->visible()) { + if (gamewindow_chat->visible() && !gamewindow_chat->small_view()) { + gamewindow_chat->hide(); } - if (map()->visible()) { - map()->hide(); + if (gamewindow_map->visible()) { + gamewindow_map->hide(); } if (gamewindow_reputation->visible()) { @@ -156,23 +155,23 @@ void GameWindow::toggle_inventory() gamewindow_trademenu->hide(); } - inventory()->show(); + gamewindow_inventory->show(); } else { - inventory()->hide(); + gamewindow_inventory->hide(); } } void GameWindow::toggle_reputation() { - if (!reputation()->visible()) { - if (chat()->visible() && !chat()->small_view()) { - chat()->hide(); + if (!gamewindow_reputation->visible()) { + if (gamewindow_chat->visible() && !gamewindow_chat->small_view()) { + gamewindow_chat->hide(); } - if (map()->visible()) { - map()->hide(); + if (gamewindow_map->visible()) { + gamewindow_map->hide(); } if (gamewindow_inventory->visible()) { @@ -191,25 +190,27 @@ void GameWindow::toggle_reputation() gamewindow_trademenu->hide(); } - reputation()->show(); + gamewindow_reputation->show(); } else { - reputation()->hide(); + gamewindow_reputation->hide(); } } void GameWindow::toggle_chat() { - if (chat()->small_view()) { - chat()->hide(); + // if the chat window is in small view, hide it first and open the full view + if (gamewindow_chat->visible() && gamewindow_chat->small_view()) { + gamewindow_chat->set_small_view(false); + gamewindow_chat->hide(); } - if (!chat()->visible()) { - if (map()->visible()) - map()->hide(); + if (!gamewindow_chat->visible()) { + if (gamewindow_map->visible()) + gamewindow_map->hide(); - if (inventory()->visible()) { - inventory()->hide(); + if (gamewindow_inventory->visible()) { + gamewindow_inventory->hide(); } if (gamewindow_reputation->visible()) { @@ -227,20 +228,27 @@ void GameWindow::toggle_chat() if (gamewindow_trademenu->visible()) { gamewindow_trademenu->hide(); } + + gamewindow_chat->set_small_view(false); + gamewindow_chat->show(); + } else { + gamewindow_chat->hide(); } - - chat()->set_small_view(false); - chat()->toggle(); } void GameWindow::toggle_chatbar() { - if (!chat()->small_view()) { - chat()->hide(); + if (gamewindow_chat->visible() && !gamewindow_chat->small_view()) { + gamewindow_chat->set_small_view(true); + gamewindow_chat->hide(); } - chat()->set_small_view(true); - chat()->toggle(); + if (!gamewindow_chat->visible()) { + gamewindow_chat->set_small_view(true); + gamewindow_chat->show(); + } else { + gamewindow_chat->hide(); + } } void GameWindow::show_menu(const std::string & args) @@ -321,10 +329,6 @@ void GameWindow::show_menu(const std::string & args) gamewindow_entitymenu->generate(core::localplayer()->view(), label.c_str()); gamewindow_entitymenu->show(); } - -/* if (chat()->visible() && chat()->small_view()) - chat()->raise(); -*/ } void GameWindow::resize() @@ -393,6 +397,7 @@ void GameWindow::draw() gamewindow_gotobutton->hide(); gamewindow_dockbutton->hide(); gamewindow_formationbutton->hide(); + } else { gamewindow_launchbutton->hide(); @@ -413,8 +418,8 @@ void GameWindow::draw() if (gamewindow_entitymenu->generated_entity() != core::localplayer()->view()) { // initially show the menu show_menu("main"); - map()->hide(); - chat()->hide(); + gamewindow_map->hide(); + gamewindow_chat->hide(); // hide other windows gamewindow_chat->hide(); @@ -426,10 +431,10 @@ void GameWindow::draw() !gamewindow_entitymenu->visible() && !gamewindow_buymenu->visible() && !gamewindow_trademenu->visible() && - !inventory()->visible() && - !reputation()->visible() && - !map()->visible() && - (!chat()->visible() || chat()->small_view()) + !gamewindow_inventory->visible() && + !gamewindow_reputation->visible() && + !gamewindow_map->visible() && + (!gamewindow_chat->visible() || gamewindow_chat->small_view()) ) { @@ -437,7 +442,7 @@ void GameWindow::draw() gamewindow_entitymenu->show(); } - gamewindow_homebutton->enable(); + gamewindow_homebutton->show(); } else { // entity without menus, plain view @@ -446,7 +451,7 @@ void GameWindow::draw() } } else { - gamewindow_homebutton->disable(); + gamewindow_homebutton->hide(); if (gamewindow_entitymenu->visible()) { gamewindow_entitymenu->hide(); @@ -464,7 +469,7 @@ void GameWindow::draw() gamewindow_trademenu->hide(); } - if (!map()->visible() && !chat()->visible() && !inventory()->visible() && !reputation()->visible()) { + if (!gamewindow_map->visible() && !gamewindow_chat->visible() && !gamewindow_inventory->visible() && !gamewindow_reputation->visible()) { gamewindow_hud->set_focus(); } @@ -472,7 +477,7 @@ void GameWindow::draw() } // reposition chat widget - if (chat()->visible()) { + if (gamewindow_chat->visible()) { if (gamewindow_chat->small_view()) { gamewindow_chat->set_size(width() - smallmargin * 2, font()->height() * 2); gamewindow_chat->set_location(smallmargin, height() - smallmargin *2 - gamewindow_chat->height()); @@ -508,13 +513,13 @@ bool GameWindow::on_keypress(const int key, const unsigned int modifier) return true; } - if (map()->visible()) { - map()->hide(); + if (gamewindow_map->visible()) { + gamewindow_map->hide(); return true; } - if (inventory()->visible()) { - inventory()->hide(); + if (gamewindow_inventory->visible()) { + gamewindow_inventory->hide(); return true; } diff --git a/src/client/gamewindow.h b/src/client/gamewindow.h index 6808eac..a16012a 100644 --- a/src/client/gamewindow.h +++ b/src/client/gamewindow.h @@ -7,10 +7,14 @@ #ifndef __INCLUDED_CLIENT_GAMEWINDOW_H__ #define __INCLUDED_CLIENT_GAMEWINDOW_H__ - #include "ui/window.h" -#include "ui/label.h" -#include "ui/iconbutton.h" + +namespace ui +{ + +class IconButton; + +} namespace client { @@ -27,7 +31,7 @@ class TradeMenu; /** * @brief the game user interface base widget - * The GameWindow is drawn if core::localcontrol() is set. + * The GameWindow is showb if core::localcontrol() is set. * It contains the HUD, icons and all menus for game interaction. **/ class GameWindow : public ui::Window @@ -58,26 +62,6 @@ public: /// show entity menus void show_menu(const std::string & label); - inline HUD *hud() { - return gamewindow_hud; - } - - inline Chat *chat() { - return gamewindow_chat; - } - - inline MapWindow *map() { - return gamewindow_map; - } - - inline InventoryWindow *inventory() { - return gamewindow_inventory; - } - - inline ReputationWindow *reputation() { - return gamewindow_reputation; - } - inline EntityMenu *menu() { return gamewindow_entitymenu; } diff --git a/src/client/inventorywindow.cc b/src/client/inventorywindow.cc index 5ffee72..459d7c5 100644 --- a/src/client/inventorywindow.cc +++ b/src/client/inventorywindow.cc @@ -92,14 +92,6 @@ InventoryWindow::~InventoryWindow() { } -void InventoryWindow::toggle() -{ - if (visible()) - hide(); - else - show(); -} - void InventoryWindow::update_inventory() { const float icon_size = 24.0f; // small icons diff --git a/src/client/inventorywindow.h b/src/client/inventorywindow.h index 472957b..b3f81e2 100644 --- a/src/client/inventorywindow.h +++ b/src/client/inventorywindow.h @@ -21,7 +21,7 @@ namespace client { /** - * @brief an inventory window widget + * @brief a player inventory window */ class InventoryWindow : public ui::Window { @@ -29,8 +29,6 @@ public: InventoryWindow(ui::Widget *parent = 0); ~InventoryWindow(); - void toggle(); - virtual void show(); protected: diff --git a/src/client/mapwidget.cc b/src/client/mapwidget.cc index 3c0b95a..770abb2 100644 --- a/src/client/mapwidget.cc +++ b/src/client/mapwidget.cc @@ -7,6 +7,8 @@ #include "client/mapwidget.h" #include "client/targets.h" #include "core/application.h" +#include "core/entity.h" +#include "core/entityglobe.h" #include "ui/paint.h" #include "render/render.h" #include "render/gl.h" @@ -112,7 +114,6 @@ void MapWidget::draw() const float r = 12.0f; // radius of map icons float scale = 4096.0f; // map size in game units math::Color color; - const core::Entity *entity = 0; // draw map icons gl::enable(GL_TEXTURE_2D); @@ -120,7 +121,7 @@ void MapWidget::draw() for (core::Zone::Content::iterator it = mapwidget_zone->content().begin(); it != mapwidget_zone->content().end(); it++) { - entity = (*it); + core::Entity *entity = (*it); bool draw_icon = false; @@ -143,14 +144,53 @@ void MapWidget::draw() } if (draw_icon) { + color.assign(entity->color()); + color.a = 1.0f; + if (entity->type() == core::Entity::Globe) { - if (entity->has_flag(core::Entity::Bright)) { + // FIXME this is copy paste from the renderer and can use a cleanup + core::EntityGlobe *globe = static_cast<core::EntityGlobe *>(entity); + + if (globe->has_flag(core::Entity::Bright)) { + + // load globe corona texture + if (!globe->corona_id() && globe->coronaname().size()) { + globe->set_corona_id(render::Textures::load("textures/" + globe->coronaname())); + if (!globe->corona_id()) { + globe->set_coronaname(""); + } + } + + // draw corona + if (globe->corona_id()) { + gl::end(); + + texture_current = render::Textures::bind(globe->corona_id()); + + gl::begin(gl::Quads); + gl::color(color); + glTexCoord2f(0.0f, 0.0f); + gl::vertex(icon_location.x() - r * 2.0f, icon_location.y() - r * 2.0f); + + glTexCoord2f(1.0f, 0.0f); + gl::vertex(icon_location.x() + r * 2.0f, icon_location.y() - r * 2.0f); + + glTexCoord2f(1.0f, 1.0f); + gl::vertex(icon_location.x() + r * 2.0f, icon_location.y() + r * 2.0f); + + glTexCoord2f(0.0f, 1.0f); + gl::vertex(icon_location.x() - r * 2.0f, icon_location.y() + r * 2.0f); + } + + // bind bright globe icon texture if (texture_current != texture_bright) { gl::end(); texture_current = render::Textures::bind(texture_bright); gl::begin(gl::Quads); } } else { + + // bind globe icon texture if (texture_current != texture_globe) { gl::end(); texture_current = render::Textures::bind(texture_globe); @@ -167,10 +207,8 @@ void MapWidget::draw() 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); @@ -192,18 +230,18 @@ void MapWidget::draw() // draw localcontrol icon // TODO draw a ship icon if (core::localcontrol()->zone() == mapwidget_zone) { - entity = core::localcontrol(); + core::EntityControlable *controlable = core::localcontrol(); //if (core::localcontrol()->state() != core::Entity::Docked) { icon_location.assign(map_center); - icon_location[0] -= map_size / scale * entity->location().y(); - icon_location[1] -= map_size / scale * entity->location().x(); + icon_location[0] -= map_size / scale * controlable->location().y(); + icon_location[1] -= map_size / scale * controlable->location().x(); if (core::application()->time() - floorf(core::application()->time()) < 0.5f) { texture_current = render::Textures::bind(texture_entity); gl::begin(gl::Quads); - math::Color color(entity->color()); + math::Color color(controlable->color()); color.a = 1.0f; gl::color(color); glTexCoord2f(0.0f, 0.0f); diff --git a/src/client/mapwindow.cc b/src/client/mapwindow.cc index 6a5a6eb..3dbb1fb 100644 --- a/src/client/mapwindow.cc +++ b/src/client/mapwindow.cc @@ -137,14 +137,6 @@ void MapWindow::show() } } -void MapWindow::toggle() -{ - if (visible()) - hide(); - else - show(); -} - void MapWindow::resize() { const float padding = ui::root()->font_large()->height(); diff --git a/src/client/mapwindow.h b/src/client/mapwindow.h index 27f11f0..8391304 100644 --- a/src/client/mapwindow.h +++ b/src/client/mapwindow.h @@ -28,9 +28,6 @@ public: MapWindow(ui::Widget *parent = 0); virtual ~MapWindow(); - /// toggle the map window - void toggle(); - /// hide the map window virtual void hide(); diff --git a/src/client/reputationwindow.h b/src/client/reputationwindow.h index b13d440..ca0c56b 100644 --- a/src/client/reputationwindow.h +++ b/src/client/reputationwindow.h @@ -18,12 +18,19 @@ namespace client { /** - * @brief an inventory window widget + * @brief a player reputation window */ class ReputationWindow : public ui::Window { public: + /** + * @brief constructor + * */ ReputationWindow(ui::Widget *parent = 0); + + /** + * @brief destructor + * */ ~ReputationWindow(); /** @@ -49,6 +56,9 @@ protected: virtual bool on_keypress(const int key, const unsigned int modifier); private: + /** + * @brief refresh window content + * */ void refresh(); void set_info(const core::Info *info = 0); |