diff options
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/buymenu.cc | 4 | ||||
-rw-r--r-- | src/client/buymenu.h | 4 | ||||
-rw-r--r-- | src/client/entitymenu.cc | 4 | ||||
-rw-r--r-- | src/client/entitymenu.h | 4 | ||||
-rw-r--r-- | src/client/playerview.cc | 89 | ||||
-rw-r--r-- | src/client/playerview.h | 12 | ||||
-rw-r--r-- | src/client/targeticonbutton.cc | 2 | ||||
-rw-r--r-- | src/client/trademenu.cc | 12 | ||||
-rw-r--r-- | src/client/trademenu.h | 2 | ||||
-rw-r--r-- | src/client/worldview.cc | 43 | ||||
-rw-r--r-- | src/client/worldview.h | 10 |
11 files changed, 105 insertions, 81 deletions
diff --git a/src/client/buymenu.cc b/src/client/buymenu.cc index b42dc00..91f3dba 100644 --- a/src/client/buymenu.cc +++ b/src/client/buymenu.cc @@ -13,7 +13,7 @@ namespace client { -BuyMenu::BuyMenu(ui::Widget *parent, const char * label) : ui::Window(parent) +BuyMenu::BuyMenu(ui::Widget *parent, const char * label) : ui::Widget(parent) { set_border(false); set_background(false); @@ -150,7 +150,7 @@ bool BuyMenu::on_keypress(const int key, const unsigned int modifier) break; } - return Window::on_keypress(key, modifier); + return Widget::on_keypress(key, modifier); } } diff --git a/src/client/buymenu.h b/src/client/buymenu.h index 85801ce..91ed10e 100644 --- a/src/client/buymenu.h +++ b/src/client/buymenu.h @@ -12,14 +12,14 @@ #include "ui/button.h" #include "ui/label.h" #include "ui/modelview.h" -#include "ui/window.h" +#include "ui/widget.h" #include "ui/scrollpane.h" namespace client { /// The buy menu is used to trade a single item, like a ship or an upgrade -class BuyMenu : public ui::Window +class BuyMenu : public ui::Widget { public: /// create a new menu diff --git a/src/client/entitymenu.cc b/src/client/entitymenu.cc index d0fccef..56ce235 100644 --- a/src/client/entitymenu.cc +++ b/src/client/entitymenu.cc @@ -12,7 +12,7 @@ namespace client { -EntityMenu::EntityMenu(ui::Widget *parent, const char * label) : ui::Window(parent) +EntityMenu::EntityMenu(ui::Widget *parent, const char * label) : ui::Widget(parent) { set_border(false); set_background(false); @@ -191,7 +191,7 @@ bool EntityMenu::on_keypress(const int key, const unsigned int modifier) break; } - return Window::on_keypress(key, modifier); + return Widget::on_keypress(key, modifier); } } diff --git a/src/client/entitymenu.h b/src/client/entitymenu.h index 0285879..4907c98 100644 --- a/src/client/entitymenu.h +++ b/src/client/entitymenu.h @@ -10,13 +10,13 @@ #include "core/entity.h" #include "ui/container.h" #include "ui/label.h" -#include "ui/window.h" +#include "ui/widget.h" namespace client { /// entity menu -class EntityMenu : public ui::Window +class EntityMenu : public ui::Widget { public: /// create a new menu diff --git a/src/client/playerview.cc b/src/client/playerview.cc index 159371c..5cbd408 100644 --- a/src/client/playerview.cc +++ b/src/client/playerview.cc @@ -10,8 +10,10 @@ #include "core/info.h" #include "core/application.h" #include "audio/audio.h" -#include "client/playerview.h" #include "ui/ui.h" +#include "client/targeticonbutton.h" +#include "client/playerview.h" + namespace client { @@ -31,16 +33,23 @@ PlayerView::PlayerView(ui::Widget *parent) : ui::Widget(parent) label_viewname->set_background(true); label_viewname->set_font(ui::root()->font_large()); - view_chat = new Chat(this); + // sub menus view_map = new Map(this); view_entitymenu = new EntityMenu(this); view_buymenu = new BuyMenu(this); view_trademenu = new TradeMenu(this); view_inventory = new Inventory(this); + view_chat = new Chat(this); - //view_hud->set_focus(); - //view_hud->raise(); - //view_entitymenu->raise(); + // icon buttons + view_menubutton = new ui::IconButton(this, "bitmaps/icons/button_menu", "ui_menu"); + + view_launchbutton = new ui::IconButton(this, "bitmaps/icons/button_launch", "launch"); + view_dockbutton = new TargetIconButton(this, "bitmaps/icons/button_dock", "dock", core::Entity::Dockable); + + view_chatbutton = new ui::IconButton(this, "bitmaps/icons/button_chat", "ui_chat"); + view_mapbutton = new ui::IconButton(this, "bitmaps/icons/button_map", "ui_map"); + view_inventorybutton = new ui::IconButton(this, "bitmaps/icons/button_inventory", "ui_inventory"); } PlayerView::~PlayerView() @@ -80,14 +89,23 @@ void PlayerView::toggle_map() if (view_entitymenu->visible()) { view_entitymenu->hide(); } + + if (view_buymenu->visible()) { + view_buymenu->hide(); + } + + if (view_trademenu->visible()) { + view_trademenu->hide(); + } } map()->toggle(); audio::play("ui/menu"); - if (map()->visible() && chat()->visible() && chat()->small_view()) { +/* if (map()->visible() && chat()->visible() && chat()->small_view()) { chat()->raise(); } +*/ } void PlayerView::toggle_inventory() @@ -105,18 +123,31 @@ void PlayerView::toggle_inventory() if (view_entitymenu->visible()) { view_entitymenu->hide(); } + + if (view_buymenu->visible()) { + view_buymenu->hide(); + } + + if (view_trademenu->visible()) { + view_trademenu->hide(); + } } inventory()->toggle(); audio::play("ui/menu"); - if (inventory()->visible() && chat()->visible() && chat()->small_view()) { +/* if (inventory()->visible() && chat()->visible() && chat()->small_view()) { chat()->raise(); } +*/ } void PlayerView::toggle_chat() { + if (chat()->small_view()) { + chat()->hide(); + } + if (!chat()->visible()) { if (map()->visible()) map()->hide(); @@ -125,9 +156,19 @@ void PlayerView::toggle_chat() inventory()->hide(); } - if (view_entitymenu->visible()) + if (view_entitymenu->visible()) { view_entitymenu->hide(); + } + + if (view_buymenu->visible()) { + view_buymenu->hide(); + } + + if (view_trademenu->visible()) { + view_trademenu->hide(); + } } + chat()->set_small_view(false); chat()->toggle(); audio::play("ui/menu"); @@ -135,6 +176,10 @@ void PlayerView::toggle_chat() void PlayerView::toggle_chatbar() { + if (!chat()->small_view()) { + chat()->hide(); + } + chat()->set_small_view(true); chat()->toggle(); } @@ -167,7 +212,7 @@ void PlayerView::show_menu(const std::string & args) // requesting the info through game makes sure it is retreived from the server view_buymenu->set_item( core::game()->request_info(id)); // show buy menu - view_buymenu->show(); + view_buymenu->show(); } else { con_print << "usage: view buy [info id] show the buy menu for this kind of item" << std::endl; } @@ -203,8 +248,9 @@ void PlayerView::show_menu(const std::string & args) view_entitymenu->show(); } - if (chat()->visible() && chat()->small_view()) +/* if (chat()->visible() && chat()->small_view()) chat()->raise(); +*/ } void PlayerView::resize() @@ -213,6 +259,21 @@ void PlayerView::resize() set_size(parent()->size()); + // icons + const float icon_margin = 4.0f; + const float icon_size = 48.0f; + const float icon_count = 7; + const float l = (width() - ((icon_count + 1) * icon_margin) - (icon_count * icon_size)) * 0.5f; + + view_menubutton->set_geometry(l, icon_margin, icon_size, icon_size); + // spacer + view_dockbutton->set_geometry(l + 2.0f *(icon_margin + icon_size), icon_margin, icon_size, icon_size); + view_launchbutton->set_geometry(l + 2.0f *(icon_margin + icon_size), icon_margin, icon_size, icon_size); + // spacer + view_inventorybutton->set_geometry(l + 4.0f *(icon_margin + icon_size), icon_margin, icon_size, icon_size); + view_chatbutton->set_geometry(l + 5.0f *(icon_margin + icon_size), icon_margin, icon_size, icon_size); + view_mapbutton->set_geometry(l + 6.0f *(icon_margin + icon_size), icon_margin, icon_size, icon_size); + // reposition buy menu view_buymenu->event_resize(); // reposition trade menu @@ -241,6 +302,14 @@ void PlayerView::resize() void PlayerView::draw() { const float smallmargin = ui::UI::elementsize.height(); + + if (core::localcontrol()->state() == core::Entity::Docked) { + view_launchbutton->show(); + view_dockbutton->hide(); + } else { + view_launchbutton->hide(); + view_dockbutton->show(); + } if (core::localplayer()->view()) { diff --git a/src/client/playerview.h b/src/client/playerview.h index 66672cf..5e82be5 100644 --- a/src/client/playerview.h +++ b/src/client/playerview.h @@ -7,6 +7,9 @@ #ifndef __INCLUDED_CLIENT_PLAYERVIEW_H__ #define __INCLUDED_CLIENT_PLAYERVIEW_H__ +#include "ui/widget.h" +#include "ui/label.h" +#include "ui/iconbutton.h" #include "client/chat.h" #include "client/buymenu.h" #include "client/entitymenu.h" @@ -15,8 +18,6 @@ #include "client/hud.h" #include "client/map.h" #include "client/notifications.h" -#include "ui/widget.h" -#include "ui/label.h" namespace client { @@ -82,6 +83,13 @@ private: TradeMenu *view_trademenu; ui::Label *label_viewname; + + ui::IconButton *view_menubutton; + ui::IconButton *view_dockbutton; + ui::IconButton *view_launchbutton; + ui::IconButton *view_chatbutton; + ui::IconButton *view_mapbutton; + ui::IconButton *view_inventorybutton; }; } diff --git a/src/client/targeticonbutton.cc b/src/client/targeticonbutton.cc index 8bd3b1a..1ef2da0 100644 --- a/src/client/targeticonbutton.cc +++ b/src/client/targeticonbutton.cc @@ -33,7 +33,7 @@ bool TargetIconButton::on_keypress(const int key, const unsigned int modifier) void TargetIconButton::draw() { - enable(targets::current() && ((targets::current()->flags() & entity_flags) == entity_flags)); + set_enabled(targets::current() && ((targets::current()->flags() & entity_flags) == entity_flags)); ui::IconButton::draw(); } diff --git a/src/client/trademenu.cc b/src/client/trademenu.cc index c0d1f03..f0030f5 100644 --- a/src/client/trademenu.cc +++ b/src/client/trademenu.cc @@ -17,7 +17,7 @@ namespace client { -TradeMenu::TradeMenu(ui::Widget *parent, const char * label) : ui::Window(parent) +TradeMenu::TradeMenu(ui::Widget *parent, const char * label) : ui::Widget(parent) { set_border(false); set_background(false); @@ -188,7 +188,7 @@ void TradeMenu::set_item(ui::ListItem *item) std::ostringstream str; str << "Price: " << std::setw(12) << (amount > 0 ? amount : 1) * trader_item->price() << '\n' - << "Volume: " << std::setw(12) << std::setprecision(2) << (float)(amount > 0 ? amount : 1) * trader_item->info()->volume(); + << "Volume: " << std::setw(12) << (float)(amount > 0 ? amount : 1) * trader_item->info()->volume(); menu_tradertext->set_text(str.str()); } else { menu_msgtext->set_text("^1Can not sell here"); @@ -244,7 +244,7 @@ void TradeMenu::set_item(ui::ListItem *item) std::ostringstream str; str << "Price: " << std::setw(12) << (amount > 0 ? amount : 1) * item->item()->price() << '\n' - << "Volume: " << std::setw(12) << std::setprecision(2) << (float) (amount > 0 ? amount : 1) * item->info()->volume(); + << "Volume: " << std::setw(12) << (float) (amount > 0 ? amount : 1) * item->info()->volume(); menu_tradertext->set_text(str.str()); } @@ -337,7 +337,7 @@ bool TradeMenu::on_emit(Widget *sender, const Event event, void *data) return true; } - return ui::Window::on_emit(sender, event, data); + return ui::Widget::on_emit(sender, event, data); } void TradeMenu::draw() @@ -361,7 +361,7 @@ void TradeMenu::draw() } menu_inventorytext->set_text(str.str()); - Window::draw(); + Widget::draw(); } bool TradeMenu::on_keypress(const int key, const unsigned int modifier) @@ -376,7 +376,7 @@ bool TradeMenu::on_keypress(const int key, const unsigned int modifier) break; } - return Window::on_keypress(key, modifier); + return Widget::on_keypress(key, modifier); } } // namespace client diff --git a/src/client/trademenu.h b/src/client/trademenu.h index ecc41b9..56fe259 100644 --- a/src/client/trademenu.h +++ b/src/client/trademenu.h @@ -22,7 +22,7 @@ namespace client { /// trade menu -class TradeMenu : public ui::Window +class TradeMenu : public ui::Widget { public: /// create a new trade menu diff --git a/src/client/worldview.cc b/src/client/worldview.cc index 265277f..35cada2 100644 --- a/src/client/worldview.cc +++ b/src/client/worldview.cc @@ -27,16 +27,6 @@ WorldView::WorldView(ui::Widget *parent) : ui::Widget(parent) view_playerview = new PlayerView(this); view_playerview->raise(); view_playerview->hide(); - - // icon buttons - view_menubutton = new ui::IconButton(this, "bitmaps/icons/button_menu", "ui_menu"); - - view_launchbutton = new ui::IconButton(this, "bitmaps/icons/button_launch", "launch"); - view_dockbutton = new TargetIconButton(this, "bitmaps/icons/button_dock", "dock", core::Entity::Dockable); - - view_chatbutton = new ui::IconButton(this, "bitmaps/icons/button_chat", "ui_chat"); - view_mapbutton = new ui::IconButton(this, "bitmaps/icons/button_map", "ui_map"); - view_inventorybutton = new ui::IconButton(this, "bitmaps/icons/button_inventory", "ui_inventory"); } WorldView::~WorldView() @@ -66,21 +56,6 @@ void WorldView::resize() view_keyinfo->set_size(font()->width()*12, font()->height()*1); view_keyinfo->set_location(width() - view_keyinfo->width() - smallmargin, height() - view_keyinfo->height() - smallmargin); - - // icons - const float icon_margin = 4.0f; - const float icon_size = 48.0f; - const float icon_count = 7; - const float l = (width() - ((icon_count + 1) * icon_margin) - (icon_count * icon_size)) * 0.5f; - - view_menubutton->set_geometry(l, icon_margin, icon_size, icon_size); - // spacer - view_dockbutton->set_geometry(l + 2.0f *(icon_margin + icon_size), icon_margin, icon_size, icon_size); - view_launchbutton->set_geometry(l + 2.0f *(icon_margin + icon_size), icon_margin, icon_size, icon_size); - // spacer - view_inventorybutton->set_geometry(l + 4.0f *(icon_margin + icon_size), icon_margin, icon_size, icon_size); - view_chatbutton->set_geometry(l + 5.0f *(icon_margin + icon_size), icon_margin, icon_size, icon_size); - view_mapbutton->set_geometry(l + 6.0f *(icon_margin + icon_size), icon_margin, icon_size, icon_size); } void WorldView::clear() @@ -104,28 +79,10 @@ void WorldView::draw() if (ui::root()->active() || !core::game()->interactive() || !core::localcontrol() || (core::localplayer()->view() && !core::localplayer()->view()->menus().size())) { view_playerview->hide(); - view_menubutton->hide(); - view_dockbutton->hide(); - view_launchbutton->hide(); - view_chatbutton->hide(); - view_mapbutton->hide(); - view_inventorybutton->hide(); } else { view_playerview->show(); view_playerview->set_focus(); - if (core::localcontrol()->state() == core::Entity::Docked) { - view_launchbutton->show(); - view_dockbutton->hide(); - } else { - view_launchbutton->hide(); - view_dockbutton->show(); - } - - view_menubutton->show(); - view_chatbutton->show(); - view_mapbutton->show(); - view_inventorybutton->show(); } } diff --git a/src/client/worldview.h b/src/client/worldview.h index 266d3eb..9def8c5 100644 --- a/src/client/worldview.h +++ b/src/client/worldview.h @@ -10,7 +10,6 @@ #include "ui/widget.h" #include "client/playerview.h" #include "client/infowidget.h" -#include "ui/iconbutton.h" namespace client { @@ -40,15 +39,6 @@ private: KeyInfoWidget *view_keyinfo; Notifications *view_notify; PlayerView *view_playerview; - - ui::IconButton *view_menubutton; - - ui::IconButton *view_dockbutton; - ui::IconButton *view_launchbutton; - - ui::IconButton *view_chatbutton; - ui::IconButton *view_mapbutton; - ui::IconButton *view_inventorybutton; }; } |