diff options
| author | Léo Lam <leo@leolam.fr> | 2025-06-22 23:48:19 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-22 23:48:19 +0200 |
| commit | 5dda15014c0ae35c31b7b0dc6c56c828752baba1 (patch) | |
| tree | 3db6e21a0025e9a0b20d88199e781c95c7947878 /src/Game/UI | |
| parent | 71530ca9b1b9a5d974f28a97ebe52ae8b29c208f (diff) | |
| parent | 3d920314042fc84ccffc5f4b503e85e3b77fc4a2 (diff) | |
Merge pull request #141 from Pistonight/cpeam
CreatePlayerEquipActorMgr
Diffstat (limited to 'src/Game/UI')
| -rw-r--r-- | src/Game/UI/uiPauseMenuDataMgr.cpp | 7 | ||||
| -rw-r--r-- | src/Game/UI/uiUtils.cpp | 67 | ||||
| -rw-r--r-- | src/Game/UI/uiUtils.h | 10 |
3 files changed, 81 insertions, 3 deletions
diff --git a/src/Game/UI/uiPauseMenuDataMgr.cpp b/src/Game/UI/uiPauseMenuDataMgr.cpp index 3840501e..6c815e70 100644 --- a/src/Game/UI/uiPauseMenuDataMgr.cpp +++ b/src/Game/UI/uiPauseMenuDataMgr.cpp @@ -4,7 +4,8 @@ #include <limits> #include <math/seadMathCalcCommon.h> #include <prim/seadScopedLock.h> -#include "Game/Actor/actCreatePlayerEquipActorMgr.h" +#include "Game/Actor/actPlayerCreateMgr.h" +#include "Game/Actor/actPlayerCreateUtils.h" #include "Game/Actor/actWeapon.h" #include "Game/Cooking/cookManager.h" #include "Game/DLC/aocManager.h" @@ -1481,7 +1482,7 @@ void PauseMenuDataMgr::createPlayerEquipment() { break; } if (item->isInInventory() && item->isEquipped()) { - u64 slot = (u64)act::getCreateEquipmentSlot(type); + u64 slot = (u64)getCreateEquipmentSlot(type); if (slot < equipment_items.size()) { equipment_items[slot] = item; } @@ -1501,7 +1502,7 @@ void PauseMenuDataMgr::createPlayerEquipment() { for (u64 i = 0; i != equipment_items.size(); slot = s32(++i)) { if (equipment_items[i]) { if (!need_head_b || i != (u64)act::CreateEquipmentSlot::ArmorHead) { - act::createEquipmentFromItem(equipment_items[i], Caller); + createEquipmentFromItem(equipment_items[i], Caller); } else { create_mgr->requestCreateArmorHeadB(equipment_items[i]->getName(), equipment_items[i]->getValue(), Caller); diff --git a/src/Game/UI/uiUtils.cpp b/src/Game/UI/uiUtils.cpp index c26117fa..49ea4852 100644 --- a/src/Game/UI/uiUtils.cpp +++ b/src/Game/UI/uiUtils.cpp @@ -1,4 +1,5 @@ #include "Game/UI/uiUtils.h" +#include "Game/Actor/actPlayerCreateMgr.h" #include "Game/Actor/actWeapon.h" #include "Game/DLC/aocHardModeManager.h" #include "Game/Damage/dmgInfoManager.h" @@ -114,4 +115,70 @@ bool isMasterSwordActorName(const sead::SafeString& name) { return name == "Weapon_Sword_070"; } +act::CreateEquipmentSlot getCreateEquipmentSlot(ui::PouchItemType type) { + switch (type) { + case ui::PouchItemType::Sword: + return act::CreateEquipmentSlot::WeaponSword; + case ui::PouchItemType::Bow: + return act::CreateEquipmentSlot::WeaponBow; + case ui::PouchItemType::Shield: + return act::CreateEquipmentSlot::WeaponShield; + case ui::PouchItemType::ArmorHead: + return act::CreateEquipmentSlot::ArmorHead; + case ui::PouchItemType::ArmorUpper: + return act::CreateEquipmentSlot::ArmorUpper; + case ui::PouchItemType::ArmorLower: + return act::CreateEquipmentSlot::ArmorLower; + default: + return act::CreateEquipmentSlot::Length; + } +} + +ui::EquipmentSlot getEquipmentSlot(act::CreateEquipmentSlot slot) { + switch (slot) { + case act::CreateEquipmentSlot::WeaponSword: + return ui::EquipmentSlot::WeaponRight; + case act::CreateEquipmentSlot::WeaponShield: + return ui::EquipmentSlot::WeaponLeft; + case act::CreateEquipmentSlot::WeaponBow: + return ui::EquipmentSlot::WeaponBow; + case act::CreateEquipmentSlot::ArmorHead: + return ui::EquipmentSlot::ArmorHead; + case act::CreateEquipmentSlot::ArmorUpper: + return ui::EquipmentSlot::ArmorUpper; + case act::CreateEquipmentSlot::ArmorLower: + return ui::EquipmentSlot::ArmorLower; + default: + return ui::EquipmentSlot::Invalid; + } +} + +bool createEquipmentFromItem(const ui::PouchItem* item, const sead::SafeString& caller) { + if (!item) { + return false; + } + + auto* mgr = act::CreatePlayerEquipActorMgr::instance(); + if (!mgr) { + return false; + } + + auto type = item->getType(); + auto slot = getCreateEquipmentSlot(type); + int slot_idx = (int)slot; + + if (slot <= act::CreateEquipmentSlot::WeaponBow) { + act::WeaponModifierInfo modifier(*item); + mgr->requestCreateWeapon(slot_idx, item->getName(), item->getValue(), &modifier, caller); + return true; + } + + if (slot <= act::CreateEquipmentSlot::ArmorLower) { + mgr->requestCreateArmor(slot_idx, item->getName(), item->getValue(), caller); + return true; + } + + return false; +} + } // namespace uking::ui diff --git a/src/Game/UI/uiUtils.h b/src/Game/UI/uiUtils.h index b68a1d58..288b7996 100644 --- a/src/Game/UI/uiUtils.h +++ b/src/Game/UI/uiUtils.h @@ -3,8 +3,14 @@ #include <prim/seadSafeString.h> #include "Game/Actor/actWeapon.h" +namespace uking::act { +enum class CreateEquipmentSlot : u8; +} + namespace uking::ui { +enum class EquipmentSlot; +enum class PouchItemType; class PouchItem; struct WeaponStats { @@ -47,4 +53,8 @@ int getItemValue(const sead::SafeString& name); // Do not implement until the location is figured out void applyScreenFade(float progress); +act::CreateEquipmentSlot getCreateEquipmentSlot(ui::PouchItemType type); +ui::EquipmentSlot getEquipmentSlot(act::CreateEquipmentSlot slot); +bool createEquipmentFromItem(const ui::PouchItem* item, const sead::SafeString& caller); + } // namespace uking::ui |
