summaryrefslogtreecommitdiff
path: root/src/gui/popups
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-08-15 13:58:32 +0300
committerAndrei Karas <akaras@inbox.ru>2015-08-16 01:52:14 +0300
commit41cc92f73e39cec5dfea6b1164176610cccc7df4 (patch)
tree22fd3d388084d2c61fe80f0441c3c30ab8ffd33c /src/gui/popups
parent7aa637abc8b0bca35aacdb9492e65f557ed32038 (diff)
downloadmanaplus-41cc92f73e39cec5dfea6b1164176610cccc7df4.tar.gz
manaplus-41cc92f73e39cec5dfea6b1164176610cccc7df4.tar.bz2
manaplus-41cc92f73e39cec5dfea6b1164176610cccc7df4.tar.xz
manaplus-41cc92f73e39cec5dfea6b1164176610cccc7df4.zip
Add strong typed int for item color.
Diffstat (limited to 'src/gui/popups')
-rw-r--r--src/gui/popups/itempopup.cpp6
-rw-r--r--src/gui/popups/itempopup.h6
-rw-r--r--src/gui/popups/popupmenu.cpp19
-rw-r--r--src/gui/popups/popupmenu.h8
4 files changed, 23 insertions, 16 deletions
diff --git a/src/gui/popups/itempopup.cpp b/src/gui/popups/itempopup.cpp
index 33b2eba91..ceb32cdaf 100644
--- a/src/gui/popups/itempopup.cpp
+++ b/src/gui/popups/itempopup.cpp
@@ -58,7 +58,7 @@ ItemPopup::ItemPopup() :
mIcon(new Icon(this, nullptr)),
mLastName(),
mLastId(0),
- mLastColor(1)
+ mLastColor(ItemColor_one)
{
// Item name
mItemName->setFont(boldFont);
@@ -153,7 +153,7 @@ void ItemPopup::setItem(const Item *const item,
}
void ItemPopup::setItem(const ItemInfo &item,
- const unsigned char color,
+ const ItemColor color,
const bool showImage,
int id,
const int *const cards)
@@ -336,6 +336,6 @@ void ItemPopup::mouseMoved(MouseEvent &event)
void ItemPopup::resetPopup()
{
mLastName.clear();
- mLastColor = 1;
+ mLastColor = ItemColor_one;
mLastId = 0;
}
diff --git a/src/gui/popups/itempopup.h b/src/gui/popups/itempopup.h
index fb3feefa2..a66262473 100644
--- a/src/gui/popups/itempopup.h
+++ b/src/gui/popups/itempopup.h
@@ -24,6 +24,8 @@
#ifndef GUI_POPUPS_ITEMPOPUP_H
#define GUI_POPUPS_ITEMPOPUP_H
+#include "enums/simpletypes/itemcolor.h"
+
#include "gui/widgets/popup.h"
#include "resources/itemtype.h"
@@ -58,7 +60,7 @@ class ItemPopup final : public Popup
* Sets the info to be displayed given a particular item.
*/
void setItem(const ItemInfo &item,
- const unsigned char color,
+ const ItemColor color,
const bool showImage,
int id,
const int *const cards);
@@ -82,7 +84,7 @@ class ItemPopup final : public Popup
Icon *mIcon;
std::string mLastName;
int mLastId;
- unsigned char mLastColor;
+ ItemColor mLastColor;
void setLabelColor(Label *label,
const ItemType::Type type) const A_NONNULL(2);
diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp
index 9adcc7b58..71a6d81d5 100644
--- a/src/gui/popups/popupmenu.cpp
+++ b/src/gui/popups/popupmenu.cpp
@@ -105,7 +105,7 @@ PopupMenu::PopupMenu() :
mFloorItemId(BeingId_zero),
mItem(nullptr),
mItemId(0),
- mItemColor(1),
+ mItemColor(ItemColor_one),
mMapItem(nullptr),
mTab(nullptr),
mSpell(nullptr),
@@ -1558,7 +1558,7 @@ void PopupMenu::handleLink(const std::string &link,
replaceAll(cmd, "'BEINGID'", toString(toInt(mBeingId, int)));
replaceAll(cmd, "'FLOORID'", toString(toInt(mFloorItemId, int)));
replaceAll(cmd, "'ITEMID'", toString(mItemId));
- replaceAll(cmd, "'ITEMCOLOR'", toString(mItemColor));
+ replaceAll(cmd, "'ITEMCOLOR'", toString(toInt(mItemColor, int)));
replaceAll(cmd, "'BEINGTYPEID'", toString(static_cast<int>(mType)));
replaceAll(cmd, "'PLAYER'", localPlayer->getName());
if (mItem)
@@ -1594,7 +1594,7 @@ void PopupMenu::handleLink(const std::string &link,
mFloorItemId = BeingId_zero;
mItem = nullptr;
mItemId = 0;
- mItemColor = 1;
+ mItemColor = ItemColor_one;
mMapItem = nullptr;
mTab = nullptr;
mSpell = nullptr;
@@ -1751,8 +1751,9 @@ void PopupMenu::showPopup(Window *const parent,
showPopup(x, y);
}
-void PopupMenu::showItemPopup(const int x, const int y, const int itemId,
- const unsigned char color)
+void PopupMenu::showItemPopup(const int x, const int y,
+ const int itemId,
+ const ItemColor color)
{
const Inventory *const inv = PlayerInfo::getInventory();
if (!inv)
@@ -1788,7 +1789,8 @@ void PopupMenu::showItemPopup(const int x, const int y, const int itemId,
}
}
-void PopupMenu::showItemPopup(const int x, const int y, Item *const item)
+void PopupMenu::showItemPopup(const int x, const int y,
+ Item *const item)
{
mItem = item;
mX = x;
@@ -1801,7 +1803,7 @@ void PopupMenu::showItemPopup(const int x, const int y, Item *const item)
else
{
mItemId = 0;
- mItemColor = 1;
+ mItemColor = ItemColor_one;
}
mNick.clear();
mBrowserBox->clearRows();
@@ -2103,7 +2105,8 @@ void PopupMenu::showPickupItemPopup(const int x, const int y,
}
void PopupMenu::showUndressPopup(const int x, const int y,
- const Being *const being, Item *const item)
+ const Being *const being,
+ Item *const item)
{
if (!being || !item)
return;
diff --git a/src/gui/popups/popupmenu.h b/src/gui/popups/popupmenu.h
index 727818317..3952178f2 100644
--- a/src/gui/popups/popupmenu.h
+++ b/src/gui/popups/popupmenu.h
@@ -28,6 +28,7 @@
#include "enums/inventorytype.h"
#include "enums/simpletypes/beingid.h"
+#include "enums/simpletypes/itemcolor.h"
#include "gui/widgets/linkhandler.h"
#include "gui/widgets/popup.h"
@@ -105,8 +106,9 @@ class PopupMenu final : public Popup, public LinkHandler
void showItemPopup(const int x, const int y, Item *const item);
- void showItemPopup(const int x, const int y, const int itemId,
- const unsigned char color);
+ void showItemPopup(const int x, const int y,
+ const int itemId,
+ const ItemColor color);
void showDropPopup(const int x, const int y, Item *const item);
@@ -208,7 +210,7 @@ class PopupMenu final : public Popup, public LinkHandler
BeingId mFloorItemId;
Item *mItem;
int mItemId;
- unsigned char mItemColor;
+ ItemColor mItemColor;
MapItem *mMapItem;
ChatTab *mTab;
TextCommand *mSpell;