summaryrefslogtreecommitdiff
path: root/src/Game/UI/uiPauseMenuDataMgr.cpp
diff options
context:
space:
mode:
authorLéo Lam <leo@leolam.fr>2021-01-21 23:57:37 +0100
committerLéo Lam <leo@leolam.fr>2021-01-22 00:14:41 +0100
commit48276bb4e788e28c5b53f098471f8c8af03e6315 (patch)
treebb461934744727ca2e1e562e2afe9eec3a43889f /src/Game/UI/uiPauseMenuDataMgr.cpp
parent7814fd527b259b5a7c499f4e78e956f789f65fdf (diff)
uking/ui: Implement material sorting for inventory
Diffstat (limited to 'src/Game/UI/uiPauseMenuDataMgr.cpp')
-rw-r--r--src/Game/UI/uiPauseMenuDataMgr.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/Game/UI/uiPauseMenuDataMgr.cpp b/src/Game/UI/uiPauseMenuDataMgr.cpp
index 74c3f8dc..bc05a5bb 100644
--- a/src/Game/UI/uiPauseMenuDataMgr.cpp
+++ b/src/Game/UI/uiPauseMenuDataMgr.cpp
@@ -1965,6 +1965,26 @@ int compareArmor(const PouchItem* lhs, const PouchItem* rhs, ksys::act::InfoData
return 0;
}
+int compareMaterial(const PouchItem* lhs, const PouchItem* rhs, ksys::act::InfoData* data) {
+ const int order1 = getCookItemOrder(lhs, data);
+ const int order2 = getCookItemOrder(rhs, data);
+ // Lower is better
+ if (order1 < order2)
+ return -1;
+ if (order1 > order2)
+ return 1;
+
+ const int hp1 = getItemHitPointRecover(lhs->getName().cstr());
+ const int hp2 = getItemHitPointRecover(rhs->getName().cstr());
+ // Higher is better
+ if (hp1 > hp2)
+ return -1;
+ if (hp1 < hp2)
+ return 1;
+
+ return compareSortKeys(lhs, rhs, data);
+}
+
int compareKeyItem(const PouchItem* lhs, const PouchItem* rhs, ksys::act::InfoData* data) {
if (auto cmp = compareSortKeys(lhs, rhs, data))
return cmp;