diff options
author | Aaron Marks <nymacro@gmail.com> | 2005-04-27 11:25:42 +0000 |
---|---|---|
committer | Aaron Marks <nymacro@gmail.com> | 2005-04-27 11:25:42 +0000 |
commit | fd193321df49fe33697a77f6721b4e1fc13fe05b (patch) | |
tree | e399497cdd2cb9c77b6e752f0578b328134f83ae | |
parent | bcc6f8b670f15976bb7bd14e96b6a1a2ab57f47d (diff) | |
download | mana-fd193321df49fe33697a77f6721b4e1fc13fe05b.tar.gz mana-fd193321df49fe33697a77f6721b4e1fc13fe05b.tar.bz2 mana-fd193321df49fe33697a77f6721b4e1fc13fe05b.tar.xz mana-fd193321df49fe33697a77f6721b4e1fc13fe05b.zip |
Updated item container (fixed rendering position errors).
Moved widgets in inventory so everything is aligned.
-rw-r--r-- | src/gui/inventory.cpp | 18 | ||||
-rw-r--r-- | src/gui/itemcontainer.cpp | 13 |
2 files changed, 18 insertions, 13 deletions
diff --git a/src/gui/inventory.cpp b/src/gui/inventory.cpp index d6851347..73a98575 100644 --- a/src/gui/inventory.cpp +++ b/src/gui/inventory.cpp @@ -37,15 +37,15 @@ InventoryWindow::InventoryWindow(): { setContentSize(322, 100); useButton = new Button("Use"); - useButton->setPosition(20, getHeight() - 48); + useButton->setPosition(8, getHeight() - 48); dropButton = new Button("Drop"); - dropButton->setPosition(60, getHeight() - 48); + dropButton->setPosition(40, getHeight() - 48); items = new ItemContainer(); items->setPosition(2, 2); invenScroll = new ScrollArea(items); - invenScroll->setPosition(4, 4); + invenScroll->setPosition(8, 8); useButton->setEventId("use"); dropButton->setEventId("drop"); @@ -168,11 +168,11 @@ void InventoryWindow::mouseMotion(int mx, int my) void InventoryWindow::updateWidgets() { - //resize widgets - useButton->setPosition(20, getHeight() - 24); - dropButton->setPosition(60, getHeight() - 24); - items->setSize(getWidth() - 24 - 12 - 8 - 1, (INVENTORY_SIZE * 24) / (getWidth() / 24) - 1); - invenScroll->setSize(getWidth() - 32, getHeight() - 32 - 8); - setContentSize(getWidth(), getHeight()); + //resize widgets + useButton->setPosition(8, getHeight() - 24); + dropButton->setPosition(40, getHeight() - 24); + items->setSize(getWidth() - 24 - 12 - 1, (INVENTORY_SIZE * 24) / (getWidth() / 24) - 1); + invenScroll->setSize(getWidth() - 16, getHeight() - 32 - 8); + setContentSize(getWidth(), getHeight()); } diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp index bb10c5a9..5bb3eb35 100644 --- a/src/gui/itemcontainer.cpp +++ b/src/gui/itemcontainer.cpp @@ -59,20 +59,25 @@ void ItemContainer::draw(gcn::Graphics* graphics) w = getWidth(); h = getHeight(); + int itemWidth = getWidth() / 24; + if (items[selectedItem].quantity <= 0) { selectedItem = -1; } if (selectedItem >= 0) { - int itemX = (((selectedItem - 2) * 24) % (getWidth() - 24)); - int itemY = (((selectedItem - 2) * 24) / (getWidth() - 24)) * 24; + int itemX = ((selectedItem - 2) % itemWidth) * 24; + int itemY = ((selectedItem - 2) / itemWidth) * 24; + itemX -= itemX % 24; selImg->draw(screen, x + itemX, y+itemY); } for (int i = 0; i < INVENTORY_SIZE; i++) { - int itemX = (((i - 2) * 24) % (getWidth() - 24)); - int itemY = (((i - 2) * 24) / (getWidth() - 24)) * 24; + int itemX = ((i - 2) % itemWidth) * 24; + int itemY = ((i - 2) / itemWidth) * 24; + + itemX -= itemX % 24; if (items[i].quantity > 0) { if (itemDb.getItemInfo(items[i].id)->getImage() > 0) { |