uking/ui: Implement material sorting for inventory

This commit is contained in:
Léo Lam 2021-01-21 23:57:37 +01:00
parent 7814fd527b
commit 48276bb4e7
No known key found for this signature in database
GPG Key ID: 0DF30F9081000741
6 changed files with 65 additions and 5 deletions

View File

@ -56383,7 +56383,7 @@
0x0000007100977908,sub_7100977908,288,
0x0000007100977a28,sub_7100977A28,272,_ZN5uking2ui13compareShieldEPKNS0_9PouchItemES3_PN4ksys3act8InfoDataE
0x0000007100977b38,sub_7100977B38,336,_ZN5uking2ui12compareArmorEPKNS0_9PouchItemES3_PN4ksys3act8InfoDataE
0x0000007100977c88,sub_7100977C88,308,
0x0000007100977c88,sub_7100977C88,308,_ZN5uking2ui15compareMaterialEPKNS0_9PouchItemES3_PN4ksys3act8InfoDataE
0x0000007100977dbc,sub_7100977DBC,540,
0x0000007100977fd8,sub_7100977FD8,116,_ZN5uking2ui14compareKeyItemEPKNS0_9PouchItemES3_PN4ksys3act8InfoDataE
0x000000710097804c,sub_710097804C,676,
@ -61685,7 +61685,7 @@
0x0000007100aa4acc,sub_7100AA4ACC,128,
0x0000007100aa4b4c,sub_7100AA4B4C,788,
0x0000007100aa4e70,sub_7100AA4E70,720,
0x0000007100aa5150,cookingStuff,252,
0x0000007100aa5150,cookingStuff,252,_ZN5uking2ui22getItemHitPointRecoverERKN4sead14SafeStringBaseIcEE
0x0000007100aa524c,getArmorInfoMaybe,2988,
0x0000007100aa5df8,sub_7100AA5DF8,584,
0x0000007100aa6040,sub_7100AA6040,1040,
@ -73309,8 +73309,8 @@
0x0000007100d2dbf8,sub_7100D2DBF8,20,
0x0000007100d2dc0c,sub_7100D2DC0C,20,
0x0000007100d2dc20,sub_7100D2DC20,20,
0x0000007100d2dc34,ActorInfoData::getCureItemHitPointRecover,20,
0x0000007100d2dc48,act::getCureItemHitPointRecover,20,
0x0000007100d2dc34,ActorInfoData::getCureItemHitPointRecover,20,_ZN4ksys3act26getCureItemHitPointRecoverEPNS0_8InfoDataEPKc
0x0000007100d2dc48,act::getCureItemHitPointRecover,20,_ZN4ksys3act26getCureItemHitPointRecoverERKN2al9ByamlIterE
0x0000007100d2dc5c,act::getCureItemEffectiveTime,20,
0x0000007100d2dc70,sub_7100D2DC70,24,
0x0000007100d2dc88,sub_7100D2DC88,24,

Can't render this file because it is too large.

View File

@ -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;

View File

@ -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)

View File

@ -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);

View File

@ -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");
}

View File

@ -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