diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-06-04 22:08:04 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-06-04 22:08:04 +0300 |
commit | a865b10749df829ef46a14e244bc88ac52bc10b4 (patch) | |
tree | 244f283ab8ba6cfcc9683eafe51be7a9d7bbabbe /src/dropshortcut.cpp | |
parent | 9b3e13d4246930f0aa4dfb86e735466032d283dd (diff) | |
download | mv-a865b10749df829ef46a14e244bc88ac52bc10b4.tar.gz mv-a865b10749df829ef46a14e244bc88ac52bc10b4.tar.bz2 mv-a865b10749df829ef46a14e244bc88ac52bc10b4.tar.xz mv-a865b10749df829ef46a14e244bc88ac52bc10b4.zip |
Add colors support for drops panel.
Delete search item function without colors support.
Diffstat (limited to 'src/dropshortcut.cpp')
-rw-r--r-- | src/dropshortcut.cpp | 51 |
1 files changed, 44 insertions, 7 deletions
diff --git a/src/dropshortcut.cpp b/src/dropshortcut.cpp index 189d76b96..c31241409 100644 --- a/src/dropshortcut.cpp +++ b/src/dropshortcut.cpp @@ -41,7 +41,8 @@ DropShortcut *dropShortcut; DropShortcut::DropShortcut(): - mItemSelected(-1) + mItemSelected(-1), + mItemColorSelected(1) { for (int i = 0; i < DROP_SHORTCUT_ITEMS; i++) mItems[i] = -1; @@ -66,9 +67,14 @@ void DropShortcut::load(bool oldConfig) for (int i = 0; i < DROP_SHORTCUT_ITEMS; i++) { int itemId = static_cast<int>(cfg->getValue("drop" + toString(i), -1)); + int itemColor = static_cast<int>( + cfg->getValue("dropColor" + toString(i), -1)); if (itemId != -1) + { mItems[i] = itemId; + mItemColors[i] = itemColor; + } } } @@ -77,10 +83,17 @@ void DropShortcut::save() for (int i = 0; i < DROP_SHORTCUT_ITEMS; i++) { const int itemId = mItems[i] ? mItems[i] : -1; + const int itemColor = mItemColors[i] ? mItemColors[i] : 1; if (itemId != -1) + { serverConfig.setValue("drop" + toString(i), itemId); + serverConfig.setValue("dropColor" + toString(i), itemColor); + } else + { serverConfig.deleteKey("drop" + toString(i)); + serverConfig.deleteKey("dropColor" + toString(i)); + } } } @@ -92,12 +105,12 @@ void DropShortcut::dropFirst() if (!Client::limitPackets(PACKET_DROP)) return; - int itemId; - itemId = getItem(0); + const int itemId = getItem(0); + const int itemColor = getItemColor(0); if (itemId > 0) { - Item *item = PlayerInfo::getInventory()->findItem(itemId); + Item *item = PlayerInfo::getInventory()->findItem(itemId, itemColor); if (item && item->getQuantity()) { if (player_node->isServerBuggy()) @@ -137,14 +150,16 @@ void DropShortcut::dropItems(int cnt) bool DropShortcut::dropItem(int cnt) { int itemId = 0; + unsigned char itemColor = 1; while (mLastDropIndex < DROP_SHORTCUT_ITEMS && itemId < 1) { itemId = getItem(mLastDropIndex); - mLastDropIndex++; + itemColor = getItemColor(mLastDropIndex); + mLastDropIndex ++; } if (itemId > 0) { - Item *item = PlayerInfo::getInventory()->findItem(itemId); + Item *item = PlayerInfo::getInventory()->findItem(itemId, itemColor); if (item && item->getQuantity() > 0) { Net::getInventoryHandler()->dropItem(item, cnt); @@ -159,11 +174,12 @@ bool DropShortcut::dropItem(int cnt) while (mLastDropIndex < DROP_SHORTCUT_ITEMS && itemId < 1) { itemId = getItem(mLastDropIndex); + itemColor = getItemColor(mLastDropIndex); mLastDropIndex++; } if (itemId > 0) { - Item *item = PlayerInfo::getInventory()->findItem(itemId); + Item *item = PlayerInfo::getInventory()->findItem(itemId, itemColor); if (item && item->getQuantity() > 0) { Net::getInventoryHandler()->dropItem(item, cnt); @@ -175,3 +191,24 @@ bool DropShortcut::dropItem(int cnt) } return false; } + +void DropShortcut::setItemSelected(Item *item) +{ + if (item) + { + mItemSelected = item->getId(); + mItemColorSelected = item->getColor(); + } + else + { + mItemSelected = -1; + mItemColorSelected = 1; + } +} + +void DropShortcut::setItem(int index) +{ + mItems[index] = mItemSelected; + mItemColors[index] = mItemColorSelected; + save(); +} |