summaryrefslogtreecommitdiff
path: root/src/gui/widgets/itemcontainer.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-08-25 22:23:01 +0300
committerAndrei Karas <akaras@inbox.ru>2016-08-25 22:23:01 +0300
commit7f58784d306fa85bf638c1a172d83bd5a2891132 (patch)
tree981846657d64b45f2881e9297c401e23541a5cf8 /src/gui/widgets/itemcontainer.cpp
parentd0ea104f577c0646aaaf701b81a1781551a0ad16 (diff)
downloadplus-7f58784d306fa85bf638c1a172d83bd5a2891132.tar.gz
plus-7f58784d306fa85bf638c1a172d83bd5a2891132.tar.bz2
plus-7f58784d306fa85bf638c1a172d83bd5a2891132.tar.xz
plus-7f58784d306fa85bf638c1a172d83bd5a2891132.zip
In inventory if item same sort it also by inventory index for remove random item jumping.
Diffstat (limited to 'src/gui/widgets/itemcontainer.cpp')
-rw-r--r--src/gui/widgets/itemcontainer.cpp52
1 files changed, 44 insertions, 8 deletions
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index 0ff13d5ad..26630afad 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -84,8 +84,14 @@ namespace
if (!pair1->mItem || !pair2->mItem)
return false;
- return (pair1->mItem->getInfo().getName()
- < pair2->mItem->getInfo().getName());
+ const std::string name1 = pair1->mItem->getInfo().getName();
+ const std::string name2 = pair2->mItem->getInfo().getName();
+ if (name1 == name2)
+ {
+ return pair1->mItem->getInvIndex() <
+ pair2->mItem->getInvIndex();
+ }
+ return (name1 < name2);
}
} itemAlphaInvSorter;
@@ -98,7 +104,14 @@ namespace
if (!pair1->mItem || !pair2->mItem)
return false;
- return pair1->mItem->getId() < pair2->mItem->getId();
+ const int id1 = pair1->mItem->getId();
+ const int id2 = pair2->mItem->getId();
+ if (id1 == id2)
+ {
+ return pair1->mItem->getInvIndex() <
+ pair2->mItem->getInvIndex();
+ }
+ return id1 < id2;
}
} itemIdInvSorter;
@@ -115,8 +128,16 @@ namespace
const int w2 = pair2->mItem->getInfo().getWeight();
if (w1 == w2)
{
- return (pair1->mItem->getInfo().getName()
- < pair2->mItem->getInfo().getName());
+ const std::string name1 =
+ pair1->mItem->getInfo().getName();
+ const std::string name2 =
+ pair2->mItem->getInfo().getName();
+ if (name1 == name2)
+ {
+ return pair1->mItem->getInvIndex() <
+ pair2->mItem->getInvIndex();
+ }
+ return (name1 < name2);
}
return w1 < w2;
}
@@ -135,8 +156,16 @@ namespace
const int c2 = pair2->mItem->getQuantity();
if (c1 == c2)
{
- return (pair1->mItem->getInfo().getName()
- < pair2->mItem->getInfo().getName());
+ const std::string name1 =
+ pair1->mItem->getInfo().getName();
+ const std::string name2 =
+ pair2->mItem->getInfo().getName();
+ if (name1 == name2)
+ {
+ return pair1->mItem->getInvIndex() <
+ pair2->mItem->getInvIndex();
+ }
+ return (name1 < name2);
}
return c1 < c2;
}
@@ -157,7 +186,14 @@ namespace
const ItemDbTypeT t2 = info2.getType();
if (t1 == t2)
{
- return (info1.getName() < info2.getName());
+ const std::string name1 = info1.getName();
+ const std::string name2 = info2.getName();
+ if (name1 == name2)
+ {
+ return pair1->mItem->getInvIndex() <
+ pair2->mItem->getInvIndex();
+ }
+ return (name1 < name2);
}
return t1 < t2;
}