mirror of
https://github.com/zeldaret/botw
synced 2026-08-10 03:05:25 -04:00
uking/ui: Implement material sorting for inventory
This commit is contained in:
@@ -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;
|
||||
|
||||
+26
-1
@@ -1,8 +1,10 @@
|
||||
#include "Game/UI/uiUtils.h"
|
||||
#include "Game/Actor/actWeapon.h"
|
||||
#include "Game/DLC/aoc2.h"
|
||||
#include "Game/UI/uiPauseMenuDataMgr.h"
|
||||
#include "KingSystem/ActorSystem/actInfoCommon.h"
|
||||
#include "KingSystem/ActorSystem/actInfoData.h"
|
||||
#include "Game/UI/uiPauseMenuDataMgr.h"
|
||||
#include "KingSystem/Utils/Byaml/Byaml.h"
|
||||
|
||||
namespace uking::ui {
|
||||
|
||||
@@ -10,6 +12,29 @@ bool isMasterSwordItem(const PouchItem& item) {
|
||||
return item.getType() == PouchItemType::Sword && isMasterSwordActorName(item.getName());
|
||||
}
|
||||
|
||||
int getItemHitPointRecover(const sead::SafeString& name) {
|
||||
auto* info = ksys::act::InfoData::instance();
|
||||
if (!info)
|
||||
return 0;
|
||||
|
||||
al::ByamlIter iter;
|
||||
if (!info->getActorIter(&iter, name.cstr()))
|
||||
return 0;
|
||||
if (!info->hasTag(iter, ksys::act::tags::CureItem))
|
||||
return 0;
|
||||
if (!info->hasTag(iter, ksys::act::tags::CanUse))
|
||||
return 0;
|
||||
|
||||
int value = ksys::act::getCureItemHitPointRecover(iter);
|
||||
|
||||
if (aoc2::instance() && aoc2::instance()->checkFlag(aoc2::Flag::EnableHardMode) &&
|
||||
aoc2::instance()->isHardModeChangeOn(aoc2::HardModeChange::NerfHpRestore)) {
|
||||
aoc2::instance()->nerfHpRestore(&value);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
int getWeaponInventoryLife(const sead::SafeString& name) {
|
||||
auto* info = ksys::act::InfoData::instance();
|
||||
if (!info)
|
||||
|
||||
@@ -7,6 +7,9 @@ namespace uking::ui {
|
||||
class PouchItem;
|
||||
|
||||
bool isMasterSwordItem(const PouchItem& item);
|
||||
|
||||
int getItemHitPointRecover(const sead::SafeString& name);
|
||||
|
||||
int getWeaponInventoryLife(const sead::SafeString& name);
|
||||
bool isMasterSwordActorName(const sead::SafeString& name);
|
||||
|
||||
|
||||
@@ -123,6 +123,14 @@ int getItemStainColor(InfoData* data, const char* actor) {
|
||||
return data->getInt(actor, "itemStainColor", -1);
|
||||
}
|
||||
|
||||
int getCureItemHitPointRecover(InfoData* data, const char* actor) {
|
||||
return data->getInt(actor, "cureItemHitPointRecover");
|
||||
}
|
||||
|
||||
int getCureItemHitPointRecover(const al::ByamlIter& iter) {
|
||||
return InfoData::getIntByKey(iter, "cureItemHitPointRecover");
|
||||
}
|
||||
|
||||
int getMonsterShopSellMamo(const al::ByamlIter& iter) {
|
||||
return InfoData::getIntByKey(iter, "monsterShopSellMamo");
|
||||
}
|
||||
|
||||
@@ -46,6 +46,10 @@ const char* getArmorNextRankName(InfoData* data, const char* actor);
|
||||
|
||||
int getItemStainColor(InfoData* data, const char* actor);
|
||||
|
||||
int getCureItemHitPointRecover(InfoData* data, const char* actor);
|
||||
int getCureItemHitPointRecover(const al::ByamlIter& iter);
|
||||
|
||||
|
||||
int getMonsterShopSellMamo(const al::ByamlIter& iter);
|
||||
|
||||
} // namespace ksys::act
|
||||
|
||||
Reference in New Issue
Block a user