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>2010-09-18 22:11:27 +0000
committerStijn Buys <ingar@osirion.org>2010-09-18 22:11:27 +0000
commitbadfb31888a6bd62e0a019b3f3dec517df4121ec (patch)
tree94cb95e405c05f013c8ae4f66a0b973aa5e59b3a /src/client/inventorylistview.cc
parent9c91a9767b570fdc3c3e19e1f452f9a8257f9999 (diff)
trade updates
Diffstat (limited to 'src/client/inventorylistview.cc')
-rw-r--r--src/client/inventorylistview.cc39
1 files changed, 34 insertions, 5 deletions
diff --git a/src/client/inventorylistview.cc b/src/client/inventorylistview.cc
index 1b46fd0..d2752d6 100644
--- a/src/client/inventorylistview.cc
+++ b/src/client/inventorylistview.cc
@@ -11,17 +11,23 @@ namespace client {
InventoryListView::InventoryListView(ui::Widget *parent) : ui::ListView (parent)
{
+ listview_timestamp = 0;
set_inventory(0, 0);
}
InventoryListView::~InventoryListView() {
}
-void InventoryListView::set_inventory(core::Inventory *inventory, core::InfoType *info_type)
+void InventoryListView::set_inventory(core::Inventory *inventory, core::InfoType *infotype)
{
remove_children();
- if (!inventory || !info_type) {
+ listview_inventory = inventory;
+ listview_infotype = infotype;
+
+ const core::Item *selecteditem = (selected() ? selected()->item() : 0);
+
+ if (!inventory || !infotype) {
return;
}
@@ -31,15 +37,38 @@ void InventoryListView::set_inventory(core::Inventory *inventory, core::InfoType
for (core::Inventory::Items::const_iterator it = inventory->items().begin(); it != inventory->items().end(); it++) {
core::Item *item = (*it);
- if (item->info() && item->info()->type() == info_type) {
- ui::ListItem *listitem = 0;
- listitem = new ui::ListItem(this, item->info()->name().c_str());
+ if (item->info() && (item->info()->type() == infotype) && (item->amount() != 0) ) {
+ ui::ListItem *listitem = 0;
+
+ std::ostringstream str;
+ str << item->info()->name().c_str();
+
+ if (item->amount() > 0) {
+ str << " (" << item->amount() << ")";
+ }
+ listitem = new ui::ListItem(this, str.str().c_str());
listitem->set_height(listitem->font()->height() * 2.0f);
+ listitem->set_item(item);
listitem->set_info(item->info());
+ // preserve previous selection during update
+ if (item == selecteditem) {
+ ui::ListView::select(listitem);
+ }
}
}
+ listview_timestamp = inventory->timestamp();
+
event_resize();
}
+void InventoryListView::draw()
+{
+ if (listview_timestamp != listview_inventory->timestamp()) {
+ set_inventory(listview_inventory, listview_infotype);
+ }
+
+ ListView::draw();
+}
+
} // namespace client \ No newline at end of file