Skip to content

Commit

Permalink
checkXXXReady
Browse files Browse the repository at this point in the history
  • Loading branch information
Pistonight committed Aug 8, 2024
1 parent f54b9e2 commit 181a709
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
4 changes: 2 additions & 2 deletions data/uking_functions.csv
Original file line number Diff line number Diff line change
Expand Up @@ -88337,8 +88337,8 @@ Address,Quality,Size,Name
0x00000071010a2a70,W,000260,_ZN4ksys2ui17LayoutResourceMgr12loadLangFontEPN4sead4HeapE
0x00000071010a2b74,U,000388,LayoutResourceMgr::__auto0
0x00000071010a2cf8,W,000680,_ZN4ksys2ui17LayoutResourceMgr18loadExtraLangFontsEPN4sead4HeapE
0x00000071010a2fa0,U,000188,LayoutResourceMgr::ready
0x00000071010a305c,U,000136,LayoutResourceMgr::ready_0
0x00000071010a2fa0,O,000188,_ZN4ksys2ui17LayoutResourceMgr18checkLangFontReadyEv
0x00000071010a305c,O,000136,_ZNK4ksys2ui17LayoutResourceMgr24checkExtraLangFontsReadyEv
0x00000071010a30e4,U,000136,LayoutResourceMgr::loadVersion
0x00000071010a316c,U,000372,LayoutResourceMgr::ready_1
0x00000071010a32e0,U,001584,
Expand Down
33 changes: 32 additions & 1 deletion src/KingSystem/System/UI/LayoutResourceMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,38 @@ void LayoutResourceMgr::loadExtraLangFonts(sead::Heap* heap) {
handle->requestLoad(path, &req, &status);
}
mZeldaGlyphHandle->requestLoad("Font/ZeldaGlyphs-v2-Deco.bfotf", &req, &status);
nn::pl::RequestSharedFontLoad(0);
nn::pl::RequestSharedFontLoad(nn::pl::SharedFontType::Unknown);
}

bool LayoutResourceMgr::checkLangFontReady() {
if (mLangFontResource) {
return true;
}
if (!mLangFontHandle->isReady()) {
return false;
}
mLangFontResource = sead::DynamicCast<sead::DirectResource>(mLangFontHandle->getResource());
return true;
}

bool LayoutResourceMgr::checkExtraLangFontsReady() const {
switch (sead::EnvUtil::getRegionLanguage().value()) {
case sead::RegionLanguageID::KRko:
case sead::RegionLanguageID::CNzh:
case sead::RegionLanguageID::TWzh:
break;
default:
return true;
}
for (const auto& handle : mExtraLangFontHandles) {
if (!handle.isReady()) {
return false;
}
}
if (!mZeldaGlyphHandle || mZeldaGlyphHandle->isReady()) {
return nn::pl::GetSharedFontLoadState(nn::pl::SharedFontType::Unknown) == 1;
}
return false;
}

} // namespace ksys::ui
10 changes: 8 additions & 2 deletions src/KingSystem/System/UI/LayoutResourceMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
#include "ArcResourceMgr.h"

namespace nn::pl {
u64 RequestSharedFontLoad(int);
enum SharedFontType : int {
Unknown = 0
};
u64 RequestSharedFontLoad(nn::pl::SharedFontType type);
u32 GetSharedFontLoadState(nn::pl::SharedFontType type);
}

namespace ksys::ui {
Expand All @@ -26,6 +30,8 @@ class LayoutResourceMgr {
u8* loadMsgPack(u32* size);
void loadLangFont(sead::Heap* heap);
void loadExtraLangFonts(sead::Heap* heap);
bool checkLangFontReady();
bool checkExtraLangFontsReady() const;

private:
res::Handle* mMsgPackHandle = nullptr;
Expand All @@ -34,7 +40,7 @@ class LayoutResourceMgr {
sead::FixedPtrArray<res::Handle, 8> mExtraLangFontHandles;
res::Handle* mZeldaGlyphHandle = nullptr;
ArcResourceMgr* mArcResourceMgr = nullptr;
res::Handle* mLangFontRes = nullptr;
sead::DirectResource* mLangFontResource = nullptr;
void* _a8 = nullptr;
void* _b0 = nullptr;
void* _b8 = nullptr;
Expand Down

0 comments on commit 181a709

Please sign in to comment.