summaryrefslogtreecommitdiff
path: root/src/gui/inventory.cpp
diff options
context:
space:
mode:
authorAaron Marks <nymacro@gmail.com>2005-04-09 12:48:06 +0000
committerAaron Marks <nymacro@gmail.com>2005-04-09 12:48:06 +0000
commit0a93e5f7e5170127d63a3d8aecab960ac13cf81f (patch)
treef32b302fcd3e2b86e4e629e8379617d48df05129 /src/gui/inventory.cpp
parent5825ea30189a028006de117bbdc62a6d7acaa919 (diff)
downloadMana-0a93e5f7e5170127d63a3d8aecab960ac13cf81f.tar.gz
Mana-0a93e5f7e5170127d63a3d8aecab960ac13cf81f.tar.bz2
Mana-0a93e5f7e5170127d63a3d8aecab960ac13cf81f.tar.xz
Mana-0a93e5f7e5170127d63a3d8aecab960ac13cf81f.zip
Added better support for inventory (currently its resizable by dragging the top
right of the window).
Diffstat (limited to 'src/gui/inventory.cpp')
-rw-r--r--src/gui/inventory.cpp41
1 files changed, 34 insertions, 7 deletions
diff --git a/src/gui/inventory.cpp b/src/gui/inventory.cpp
index 21724927..17903ba3 100644
--- a/src/gui/inventory.cpp
+++ b/src/gui/inventory.cpp
@@ -36,9 +36,15 @@ InventoryWindow::InventoryWindow():
{
setContentSize(322, 100);
useButton = new Button("Use");
- useButton->setPosition(20, 50);
+ useButton->setPosition(20, getHeight() - 48);
dropButton = new Button("Drop");
- dropButton->setPosition(60, 50);
+ dropButton->setPosition(60, getHeight() - 48);
+
+ items = new ItemContainer();
+ items->setPosition(2, 2);
+
+ invenScroll = new gcn::ScrollArea(items);
+ invenScroll->setPosition(4, 4);
useButton->setEventId("use");
dropButton->setEventId("drop");
@@ -47,11 +53,13 @@ InventoryWindow::InventoryWindow():
add(useButton);
add(dropButton);
-
- items = new ItemContainer();
- items->setSize(318, 40);
- items->setPosition(2, 2);
- add(items);
+ add(invenScroll);
+
+ setResizeable(true);
+ setMinWidth(240);
+ setMinHeight(96);
+
+ updateWidgets();
}
InventoryWindow::~InventoryWindow()
@@ -147,3 +155,22 @@ void InventoryWindow::action(const std::string &eventId)
}
}
}
+
+void InventoryWindow::mouseMotion(int mx, int my)
+{
+ int tmpWidth = getWidth(), tmpHeight = getHeight();
+ Window::mouseMotion(mx, my);
+ if (getWidth() != tmpWidth || getHeight() != tmpHeight) {
+ updateWidgets();
+ }
+}
+
+void InventoryWindow::updateWidgets()
+{
+ //resize widgets
+ useButton->setPosition(20, getHeight() - 48);
+ dropButton->setPosition(60, getHeight() - 48);
+ items->setSize(getWidth() - 24 - 12 - 8 - 1, (getHeight() - 40 - 8 - 1) + items->getQuantity() * 24 - 1);
+ invenScroll->setSize(getWidth() - 32, getHeight() - 48 - 8);
+ setContentSize(getWidth(), getHeight());
+}