diff options
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/trademenu.cc | 54 | ||||
-rw-r--r-- | src/client/trademenu.h | 5 |
2 files changed, 58 insertions, 1 deletions
diff --git a/src/client/trademenu.cc b/src/client/trademenu.cc index e96f1a6..837ee87 100644 --- a/src/client/trademenu.cc +++ b/src/client/trademenu.cc @@ -59,6 +59,12 @@ TradeMenu::TradeMenu(ui::Widget *parent, const char * label) : ui::Window(parent menu_closebutton = new ui::Button(menu_tradewindow, "Return", "view hide"); + menu_buyallbutton = new ui::Button(menu_modelview, "<<"); + menu_buybutton = new ui::Button(menu_modelview, "<"); + menu_sellallbutton = new ui::Button(menu_modelview, ">"); + menu_sellbutton = new ui::Button(menu_modelview, ">>"); + + std::string test("test"); set_item_type(0); @@ -74,7 +80,6 @@ void TradeMenu::set_item_type(core::InfoType *item_type) { // reset menu_namelabel->set_text(0); - menu_infotext.clear(); core::Inventory *inventory_player = 0; core::Inventory *inventory_view = 0; @@ -93,21 +98,55 @@ void TradeMenu::set_item_type(core::InfoType *item_type) void TradeMenu::set_item(ui::ListItem *item) { + menu_infotext.clear(); menu_namelabel->clear(); if (!item || !item->info()) { + menu_traderlistview->deselect(); + menu_inventorylistview->deselect(); + menu_scrollpane->hide(); menu_modelview->hide(); return; } if (item->parent() == menu_inventorylistview) { + menu_traderlistview->deselect(); // item in ship inventory selected (SELL) menu_namelabel->set_text("Sell " + item->text()); + menu_buyallbutton->hide(); + menu_buybutton->hide(); + + menu_sellallbutton->show(); + menu_sellallbutton->set_command("remote sell " + item->info()->type()->label() + " " + item->info()->label() + " -1"); + + menu_sellbutton->show(); + menu_sellbutton->set_command("remote sell " + item->info()->type()->label() + " " + item->info()->label() + " 1"); + } else if (item->parent() == menu_traderlistview) { + menu_inventorylistview->deselect(); // item in trader inventory selected (BUY) menu_namelabel->set_text("Buy " + item->text()); + + menu_buyallbutton->show(); + menu_buyallbutton->set_command("remote buy " + item->info()->type()->label() + " " + item->info()->label() + " -1"); + + menu_buybutton->show(); + menu_buybutton->set_command("remote buy " + item->info()->type()->label() + " " + item->info()->label() + " 1; "); + + menu_sellallbutton->hide(); + menu_sellbutton->hide(); + + } else { + menu_traderlistview->deselect(); + menu_inventorylistview->deselect(); + + menu_buyallbutton->hide(); + menu_buybutton->hide(); + + menu_sellallbutton->hide(); + menu_sellbutton->hide(); } if (item->info()) { @@ -145,6 +184,19 @@ void TradeMenu::resize() menu_modelview->set_size(menu_tradewindow->width() - 2.0f * ui::UI::elementsize.width() - fontmargin * 4.0f, ui::UI::elementsize.width()); menu_modelview->set_location(fontmargin * 2.0f + ui::UI::elementsize.width(), fontmargin * 3.0f); + // resize buttons + menu_buyallbutton->set_size(fontmargin, fontmargin); + menu_buyallbutton->set_location(0, menu_modelview->height() - fontmargin); + + menu_buybutton->set_size(fontmargin, fontmargin); + menu_buybutton->set_location(2.0f * fontmargin, menu_modelview->height() - fontmargin); + + menu_sellallbutton->set_size(fontmargin, fontmargin); + menu_sellallbutton->set_location(menu_modelview->width() - fontmargin, menu_modelview->height() - fontmargin); + + menu_sellbutton->set_size(fontmargin, fontmargin); + menu_sellbutton->set_location(menu_modelview->width() - 3.0f * fontmargin, menu_modelview->height() - fontmargin); + // resize scrollpane menu_scrollpane->set_size(menu_tradewindow->width() - 2.0f * ui::UI::elementsize.width() - fontmargin * 4.0f, menu_inventorylistview->height() - fontmargin - ui::UI::elementsize.width()); menu_scrollpane->set_location(fontmargin * 2.0f + ui::UI::elementsize.width(), fontmargin * 4.0f + ui::UI::elementsize.width()); diff --git a/src/client/trademenu.h b/src/client/trademenu.h index b95ee57..477a372 100644 --- a/src/client/trademenu.h +++ b/src/client/trademenu.h @@ -46,6 +46,11 @@ private: ui::ModelView *menu_modelview; ui::ScrollPane *menu_scrollpane; + ui::Button *menu_buyallbutton; + ui::Button *menu_buybutton; + ui::Button *menu_sellallbutton; + ui::Button *menu_sellbutton; + InventoryListView *menu_inventorylistview; InventoryListView *menu_traderlistview; |