diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/itemcontainer.cpp | 2 | ||||
-rw-r--r-- | src/gui/itemshortcutcontainer.cpp | 4 | ||||
-rw-r--r-- | src/gui/minimap.cpp | 27 | ||||
-rw-r--r-- | src/gui/widgets/resizegrip.cpp | 4 | ||||
-rw-r--r-- | src/gui/widgets/resizegrip.h | 2 | ||||
-rw-r--r-- | src/inventory.cpp | 6 | ||||
-rw-r--r-- | src/inventory.h | 6 | ||||
-rw-r--r-- | src/itemshortcut.cpp | 22 | ||||
-rw-r--r-- | src/net/equipmenthandler.cpp | 2 | ||||
-rw-r--r-- | src/resources/itemdb.cpp | 2 |
10 files changed, 47 insertions, 30 deletions
diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp index 30cb1d6d..5069e102 100644 --- a/src/gui/itemcontainer.cpp +++ b/src/gui/itemcontainer.cpp @@ -206,7 +206,7 @@ ItemContainer::mousePressed(gcn::MouseEvent &event) } Item *item = mInventory->getItem(index); setSelectedItem(item); - if (item && !item->isEquipment()) + if (item) { itemShortcut->setItemSelected(item->getId()); } diff --git a/src/gui/itemshortcutcontainer.cpp b/src/gui/itemshortcutcontainer.cpp index 86a53aca..f8a0959a 100644 --- a/src/gui/itemshortcutcontainer.cpp +++ b/src/gui/itemshortcutcontainer.cpp @@ -96,11 +96,13 @@ ItemShortcutContainer::draw(gcn::Graphics *graphics) player_node->getInventory()->findItem(itemShortcut->getItem(i)); if (item) { // Draw item icon. + const std::string label = + item->isEquipped() ? "Eq." : toString(item->getQuantity()); Image* image = item->getImage(); if (image) { g->drawImage(image, itemX, itemY); g->drawText( - toString(item->getQuantity()), + label, itemX + mBoxWidth / 2, itemY + mBoxHeight - 14, gcn::Graphics::CENTER); diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index 728f61e4..bd79ec87 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -70,18 +70,29 @@ void Minimap::draw(gcn::Graphics *graphics) { Window::draw(graphics); - if (mMapImage != NULL) + const gcn::Rectangle a = getChildrenArea(); + + int mapOriginX = a.x; + int mapOriginY = a.y; + + if (mMapImage) { + if (mMapImage->getWidth() > a.width || + mMapImage->getHeight() > a.height) + { + mapOriginX += (a.width - player_node->mX) / 2; + mapOriginY += (a.height - player_node->mY) / 2; + } static_cast<Graphics*>(graphics)-> - drawImage(mMapImage, getPadding(), getTitleBarHeight()); + drawImage(mMapImage, mapOriginX, mapOriginY); } - Beings &beings = beingManager->getAll(); - BeingIterator bi; + const Beings &beings = beingManager->getAll(); + Beings::const_iterator bi; for (bi = beings.begin(); bi != beings.end(); bi++) { - Being *being = (*bi); + const Being *being = (*bi); int dotSize = 2; switch (being->getType()) { @@ -107,11 +118,11 @@ void Minimap::draw(gcn::Graphics *graphics) continue; } - int offset = (dotSize - 1) * (int) mProportion; + const int offset = (dotSize - 1) * (int) mProportion; graphics->fillRectangle(gcn::Rectangle( - (being->mX * (int) mProportion) + getPadding() - offset, - (being->mY * (int) mProportion) + getTitleBarHeight() - offset, + (being->mX * (int) mProportion) + mapOriginX - offset, + (being->mY * (int) mProportion) + mapOriginY - offset, dotSize, dotSize)); } } diff --git a/src/gui/widgets/resizegrip.cpp b/src/gui/widgets/resizegrip.cpp index e8b50dc9..87527f0a 100644 --- a/src/gui/widgets/resizegrip.cpp +++ b/src/gui/widgets/resizegrip.cpp @@ -31,13 +31,13 @@ Image *ResizeGrip::gripImage = 0; int ResizeGrip::mInstances = 0; -ResizeGrip::ResizeGrip() +ResizeGrip::ResizeGrip(std::string image) { if (mInstances == 0) { // Load the grip image ResourceManager *resman = ResourceManager::getInstance(); - gripImage = resman->getImage("graphics/gui/resize.png"); + gripImage = resman->getImage(image); } mInstances++; diff --git a/src/gui/widgets/resizegrip.h b/src/gui/widgets/resizegrip.h index 5f3a09a4..acb934d2 100644 --- a/src/gui/widgets/resizegrip.h +++ b/src/gui/widgets/resizegrip.h @@ -41,7 +41,7 @@ class ResizeGrip : public gcn::Widget /** * Constructor. */ - ResizeGrip(); + ResizeGrip(std::string image = "graphics/gui/resize.png"); /** * Destructor. diff --git a/src/inventory.cpp b/src/inventory.cpp index 764d7fee..d346a50b 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -124,19 +124,19 @@ bool Inventory::contains(Item *item) const return false; } -int Inventory::getFreeSlot() +int Inventory::getFreeSlot() const { Item **i = std::find_if(mItems + 2, mItems + mSize, std::not1(SlotUsed())); return (i == mItems + mSize) ? -1 : (i - mItems); } -int Inventory::getNumberOfSlotsUsed() +int Inventory::getNumberOfSlotsUsed() const { return count_if(mItems, mItems + mSize, SlotUsed()); } -int Inventory::getLastUsedSlot() +int Inventory::getLastUsedSlot() const { for (int i = mSize - 1; i >= 0; i--) { if (SlotUsed()(mItems[i])) { diff --git a/src/inventory.h b/src/inventory.h index 87d09567..566ca17c 100644 --- a/src/inventory.h +++ b/src/inventory.h @@ -83,7 +83,7 @@ class Inventory /** * Returns id of next free slot or -1 if all occupied. */ - int getFreeSlot(); + int getFreeSlot() const; /** * Reset all item slots. @@ -93,12 +93,12 @@ class Inventory /** * Get the number of slots filled with an item */ - int getNumberOfSlotsUsed(); + int getNumberOfSlotsUsed() const; /** * Returns the index of the last occupied slot or 0 if none occupied. */ - int getLastUsedSlot(); + int getLastUsedSlot() const; protected: Item **mItems; /**< The holder of items */ diff --git a/src/itemshortcut.cpp b/src/itemshortcut.cpp index a3812042..cfe46238 100644 --- a/src/itemshortcut.cpp +++ b/src/itemshortcut.cpp @@ -61,14 +61,8 @@ void ItemShortcut::save() { for (int i = 0; i < SHORTCUT_ITEMS; i++) { - if (mItems[i]) - { - config.setValue("shortcut" + toString(i), mItems[i]); - } - else - { - config.setValue("shortcut" + toString(i), -1); - } + const int itemId = mItems[i] ? mItems[i] : -1; + config.setValue("shortcut" + toString(i), itemId); } } @@ -78,6 +72,16 @@ void ItemShortcut::useItem(int index) { Item *item = player_node->getInventory()->findItem(mItems[index]); if (item && item->getQuantity()) - player_node->useItem(item); + { + if (item->isEquipment()) { + if (item->isEquipped()) { + player_node->unequipItem(item); + } else { + player_node->equipItem(item); + } + } else { + player_node->useItem(item); + } + } } } diff --git a/src/net/equipmenthandler.cpp b/src/net/equipmenthandler.cpp index 4775371a..23a8063f 100644 --- a/src/net/equipmenthandler.cpp +++ b/src/net/equipmenthandler.cpp @@ -156,7 +156,7 @@ void EquipmentHandler::handleMessage(MessageIn *msg) item->setEquipped(false); if (equipPoint & 0x8000) { // Arrows - player_node->mEquipment->setArrows(NULL); + player_node->mEquipment->setArrows(0); } else { player_node->mEquipment->removeEquipment(position); diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index 3f8dadce..f4ccc511 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -89,7 +89,7 @@ void ItemDB::load() std::string image = XML::getProperty(node, "image", ""); std::string description = XML::getProperty(node, "description", ""); std::string effect = XML::getProperty(node, "effect", ""); - int weaponType = XML::getProperty(node, "weapon_type", 0);// Not used by Aethyra + int weaponType = XML::getProperty(node, "weapon_type", 0); if (id) { |