summaryrefslogtreecommitdiff
path: root/src/gui/windows
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/windows
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/windows')
-rw-r--r--src/gui/windows/buydialog.cpp5
-rw-r--r--src/gui/windows/buydialog.h3
-rw-r--r--src/gui/windows/buyingstoreselldialog.cpp2
-rw-r--r--src/gui/windows/charcreatedialog.cpp9
-rw-r--r--src/gui/windows/itemamountwindow.cpp3
-rw-r--r--src/gui/windows/maileditwindow.cpp3
-rw-r--r--src/gui/windows/mailviewwindow.cpp3
-rw-r--r--src/gui/windows/npcdialog.cpp4
-rw-r--r--src/gui/windows/outfitwindow.cpp11
-rw-r--r--src/gui/windows/outfitwindow.h4
-rw-r--r--src/gui/windows/shopwindow.cpp25
-rw-r--r--src/gui/windows/tradewindow.cpp4
-rw-r--r--src/gui/windows/tradewindow.h5
13 files changed, 48 insertions, 33 deletions
diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp
index 84a7a1182..667867ff4 100644
--- a/src/gui/windows/buydialog.cpp
+++ b/src/gui/windows/buydialog.cpp
@@ -363,7 +363,7 @@ void BuyDialog::reset()
ShopItem *BuyDialog::addItem(const int id,
const int type,
- const unsigned char color,
+ const ItemColor color,
const int amount,
const int price)
{
@@ -493,7 +493,8 @@ void BuyDialog::action(const ActionEvent &event)
if (mNpcId == fromInt(Items, BeingId))
{
adminHandler->createItems(item->getId(),
- mAmountItems, item->getColor());
+ item->getColor(),
+ mAmountItems);
}
else if (mNpcId != fromInt(Nick, BeingId))
{
diff --git a/src/gui/windows/buydialog.h b/src/gui/windows/buydialog.h
index 7aaa1e7c5..104b5c4ee 100644
--- a/src/gui/windows/buydialog.h
+++ b/src/gui/windows/buydialog.h
@@ -24,6 +24,7 @@
#define GUI_WINDOWS_BUYDIALOG_H
#include "enums/simpletypes/beingid.h"
+#include "enums/simpletypes/itemcolor.h"
#include "gui/widgets/window.h"
@@ -105,7 +106,7 @@ class BuyDialog final : public Window,
*/
ShopItem *addItem(const int id,
const int type,
- const unsigned char color,
+ const ItemColor color,
const int amount,
const int price);
diff --git a/src/gui/windows/buyingstoreselldialog.cpp b/src/gui/windows/buyingstoreselldialog.cpp
index 55b6a96fb..637bdc5bd 100644
--- a/src/gui/windows/buyingstoreselldialog.cpp
+++ b/src/gui/windows/buyingstoreselldialog.cpp
@@ -58,7 +58,7 @@ void BuyingStoreSellDialog::sellAction(const ActionEvent &event A_UNUSED)
return;
// +++ need add colors
Item *const item2 = PlayerInfo::getInventory()->findItem(
- item1->getId(), 1);
+ item1->getId(), ItemColor_one);
if (!item2)
return;
diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp
index 2168ad0a1..6af4a6437 100644
--- a/src/gui/windows/charcreatedialog.cpp
+++ b/src/gui/windows/charcreatedialog.cpp
@@ -624,11 +624,13 @@ void CharCreateDialog::updateHair()
{
mHairColor = minHairColor;
}
- mHairColorNameLabel->setCaption(ColorDB::getHairColorName(mHairColor));
+ mHairColorNameLabel->setCaption(ColorDB::getHairColorName(
+ fromInt(mHairColor, ItemColor)));
mHairColorNameLabel->resizeTo(150, 150);
mPlayer->setSprite(charServerHandler->hairSprite(),
- mHairStyle * -1, item.getDyeColorsString(mHairColor));
+ mHairStyle * -1,
+ item.getDyeColorsString(fromInt(mHairColor, ItemColor)));
}
void CharCreateDialog::updateRace()
@@ -667,7 +669,8 @@ void CharCreateDialog::updateLook()
}
if (mLookNameLabel)
{
- mLookNameLabel->setCaption(item.getColorName(mLook));
+ mLookNameLabel->setCaption(item.getColorName(
+ fromInt(mLook, ItemColor)));
mLookNameLabel->resizeTo(150, 150);
}
}
diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp
index b1c10f058..a48a6dab2 100644
--- a/src/gui/windows/itemamountwindow.cpp
+++ b/src/gui/windows/itemamountwindow.cpp
@@ -355,7 +355,8 @@ void ItemAmountWindow::action(const ActionEvent &event)
const int id = ItemDB::get(mItemsModal->getElementAt(
mItemDropDown->getSelected())).getId();
- mItem = new Item(id, 0, 10000, 0, 1,
+ mItem = new Item(id, 0, 10000, 0,
+ ItemColor_one,
Identified_true,
Damaged_true,
Favorite_false,
diff --git a/src/gui/windows/maileditwindow.cpp b/src/gui/windows/maileditwindow.cpp
index 1699b979c..51495563d 100644
--- a/src/gui/windows/maileditwindow.cpp
+++ b/src/gui/windows/maileditwindow.cpp
@@ -138,7 +138,8 @@ void MailEditWindow::action(const ActionEvent &event)
const Inventory *const inv = PlayerInfo::getInventory();
if (inv)
{
- const Item *const item = inv->findItem(tempItem->getId(), 1);
+ const Item *const item = inv->findItem(
+ tempItem->getId(), ItemColor_one);
if (item)
{
mailHandler->setAttach(item->getInvIndex(),
diff --git a/src/gui/windows/mailviewwindow.cpp b/src/gui/windows/mailviewwindow.cpp
index 544c80f0d..ad7eb8a88 100644
--- a/src/gui/windows/mailviewwindow.cpp
+++ b/src/gui/windows/mailviewwindow.cpp
@@ -111,7 +111,8 @@ MailViewWindow::MailViewWindow(const MailMessage *const message) :
const ItemInfo &item = ItemDB::get(message->itemId);
Image *const image = resman->getImage(combineDye2(
paths.getStringValue("itemIcons").append(
- item.getDisplay().image), item.getDyeColorsString(1)));
+ item.getDisplay().image),
+ item.getDyeColorsString(ItemColor_one)));
mIcon = new Icon(this, image);
if (message->itemAmount != 1)
diff --git a/src/gui/windows/npcdialog.cpp b/src/gui/windows/npcdialog.cpp
index 10eb3dc8a..c0396bc06 100644
--- a/src/gui/windows/npcdialog.cpp
+++ b/src/gui/windows/npcdialog.cpp
@@ -369,7 +369,7 @@ void NpcDialog::action(const ActionEvent &event)
if (item)
{
str = strprintf("%d,%d", item->getId(),
- item->getColor());
+ toInt(item->getColor(), int));
}
else
{
@@ -382,7 +382,7 @@ void NpcDialog::action(const ActionEvent &event)
if (item)
{
str.append(strprintf("%d,%d", item->getId(),
- item->getColor()));
+ toInt(item->getColor(), int)));
}
else
{
diff --git a/src/gui/windows/outfitwindow.cpp b/src/gui/windows/outfitwindow.cpp
index a0a7fa7c2..7ce43333b 100644
--- a/src/gui/windows/outfitwindow.cpp
+++ b/src/gui/windows/outfitwindow.cpp
@@ -172,7 +172,7 @@ void OutfitWindow::load(const bool oldConfig)
for (size_t i = 0, sz = tokens2.size();
i < sz && i < OUTFIT_ITEM_COUNT; i++)
{
- mItemColors[o][i] = tokens2[i];
+ mItemColors[o][i] = fromInt(tokens2[i], ItemColor);
}
mItemsUnequip[o] = cfg->getValueBool("OutfitUnequip" + toString(o),
@@ -203,7 +203,7 @@ void OutfitWindow::save() const
if (i < OUTFIT_ITEM_COUNT - 1)
outfitStr.append(" ");
outfitColorsStr.append(toString(static_cast<int>(
- mItemColors[o][i])));
+ toInt(mItemColors[o][i], int))));
if (i < OUTFIT_ITEM_COUNT - 1)
outfitColorsStr.append(" ");
}
@@ -278,7 +278,8 @@ void OutfitWindow::wearOutfit(const int outfit, const bool unwearEmpty,
for (unsigned i = 0; i < OUTFIT_ITEM_COUNT; i++)
{
const Item *const item = PlayerInfo::getInventory()->findItem(
- mItems[outfit][i], mItemColors[outfit][i]);
+ mItems[outfit][i],
+ mItemColors[outfit][i]);
if (item
&& item->isEquipped() == Equipped_false
&& item->getQuantity())
@@ -453,7 +454,7 @@ void OutfitWindow::mouseDragged(MouseEvent &event)
return;
}
const int itemId = mItems[mCurrentOutfit][index];
- const unsigned char itemColor = mItemColors[mCurrentOutfit][index];
+ const ItemColor itemColor = mItemColors[mCurrentOutfit][index];
if (itemId < 0)
{
Window::mouseDragged(event);
@@ -719,7 +720,7 @@ void OutfitWindow::clearCurrentOutfit()
for (unsigned f = 0; f < OUTFIT_ITEM_COUNT; f++)
{
mItems[mCurrentOutfit][f] = -1;
- mItemColors[mCurrentOutfit][f] = 1;
+ mItemColors[mCurrentOutfit][f] = ItemColor_one;
}
save();
}
diff --git a/src/gui/windows/outfitwindow.h b/src/gui/windows/outfitwindow.h
index 7033a3f13..27a3d73aa 100644
--- a/src/gui/windows/outfitwindow.h
+++ b/src/gui/windows/outfitwindow.h
@@ -23,6 +23,8 @@
#ifndef GUI_WINDOWS_OUTFITWINDOW_H
#define GUI_WINDOWS_OUTFITWINDOW_H
+#include "enums/simpletypes/itemcolor.h"
+
#include "gui/widgets/window.h"
#include "listeners/actionlistener.h"
@@ -119,7 +121,7 @@ class OutfitWindow final : public Window,
int mItems[OUTFITS_COUNT + 1][OUTFIT_ITEM_COUNT];
int mAwayOutfit;
- unsigned char mItemColors[OUTFITS_COUNT + 1][OUTFIT_ITEM_COUNT];
+ ItemColor mItemColors[OUTFITS_COUNT + 1][OUTFIT_ITEM_COUNT];
bool mItemClicked;
bool mItemsUnequip[OUTFITS_COUNT];
};
diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp
index b8e31ead8..c5014f902 100644
--- a/src/gui/windows/shopwindow.cpp
+++ b/src/gui/windows/shopwindow.cpp
@@ -348,7 +348,8 @@ void ShopWindow::action(const ActionEvent &event)
if (!item)
continue;
// +++ need add colors
- Item *const cartItem = inv->findItem(item->getId(), 1);
+ Item *const cartItem = inv->findItem(item->getId(),
+ ItemColor_one);
if (!cartItem)
continue;
item->setInvIndex(cartItem->getInvIndex());
@@ -391,7 +392,7 @@ void ShopWindow::action(const ActionEvent &event)
return;
// +++ need support for colors
- Item *const item = inv->findItem(mSelectedItem, 0);
+ Item *const item = inv->findItem(mSelectedItem, ItemColor_zero);
if (item)
{
if (eventId == "add")
@@ -551,12 +552,12 @@ void ShopWindow::loadList()
if (tokens[1] && tokens[2] && mBuyShopItems)
{
mBuyShopItems->addItem(
- tokens[0], 0, 1, tokens[1], tokens[2]);
+ tokens[0], 0, ItemColor_one, tokens[1], tokens[2]);
}
if (tokens[3] && tokens[4] && mSellShopItems)
{
mSellShopItems->addItem(
- tokens[0], 0, 1, tokens[3], tokens[4]);
+ tokens[0], 0, ItemColor_one, tokens[3], tokens[4]);
}
}
}
@@ -748,7 +749,8 @@ void ShopWindow::giveList(const std::string &nick, const int mode)
if (mode == SELL)
{
// +++ need support for colors
- const Item *const item2 = inv->findItem(item->getId(), 0);
+ const Item *const item2 = inv->findItem(item->getId(),
+ ItemColor_zero);
if (item2)
{
int amount = item->getQuantity();
@@ -844,19 +846,19 @@ void ShopWindow::showList(const std::string &nick, std::string data)
int amount = decodeStr(data.substr(f + 6, 3));
// +++ need impliment colors?
if (buyDialog && amount > 0)
- buyDialog->addItem(id, 0, 1, amount, price);
+ buyDialog->addItem(id, 0, ItemColor_one, amount, price);
if (sellDialog)
{
// +++ need support for colors
- const Item *const item = inv->findItem(id, 0);
+ const Item *const item = inv->findItem(id, ItemColor_zero);
if (item)
{
if (item->getQuantity() < amount)
amount = item->getQuantity();
if (amount > 0)
- sellDialog->addItem(id, 0, 1, amount, price);
+ sellDialog->addItem(id, 0, ItemColor_one, amount, price);
else
- sellDialog->addItem(id, 0, 1, -1, price);
+ sellDialog->addItem(id, 0, ItemColor_one, -1, price);
}
}
}
@@ -919,12 +921,13 @@ void ShopWindow::processRequest(const std::string &nick, std::string data,
delete mTradeItem;
// +++ need impliment colors?
- mTradeItem = new ShopItem(-1, id, 0, 1, amount, price);
+ mTradeItem = new ShopItem(-1, id, 0, ItemColor_one, amount, price);
if (mode == BUY)
{
// +++ need support for colors
- const Item *const item2 = inv->findItem(mTradeItem->getId(), 0);
+ const Item *const item2 = inv->findItem(mTradeItem->getId(),
+ ItemColor_zero);
if (!item2 || item2->getQuantity() < amount
|| !findShopItem(mTradeItem, SELL))
{
diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp
index bf4963daf..7a835b686 100644
--- a/src/gui/windows/tradewindow.cpp
+++ b/src/gui/windows/tradewindow.cpp
@@ -196,7 +196,7 @@ void TradeWindow::addItem(const int id,
const bool own,
const int quantity,
const uint8_t refine,
- const unsigned char color,
+ const ItemColor color,
const Identified identified,
const Damaged damaged,
const Favorite favorite) const
@@ -221,7 +221,7 @@ void TradeWindow::addItem2(const int id,
const bool own,
const int quantity,
const uint8_t refine,
- const unsigned char color,
+ const ItemColor color,
const Identified identified,
const Damaged damaged,
const Favorite favorite,
diff --git a/src/gui/windows/tradewindow.h b/src/gui/windows/tradewindow.h
index a191671d5..b1ac84045 100644
--- a/src/gui/windows/tradewindow.h
+++ b/src/gui/windows/tradewindow.h
@@ -29,6 +29,7 @@
#include "enums/simpletypes/equipm.h"
#include "enums/simpletypes/favorite.h"
#include "enums/simpletypes/identified.h"
+#include "enums/simpletypes/itemcolor.h"
#include "listeners/actionlistener.h"
#include "listeners/selectionlistener.h"
@@ -75,7 +76,7 @@ class TradeWindow final : public Window,
const bool own,
const int quantity,
const uint8_t refine,
- const unsigned char color,
+ const ItemColor color,
const Identified identified,
const Damaged damaged,
const Favorite favorite) const;
@@ -95,7 +96,7 @@ class TradeWindow final : public Window,
const bool own,
const int quantity,
const uint8_t refine,
- const unsigned char color,
+ const ItemColor color,
const Identified identified,
const Damaged damaged,
const Favorite favorite,