summaryrefslogtreecommitdiff
path: root/src/KingSystem/Effect/eftInfoData.cpp
blob: 298ef99f1c2d3ae3dcdcb4d5bac49596f840b217 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "KingSystem/Effect/eftInfoData.h"
#include "KingSystem/Resource/resLoadRequest.h"

namespace ksys::eft {

SEAD_SINGLETON_DISPOSER_IMPL(InfoData)

InfoData::~InfoData() {
    if (mRootIter)
        delete mRootIter;
}

void InfoData::loadEffectInfo(sead::Heap* heap) {
    res::LoadRequest req;
    req.mRequester = "eft::InfoData";
    req._22 = true;
    mResHandle.load("Actor/Effect/EffectInfo.byml", &req);

    auto* resource = sead::DynamicCast<sead::DirectResource>(mResHandle.getResource());

    if (mRootIter)
        delete mRootIter;
    mRootIter = new (heap) al::ByamlIter(resource->getRawData());
}

void InfoData::init(sead::Heap* heap) {
    loadEffectInfo(heap);
}

al::ByamlIter InfoData::getIter(const sead::SafeString& key) const {
    const auto iter = mRootIter->getIterByKey(key.cstr());
    return al::ByamlIter(iter);
}

sead::SafeString InfoData::getEffectSettingUserName(const sead::SafeString& key) const {
    const auto iter = getIter(key);
    const char* value = "Dummy";
    iter.tryGetStringByKey(&value, "EffectSettingUserName");
    return value;
}

}  // namespace ksys::eft