diff options
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/buymenu.cc | 23 | ||||
-rw-r--r-- | src/client/inventorylistview.cc | 14 | ||||
-rw-r--r-- | src/client/trademenu.cc | 49 | ||||
-rw-r--r-- | src/client/trademenu.h | 1 |
4 files changed, 61 insertions, 26 deletions
diff --git a/src/client/buymenu.cc b/src/client/buymenu.cc index ba93f42..b42dc00 100644 --- a/src/client/buymenu.cc +++ b/src/client/buymenu.cc @@ -65,6 +65,8 @@ void BuyMenu::set_item(core::Info *info) menu_infotext.clear(); menu_namelabel->set_text(0); menu_modelview->set_modelname(0); + menu_buybutton->hide(); + menu_modelview->hide(); // if the information timestamp is 0, the info is available menu_inforecord = info; @@ -78,22 +80,19 @@ void BuyMenu::set_item(core::Info *info) } else { for (core::Info::Text::const_iterator it = menu_inforecord->text().begin(); it != menu_inforecord->text().end(); it++) { menu_infotext.push_back((*it)); - } - - menu_infotimestamp = menu_inforecord->timestamp(); - if (menu_inforecord->type() && !menu_inforecord->timestamp()) { + } + if (menu_inforecord->type()) { menu_namelabel->set_text(menu_inforecord->name()); menu_modelview->set_modelname(menu_inforecord->modelname()); - menu_buybutton->set_command("remote buy " + menu_inforecord->type()->label() + ' ' + menu_inforecord->label() + "; view hide"); - menu_buybutton->set_label("buy " + menu_inforecord->name()); + if (menu_inforecord->label().size()) { + menu_buybutton->set_command("remote buy " + menu_inforecord->type()->label() + ' ' + menu_inforecord->label() + "; view hide"); + menu_buybutton->set_label("buy " + menu_inforecord->type()->label() + ' ' + menu_inforecord->label()); - menu_buybutton->show(); - menu_modelview->show(); - } else { - menu_buybutton->hide(); - menu_modelview->hide(); - } + menu_buybutton->show(); + menu_modelview->show(); + } + } menu_infotimestamp = menu_inforecord->timestamp(); } } diff --git a/src/client/inventorylistview.cc b/src/client/inventorylistview.cc index e2b613b..87cc367 100644 --- a/src/client/inventorylistview.cc +++ b/src/client/inventorylistview.cc @@ -96,13 +96,25 @@ void InventoryListView::draw() if (listview_inventory && listview_infotype) { // inventory was updated if (listview_timestamp != listview_inventory->timestamp()) { + //con_debug << "CLIENT inventory update from " << listview_timestamp << " to " << listview_inventory->timestamp() << std::endl; set_inventory(listview_inventory, listview_infotype); // inventory info was updated } else if (!verify_inventory()) { + //con_debug << "CLIENT inventory info update" << std::endl; set_inventory(listview_inventory, listview_infotype); } } - + + /* + * DEBUG + std::ostringstream str; + if (listview_inventory && listview_infotype) { + str << listview_timestamp << " " << listview_inventory->timestamp() << " " << listview_infotimestamp; + } else { + str << "EMPTY"; + } + ui::Paint::draw_label(global_location(), size(), font(), str.str() , ui::AlignBottom) ; + */ ListView::draw(); } diff --git a/src/client/trademenu.cc b/src/client/trademenu.cc index 91724f7..8aa9a52 100644 --- a/src/client/trademenu.cc +++ b/src/client/trademenu.cc @@ -38,6 +38,12 @@ TradeMenu::TradeMenu(ui::Widget *parent, const char * label) : ui::Window(parent menu_slider = new ui::Slider(menu_tradewindow); menu_slider->set_background(false); menu_slider->set_border(true); + + menu_msgtext = new ui::Label(menu_tradewindow); + menu_msgtext->set_label("label"); + menu_msgtext->set_background(false); + menu_msgtext->set_border(false); + menu_msgtext->set_alignment(ui::AlignCenter); menu_namelabel = new ui::Label(menu_tradewindow); menu_namelabel->set_label("label"); @@ -113,11 +119,17 @@ void TradeMenu::set_itemtype(core::InfoType *item_type) void TradeMenu::set_item(ui::ListItem *item) { menu_infotext.clear(); + menu_namelabel->set_text("Trade"); + menu_tradertext->clear(); - menu_buybutton->hide(); + menu_msgtext->clear(); + menu_msgtext->hide(); menu_slider->hide(); + menu_buybutton->set_command(""); + menu_buybutton->hide(); // FIXME enable/disable button + if (item != menu_listitem) { menu_slider->set_range(0, 2); menu_slider->set_value(1); @@ -148,7 +160,7 @@ void TradeMenu::set_item(ui::ListItem *item) if (item->parent() == menu_inventorylistview) { // item in ship inventory selected (SELL) - + menu_buybutton->set_text("Sell"); menu_traderlistview->deselect(); const core::Item *trader_item = (menu_traderlistview->inventory() ? menu_traderlistview->inventory()->find(item->info()) : 0); @@ -164,14 +176,14 @@ 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) { - menu_buybutton->set_command(""); - menu_buybutton->set_text("^1Can not sell"); - menu_buybutton->show(); + if (amount < 1) { + menu_msgtext->set_text("^1Can not sell"); + menu_msgtext->show(); } std::ostringstream str; @@ -179,7 +191,8 @@ void TradeMenu::set_item(ui::ListItem *item) << "Volume: " << std::setw(12) << std::setprecision(2) << (float)(amount > 0 ? amount : 1) * trader_item->info()->volume(); menu_tradertext->set_text(str.str()); } else { - menu_tradertext->set_text(" ^1Can not sell here"); + menu_msgtext->set_text("^1Can not sell here"); + menu_msgtext->show(); } std::ostringstream labelstr; @@ -192,7 +205,7 @@ void TradeMenu::set_item(ui::ListItem *item) } else if (item->parent() == menu_traderlistview) { // item in trader inventory selected (BUY) - + menu_buybutton->set_text("Buy"); menu_inventorylistview->deselect(); if (menu_inventorylistview->inventory()) { @@ -213,14 +226,20 @@ void TradeMenu::set_item(ui::ListItem *item) std::ostringstream commandstr; 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) { - menu_buybutton->set_command(""); - menu_buybutton->set_text("^1Can not buy"); - menu_buybutton->show(); + if (item_unit_price > core::localplayer()->credits()) { + menu_msgtext->set_text("^1Not enough credits"); + } else if (item_unit_volume > menu_inventorylistview->inventory()->capacity_available()) { + menu_msgtext->set_text("^1Not enough cargo space"); + } else { + menu_msgtext->set_text("^1Can not buy"); + } + menu_msgtext->show(); } std::ostringstream str; @@ -272,6 +291,10 @@ void TradeMenu::resize() // resize slider menu_slider->set_size(menu_modelview->width(), fontmargin); menu_slider->set_location(menu_modelview->left(), menu_modelview->bottom() - menu_slider->height()); + + // warning text + menu_msgtext->set_size(menu_slider->size()); + menu_msgtext->set_location(menu_slider->location()); // resize scrollpane menu_scrollpane->set_size(menu_tradewindow->width() - 2.0f * ui::UI::elementsize.width() - fontmargin * 4.0f, menu_inventorylistview->height() + 2.0f * fontmargin - ui::UI::elementsize.width()); diff --git a/src/client/trademenu.h b/src/client/trademenu.h index e835043..5ea34aa 100644 --- a/src/client/trademenu.h +++ b/src/client/trademenu.h @@ -51,6 +51,7 @@ private: ui::ModelView *menu_modelview; ui::ScrollPane *menu_scrollpane; ui::Slider *menu_slider; + ui::Label *menu_msgtext; ui::Button *menu_closebutton; ui::Button *menu_buybutton; |