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>2013-01-06 15:28:09 +0000
committerStijn Buys <ingar@osirion.org>2013-01-06 15:28:09 +0000
commit8a238b236ed89b31e21d6da7d1952eea6a29508e (patch)
tree73276136246f37d1b0e938e8edc2189e470b92fc /src/client/inventorywindow.cc
parentcafb6d40174459819b33ffc5e3d5e96762375619 (diff)
Replaced the mount button with an in-place mount indicator,
show mounted items at the top of the weapons list.
Diffstat (limited to 'src/client/inventorywindow.cc')
-rw-r--r--src/client/inventorywindow.cc80
1 files changed, 47 insertions, 33 deletions
diff --git a/src/client/inventorywindow.cc b/src/client/inventorywindow.cc
index 51ced0e..4ab7f25 100644
--- a/src/client/inventorywindow.cc
+++ b/src/client/inventorywindow.cc
@@ -69,7 +69,7 @@ InventoryWindow::InventoryWindow(ui::Widget *parent) : ui::Window(parent)
inventorywindow_shipbutton = new ui::IconButton(this, "bitmaps/icons/button_ship");
inventorywindow_ejectbutton = new ui::IconButton(this, "bitmaps/icons/button_eject");
- inventorywindow_mountbutton = new ui::IconButton(this, "bitmaps/icons/button_mount");
+ //inventorywindow_mountbutton = new ui::IconButton(this, "bitmaps/icons/button_mount");
// eject dialog
inventorywindow_ejectconfirmbutton = new ui::Button(inventorywindow_scrollpane, "Eject");
@@ -92,6 +92,9 @@ void InventoryWindow::toggle()
}
void InventoryWindow::update_inventory()
{
+ const float icon_size = 24.0f; // small icons
+ const float padding = ui::root()->font_large()->height();
+
const core::Item *selecteditem = (inventorywindow_listview->selected() ? inventorywindow_listview->selected()->item() : 0);
inventorywindow_listview->clear();
@@ -133,22 +136,33 @@ void InventoryWindow::update_inventory()
listitem->set_info(item->info());
std::string sortkey(item->info()->type()->label());
- sortkey += '.';
+ if (item->has_flag(core::Item::Mounted)) {
+ sortkey += '+';
+ } else {
+ sortkey += '.';
+ }
sortkey += item->info()->label();
listitem->set_sortkey(sortkey);
- // mount indicator
if (item->has_flag(core::Item::Mounted)) {
- const float icon_size = 24.0f; // small icons
- const float padding = ui::root()->font_large()->height();
+ // unmount button
+ ui::IconButton *ismounted_button = new ui::IconButton(listitem, "bitmaps/icons/button_mount");
+ std::ostringstream strcmd;
+ strcmd << "remote mount " << item->id();
+ ismounted_button->set_command(strcmd.str());
+ ismounted_button->set_background(true);
+ ismounted_button->set_size(icon_size, icon_size);
+ ismounted_button->set_location(ui::UI::elementsize.width() - icon_size - padding, padding);
- ui::IconButton *unmount_button = new ui::IconButton(listitem, "bitmaps/icons/button_unmount");
+ } else if (item->has_flag(core::Item::Mountable)) {
+ // mount button
+ ui::IconButton *isunmounted_button = new ui::IconButton(listitem, "bitmaps/icons/button_unmount");
std::ostringstream strcmd;
strcmd << "remote mount " << item->id();
- unmount_button->set_command(strcmd.str());
- unmount_button->set_background(true);
- unmount_button->set_size(icon_size, icon_size);
- unmount_button->set_location(ui::UI::elementsize.width() - icon_size - padding, padding);
+ isunmounted_button->set_command(strcmd.str());
+ isunmounted_button->set_background(true);
+ isunmounted_button->set_size(icon_size, icon_size);
+ isunmounted_button->set_location(ui::UI::elementsize.width() - icon_size - padding, padding);
}
// preserve previous selection during update
@@ -222,8 +236,8 @@ void InventoryWindow::resize()
inventorywindow_ejectbutton->set_size(icon_size, icon_size);
inventorywindow_ejectbutton->set_location(inventorywindow_inventorytext->right() - icon_size, height() - icon_size - padding);
- inventorywindow_mountbutton->set_size(icon_size, icon_size);
- inventorywindow_mountbutton->set_location(inventorywindow_ejectbutton->left() - icon_size - padding, height() - icon_size - padding);
+// inventorywindow_mountbutton->set_size(icon_size, icon_size);
+// inventorywindow_mountbutton->set_location(inventorywindow_ejectbutton->left() - icon_size - padding, height() - icon_size - padding);
// resize modelview
inventorywindow_modelview->set_size( width() - inventorywindow_listview->right() - padding * 2.0f ,ui::UI::elementsize.width());
@@ -351,21 +365,21 @@ void InventoryWindow::act_eject()
show_item_info(0);
}
-void InventoryWindow::act_mount()
-{
- if (!inventorywindow_listview->selected()) {
- return;
- }
- if (!inventorywindow_listview->selected()->item()) {
- return;
- }
-
- std::ostringstream cmdstr;
-
- cmdstr << "remote mount ";
- cmdstr << inventorywindow_listview->selected()->item()->id();
- core::CommandBuffer::exec(cmdstr.str());
-}
+// void InventoryWindow::act_mount()
+// {
+// if (!inventorywindow_listview->selected()) {
+// return;
+// }
+// if (!inventorywindow_listview->selected()->item()) {
+// return;
+// }
+//
+// std::ostringstream cmdstr;
+//
+// cmdstr << "remote mount ";
+// cmdstr << inventorywindow_listview->selected()->item()->id();
+// core::CommandBuffer::exec(cmdstr.str());
+// }
void InventoryWindow::show_item_info(const ui::ListItem *listitem)
{
@@ -373,9 +387,9 @@ void InventoryWindow::show_item_info(const ui::ListItem *listitem)
set_info(listitem->info(), listitem->item()->amount());
if (listitem->item()->amount()) {
inventorywindow_ejectbutton->enable();
- if (listitem->item()->has_flag(core::Item::Unique) && !listitem->item()->has_flag(core::Item::Mounted)) {
- inventorywindow_mountbutton->enable();
- }
+// if (listitem->item()->has_flag(core::Item::Unique) && !listitem->item()->has_flag(core::Item::Mounted)) {
+// inventorywindow_mountbutton->enable();
+// }
}
} else {
set_info(0, 0);
@@ -388,7 +402,7 @@ void InventoryWindow::set_info(const core::Info *info, const int amount)
inventorywindow_infotext.clear();
inventorywindow_amount = amount;
inventorywindow_ejectbutton->disable();
- inventorywindow_mountbutton->disable();
+// inventorywindow_mountbutton->disable();
inventorywindow_ejectconfirmbutton->hide();
inventorywindow_ejectcancelbutton->hide();
@@ -430,8 +444,8 @@ bool InventoryWindow::on_emit(Widget *sender, const Event event, void *data)
show_item_info(inventorywindow_listview->selected());
} else if (sender == inventorywindow_ejectconfirmbutton) {
act_eject();
- } else if (sender == inventorywindow_mountbutton) {
- act_mount();
+// } else if (sender == inventorywindow_mountbutton) {
+// act_mount();
} else if (sender == inventorywindow_closebutton) {
hide();
}