summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-02-03 13:07:57 +0300
committerAndrei Karas <akaras@inbox.ru>2013-02-03 13:07:57 +0300
commitca4582756ce9ad0c4f4222da0760bd6ccffc829a (patch)
tree3d65b06b31aadf18f59bce4e0802945158a52950 /src
parentab4a00c231e84267c7d06b2b1bb167593f22d91f (diff)
downloadmv-ca4582756ce9ad0c4f4222da0760bd6ccffc829a.tar.gz
mv-ca4582756ce9ad0c4f4222da0760bd6ccffc829a.tar.bz2
mv-ca4582756ce9ad0c4f4222da0760bd6ccffc829a.tar.xz
mv-ca4582756ce9ad0c4f4222da0760bd6ccffc829a.zip
Fix inventory sorting.
Was broken because conflict with buy dialog sorting.
Diffstat (limited to 'src')
-rw-r--r--src/actorspritemanager.cpp54
-rw-r--r--src/gui/buydialog.cpp46
-rw-r--r--src/gui/buydialog.h4
-rw-r--r--src/gui/inventorywindow.cpp10
-rw-r--r--src/gui/inventorywindow.h4
-rw-r--r--src/gui/widgets/itemcontainer.cpp32
-rw-r--r--src/inputmanager.cpp6
-rw-r--r--src/playerrelations.cpp8
8 files changed, 83 insertions, 81 deletions
diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp
index af73ad897..7cae07a5b 100644
--- a/src/actorspritemanager.cpp
+++ b/src/actorspritemanager.cpp
@@ -51,7 +51,7 @@
#define for_actors for (ActorSpritesConstIterator it = mActors.begin(), \
it_end = mActors.end() ; it != it_end; ++it)
-static class FindBeingFunctor final
+class FindBeingFunctor final
{
public:
bool operator() (const ActorSprite *const actor) const
@@ -75,9 +75,9 @@ static class FindBeingFunctor final
uint16_t x, y;
ActorSprite::Type type;
-} beingFinder;
+} beingActorFinder;
-static class FindBeingEqualFunctor final
+class FindBeingEqualFunctor final
{
public:
bool operator() (const Being *const being) const
@@ -88,9 +88,9 @@ static class FindBeingEqualFunctor final
}
Being *findBeing;
-} beingEqualFinder;
+} beingEqualActorFinder;
-static class SortBeingFunctor final
+class SortBeingFunctor final
{
public:
bool operator() (const Being *const being1,
@@ -178,7 +178,7 @@ static class SortBeingFunctor final
int defaultPriorityIndex;
bool specialDistance;
int attackRange;
-} beingSorter;
+} beingActorSorter;
ActorSpriteManager::ActorSpriteManager() :
mMap(nullptr),
@@ -301,12 +301,12 @@ Being *ActorSpriteManager::findBeing(const int id) const
Being *ActorSpriteManager::findBeing(const int x, const int y,
const ActorSprite::Type type) const
{
- beingFinder.x = static_cast<uint16_t>(x);
- beingFinder.y = static_cast<uint16_t>(y);
- beingFinder.type = type;
+ beingActorFinder.x = static_cast<uint16_t>(x);
+ beingActorFinder.y = static_cast<uint16_t>(y);
+ beingActorFinder.type = type;
const ActorSpritesConstIterator it = std::find_if(
- mActors.begin(), mActors.end(), beingFinder);
+ mActors.begin(), mActors.end(), beingActorFinder);
return (it == mActors.end()) ? nullptr : static_cast<Being*>(*it);
}
@@ -880,10 +880,10 @@ Being *ActorSpriteManager::findNearestLivingBeing(const Being *const
ignoreAttackMobs = mIgnoreAttackMobsSet;
attackMobsMap = mAttackMobsMap;
priorityMobsMap = mPriorityAttackMobsMap;
- beingSorter.attackBeings = &attackMobsMap;
- beingSorter.priorityBeings = &priorityMobsMap;
- beingSorter.specialDistance = specialDistance;
- beingSorter.attackRange = attackRange;
+ beingActorSorter.attackBeings = &attackMobsMap;
+ beingActorSorter.priorityBeings = &priorityMobsMap;
+ beingActorSorter.specialDistance = specialDistance;
+ beingActorSorter.attackRange = attackRange;
if (ignoreAttackMobs.find("") != ignoreAttackMobs.end())
ignoreDefault = true;
std::map<std::string, int>::const_iterator
@@ -941,25 +941,25 @@ Being *ActorSpriteManager::findNearestLivingBeing(const Being *const
if (sortedBeings.empty())
return nullptr;
- beingSorter.x = x;
- beingSorter.y = y;
+ beingActorSorter.x = x;
+ beingActorSorter.y = y;
if (filtered)
{
- beingSorter.attackBeings = &attackMobsMap;
- beingSorter.defaultAttackIndex = defaultAttackIndex;
- beingSorter.priorityBeings = &priorityMobsMap;
- beingSorter.defaultPriorityIndex = defaultPriorityIndex;
+ beingActorSorter.attackBeings = &attackMobsMap;
+ beingActorSorter.defaultAttackIndex = defaultAttackIndex;
+ beingActorSorter.priorityBeings = &priorityMobsMap;
+ beingActorSorter.defaultPriorityIndex = defaultPriorityIndex;
}
else
{
- beingSorter.attackBeings = nullptr;
- beingSorter.priorityBeings = nullptr;
+ beingActorSorter.attackBeings = nullptr;
+ beingActorSorter.priorityBeings = nullptr;
}
- std::sort(sortedBeings.begin(), sortedBeings.end(), beingSorter);
+ std::sort(sortedBeings.begin(), sortedBeings.end(), beingActorSorter);
if (filtered)
{
- beingSorter.attackBeings = nullptr;
- beingSorter.priorityBeings = nullptr;
+ beingActorSorter.attackBeings = nullptr;
+ beingActorSorter.priorityBeings = nullptr;
}
if (player_node->getTarget() == nullptr)
@@ -975,9 +975,9 @@ Being *ActorSpriteManager::findNearestLivingBeing(const Being *const
return target;
}
- beingEqualFinder.findBeing = player_node->getTarget();
+ beingEqualActorFinder.findBeing = player_node->getTarget();
std::vector<Being*>::const_iterator i = std::find_if(
- sortedBeings.begin(), sortedBeings.end(), beingEqualFinder);
+ sortedBeings.begin(), sortedBeings.end(), beingEqualActorFinder);
if (i == sortedBeings.end() || ++i == sortedBeings.end())
{
diff --git a/src/gui/buydialog.cpp b/src/gui/buydialog.cpp
index 2fc49d240..404a126b7 100644
--- a/src/gui/buydialog.cpp
+++ b/src/gui/buydialog.cpp
@@ -49,7 +49,7 @@
#include "debug.h"
-static const char *SORT_NAME[7] =
+static const char *SORT_NAME_BUY[7] =
{
N_("unsorted"),
N_("by price"),
@@ -60,10 +60,10 @@ static const char *SORT_NAME[7] =
N_("by type")
};
-class SortListModel final : public gcn::ListModel
+class SortListModelBuy final : public gcn::ListModel
{
public:
- virtual ~SortListModel()
+ virtual ~SortListModelBuy()
{ }
virtual int getNumberOfElements()
@@ -74,11 +74,11 @@ public:
if (i >= getNumberOfElements() || i < 0)
return _("???");
- return gettext(SORT_NAME[i]);
+ return gettext(SORT_NAME_BUY[i]);
}
};
-static class SortItemPriceFunctor final
+class SortItemPriceFunctor final
{
public:
bool operator() (const ShopItem *const item1,
@@ -93,9 +93,9 @@ static class SortItemPriceFunctor final
return item1->getDisplayName() < item2->getDisplayName();
return price1 < price2;
}
-} itemPriceSorter;
+} itemPriceBuySorter;
-static class SortItemNameFunctor final
+class SortItemNameFunctor final
{
public:
bool operator() (const ShopItem *const item1,
@@ -110,9 +110,9 @@ static class SortItemNameFunctor final
return item1->getPrice() < item2->getPrice();
return name1 < name2;
}
-} itemNameSorter;
+} itemNameBuySorter;
-static class SortItemIdFunctor final
+class SortItemIdFunctor final
{
public:
bool operator() (const ShopItem *const item1,
@@ -127,9 +127,9 @@ static class SortItemIdFunctor final
return item1->getPrice() < item2->getPrice();
return id1 < id2;
}
-} itemIdSorter;
+} itemIdBuySorter;
-static class SortItemWeightFunctor final
+class SortItemWeightFunctor final
{
public:
bool operator() (const ShopItem *const item1,
@@ -144,9 +144,9 @@ static class SortItemWeightFunctor final
return item1->getPrice() < item2->getPrice();
return weight1 < weight2;
}
-} itemWeightSorter;
+} itemWeightBuySorter;
-static class SortItemAmountFunctor final
+class SortItemAmountFunctor final
{
public:
bool operator() (const ShopItem *const item1,
@@ -161,9 +161,9 @@ static class SortItemAmountFunctor final
return item1->getPrice() < item2->getPrice();
return amount1 < amount2;
}
-} itemAmountSorter;
+} itemAmountBuySorter;
-static class SortItemTypeFunctor final
+class SortItemTypeFunctor final
{
public:
bool operator() (const ShopItem *const item1,
@@ -178,7 +178,7 @@ static class SortItemTypeFunctor final
return item1->getPrice() < item2->getPrice();
return type1 < type2;
}
-} itemTypeSorter;
+} itemTypeBuySorter;
BuyDialog::DialogList BuyDialog::instances;
@@ -198,7 +198,7 @@ BuyDialog::BuyDialog(std::string nick) :
gcn::ActionListener(),
gcn::SelectionListener(),
mNpcId(-1), mMoney(0), mAmountItems(0), mMaxItems(0), mNick(nick),
- mSortModel(new SortListModel),
+ mSortModel(new SortListModelBuy),
mSortDropDown(new DropDown(this, mSortModel, false, false, this, "sort"))
{
init();
@@ -345,22 +345,22 @@ void BuyDialog::action(const gcn::ActionEvent &event)
switch (mSortDropDown->getSelected())
{
case 1:
- std::sort(items.begin(), items.end(), itemPriceSorter);
+ std::sort(items.begin(), items.end(), itemPriceBuySorter);
break;
case 2:
- std::sort(items.begin(), items.end(), itemNameSorter);
+ std::sort(items.begin(), items.end(), itemNameBuySorter);
break;
case 3:
- std::sort(items.begin(), items.end(), itemIdSorter);
+ std::sort(items.begin(), items.end(), itemIdBuySorter);
break;
case 4:
- std::sort(items.begin(), items.end(), itemWeightSorter);
+ std::sort(items.begin(), items.end(), itemWeightBuySorter);
break;
case 5:
- std::sort(items.begin(), items.end(), itemAmountSorter);
+ std::sort(items.begin(), items.end(), itemAmountBuySorter);
break;
case 6:
- std::sort(items.begin(), items.end(), itemTypeSorter);
+ std::sort(items.begin(), items.end(), itemTypeBuySorter);
break;
case 0:
default:
diff --git a/src/gui/buydialog.h b/src/gui/buydialog.h
index 76910f247..9d6bf447c 100644
--- a/src/gui/buydialog.h
+++ b/src/gui/buydialog.h
@@ -32,7 +32,7 @@ class Button;
class DropDown;
class ShopItems;
class ShopListBox;
-class SortListModel;
+class SortListModelBuy;
class IntTextField;
class Label;
class ListBox;
@@ -147,7 +147,7 @@ class BuyDialog final : public Window,
int mAmountItems;
int mMaxItems;
std::string mNick;
- SortListModel *mSortModel;
+ SortListModelBuy *mSortModel;
DropDown *mSortDropDown;
};
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index 19043510a..5223e033a 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -58,7 +58,7 @@
#include "debug.h"
-static const char *SORT_NAME[6] =
+static const char *SORT_NAME_INVENTORY[6] =
{
N_("default"),
N_("by name"),
@@ -68,10 +68,10 @@ static const char *SORT_NAME[6] =
N_("by type")
};
-class SortListModel final : public gcn::ListModel
+class SortListModelInv final : public gcn::ListModel
{
public:
- virtual ~SortListModel()
+ virtual ~SortListModelInv()
{ }
virtual int getNumberOfElements()
@@ -82,7 +82,7 @@ public:
if (i >= getNumberOfElements() || i < 0)
return _("???");
- return gettext(SORT_NAME[i]);
+ return gettext(SORT_NAME_INVENTORY[i]);
}
};
@@ -107,7 +107,7 @@ InventoryWindow::InventoryWindow(Inventory *const inventory):
mWeightBar(nullptr),
mSlotsBar(new ProgressBar(this, 0.0f, 100, 0, Theme::PROG_INVY_SLOTS)),
mFilter(nullptr),
- mSortModel(new SortListModel),
+ mSortModel(new SortListModelInv),
mSortDropDown(new DropDown(this, mSortModel, false, false, this, "sort")),
mNameFilter(new TextField(this, "", true, this, "namefilter", true)),
mSortDropDownCell(nullptr),
diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h
index ad40bb5df..b6bcbd304 100644
--- a/src/gui/inventorywindow.h
+++ b/src/gui/inventorywindow.h
@@ -42,7 +42,7 @@ class ItemContainer;
class Label;
class LayoutCell;
class ProgressBar;
-class SortListModel;
+class SortListModelInv;
class TabStrip;
class TextField;
@@ -174,7 +174,7 @@ class InventoryWindow final : public Window,
ProgressBar *mWeightBar;
ProgressBar *mSlotsBar;
TabStrip *mFilter;
- SortListModel *mSortModel;
+ SortListModelInv *mSortModel;
DropDown *mSortDropDown;
TextField *mNameFilter;
LayoutCell *mSortDropDownCell;
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index 70c938559..b677ce83a 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -62,7 +62,7 @@ class ItemIdPair final
Item* mItem;
};
-static class SortItemAlphaFunctor final
+class SortItemAlphaFunctor final
{
public:
bool operator() (const ItemIdPair *const pair1,
@@ -74,9 +74,9 @@ static class SortItemAlphaFunctor final
return (pair1->mItem->getInfo().getName()
< pair2->mItem->getInfo().getName());
}
-} itemAlphaSorter;
+} itemAlphaInvSorter;
-static class SortItemIdFunctor final
+class SortItemIdFunctor final
{
public:
bool operator() (const ItemIdPair *const pair1,
@@ -87,9 +87,9 @@ static class SortItemIdFunctor final
return pair1->mItem->getId() < pair2->mItem->getId();
}
-} itemIdSorter;
+} itemIdInvSorter;
-static class SortItemWeightFunctor final
+class SortItemWeightFunctor final
{
public:
bool operator() (const ItemIdPair *const pair1,
@@ -107,9 +107,9 @@ static class SortItemWeightFunctor final
}
return w1 < w2;
}
-} itemWeightSorter;
+} itemWeightInvSorter;
-static class SortItemAmountFunctor final
+class SortItemAmountFunctor final
{
public:
bool operator() (const ItemIdPair *const pair1,
@@ -127,9 +127,9 @@ static class SortItemAmountFunctor final
}
return c1 < c2;
}
-} itemAmountSorter;
+} itemAmountInvSorter;
-static class SortItemTypeFunctor final
+class SortItemTypeFunctor final
{
public:
bool operator() (const ItemIdPair *const pair1,
@@ -147,7 +147,7 @@ static class SortItemTypeFunctor final
}
return t1 < t2;
}
-} itemTypeSorter;
+} itemTypeInvSorter;
ItemContainer::ItemContainer(const Widget2 *const widget,
Inventory *const inventory,
@@ -554,21 +554,23 @@ void ItemContainer::updateMatrix()
default:
break;
case 1:
- std::sort(sortedItems.begin(), sortedItems.end(), itemAlphaSorter);
+ std::sort(sortedItems.begin(), sortedItems.end(),
+ itemAlphaInvSorter);
break;
case 2:
- std::sort(sortedItems.begin(), sortedItems.end(), itemIdSorter);
+ std::sort(sortedItems.begin(), sortedItems.end(), itemIdInvSorter);
break;
case 3:
std::sort(sortedItems.begin(), sortedItems.end(),
- itemWeightSorter);
+ itemWeightInvSorter);
break;
case 4:
std::sort(sortedItems.begin(), sortedItems.end(),
- itemAmountSorter);
+ itemAmountInvSorter);
break;
case 5:
- std::sort(sortedItems.begin(), sortedItems.end(), itemTypeSorter);
+ std::sort(sortedItems.begin(), sortedItems.end(),
+ itemTypeInvSorter);
break;
}
diff --git a/src/inputmanager.cpp b/src/inputmanager.cpp
index 314b866e8..c011784ba 100644
--- a/src/inputmanager.cpp
+++ b/src/inputmanager.cpp
@@ -61,7 +61,7 @@ static class KeyFunctor final
const KeyData *keys;
-} keySorter;
+} keyDataSorter;
InputManager::InputManager() :
@@ -664,12 +664,12 @@ void InputManager::updateKeyActionMap(KeyToActionMap &actionMap,
}
}
- keySorter.keys = &keyData[0];
+ keyDataSorter.keys = &keyData[0];
FOR_EACH (KeyToActionMapIter, it, actionMap)
{
KeysVector *const keys = &it->second;
if (keys && keys->size() > 1)
- std::sort(keys->begin(), keys->end(), keySorter);
+ std::sort(keys->begin(), keys->end(), keyDataSorter);
}
}
diff --git a/src/playerrelations.cpp b/src/playerrelations.cpp
index 0b5507876..cfba142ed 100644
--- a/src/playerrelations.cpp
+++ b/src/playerrelations.cpp
@@ -49,7 +49,7 @@ typedef PlayerRelations::const_iterator PlayerRelationsCIter;
typedef std::list<PlayerRelationsListener *> PlayerRelationListeners;
typedef PlayerRelationListeners::const_iterator PlayerRelationListenersCIter;
-static class SortPlayersFunctor final
+class SortPlayersFunctor final
{
public:
bool operator() (const std::string &str1,
@@ -63,7 +63,7 @@ static class SortPlayersFunctor final
return str1 < str2;
return s1 < s2;
}
-} playersSorter;
+} playersRelSorter;
// (De)serialisation class
class PlayerConfSerialiser final :
@@ -352,7 +352,7 @@ StringVect * PlayerRelationsManager::getPlayers()
retval->push_back(it->first);
}
- std::sort(retval->begin(), retval->end(), playersSorter);
+ std::sort(retval->begin(), retval->end(), playersRelSorter);
return retval;
}
@@ -368,7 +368,7 @@ StringVect *PlayerRelationsManager::getPlayersByRelation(
retval->push_back(it->first);
}
- std::sort(retval->begin(), retval->end(), playersSorter);
+ std::sort(retval->begin(), retval->end(), playersRelSorter);
return retval;
}