summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-04-06 06:11:38 -0600
committerJared Adams <jaxad0127@gmail.com>2009-04-06 06:11:38 -0600
commit9e44d5af1d7576b99553305aa7cee53dd0f6ff45 (patch)
treec6c7607f8dcfe1ac59e1e508b6a661d0b3d1f10e
parentbcc4695387d21f9629ab6f013aadbfe0d238aa6d (diff)
downloadmana-9e44d5af1d7576b99553305aa7cee53dd0f6ff45.tar.gz
mana-9e44d5af1d7576b99553305aa7cee53dd0f6ff45.tar.bz2
mana-9e44d5af1d7576b99553305aa7cee53dd0f6ff45.tar.xz
mana-9e44d5af1d7576b99553305aa7cee53dd0f6ff45.zip
Clean up and expand item equip handling in the GUI
-rw-r--r--src/gui/itemcontainer.cpp27
-rw-r--r--src/gui/itemcontainer.h4
-rw-r--r--src/gui/itemshortcutcontainer.cpp14
-rw-r--r--src/gui/palette.cpp4
-rw-r--r--src/gui/palette.h1
-rw-r--r--src/gui/setup_colors.cpp5
-rw-r--r--src/gui/storagewindow.cpp2
7 files changed, 36 insertions, 21 deletions
diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp
index 70cf8176..4dac0b25 100644
--- a/src/gui/itemcontainer.cpp
+++ b/src/gui/itemcontainer.cpp
@@ -50,8 +50,8 @@ static const int BOX_WIDTH = 36;
static const int BOX_HEIGHT = 44;
ItemContainer::ItemContainer(Inventory *inventory,
- int gridColumns,
- int gridRows):
+ int gridColumns, int gridRows,
+ bool forceQuantity):
mInventory(inventory),
mGridColumns(gridColumns),
mGridRows(gridRows),
@@ -59,7 +59,8 @@ ItemContainer::ItemContainer(Inventory *inventory,
mHighlightedItem(NULL),
mSelectionStatus(SEL_NONE),
mSwapItems(false),
- mDescItems(false)
+ mDescItems(false),
+ mForceQuantity(forceQuantity)
{
mItemPopup = new ItemPopup;
setFocusable(true);
@@ -122,15 +123,17 @@ void ItemContainer::draw(gcn::Graphics *graphics)
}
g->drawImage(image, itemX, itemY);
}
- if (item->getQuantity() > 1) {
- // Draw item caption
- g->drawText(
- toString(item->getQuantity()),
- itemX + BOX_WIDTH / 2,
- itemY + BOX_HEIGHT - 14,
- gcn::Graphics::CENTER);
- }
-
+ // Draw item caption
+ std::string caption;
+ if (item->getQuantity() > 1 || mForceQuantity)
+ caption = toString(item->getQuantity());
+ else if (item->isEquipped())
+ caption = "(Eq)";
+
+ if (item->isEquipped())
+ g->setColor(guiPalette->getColor(Palette::ITEM_EQUIPED));
+ g->drawText(caption, itemX + BOX_WIDTH / 2,
+ itemY + BOX_HEIGHT - 14, gcn::Graphics::CENTER);
}
}
diff --git a/src/gui/itemcontainer.h b/src/gui/itemcontainer.h
index b2857563..ba834d01 100644
--- a/src/gui/itemcontainer.h
+++ b/src/gui/itemcontainer.h
@@ -55,7 +55,8 @@ class ItemContainer : public gcn::Widget,
* @param gridRows Amount of rows in grid.
* @param offset Index offset
*/
- ItemContainer(Inventory *inventory, int gridColumns, int gridRows);
+ ItemContainer(Inventory *inventory, int gridColumns, int gridRows,
+ bool forceQuantity = false);
/**
* Destructor.
@@ -169,6 +170,7 @@ class ItemContainer : public gcn::Widget,
Image *mSelImg;
Item *mSelectedItem, *mHighlightedItem;
SelectionState mSelectionStatus;
+ bool mForceQuantity;
bool mSwapItems;
bool mDescItems;
int mDragPosX, mDragPosY;
diff --git a/src/gui/itemshortcutcontainer.cpp b/src/gui/itemshortcutcontainer.cpp
index 62edd1af..f66aa84d 100644
--- a/src/gui/itemshortcutcontainer.cpp
+++ b/src/gui/itemshortcutcontainer.cpp
@@ -39,7 +39,6 @@
#include "resources/resourcemanager.h"
#include "utils/stringutils.h"
-#include "utils/strprintf.h"
ItemShortcutContainer::ItemShortcutContainer():
ShortcutContainer(),
@@ -107,11 +106,16 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics)
if (image)
{
- const std::string label = strprintf("%d%s",
- toString(item->getQuantity()).c_str(),
- item->isEquipped() ? "(Eq)" : "");
+ std::string caption;
+ if (item->getQuantity() > 1)
+ caption = toString(item->getQuantity());
+ else if (item->isEquipped())
+ caption = "(Eq)";
+
g->drawImage(image, itemX, itemY);
- g->drawText(label, itemX + mBoxWidth / 2,
+ if (item->isEquipped())
+ g->setColor(guiPalette->getColor(Palette::ITEM_EQUIPED));
+ g->drawText(caption, itemX + mBoxWidth / 2,
itemY + mBoxHeight - 14, gcn::Graphics::CENTER);
}
}
diff --git a/src/gui/palette.cpp b/src/gui/palette.cpp
index f226d512..5526e802 100644
--- a/src/gui/palette.cpp
+++ b/src/gui/palette.cpp
@@ -89,8 +89,8 @@ Palette::Palette() :
addColor(HIGHLIGHT, 0xebc873, STATIC, _("Highlight"), 'H');
addColor(TAB_HIGHLIGHT, 0xff0000, PULSE, indent + _("Tab Highlight"));
- addColor(SHOP_WARNING, 0x910000, STATIC, indent +
- _("Item too expensive"));
+ addColor(SHOP_WARNING, 0x910000, STATIC, indent + _("Item too expensive"));
+ addColor(ITEM_EQUIPED, 0x000091, STATIC, indent + _("Item is equiped"));
addColor(CHAT, 0x000000, STATIC, _("Chat"), 'C');
addColor(GM, 0xff0000, STATIC, indent + _("GM"), 'G');
diff --git a/src/gui/palette.h b/src/gui/palette.h
index 47863cb0..60f4ca8d 100644
--- a/src/gui/palette.h
+++ b/src/gui/palette.h
@@ -58,6 +58,7 @@ class Palette : public gcn::ListModel
ENTRY(HIGHLIGHT)\
ENTRY(TAB_HIGHLIGHT)\
ENTRY(SHOP_WARNING)\
+ ENTRY(ITEM_EQUIPED)\
ENTRY(CHAT)\
ENTRY(GM)\
ENTRY(PLAYER)\
diff --git a/src/gui/setup_colors.cpp b/src/gui/setup_colors.cpp
index da2cfb6b..fdc2416f 100644
--- a/src/gui/setup_colors.cpp
+++ b/src/gui/setup_colors.cpp
@@ -237,6 +237,11 @@ void Setup_Colors::action(const gcn::ActionEvent &event)
mPreview->addRow(msg);
break;
+ case Palette::ITEM_EQUIPED:
+ mTextPreview->setTextColor(col);
+ mTextPreview->setOutline(false);
+ mTextPreview->setShadow(false);
+ break;
case Palette::UNKNOWN_ITEM:
case Palette::GENERIC:
case Palette::HEAD:
diff --git a/src/gui/storagewindow.cpp b/src/gui/storagewindow.cpp
index 22b28a8f..7daf8045 100644
--- a/src/gui/storagewindow.cpp
+++ b/src/gui/storagewindow.cpp
@@ -64,7 +64,7 @@ StorageWindow::StorageWindow(int invSize):
mStoreButton = new Button(_("Store"), "store", this);
mRetrieveButton = new Button(_("Retrieve"), "retrieve", this);
- mItems = new ItemContainer(player_node->getStorage(), 10, 5);
+ mItems = new ItemContainer(player_node->getStorage(), 10, 30, true);
mItems->addSelectionListener(this);
mInvenScroll = new ScrollArea(mItems);