diff options
-rw-r--r-- | src/client/inventorywindow.cc | 14 | ||||
-rw-r--r-- | src/client/inventorywindow.h | 2 | ||||
-rw-r--r-- | src/client/mapwindow.cc | 21 | ||||
-rw-r--r-- | src/client/mapwindow.h | 8 | ||||
-rw-r--r-- | src/client/trademenu.cc | 30 | ||||
-rw-r--r-- | src/client/trademenu.h | 4 |
6 files changed, 60 insertions, 19 deletions
diff --git a/src/client/inventorywindow.cc b/src/client/inventorywindow.cc index cca8cc2..f22a36d 100644 --- a/src/client/inventorywindow.cc +++ b/src/client/inventorywindow.cc @@ -30,6 +30,9 @@ InventoryWindow::InventoryWindow(ui::Widget *parent) : ui::Window(parent) inventorywindow_titlelabel->set_alignment(ui::AlignCenter); inventorywindow_titlelabel->set_text("INVENTORY"); + // close button + inventorywindow_closebutton = new ui::IconButton(inventorywindow_titlelabel, "bitmaps/icons/window_close"); + inventorywindow_modelview = new ui::ModelView(this); inventorywindow_modelview->set_label("modelview"); inventorywindow_modelview->set_background(false); @@ -183,6 +186,10 @@ void InventoryWindow::resize() inventorywindow_titlelabel->set_size(width() - padding * 2.0f, inventorywindow_titlelabel->font()->height()); inventorywindow_titlelabel->set_location(padding, padding); + // resize close button + inventorywindow_closebutton->set_size(inventorywindow_titlelabel->font()->height(), inventorywindow_titlelabel->font()->height()); + inventorywindow_closebutton->set_location(inventorywindow_titlelabel->width() - inventorywindow_closebutton->width(), 0); + // resize inventory listview inventorywindow_listview->set_size(ui::UI::elementsize.width(), height() -icon_size - padding * 8.0f); inventorywindow_listview->set_location(padding, padding * 6.0f); @@ -275,11 +282,14 @@ bool InventoryWindow::on_emit(Widget *sender, const Event event, void *data) { if (event == ui::Widget::EventButtonClicked) { - if (sender == inventorywindow_shipbutton) { + if (sender == inventorywindow_shipbutton) { inventorywindow_listview->deselect(); set_info(core::localcontrol() ? core::localcontrol()->info() : 0, 0); inventorywindow_modeltitlelabel->set_text("Ship Info"); + } else if (sender == inventorywindow_closebutton) { + hide(); } + return true; } else if (event == ui::Widget::EventListViewChanged) { @@ -289,7 +299,7 @@ bool InventoryWindow::on_emit(Widget *sender, const Event event, void *data) set_info(inventorywindow_listview->selected() ? inventorywindow_listview->selected()->info() : 0, inventorywindow_listview->selected()->item()->amount()); } return true; - } + } return Window::on_emit(sender, event, data); } diff --git a/src/client/inventorywindow.h b/src/client/inventorywindow.h index 474df25..32175b1 100644 --- a/src/client/inventorywindow.h +++ b/src/client/inventorywindow.h @@ -63,6 +63,8 @@ private: ui::ModelView *inventorywindow_modelview; ui::Label *inventorywindow_titlelabel; + ui::IconButton *inventorywindow_closebutton; + ui::Label *inventorywindow_modeltitlelabel; ui::Label *inventorywindow_modelnamelabel; diff --git a/src/client/mapwindow.cc b/src/client/mapwindow.cc index d6e45bc..9744062 100644 --- a/src/client/mapwindow.cc +++ b/src/client/mapwindow.cc @@ -34,6 +34,9 @@ MapWindow::MapWindow(ui::Widget *parent) : ui::Window(parent) mapwindow_titlelabel->set_alignment(ui::AlignCenter); mapwindow_titlelabel->set_text("STAR CHART"); + // close button + mapwindow_closebutton = new ui::IconButton(mapwindow_titlelabel, "bitmaps/icons/window_close"); + // map widget mapwindow_mapwidget = new MapWidget(this); mapwindow_mapwidget->set_background(false); @@ -104,6 +107,10 @@ void MapWindow::resize() // resize title label mapwindow_titlelabel->set_size(width() - padding * 2.0f, mapwindow_titlelabel->font()->height()); mapwindow_titlelabel->set_location(padding, padding); + + // resize close button + mapwindow_closebutton->set_size(mapwindow_titlelabel->font()->height(), mapwindow_titlelabel->font()->height()); + mapwindow_closebutton->set_location(mapwindow_titlelabel->width() - mapwindow_closebutton->width(), 0); // resize map widget mapwindow_mapwidget->set_size((width() - padding * 3.0f) * 0.5f, height() - mapwindow_titlelabel->bottom() - padding * 2.0f ); @@ -318,7 +325,7 @@ void MapWindow::set_target(const core::Entity *entity) { mapwindow_targetlabel->set_text(mapwindow_target->name()); if (mapwindow_target->info()) - mapwindow_inforecord = core::game()->request_info(mapwindow_target->info()->id()); + mapwindow_inforecord = core::game()->request_info(mapwindow_target->info()->id()); else mapwindow_inforecord = 0; @@ -371,4 +378,16 @@ bool MapWindow::on_keypress(const int key, const unsigned int modifier) return false; } +bool MapWindow::on_emit(Widget *sender, const Event event, void *data) +{ + if (sender == mapwindow_closebutton) { + if (event == ui::Widget::EventButtonClicked) { + hide(); + return true; + } + } + + return Window::on_emit(sender, event, data); +} + } diff --git a/src/client/mapwindow.h b/src/client/mapwindow.h index d65e115..46fd8b1 100644 --- a/src/client/mapwindow.h +++ b/src/client/mapwindow.h @@ -9,6 +9,7 @@ #include "core/entity.h" #include "core/info.h" +#include "ui/iconbutton.h" #include "ui/label.h" #include "ui/modelview.h" #include "ui/scrollpane.h" @@ -33,10 +34,14 @@ public: /// show the map window virtual void show(); +protected: + /// called when the widget receives a key press virtual bool on_keypress(const int key, const unsigned int modifier); -protected: + /// called if the widget receives an emit evet + virtual bool on_emit(Widget *sender, const Event event, void *data); + virtual void resize(); virtual void draw(); @@ -54,6 +59,7 @@ private: ui::ModelView *mapwindow_modelview; ui::Label *mapwindow_targetlabel; ui::ScrollPane *mapwindow_scrollpane; + ui::IconButton *mapwindow_closebutton; const core::Entity *mapwindow_target; diff --git a/src/client/trademenu.cc b/src/client/trademenu.cc index d86a04a..c762867 100644 --- a/src/client/trademenu.cc +++ b/src/client/trademenu.cc @@ -59,6 +59,9 @@ TradeMenu::TradeMenu(ui::Widget *parent, const char * label) : ui::Window(parent menu_namelabel->set_alignment(ui::AlignCenter); menu_namelabel->show(); + // close button + menu_closebutton = new ui::IconButton(menu_namelabel, "bitmaps/icons/window_close"); + menu_inventorylistview = new InventoryListView(menu_tradewindow); menu_inventorylistview->set_label("inventorylistview"); //menu_inventorylistview->set_background(false); @@ -87,8 +90,6 @@ TradeMenu::TradeMenu(ui::Widget *parent, const char * label) : ui::Window(parent menu_tradertext->set_border(true); menu_tradertext->set_font(ui::root()->font_small()); - menu_closebutton = new ui::Button(menu_tradewindow, "Return", "view hide"); - menu_closebutton->hide(); menu_buybutton = new ui::Button(menu_tradewindow, "Buy"); menu_listitem = 0; @@ -144,7 +145,7 @@ void TradeMenu::set_item(ui::ListItem *item) menu_slider->hide(); menu_buybutton->set_command(""); - menu_buybutton->hide(); // FIXME enable/disable button + menu_buybutton->disable(); if (item != menu_listitem) { menu_slider->set_range(0, 2); @@ -175,6 +176,8 @@ void TradeMenu::set_item(ui::ListItem *item) if (item->parent() == menu_inventorylistview) { + menu_buybutton->set_text("Sell"); + // item in ship inventory selected (SELL) menu_traderlistview->deselect(); @@ -191,11 +194,7 @@ void TradeMenu::set_item(ui::ListItem *item) std::ostringstream commandstr; commandstr << "remote sell " << item->info()->type()->label() << " " << item->info()->label() << " " << amount; menu_buybutton->set_command(commandstr.str()); - - menu_buybutton->set_text("Sell"); - menu_buybutton->enable(); - menu_buybutton->show(); } if (amount < 1) { @@ -217,6 +216,8 @@ void TradeMenu::set_item(ui::ListItem *item) } else if (item->parent() == menu_traderlistview) { + menu_buybutton->set_text("Buy"); + // item in trader inventory selected (BUY) menu_inventorylistview->deselect(); @@ -239,10 +240,7 @@ void TradeMenu::set_item(ui::ListItem *item) commandstr << "remote buy " << item->info()->type()->label() << " " << item->info()->label() << " " << amount; menu_buybutton->set_command(commandstr.str()); - menu_buybutton->set_text("Buy"); - menu_buybutton->enable(); - menu_buybutton->show(); } if (amount < 1) { @@ -291,6 +289,10 @@ void TradeMenu::resize() menu_namelabel->set_size(menu_tradewindow->width() - fontmargin * 2.0f, menu_namelabel->font()->height()); menu_namelabel->set_location(fontmargin, fontmargin); + // resize close button + menu_closebutton->set_size(menu_namelabel->font()->height(), menu_namelabel->font()->height()); + menu_closebutton->set_location(menu_namelabel->width() - menu_closebutton->width(), 0); + // resize player inventory text menu_inventorytext->set_size( ui::UI::elementsize.width(), @@ -362,9 +364,6 @@ void TradeMenu::resize() fontmargin * 2.0f + ui::UI::elementsize.width(), menu_buybutton->bottom() + fontmargin ); - - //menu_closebutton->set_size(ui::UI::elementsize); - //menu_closebutton->set_location(menu_tradewindow->width() * 0.5f + smallmargin * 2.0f, menu_tradewindow->height() - smallmargin * 1.5f); } bool TradeMenu::on_emit(Widget *sender, const Event event, void *data) @@ -387,6 +386,11 @@ bool TradeMenu::on_emit(Widget *sender, const Event event, void *data) set_item(menu_inventorylistview->selected()); } return true; + } else if (event == ui::Widget::EventButtonClicked) { + if (sender == menu_closebutton) { + hide(); + } + return true; } return ui::Window::on_emit(sender, event, data); diff --git a/src/client/trademenu.h b/src/client/trademenu.h index 60aad55..3dc83c0 100644 --- a/src/client/trademenu.h +++ b/src/client/trademenu.h @@ -8,8 +8,8 @@ #define __INCLUDED_CLIENT_TRADEMENU_H__ #include "core/info.h" -#include "ui/container.h" #include "ui/label.h" +#include "ui/iconbutton.h" #include "ui/listitem.h" #include "ui/modelview.h" #include "ui/plaintext.h" @@ -59,7 +59,7 @@ private: ui::Slider *menu_slider; ui::Label *menu_msgtext; - ui::Button *menu_closebutton; + ui::IconButton *menu_closebutton; ui::Button *menu_buybutton; InventoryListView *menu_inventorylistview; |