Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2011-07-30 22:21:31 +0000
committerStijn Buys <ingar@osirion.org>2011-07-30 22:21:31 +0000
commit14d406cdcfabf77b6fc1fbce0d381bcdecbb0e94 (patch)
treebb91be328c0a12310de51180f593ca4062da19be /src/client/inventorylistview.cc
parent483bd5dc4e3ecafee54ff608674eb7e6361622b3 (diff)
Improved trade menu.
Diffstat (limited to 'src/client/inventorylistview.cc')
-rw-r--r--src/client/inventorylistview.cc74
1 files changed, 62 insertions, 12 deletions
diff --git a/src/client/inventorylistview.cc b/src/client/inventorylistview.cc
index 8ec2c82..5b1dbde 100644
--- a/src/client/inventorylistview.cc
+++ b/src/client/inventorylistview.cc
@@ -8,6 +8,9 @@
#include "client/inventorylistview.h"
#include "ui/listitem.h"
#include "ui/paint.h"
+#include "ui/ui.h"
+
+#include <iomanip>
namespace client {
@@ -61,25 +64,72 @@ void InventoryListView::set_inventory(core::Inventory *inventory, core::InfoType
std::ostringstream str;
- if (item->amount() == 0) {
- str << "^N";
- }
- str << item->info()->name().c_str();
+ if (inventory == core::localcontrol()->inventory()) {
+
+ // special rules for own ship inventory
+ // retreive price from the trader
+ const core::Item *trader_item = (core::localplayer()->view() && core::localplayer()->view()->inventory() ? core::localplayer()->view()->inventory()->find(item->info()) : 0);
+ if (!trader_item) {
+ // not sold here
+ str << "^N";
+ }
+
+ str << item->info()->name();
+
+ std::ostringstream str_amount;
+ str_amount << item->amount();
+ str << '\n' << aux::pad_right(str_amount.str(), 10);
+
+ if (trader_item) {
+ std::ostringstream std_price;
+ std_price << trader_item->price() << " credits";
+ str << aux::pad_left(std_price.str(), 14);
+ }
+
+ if (trader_item) {
+ sortkey.assign("+");
+ } else {
+ sortkey.assign("-");
+ }
+
+
+ } else {
- if (item->amount() > 0) {
- str << " (" << item->amount() << ")";
- }
+ if (item->amount() == 0) {
+ str << "^N";
+ }
+
+ str << item->info()->name();
+
+ if (item->amount() > 0) {
+ std::ostringstream str_amount;
+ str_amount << item->amount();
+ str << '\n' << aux::pad_right(str_amount.str(), 10);
+
+ std::ostringstream std_price;
+ std_price << item->price() << " credits";
+ str << aux::pad_left(std_price.str(), 14);
+
+ } else {
+ std::ostringstream std_price;
+ std_price << item->price() << " credits";
+ str << '\n' << aux::pad_left(std_price.str(), 24);
+ }
+
+
+ if (item->amount() == 0) {
+ sortkey.assign("-");
+ } else {
+ sortkey.assign("+");
+ }
- if (item->amount() == 0) {
- sortkey.assign("-");
- } else {
- sortkey.assign("+");
}
sortkey.append(item->info()->label());
listitem = new ui::ListItem(this, str.str().c_str());
- listitem->set_height(listitem->font()->height() * 2.0f);
+ listitem->set_font(ui::root()->font_tiny());
+ listitem->set_height(listitem->font()->height() * 3.0f);
listitem->set_item(item);
listitem->set_info(item->info());
listitem->set_sortkey(sortkey);