metaforce/Runtime/CGameHintInfo.cpp

48 lines
1.6 KiB
C++
Raw Normal View History

2016-09-07 19:01:29 -07:00
#include "CGameHintInfo.hpp"
#include "CToken.hpp"
2017-02-17 18:19:50 -08:00
#include "CMemoryCardSys.hpp"
#include "GameGlobalObjects.hpp"
2016-09-07 19:01:29 -07:00
2018-12-07 21:30:43 -08:00
namespace urde {
CGameHintInfo::CGameHintInfo(CInputStream& in, s32 version) {
u32 hintCount = in.readUint32Big();
x0_hints.reserve(hintCount);
for (u32 i = 0; i < hintCount; ++i)
x0_hints.emplace_back(in, version);
2016-09-07 19:01:29 -07:00
}
CGameHintInfo::CGameHint::CGameHint(CInputStream& in, s32 version)
: x0_name(in.readString())
2017-02-17 18:19:50 -08:00
, x10_immediateTime(in.readFloatBig())
, x14_normalTime(in.readFloatBig())
2016-09-07 19:01:29 -07:00
, x18_stringId(in.readUint32Big())
2018-12-07 21:30:43 -08:00
, x1c_textTime(3.f * float(version <= 0 ? 1 : in.readUint32Big())) {
u32 locationCount = in.readUint32Big();
x20_locations.reserve(locationCount);
for (u32 i = 0; i < locationCount; ++i)
x20_locations.emplace_back(in, version);
2016-09-07 19:01:29 -07:00
}
CGameHintInfo::SHintLocation::SHintLocation(CInputStream& in, s32)
: x0_mlvlId(in.readUint32Big())
, x4_mreaId(in.readUint32Big())
, x8_areaId(in.readUint32Big())
2018-12-07 21:30:43 -08:00
, xc_stringId(in.readUint32Big()) {}
2016-09-07 19:01:29 -07:00
2018-12-07 21:30:43 -08:00
int CGameHintInfo::FindHintIndex(const char* str) {
const std::vector<CGameHint>& gameHints = g_MemoryCardSys->GetHints();
const auto& it = std::find_if(gameHints.begin(), gameHints.end(),
2019-10-01 00:38:03 -07:00
[&str](const CGameHint& gh) -> bool { return gh.GetName() == str; });
2018-12-07 21:30:43 -08:00
return (it != gameHints.end() ? it - gameHints.begin() : -1);
2017-02-17 18:19:50 -08:00
}
2018-12-07 21:30:43 -08:00
CFactoryFnReturn FHintFactory(const SObjectTag&, CInputStream& in, const CVParamTransfer, CObjectReference*) {
in.readUint32Big();
s32 version = in.readInt32Big();
2016-09-07 19:01:29 -07:00
2018-12-07 21:30:43 -08:00
return TToken<CGameHintInfo>::GetIObjObjectFor(std::make_unique<CGameHintInfo>(in, version));
2016-09-07 19:01:29 -07:00
}
2018-12-07 21:30:43 -08:00
} // namespace urde