diff options
| author | Léo Lam <leo@leolam.fr> | 2021-01-08 12:44:00 +0100 |
|---|---|---|
| committer | Léo Lam <leo@leolam.fr> | 2021-01-08 12:55:01 +0100 |
| commit | 5912b65eff783ea45082599020b61982ad766223 (patch) | |
| tree | 70dcbbabcbaed9ff862a6662d3cefbd68114723c /src/Game/UI/uiPauseMenuDataMgr.cpp | |
| parent | e3791db95eabbb11575bbd346d935773e0702ed0 (diff) | |
uking/ui: Add Master Sword related inventory functions
Diffstat (limited to 'src/Game/UI/uiPauseMenuDataMgr.cpp')
| -rw-r--r-- | src/Game/UI/uiPauseMenuDataMgr.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/Game/UI/uiPauseMenuDataMgr.cpp b/src/Game/UI/uiPauseMenuDataMgr.cpp index a7be9a98..e2d4e9dd 100644 --- a/src/Game/UI/uiPauseMenuDataMgr.cpp +++ b/src/Game/UI/uiPauseMenuDataMgr.cpp @@ -2,6 +2,7 @@ #include <container/seadBuffer.h> #include <limits> #include <prim/seadScopedLock.h> +#include "Game/UI/uiUtils.h" #include "KingSystem/ActorSystem/actActorUtil.h" #include "KingSystem/ActorSystem/actInfoData.h" #include "KingSystem/GameData/gdtCommonFlagsUtils.h" @@ -355,6 +356,41 @@ int PauseMenuDataMgr::getRealArrowCount(const sead::SafeString& name) const { return status == 2 ? 0 : count; } +void PauseMenuDataMgr::breakMasterSword() { + const auto lock = sead::makeScopedLock(mCritSection); + s32 idx = 0; + for (auto& item : getItems()) { + if (item.getType() == PouchItemType::Weapon && isMasterSwordActorName(item.getName())) { + item.mValue = 0; + item.mValid = false; + if (!mIsPouchForQuest && idx >= 0) { + ksys::gdt::setFlag_PorchItem_Value1(0, idx); + ksys::gdt::setFlag_PorchItem_EquipFlag(false, idx); + } + break; + } + ++idx; + } +} + +void PauseMenuDataMgr::restoreMasterSword(bool only_if_broken) { + const auto lock = sead::makeScopedLock(mCritSection); + s32 idx = 0; + for (auto& item : getItems()) { + if (item.getType() == PouchItemType::Weapon && isMasterSwordActorName(item.getName())) { + if (only_if_broken && item.getValue() > 0) + break; + + item.mValue = getWeaponInventoryLife(item.getName()); + if (!mIsPouchForQuest && idx >= 0) + ksys::gdt::setFlag_PorchItem_Value1(item.mValue, idx); + + break; + } + ++idx; + } +} + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) void PauseMenuDataMgr::updateDivineBeastClearFlags(int num_cleared_beasts) { switch (num_cleared_beasts) { |
