mirror of
https://github.com/HarbourMasters/2ship2harkinian.git
synced 2024-11-23 05:59:40 +00:00
Changes for new LUS resources (#151)
* Changes for new LUS resources * fix factory issues and bump modules * add build version, custom assets folder, and fix extraction * add missing custom assets * fix build .h * libzip in the workflows * apt-deps * Fixes to importers to work with upstream Resource Manager. Also remove duplicated structs. * Bump LUS * bump LUS * Bump LUS * bump lus * point back to louist103/mm --------- Co-authored-by: Adam Bird <archez39@me.com>
This commit is contained in:
parent
9da273a8ea
commit
904bf60b36
2
.github/workflows/apt-deps.txt
vendored
2
.github/workflows/apt-deps.txt
vendored
@ -1 +1 @@
|
||||
libsdl2-dev libsdl2-net-dev libpng-dev libglew-dev ninja-build
|
||||
libsdl2-dev libsdl2-net-dev libpng-dev libglew-dev ninja-build libzip-dev zipcmp zipmerge ziptool
|
15
.github/workflows/main.yml
vendored
15
.github/workflows/main.yml
vendored
@ -45,6 +45,21 @@ jobs:
|
||||
make -j
|
||||
sudo make install
|
||||
sudo cp -av /usr/local/lib/libSDL* /lib/x86_64-linux-gnu/
|
||||
- name: Install latest libzip
|
||||
if: ${{ (matrix.os == 'ubuntu-20.04' && !vars.LINUX_COMPATIBILITY_RUNNER) }}
|
||||
run: |
|
||||
sudo apt-get remove libzip-dev zipcmp zipmerge ziptool
|
||||
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
|
||||
if [ ! -d "libzip-1.10.1" ]; then
|
||||
wget https://libzip.org/download/libzip-1.10.1.tar.gz
|
||||
tar -xzvf libzip-1.10.1.tar.gz
|
||||
fi
|
||||
cd libzip-1.10.1
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
make
|
||||
sudo make install
|
||||
- name: Download Rom
|
||||
run: |
|
||||
url="${{ secrets.BASEROM }}"
|
||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -56,3 +56,5 @@ mm/libultraship/extern/StrHash64.dir/Debug/StrHash64.tlog/Lib.command.1.tlog
|
||||
/Release
|
||||
.vs/*
|
||||
/x64
|
||||
|
||||
/mm/src/boot/build.c
|
||||
|
@ -33,7 +33,7 @@ elseif ("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64")
|
||||
set(VCPKG_TARGET_TRIPLET x64-windows-static)
|
||||
endif()
|
||||
vcpkg_bootstrap()
|
||||
vcpkg_install_packages(zlib bzip2 libpng sdl2 sdl2-net glew glfw3)
|
||||
vcpkg_install_packages(zlib bzip2 libpng sdl2 sdl2-net glew glfw3 libzip)
|
||||
endif()
|
||||
|
||||
################################################################################
|
||||
@ -132,7 +132,7 @@ add_custom_target(
|
||||
ExtractAssets
|
||||
# CMake versions prior to 3.17 do not have the rm command, use remove instead for older versions
|
||||
COMMAND ${CMAKE_COMMAND} -E $<IF:$<VERSION_LESS:${CMAKE_VERSION},3.17>,remove,rm> -f mm.otr soh.otr
|
||||
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets.py -z "$<TARGET_FILE:ZAPD>" --non-interactive
|
||||
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets.py -z "$<TARGET_FILE:ZAPD>" --non-interactive --xml-root ../mm/assets/xml --custom-otr-file soh.otr "--custom-assets-path" ${CMAKE_CURRENT_SOURCE_DIR}/mm/assets/custom --port-ver "${CMAKE_PROJECT_VERSION}"
|
||||
COMMAND ${CMAKE_COMMAND} -DSYSTEM_NAME=${CMAKE_SYSTEM_NAME} -DTARGET_DIR="$<TARGET_FILE_DIR:ZAPD>" -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DBINARY_DIR=${CMAKE_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/copy-existing-otrs.cmake
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter
|
||||
COMMENT "Running asset extraction..."
|
||||
@ -143,7 +143,7 @@ add_custom_target(
|
||||
# Target to generate headers
|
||||
add_custom_target(
|
||||
ExtractAssetHeaders
|
||||
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets.py -z "$<TARGET_FILE:ZAPD>" --non-interactive --gen-headers
|
||||
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets.py -z "$<TARGET_FILE:ZAPD>" --non-interactive --xml-root ../mm/assets/xml --gen-headers
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter
|
||||
COMMENT "Generating asset headers..."
|
||||
DEPENDS ZAPD
|
||||
@ -154,7 +154,7 @@ add_custom_target(
|
||||
GenerateSohOtr
|
||||
# CMake versions prior to 3.17 do not have the rm command, use remove instead for older versions
|
||||
COMMAND ${CMAKE_COMMAND} -E $<IF:$<VERSION_LESS:${CMAKE_VERSION},3.17>,remove,rm> -f soh.otr
|
||||
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets.py -z "$<TARGET_FILE:ZAPD>" --norom
|
||||
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets.py -z "$<TARGET_FILE:ZAPD>" --norom --custom-otr-file soh.otr "--custom-assets-path" ${CMAKE_CURRENT_SOURCE_DIR}/mm/assets/custom --port-ver "${CMAKE_PROJECT_VERSION}"
|
||||
COMMAND ${CMAKE_COMMAND} -DSYSTEM_NAME=${CMAKE_SYSTEM_NAME} -DTARGET_DIR="$<TARGET_FILE_DIR:ZAPD>" -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DBINARY_DIR=${CMAKE_BINARY_DIR} -DONLYSOHOTR=On -P ${CMAKE_CURRENT_SOURCE_DIR}/copy-existing-otrs.cmake
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter
|
||||
COMMENT "Generating soh.otr..."
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 2e378fe443aba5e32d8975c9f06b2fa5f1991c2c
|
||||
Subproject commit 5c48f3411cd404c3ad1a945d7f7cd10d41cb5e4a
|
2
ZAPDTR
2
ZAPDTR
@ -1 +1 @@
|
||||
Subproject commit 01ed7e87f2b4b8145d8b0af8c8d8912b86f4b908
|
||||
Subproject commit a406a7d4310c26f6e7aeece3bb4475cd8fd2d9e3
|
@ -1 +1 @@
|
||||
Subproject commit 87d3a14cb433c499014ff810191fe83673dc69e2
|
||||
Subproject commit e40c19e992073e1cde514ad1c4272c08b85b9708
|
@ -30,7 +30,6 @@ static const std::unordered_map<int32_t, const char*> textureFilteringMap = {
|
||||
|
||||
static const std::unordered_map<LUS::AudioBackend, const char*> audioBackendsMap = {
|
||||
{ LUS::AudioBackend::WASAPI, "Windows Audio Session API" },
|
||||
{ LUS::AudioBackend::PULSE, "PulseAudio" },
|
||||
{ LUS::AudioBackend::SDL, "SDL" },
|
||||
};
|
||||
|
||||
|
@ -59,6 +59,7 @@ CrowdControl* CrowdControl::Instance;
|
||||
#include "2s2h/Enhancements/GfxPatcher/AuthenticGfxPatches.h"
|
||||
|
||||
// Resource Types/Factories
|
||||
#include "2s2h/resource//type/2shResourceType.h"
|
||||
#include "2s2h/resource/type/Animation.h"
|
||||
#include "2s2h/resource/type/AudioSample.h"
|
||||
#include "2s2h/resource/type/AudioSequence.h"
|
||||
@ -70,7 +71,6 @@ CrowdControl* CrowdControl::Instance;
|
||||
#include "2s2h/resource/type/Scene.h"
|
||||
#include "2s2h/resource/type/Skeleton.h"
|
||||
#include "2s2h/resource/type/SkeletonLimb.h"
|
||||
#include "2s2h/resource/type/Text.h"
|
||||
#include "2s2h/resource/importer/AnimationFactory.h"
|
||||
#include "2s2h/resource/importer/AudioSampleFactory.h"
|
||||
#include "2s2h/resource/importer/AudioSequenceFactory.h"
|
||||
@ -82,7 +82,6 @@ CrowdControl* CrowdControl::Instance;
|
||||
#include "2s2h/resource/importer/SceneFactory.h"
|
||||
#include "2s2h/resource/importer/SkeletonFactory.h"
|
||||
#include "2s2h/resource/importer/SkeletonLimbFactory.h"
|
||||
#include "2s2h/resource/importer/TextFactory.h"
|
||||
#include "2s2h/resource/importer/TextMMFactory.h"
|
||||
#include "2s2h/resource/importer/BackgroundFactory.h"
|
||||
#include "2s2h/resource/importer/TextureAnimationFactory.h"
|
||||
@ -130,42 +129,44 @@ OTRGlobals::OTRGlobals() {
|
||||
// tell LUS to reserve 3 SoH specific threads (Game, Audio, Save)
|
||||
context = LUS::Context::CreateInstance("2 Ship 2 Harkinian", appShortName, "shipofharkinian.json", OTRFiles, {}, 3);
|
||||
//context = LUS::Context::CreateUninitializedInstance("Ship of Harkinian", appShortName, "shipofharkinian.json");
|
||||
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(
|
||||
LUS::ResourceType::SOH_Animation, "Animation", std::make_shared<LUS::AnimationFactory>());
|
||||
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(
|
||||
LUS::ResourceType::SOH_PlayerAnimation, "PlayerAnimation", std::make_shared<LUS::PlayerAnimationFactory>());
|
||||
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(
|
||||
LUS::ResourceType::SOH_Room, "Room", std::make_shared<LUS::SceneFactory>()); // Is room scene? maybe?
|
||||
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(
|
||||
LUS::ResourceType::SOH_CollisionHeader, "CollisionHeader", std::make_shared<LUS::CollisionHeaderFactory>());
|
||||
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(
|
||||
LUS::ResourceType::SOH_Skeleton, "Skeleton", std::make_shared<LUS::SkeletonFactory>());
|
||||
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(
|
||||
LUS::ResourceType::SOH_SkeletonLimb, "SkeletonLimb", std::make_shared<LUS::SkeletonLimbFactory>());
|
||||
// TODO should we use a custom command for this?
|
||||
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(LUS::ResourceType::SOH_Path, "Path",
|
||||
std::make_shared<LUS::PathFactoryMM>());
|
||||
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(
|
||||
LUS::ResourceType::SOH_Cutscene, "Cutscene", std::make_shared<LUS::CutsceneFactory>());
|
||||
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(LUS::ResourceType::SOH_Text, "Text",
|
||||
std::make_shared<LUS::TextFactory>());
|
||||
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(LUS::ResourceType::SOH_TextMM, "TextMM",
|
||||
std::make_shared<LUS::TextMMFactory>());
|
||||
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(
|
||||
LUS::ResourceType::SOH_AudioSample, "AudioSample", std::make_shared<LUS::AudioSampleFactory>());
|
||||
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(
|
||||
LUS::ResourceType::SOH_AudioSoundFont, "AudioSoundFont", std::make_shared<LUS::AudioSoundFontFactory>());
|
||||
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(
|
||||
LUS::ResourceType::SOH_AudioSequence, "AudioSequence", std::make_shared<LUS::AudioSequenceFactory>());
|
||||
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(
|
||||
LUS::ResourceType::SOH_Background, "Background", std::make_shared<LUS::BackgroundFactory>());
|
||||
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(
|
||||
LUS::ResourceType::TSH_TexAnim, "TextureAnimation", std::make_shared<LUS::TextureAnimationFactory>());
|
||||
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(
|
||||
LUS::ResourceType::TSH_CKeyFrameAnim, "KeyFrameAnim", std::make_shared<LUS::KeyFrameAnimFactory>());
|
||||
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(
|
||||
LUS::ResourceType::TSH_CKeyFrameSkel, "KeyFrameSkel", std::make_shared<LUS::KeyFrameSkelFactory>());
|
||||
|
||||
auto loader = context->GetResourceManager()->GetResourceLoader();
|
||||
loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryBinaryAnimationV0>(), RESOURCE_FORMAT_BINARY,
|
||||
"Animation", static_cast<uint32_t>(SOH::ResourceType::SOH_Animation), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryBinaryPlayerAnimationV0>(),
|
||||
RESOURCE_FORMAT_BINARY, "PlayerAnimation",
|
||||
static_cast<uint32_t>(SOH::ResourceType::SOH_PlayerAnimation), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryBinarySceneV0>(), RESOURCE_FORMAT_BINARY,
|
||||
"Room", static_cast<uint32_t>(SOH::ResourceType::SOH_Room), 0);
|
||||
loader
|
||||
->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryBinaryCollisionHeaderV0>(), RESOURCE_FORMAT_BINARY,
|
||||
"CollisionHeader", static_cast<uint32_t>(SOH::ResourceType::SOH_CollisionHeader), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryBinarySkeletonV0>(), RESOURCE_FORMAT_BINARY,
|
||||
"Skeleton", static_cast<uint32_t>(SOH::ResourceType::SOH_Skeleton), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryBinarySkeletonLimbV0>(),
|
||||
RESOURCE_FORMAT_BINARY, "SkeletonLimb",
|
||||
static_cast<uint32_t>(SOH::ResourceType::SOH_SkeletonLimb), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryBinaryPathMMV0>(), RESOURCE_FORMAT_BINARY,
|
||||
"Path", static_cast<uint32_t>(SOH::ResourceType::SOH_Path), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryBinaryCutsceneV0>(), RESOURCE_FORMAT_BINARY,
|
||||
"Cutscene", static_cast<uint32_t>(SOH::ResourceType::SOH_Cutscene), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryBinaryTextMMV0>(), RESOURCE_FORMAT_BINARY,
|
||||
"TextMM", static_cast<uint32_t>(SOH::ResourceType::TSH_TextMM), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryBinaryAudioSampleV2>(), RESOURCE_FORMAT_BINARY,
|
||||
"AudioSample", static_cast<uint32_t>(SOH::ResourceType::SOH_AudioSample), 2);
|
||||
loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryBinaryAudioSoundFontV2>(),
|
||||
RESOURCE_FORMAT_BINARY, "AudioSoundFont",
|
||||
static_cast<uint32_t>(SOH::ResourceType::SOH_AudioSoundFont), 2);
|
||||
loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryBinaryAudioSequenceV2>(),
|
||||
RESOURCE_FORMAT_BINARY, "AudioSequence", static_cast<uint32_t>(SOH::ResourceType::SOH_AudioSequence), 2);
|
||||
loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryBinaryBackgroundV0>(), RESOURCE_FORMAT_BINARY,
|
||||
"Background", static_cast<uint32_t>(SOH::ResourceType::SOH_Background), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryBinaryTextureAnimationV0>(),
|
||||
RESOURCE_FORMAT_BINARY, "TextureAnimation",
|
||||
static_cast<uint32_t>(SOH::ResourceType::TSH_TexAnim), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryBinaryKeyFrameAnim>(), RESOURCE_FORMAT_BINARY,
|
||||
"KeyFrameAnim", static_cast<uint32_t>(SOH::ResourceType::TSH_CKeyFrameAnim), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryBinaryKeyFrameSkel>(), RESOURCE_FORMAT_BINARY,
|
||||
"KeyFrameSkel", static_cast<uint32_t>(SOH::ResourceType::TSH_CKeyFrameSkel), 0);
|
||||
context->GetControlDeck()->SetSinglePlayerMappingMode(true);
|
||||
|
||||
//gSaveStateMgr = std::make_shared<SaveStateMgr>();
|
||||
@ -183,7 +184,7 @@ OTRGlobals::OTRGlobals() {
|
||||
// cameraStrings[i] = dup;
|
||||
//}
|
||||
|
||||
auto versions = context->GetResourceManager()->GetArchive()->GetGameVersions();
|
||||
auto versions = context->GetResourceManager()->GetArchiveManager()->GetGameVersions();
|
||||
#if 0
|
||||
for (uint32_t version : versions) {
|
||||
if (!ValidHashes.contains(version)) {
|
||||
@ -266,7 +267,7 @@ extern "C" void ResourceMgr_LoadDirectory(const char* resName);
|
||||
std::unordered_map<std::string, ExtensionEntry> ExtensionCache;
|
||||
|
||||
extern "C" void OTRExtScanner() {
|
||||
auto lst = *LUS::Context::GetInstance()->GetResourceManager()->GetArchive()->ListFiles("*").get();
|
||||
auto lst = *LUS::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->ListFiles("*").get();
|
||||
|
||||
for (auto& rPath : lst) {
|
||||
std::vector<std::string> raw = StringHelper::Split(rPath, ".");
|
||||
@ -632,15 +633,15 @@ extern "C" uint16_t OTRGetPixelDepth(float x, float y) {
|
||||
}
|
||||
|
||||
extern "C" uint32_t ResourceMgr_GetNumGameVersions() {
|
||||
return LUS::Context::GetInstance()->GetResourceManager()->GetArchive()->GetGameVersions().size();
|
||||
return LUS::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions().size();
|
||||
}
|
||||
|
||||
extern "C" uint32_t ResourceMgr_GetGameVersion(int index) {
|
||||
return LUS::Context::GetInstance()->GetResourceManager()->GetArchive()->GetGameVersions()[index];
|
||||
return LUS::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[index];
|
||||
}
|
||||
|
||||
extern "C" uint32_t ResourceMgr_GetGamePlatform(int index) {
|
||||
uint32_t version = LUS::Context::GetInstance()->GetResourceManager()->GetArchive()->GetGameVersions()[index];
|
||||
uint32_t version = LUS::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[index];
|
||||
|
||||
switch (version) {
|
||||
case OOT_NTSC_US_10:
|
||||
@ -663,7 +664,7 @@ extern "C" uint32_t ResourceMgr_GetGamePlatform(int index) {
|
||||
}
|
||||
|
||||
extern "C" uint32_t ResourceMgr_GetGameRegion(int index) {
|
||||
uint32_t version = LUS::Context::GetInstance()->GetResourceManager()->GetArchive()->GetGameVersions()[index];
|
||||
uint32_t version = LUS::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[index];
|
||||
|
||||
switch (version) {
|
||||
case OOT_NTSC_US_10:
|
||||
@ -742,7 +743,7 @@ extern "C" void ResourceMgr_DirtyDirectory(const char* resName) {
|
||||
// OTRTODO: There is probably a more elegant way to go about this...
|
||||
// Kenix: This is definitely leaking memory when it's called.
|
||||
extern "C" char** ResourceMgr_ListFiles(const char* searchMask, int* resultSize) {
|
||||
auto lst = LUS::Context::GetInstance()->GetResourceManager()->GetArchive()->ListFiles(searchMask);
|
||||
auto lst = LUS::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->ListFiles(searchMask);
|
||||
char** result = (char**)malloc(lst->size() * sizeof(char*));
|
||||
|
||||
for (size_t i = 0; i < lst->size(); i++) {
|
||||
@ -806,7 +807,7 @@ extern "C" char* ResourceMgr_LoadFileFromDisk(const char* filePath) {
|
||||
|
||||
extern "C" uint8_t ResourceMgr_ResourceIsBackground(char* texPath) {
|
||||
auto res = GetResourceByNameHandlingMQ(texPath);
|
||||
return res->GetInitData()->Type == LUS::ResourceType::SOH_Background;
|
||||
return res->GetInitData()->Type == static_cast<uint32_t>(SOH::ResourceType::SOH_Background);
|
||||
}
|
||||
|
||||
extern "C" char* ResourceMgr_LoadJPEG(char* data, size_t dataSize) {
|
||||
@ -853,9 +854,9 @@ extern "C" uint16_t ResourceMgr_LoadTexHeightByName(char* texPath);
|
||||
extern "C" char* ResourceMgr_LoadTexOrDListByName(const char* filePath) {
|
||||
auto res = GetResourceByNameHandlingMQ(filePath);
|
||||
|
||||
if (res->GetInitData()->Type == LUS::ResourceType::DisplayList)
|
||||
if (res->GetInitData()->Type == static_cast<uint32_t>(LUS::ResourceType::DisplayList))
|
||||
return (char*)&((std::static_pointer_cast<LUS::DisplayList>(res))->Instructions[0]);
|
||||
else if (res->GetInitData()->Type == LUS::ResourceType::Array)
|
||||
else if (res->GetInitData()->Type == static_cast<uint32_t>(LUS::ResourceType::Array))
|
||||
return (char*)(std::static_pointer_cast<LUS::Array>(res))->Vertices.data();
|
||||
else {
|
||||
return (char*)GetResourceDataByNameHandlingMQ(filePath);
|
||||
@ -865,7 +866,7 @@ extern "C" char* ResourceMgr_LoadTexOrDListByName(const char* filePath) {
|
||||
extern "C" char* ResourceMgr_LoadIfDListByName(const char* filePath) {
|
||||
auto res = GetResourceByNameHandlingMQ(filePath);
|
||||
|
||||
if (res->GetInitData()->Type == LUS::ResourceType::DisplayList)
|
||||
if (res->GetInitData()->Type == static_cast<uint32_t>(LUS::ResourceType::DisplayList))
|
||||
return (char*)&((std::static_pointer_cast<LUS::DisplayList>(res))->Instructions[0]);
|
||||
|
||||
return nullptr;
|
||||
@ -876,7 +877,7 @@ extern "C" char* ResourceMgr_LoadIfDListByName(const char* filePath) {
|
||||
//}
|
||||
|
||||
extern "C" char* ResourceMgr_LoadPlayerAnimByName(const char* animPath) {
|
||||
auto anim = std::static_pointer_cast<LUS::PlayerAnimation>(GetResourceByNameHandlingMQ(animPath));
|
||||
auto anim = std::static_pointer_cast<SOH::PlayerAnimation>(GetResourceByNameHandlingMQ(animPath));
|
||||
|
||||
return (char*)&anim->limbRotData[0];
|
||||
}
|
||||
@ -1160,12 +1161,12 @@ extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path, Skel
|
||||
|
||||
extern "C" void ResourceMgr_UnregisterSkeleton(SkelAnime* skelAnime) {
|
||||
if (skelAnime != nullptr)
|
||||
LUS::SkeletonPatcher::UnregisterSkeleton(skelAnime);
|
||||
SOH::SkeletonPatcher::UnregisterSkeleton(skelAnime);
|
||||
}
|
||||
|
||||
extern "C" void ResourceMgr_ClearSkeletons(SkelAnime* skelAnime) {
|
||||
if (skelAnime != nullptr)
|
||||
LUS::SkeletonPatcher::ClearSkeletons();
|
||||
SOH::SkeletonPatcher::ClearSkeletons();
|
||||
}
|
||||
|
||||
extern "C" s32* ResourceMgr_LoadCSByName(const char* path) {
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "Extract.h"
|
||||
#include "portable-file-dialogs.h"
|
||||
#include <Utils/BitConverter.h>
|
||||
#include "build.h"
|
||||
|
||||
#ifdef unix
|
||||
#include <dirent.h>
|
||||
@ -535,9 +536,10 @@ std::string Extractor::Mkdtemp() {
|
||||
extern "C" int zapd_main(int argc, char** argv);
|
||||
|
||||
bool Extractor::CallZapd(std::string installPath, std::string exportdir) {
|
||||
constexpr int argc = 16;
|
||||
constexpr int argc = 18;
|
||||
char xmlPath[1024];
|
||||
char confPath[1024];
|
||||
char portVersion[18]; // 5 digits for int16_max (x3) + separators + terminator
|
||||
std::array<const char*, argc> argv;
|
||||
// const char* version = GetZapdVerStr();
|
||||
const char* otrFile = "mm.otr";
|
||||
@ -559,6 +561,7 @@ bool Extractor::CallZapd(std::string installPath, std::string exportdir) {
|
||||
|
||||
snprintf(xmlPath, 1024, "assets/extractor/xmls");
|
||||
snprintf(confPath, 1024, "assets/extractor/Config.xml");
|
||||
snprintf(portVersion, 18, "%d.%d.%d", gBuildVersionMajor, gBuildVersionMinor, gBuildVersionPatch);
|
||||
|
||||
argv[0] = "ZAPD";
|
||||
argv[1] = "ed";
|
||||
@ -576,6 +579,8 @@ bool Extractor::CallZapd(std::string installPath, std::string exportdir) {
|
||||
argv[13] = "OTR";
|
||||
argv[14] = "--otrfile";
|
||||
argv[15] = otrFile;
|
||||
argv[16] = "--portVer";
|
||||
argv[17] = portVersion;
|
||||
|
||||
#ifdef _WIN32
|
||||
// Grab a handle to the command window.
|
||||
@ -584,6 +589,9 @@ bool Extractor::CallZapd(std::string installPath, std::string exportdir) {
|
||||
// Normally the command window is hidden. We want the window to be shown here so the user can see the progess of the extraction.
|
||||
ShowWindow(cmdWindow, SW_SHOW);
|
||||
SetWindowPos(cmdWindow, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
|
||||
#else
|
||||
// Show extraction in background message until linux/mac can have visual progress
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, "Extracting", "Extraction will now begin in the background.\n\nPlease be patient for the process to finish. Do not close the main program.", nullptr);
|
||||
#endif
|
||||
|
||||
zapd_main(argc, (char**)argv.data());
|
||||
|
@ -4,32 +4,15 @@
|
||||
#include <libultraship/libultraship.h>
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
namespace LUS {
|
||||
std::shared_ptr<IResource>
|
||||
AnimationFactory::ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<Animation>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<AnimationFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load Animation with version {}", resource->GetInitData()->ResourceVersion);
|
||||
namespace SOH {
|
||||
std::shared_ptr<LUS::IResource>
|
||||
ResourceFactoryBinaryAnimationV0::ReadResource(std::shared_ptr<LUS::File> file) {
|
||||
if (!FileHasValidFormatAndReader(file)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void LUS::AnimationFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) {
|
||||
std::shared_ptr<Animation> animation = std::static_pointer_cast<Animation>(resource);
|
||||
|
||||
ResourceVersionFactory::ParseFileBinary(reader, animation);
|
||||
auto animation = std::make_shared<Animation>(file->InitData);
|
||||
auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader);
|
||||
|
||||
AnimationType animType = (AnimationType)reader->ReadUInt32();
|
||||
animation->type = animType;
|
||||
@ -99,10 +82,12 @@ void LUS::AnimationFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> read
|
||||
|
||||
// Read the segment pointer (always 32 bit, doesn't adjust for system pointer size)
|
||||
std::string path = reader->ReadString();
|
||||
|
||||
animation->animationData.linkAnimationHeader.segment = ResourceGetDataByName(path.c_str());
|
||||
const auto animData = std::static_pointer_cast<Animation>(LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(path.c_str()));
|
||||
|
||||
animation->animationData.linkAnimationHeader.segment = animData->GetPointer();
|
||||
} else if (animType == AnimationType::Legacy) {
|
||||
SPDLOG_DEBUG("BEYTAH ANIMATION?!");
|
||||
}
|
||||
return animation;
|
||||
}
|
||||
} // namespace LUS
|
||||
} // namespace SOH
|
||||
|
@ -1,17 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "Resource.h"
|
||||
#include "ResourceFactory.h"
|
||||
#include "ResourceFactoryBinary.h"
|
||||
|
||||
namespace LUS {
|
||||
class AnimationFactory : public ResourceFactory {
|
||||
namespace SOH {
|
||||
class ResourceFactoryBinaryAnimationV0 : public LUS::ResourceFactoryBinary {
|
||||
public:
|
||||
std::shared_ptr<IResource>
|
||||
ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) override;
|
||||
};
|
||||
|
||||
class AnimationFactoryV0 : public ResourceVersionFactory {
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override;
|
||||
};
|
||||
}; // namespace LUS
|
||||
|
@ -2,33 +2,14 @@
|
||||
#include "2s2h/resource/type/AudioSample.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
namespace LUS {
|
||||
std::shared_ptr<IResource>
|
||||
AudioSampleFactory::ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<AudioSample>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 2:
|
||||
factory = std::make_shared<AudioSampleFactoryV0>();
|
||||
break;
|
||||
namespace SOH {
|
||||
std::shared_ptr<LUS::IResource> ResourceFactoryBinaryAudioSampleV2::ReadResource(std::shared_ptr<LUS::File> file) {
|
||||
if (!FileHasValidFormatAndReader(file)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load AudioSample with version {}", resource->GetInitData()->ResourceVersion);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void LUS::AudioSampleFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource)
|
||||
{
|
||||
std::shared_ptr<AudioSample> audioSample = std::static_pointer_cast<AudioSample>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, audioSample);
|
||||
auto audioSample = std::make_shared<AudioSample>(file->InitData);
|
||||
auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader);
|
||||
|
||||
audioSample->sample.codec = reader->ReadUByte();
|
||||
audioSample->sample.medium = reader->ReadUByte();
|
||||
@ -65,9 +46,10 @@ void LUS::AudioSampleFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> re
|
||||
}
|
||||
audioSample->book.book = audioSample->bookData.data();
|
||||
audioSample->sample.book = &audioSample->book;
|
||||
}
|
||||
} // namespace LUS
|
||||
|
||||
return audioSample;
|
||||
}
|
||||
} // namespace SOH
|
||||
|
||||
/*
|
||||
in ResourceMgr_LoadAudioSample we used to have
|
||||
|
@ -1,19 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "Resource.h"
|
||||
#include "ResourceFactory.h"
|
||||
#include "ResourceFactoryBinary.h"
|
||||
|
||||
namespace LUS {
|
||||
class AudioSampleFactory : public ResourceFactory
|
||||
{
|
||||
namespace SOH {
|
||||
class ResourceFactoryBinaryAudioSampleV2 : public LUS::ResourceFactoryBinary {
|
||||
public:
|
||||
std::shared_ptr<IResource>
|
||||
ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) override;
|
||||
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override;
|
||||
};
|
||||
|
||||
class AudioSampleFactoryV0 : public ResourceVersionFactory
|
||||
{
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
};
|
||||
}; // namespace LUS
|
||||
} // namespace SOH
|
||||
|
@ -2,33 +2,14 @@
|
||||
#include "2s2h/resource/type/AudioSequence.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
namespace LUS {
|
||||
std::shared_ptr<IResource>
|
||||
AudioSequenceFactory::ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<AudioSequence>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 2:
|
||||
factory = std::make_shared<AudioSequenceFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr)
|
||||
{
|
||||
SPDLOG_ERROR("Failed to load AudioSequence with version {}", resource->GetInitData()->ResourceVersion);
|
||||
namespace SOH {
|
||||
std::shared_ptr<LUS::IResource> ResourceFactoryBinaryAudioSequenceV2::ReadResource(std::shared_ptr<LUS::File> file) {
|
||||
if (!FileHasValidFormatAndReader(file)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void LUS::AudioSequenceFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource) {
|
||||
std::shared_ptr<AudioSequence> audioSequence = std::static_pointer_cast<AudioSequence>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, audioSequence);
|
||||
auto audioSequence = std::make_shared<AudioSequence>(file->InitData);
|
||||
auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader);
|
||||
|
||||
audioSequence->sequence.seqDataSize = reader->ReadInt32();
|
||||
audioSequence->sequenceData.reserve(audioSequence->sequence.seqDataSize);
|
||||
@ -48,5 +29,7 @@ void LUS::AudioSequenceFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader>
|
||||
for (uint32_t i = 0; i < audioSequence->sequence.numFonts; i++) {
|
||||
audioSequence->sequence.fonts[i] = reader->ReadUByte();
|
||||
}
|
||||
|
||||
return audioSequence;
|
||||
}
|
||||
} // namespace LUS
|
||||
} // namespace SOH
|
||||
|
@ -1,19 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "Resource.h"
|
||||
#include "ResourceFactory.h"
|
||||
#include "ResourceFactoryBinary.h"
|
||||
|
||||
namespace LUS {
|
||||
class AudioSequenceFactory : public ResourceFactory
|
||||
{
|
||||
namespace SOH {
|
||||
class ResourceFactoryBinaryAudioSequenceV2 : public LUS::ResourceFactoryBinary {
|
||||
public:
|
||||
std::shared_ptr<IResource>
|
||||
ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) override;
|
||||
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override;
|
||||
};
|
||||
|
||||
class AudioSequenceFactoryV0 : public ResourceVersionFactory
|
||||
{
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
};
|
||||
}; // namespace LUS
|
||||
} // namespace SOH
|
||||
|
@ -3,33 +3,14 @@
|
||||
#include "spdlog/spdlog.h"
|
||||
#include "libultraship/libultraship.h"
|
||||
|
||||
namespace LUS {
|
||||
std::shared_ptr<IResource>
|
||||
AudioSoundFontFactory::ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<AudioSoundFont>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 2:
|
||||
factory = std::make_shared<AudioSoundFontFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr)
|
||||
{
|
||||
SPDLOG_ERROR("Failed to load AudioSoundFont with version {}", resource->GetInitData()->ResourceVersion);
|
||||
namespace SOH {
|
||||
std::shared_ptr<LUS::IResource> ResourceFactoryBinaryAudioSoundFontV2::ReadResource(std::shared_ptr<LUS::File> file) {
|
||||
if (!FileHasValidFormatAndReader(file)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void LUS::AudioSoundFontFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource) {
|
||||
std::shared_ptr<AudioSoundFont> audioSoundFont = std::static_pointer_cast<AudioSoundFont>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, audioSoundFont);
|
||||
auto audioSoundFont = std::make_shared<AudioSoundFont>(file->InitData);
|
||||
auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader);
|
||||
|
||||
audioSoundFont->soundFont.fntIndex = reader->ReadInt32();
|
||||
audioSoundFont->medium = reader->ReadInt8();
|
||||
@ -186,5 +167,7 @@ void LUS::AudioSoundFontFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader>
|
||||
audioSoundFont->soundEffects.push_back(soundEffect);
|
||||
}
|
||||
audioSoundFont->soundFont.soundEffects = audioSoundFont->soundEffects.data();
|
||||
|
||||
return audioSoundFont;
|
||||
}
|
||||
} // namespace LUS
|
||||
} // namespace SOH
|
||||
|
@ -1,19 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "Resource.h"
|
||||
#include "ResourceFactory.h"
|
||||
#include "ResourceFactoryBinary.h"
|
||||
|
||||
namespace LUS {
|
||||
class AudioSoundFontFactory : public ResourceFactory
|
||||
{
|
||||
namespace SOH {
|
||||
class ResourceFactoryBinaryAudioSoundFontV2 : public LUS::ResourceFactoryBinary {
|
||||
public:
|
||||
std::shared_ptr<IResource>
|
||||
ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) override;
|
||||
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override;
|
||||
};
|
||||
|
||||
class AudioSoundFontFactoryV0 : public ResourceVersionFactory
|
||||
{
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
};
|
||||
}; // namespace LUS
|
||||
} // namespace SOH
|
||||
|
11
mm/2s2h/resource/importer/AudioSoundFontFactory.h.1
Normal file
11
mm/2s2h/resource/importer/AudioSoundFontFactory.h.1
Normal file
@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "Resource.h"
|
||||
#include "ResourceFactoryBinary.h"
|
||||
|
||||
namespace SOH {
|
||||
class ResourceFactoryBinaryAudioSoundFontV2 : public LUS::ResourceFactoryBinary {
|
||||
public:
|
||||
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override;
|
||||
};
|
||||
} // namespace SOH
|
@ -2,31 +2,14 @@
|
||||
#include "2s2h/resource/type/Background.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
namespace LUS {
|
||||
std::shared_ptr<IResource>
|
||||
BackgroundFactory::ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<Background>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<BackgroundFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load Background with version {}", resource->GetInitData()->ResourceVersion);
|
||||
namespace SOH {
|
||||
std::shared_ptr<LUS::IResource> ResourceFactoryBinaryBackgroundV0::ReadResource(std::shared_ptr<LUS::File> file) {
|
||||
if (!FileHasValidFormatAndReader(file)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void BackgroundFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) {
|
||||
std::shared_ptr<Background> background = std::static_pointer_cast<Background>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, background);
|
||||
auto background = std::make_shared<Background>(file->InitData);
|
||||
auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader);
|
||||
|
||||
uint32_t dataSize = reader->ReadUInt32();
|
||||
|
||||
@ -35,5 +18,7 @@ void BackgroundFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
for (uint32_t i = 0; i < dataSize; i++) {
|
||||
background->Data.push_back(reader->ReadUByte());
|
||||
}
|
||||
|
||||
return background;
|
||||
}
|
||||
} // namespace LUS
|
||||
} // namespace SOH
|
||||
|
@ -1,17 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "resource/Resource.h"
|
||||
#include "resource/ResourceFactory.h"
|
||||
#include "resource/ResourceFactoryBinary.h"
|
||||
|
||||
namespace LUS {
|
||||
class BackgroundFactory : public ResourceFactory {
|
||||
namespace SOH {
|
||||
class ResourceFactoryBinaryBackgroundV0 : public LUS::ResourceFactoryBinary {
|
||||
public:
|
||||
std::shared_ptr<IResource>
|
||||
ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) override;
|
||||
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override;
|
||||
};
|
||||
|
||||
class BackgroundFactoryV0 : public ResourceVersionFactory {
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
};
|
||||
}; // namespace LUS
|
||||
} // namespace SOH
|
||||
|
@ -2,33 +2,14 @@
|
||||
#include "2s2h/resource/type/CollisionHeader.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
namespace LUS {
|
||||
std::shared_ptr<IResource>
|
||||
CollisionHeaderFactory::ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<CollisionHeader>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<CollisionHeaderFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load Collision Header with version {}", resource->GetInitData()->ResourceVersion);
|
||||
namespace SOH {
|
||||
std::shared_ptr<LUS::IResource> ResourceFactoryBinaryCollisionHeaderV0::ReadResource(std::shared_ptr<LUS::File> file) {
|
||||
if (!FileHasValidFormatAndReader(file)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void LUS::CollisionHeaderFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource)
|
||||
{
|
||||
std::shared_ptr<CollisionHeader> collisionHeader = std::static_pointer_cast<CollisionHeader>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, collisionHeader);
|
||||
auto collisionHeader = std::make_shared<CollisionHeader>(file->InitData);
|
||||
auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader);
|
||||
|
||||
collisionHeader->collisionHeaderData.minBounds.x = reader->ReadInt16();
|
||||
collisionHeader->collisionHeaderData.minBounds.y = reader->ReadInt16();
|
||||
@ -138,5 +119,129 @@ void LUS::CollisionHeaderFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader
|
||||
collisionHeader->waterBoxes.push_back(waterBox);
|
||||
}
|
||||
collisionHeader->collisionHeaderData.waterBoxes = collisionHeader->waterBoxes.data();
|
||||
|
||||
return collisionHeader;
|
||||
}
|
||||
|
||||
std::shared_ptr<LUS::IResource> ResourceFactoryXMLCollisionHeaderV0::ReadResource(std::shared_ptr<LUS::File> file) {
|
||||
if (!FileHasValidFormatAndReader(file)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto collisionHeader = std::make_shared<CollisionHeader>(file->InitData);
|
||||
|
||||
auto reader = std::get<std::shared_ptr<tinyxml2::XMLDocument>>(file->Reader)->FirstChildElement();
|
||||
auto child = reader->FirstChildElement();
|
||||
|
||||
collisionHeader->collisionHeaderData.minBounds.x = reader->IntAttribute("MinBoundsX");
|
||||
collisionHeader->collisionHeaderData.minBounds.y = reader->IntAttribute("MinBoundsY");
|
||||
collisionHeader->collisionHeaderData.minBounds.z = reader->IntAttribute("MinBoundsZ");
|
||||
|
||||
collisionHeader->collisionHeaderData.maxBounds.x = reader->IntAttribute("MaxBoundsX");
|
||||
collisionHeader->collisionHeaderData.maxBounds.y = reader->IntAttribute("MaxBoundsY");
|
||||
collisionHeader->collisionHeaderData.maxBounds.z = reader->IntAttribute("MaxBoundsZ");
|
||||
|
||||
Vec3s zero;
|
||||
zero.x = 0;
|
||||
zero.y = 0;
|
||||
zero.z = 0;
|
||||
collisionHeader->camPosDataZero = zero;
|
||||
|
||||
while (child != nullptr) {
|
||||
std::string childName = child->Name();
|
||||
if (childName == "Vertex") {
|
||||
Vec3s vtx;
|
||||
vtx.x = child->IntAttribute("X");
|
||||
vtx.y = child->IntAttribute("Y");
|
||||
vtx.z = child->IntAttribute("Z");
|
||||
collisionHeader->vertices.push_back(vtx);
|
||||
} else if (childName == "Polygon") {
|
||||
CollisionPoly polygon;
|
||||
|
||||
polygon.type = child->UnsignedAttribute("Type");
|
||||
|
||||
polygon.flags_vIA = child->UnsignedAttribute("VertexA");
|
||||
polygon.flags_vIB = child->UnsignedAttribute("VertexB");
|
||||
polygon.vIC = child->UnsignedAttribute("VertexC");
|
||||
|
||||
polygon.normal.x = child->IntAttribute("NormalX");
|
||||
polygon.normal.y = child->IntAttribute("NormalY");
|
||||
polygon.normal.z = child->IntAttribute("NormalZ");
|
||||
|
||||
polygon.dist = child->IntAttribute("Dist");
|
||||
|
||||
collisionHeader->polygons.push_back(polygon);
|
||||
} else if (childName == "PolygonType") {
|
||||
SurfaceType surfaceType;
|
||||
|
||||
surfaceType.data[0] = child->UnsignedAttribute("Data1");
|
||||
surfaceType.data[1] = child->UnsignedAttribute("Data2");
|
||||
|
||||
collisionHeader->surfaceTypes.push_back(surfaceType);
|
||||
} else if (childName == "CameraData") {
|
||||
CamData camDataEntry;
|
||||
camDataEntry.cameraSType = child->UnsignedAttribute("SType");
|
||||
camDataEntry.numCameras = child->IntAttribute("NumData");
|
||||
collisionHeader->camData.push_back(camDataEntry);
|
||||
|
||||
int32_t camPosDataIdx = child->IntAttribute("CameraPosDataSeg");
|
||||
collisionHeader->camPosDataIndices.push_back(camPosDataIdx);
|
||||
} else if (childName == "CameraPositionData") {
|
||||
//each camera position data is made up of 3 Vec3s
|
||||
Vec3s pos;
|
||||
pos.x = child->IntAttribute("PosX");
|
||||
pos.y = child->IntAttribute("PosY");
|
||||
pos.z = child->IntAttribute("PosZ");
|
||||
collisionHeader->camPosData.push_back(pos);
|
||||
Vec3s rot;
|
||||
rot.x = child->IntAttribute("RotX");
|
||||
rot.y = child->IntAttribute("RotY");
|
||||
rot.z = child->IntAttribute("RotZ");
|
||||
collisionHeader->camPosData.push_back(rot);
|
||||
Vec3s other;
|
||||
other.x = child->IntAttribute("FOV");
|
||||
other.y = child->IntAttribute("JfifID");
|
||||
other.z = child->IntAttribute("Unknown");
|
||||
collisionHeader->camPosData.push_back(other);
|
||||
} else if (childName == "WaterBox") {
|
||||
WaterBox waterBox;
|
||||
waterBox.xMin = child->IntAttribute("XMin");
|
||||
waterBox.ySurface = child->IntAttribute("Ysurface");
|
||||
waterBox.zMin = child->IntAttribute("ZMin");
|
||||
waterBox.xLength = child->IntAttribute("XLength");
|
||||
waterBox.zLength = child->IntAttribute("ZLength");
|
||||
waterBox.properties = child->IntAttribute("Properties");
|
||||
|
||||
collisionHeader->waterBoxes.push_back(waterBox);
|
||||
}
|
||||
|
||||
child = child->NextSiblingElement();
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < collisionHeader->camData.size(); i++) {
|
||||
int32_t idx = collisionHeader->camPosDataIndices[i];
|
||||
|
||||
if (collisionHeader->camPosData.size() > 0) {
|
||||
collisionHeader->camData[i].camPosData = &collisionHeader->camPosData[idx];
|
||||
} else {
|
||||
collisionHeader->camData[i].camPosData = &collisionHeader->camPosDataZero;
|
||||
}
|
||||
}
|
||||
|
||||
collisionHeader->collisionHeaderData.numVertices = collisionHeader->vertices.size();
|
||||
collisionHeader->collisionHeaderData.numPolygons = collisionHeader->polygons.size();
|
||||
collisionHeader->surfaceTypesCount = collisionHeader->surfaceTypes.size();
|
||||
collisionHeader->camDataCount = collisionHeader->camData.size();
|
||||
collisionHeader->camPosCount = collisionHeader->camPosData.size();
|
||||
collisionHeader->collisionHeaderData.numWaterBoxes = collisionHeader->waterBoxes.size();
|
||||
|
||||
collisionHeader->collisionHeaderData.vtxList = collisionHeader->vertices.data();
|
||||
collisionHeader->collisionHeaderData.polyList = collisionHeader->polygons.data();
|
||||
collisionHeader->collisionHeaderData.surfaceTypeList = collisionHeader->surfaceTypes.data();
|
||||
collisionHeader->collisionHeaderData.cameraDataList = collisionHeader->camData.data();
|
||||
collisionHeader->collisionHeaderData.cameraDataListLen = collisionHeader->camDataCount;
|
||||
collisionHeader->collisionHeaderData.waterBoxes = collisionHeader->waterBoxes.data();
|
||||
|
||||
return collisionHeader;
|
||||
}
|
||||
} // namespace SOH
|
||||
|
@ -1,17 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "Resource.h"
|
||||
#include "ResourceFactory.h"
|
||||
#include "ResourceFactoryBinary.h"
|
||||
#include "ResourceFactoryXML.h"
|
||||
|
||||
namespace LUS {
|
||||
class CollisionHeaderFactory : public ResourceFactory {
|
||||
namespace SOH {
|
||||
class ResourceFactoryBinaryCollisionHeaderV0 : public LUS::ResourceFactoryBinary {
|
||||
public:
|
||||
std::shared_ptr<IResource>
|
||||
ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) override;
|
||||
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override;
|
||||
};
|
||||
|
||||
class CollisionHeaderFactoryV0 : public ResourceVersionFactory {
|
||||
class ResourceFactoryXMLCollisionHeaderV0 : public LUS::ResourceFactoryXML {
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override;
|
||||
};
|
||||
}; // namespace LUS
|
||||
} // namespace SOH
|
||||
|
@ -243,36 +243,16 @@ typedef enum {
|
||||
/* -1 */ CS_CAM_STOP // OoT Remnant
|
||||
} CutsceneCmd;
|
||||
|
||||
namespace LUS {
|
||||
std::shared_ptr<IResource> CutsceneFactory::ReadResource(std::shared_ptr<ResourceInitData> initData,
|
||||
std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<Cutscene>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
namespace SOH {
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<CutsceneFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load Cutscene with version {}", resource->GetInitData()->ResourceVersion);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
static inline uint32_t read_CMD_BBBB(std::shared_ptr<BinaryReader> reader) {
|
||||
static inline uint32_t read_CMD_BBBB(std::shared_ptr<LUS::BinaryReader> reader) {
|
||||
uint32_t v;
|
||||
reader->Read((char*)&v, sizeof(uint32_t));
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
static inline uint32_t read_CMD_BBH(std::shared_ptr<BinaryReader> reader) {
|
||||
static inline uint32_t read_CMD_BBH(std::shared_ptr<LUS::BinaryReader> reader) {
|
||||
uint32_t v;
|
||||
reader->Read((char*)&v, sizeof(uint32_t));
|
||||
|
||||
@ -287,7 +267,7 @@ static inline uint32_t read_CMD_BBH(std::shared_ptr<BinaryReader> reader) {
|
||||
return v;
|
||||
}
|
||||
|
||||
static inline uint32_t read_CMD_HBB(std::shared_ptr<BinaryReader> reader) {
|
||||
static inline uint32_t read_CMD_HBB(std::shared_ptr<LUS::BinaryReader> reader) {
|
||||
uint32_t v;
|
||||
reader->Read((char*)&v, sizeof(uint32_t));
|
||||
|
||||
@ -302,7 +282,7 @@ static inline uint32_t read_CMD_HBB(std::shared_ptr<BinaryReader> reader) {
|
||||
return v;
|
||||
}
|
||||
|
||||
static inline uint32_t read_CMD_HH(std::shared_ptr<BinaryReader> reader) {
|
||||
static inline uint32_t read_CMD_HH(std::shared_ptr<LUS::BinaryReader> reader) {
|
||||
uint32_t v;
|
||||
reader->Read((char*)&v, sizeof(uint32_t));
|
||||
|
||||
@ -320,10 +300,13 @@ static inline uint32_t read_CMD_HH(std::shared_ptr<BinaryReader> reader) {
|
||||
return v;
|
||||
}
|
||||
|
||||
void LUS::CutsceneFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource) {
|
||||
std::shared_ptr<Cutscene> cutscene = std::static_pointer_cast<Cutscene>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, cutscene);
|
||||
std::shared_ptr<LUS::IResource> ResourceFactoryBinaryCutsceneV0::ReadResource(std::shared_ptr<LUS::File> file) {
|
||||
if (!FileHasValidFormatAndReader(file)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto cutscene = std::make_shared<Cutscene>(file->InitData);
|
||||
auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader);
|
||||
|
||||
uint32_t numEntries = reader->ReadUInt32();
|
||||
cutscene->commands.reserve(numEntries);
|
||||
@ -335,9 +318,161 @@ void LUS::CutsceneFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reade
|
||||
cutscene->commands.push_back(cutscene->endFrame);
|
||||
|
||||
// BENTODO detect the game
|
||||
ParseFileBinaryMM(reader, cutscene);
|
||||
while (true) {
|
||||
uint32_t command = reader->ReadUInt32();
|
||||
cutscene->commands.push_back(command);
|
||||
|
||||
if (((command >= CS_CMD_ACTOR_CUE_100) && (command <= CS_CMD_ACTOR_CUE_149)) ||
|
||||
(command == CS_CMD_ACTOR_CUE_201) ||
|
||||
((command >= CS_CMD_ACTOR_CUE_450) && (command <= CS_CMD_ACTOR_CUE_599))) {
|
||||
goto actorCue;
|
||||
}
|
||||
|
||||
switch (command) {
|
||||
case CS_CMD_TEXT: {
|
||||
uint32_t size = reader->ReadUInt32();
|
||||
cutscene->commands.push_back(size);
|
||||
|
||||
for (uint32_t i = 0; i < size; i++) {
|
||||
cutscene->commands.push_back(read_CMD_HH(reader));
|
||||
cutscene->commands.push_back(read_CMD_HH(reader));
|
||||
cutscene->commands.push_back(read_CMD_HH(reader));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CS_CMD_CAMERA_SPLINE: {
|
||||
uint32_t size = reader->ReadUInt32();
|
||||
cutscene->commands.push_back(size);
|
||||
|
||||
while (1) {
|
||||
// We need to store the first half of the header to get the number of entries.
|
||||
uint32_t header1 = read_CMD_HH(reader);
|
||||
|
||||
uint32_t numEntries = header1 & 0xFFFF;
|
||||
|
||||
cutscene->commands.push_back(header1);
|
||||
if (numEntries == 0xFFFF) {
|
||||
break; // Last command is HH(0xFFFF, 0004) which was already read in and pushed into the vector
|
||||
}
|
||||
cutscene->commands.push_back(read_CMD_HH(reader));
|
||||
|
||||
for (size_t j = 0; j < numEntries * 2; j++) {
|
||||
cutscene->commands.push_back(read_CMD_BBH(reader));
|
||||
cutscene->commands.push_back(read_CMD_HH(reader));
|
||||
cutscene->commands.push_back(read_CMD_HH(reader));
|
||||
}
|
||||
|
||||
for (size_t j = 0; j < numEntries; j++) {
|
||||
cutscene->commands.push_back(read_CMD_HH(reader));
|
||||
cutscene->commands.push_back(read_CMD_HH(reader));
|
||||
}
|
||||
}
|
||||
|
||||
// for (uint32_t i = 0; i < (size / 4); i++) {
|
||||
|
||||
// cutscene->commands.push_back(read_CMD_HH(reader));
|
||||
//}
|
||||
break;
|
||||
}
|
||||
case CS_CMD_MISC:
|
||||
case CS_CMD_LIGHT_SETTING:
|
||||
case CS_CMD_TRANSITION:
|
||||
case CS_CMD_MOTION_BLUR:
|
||||
case CS_CMD_GIVE_TATL:
|
||||
case CS_CMD_START_SEQ:
|
||||
case CS_CMD_STOP_SEQ:
|
||||
case CS_CMD_SFX_REVERB_INDEX_2:
|
||||
case CS_CMD_SFX_REVERB_INDEX_1:
|
||||
case CS_CMD_MODIFY_SEQ:
|
||||
case CS_CMD_START_AMBIENCE:
|
||||
case CS_CMD_FADE_OUT_AMBIENCE:
|
||||
case CS_CMD_DESTINATION:
|
||||
case CS_CMD_CHOOSE_CREDITS_SCENES:
|
||||
default: {
|
||||
uint32_t size = reader->ReadUInt32();
|
||||
cutscene->commands.push_back(size);
|
||||
|
||||
for (uint32_t i = 0; i < size; i++) {
|
||||
cutscene->commands.push_back(read_CMD_HH(reader));
|
||||
cutscene->commands.push_back(read_CMD_HH(reader));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CS_CMD_TRANSITION_GENERAL: {
|
||||
uint32_t size = reader->ReadUInt32();
|
||||
cutscene->commands.push_back(size);
|
||||
|
||||
for (uint32_t i = 0; i < size; i++) {
|
||||
cutscene->commands.push_back(read_CMD_HH(reader));
|
||||
cutscene->commands.push_back(read_CMD_HBB(reader));
|
||||
cutscene->commands.push_back(read_CMD_BBBB(reader));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CS_CMD_FADE_OUT_SEQ: {
|
||||
uint32_t size = reader->ReadUInt32();
|
||||
cutscene->commands.push_back(size);
|
||||
|
||||
for (uint32_t i = 0; i < size; i++) {
|
||||
cutscene->commands.push_back(read_CMD_HH(reader));
|
||||
cutscene->commands.push_back(read_CMD_HH(reader));
|
||||
cutscene->commands.push_back(reader->ReadUInt32());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CS_CMD_TIME: {
|
||||
uint32_t size = reader->ReadUInt32();
|
||||
cutscene->commands.push_back(size);
|
||||
|
||||
for (uint32_t i = 0; i < size; i++) {
|
||||
cutscene->commands.push_back(read_CMD_HH(reader));
|
||||
cutscene->commands.push_back(read_CMD_HBB(reader));
|
||||
cutscene->commands.push_back(reader->ReadUInt32());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CS_CMD_PLAYER_CUE: {
|
||||
actorCue:
|
||||
uint32_t size = reader->ReadUInt32();
|
||||
cutscene->commands.push_back(size);
|
||||
for (uint32_t i = 0; i < size; i++) {
|
||||
cutscene->commands.push_back(read_CMD_HH(reader));
|
||||
cutscene->commands.push_back(read_CMD_HH(reader));
|
||||
cutscene->commands.push_back(read_CMD_HH(reader));
|
||||
cutscene->commands.push_back(reader->ReadUInt32());
|
||||
cutscene->commands.push_back(reader->ReadUInt32());
|
||||
cutscene->commands.push_back(reader->ReadUInt32());
|
||||
cutscene->commands.push_back(reader->ReadUInt32());
|
||||
cutscene->commands.push_back(reader->ReadUInt32());
|
||||
cutscene->commands.push_back(reader->ReadUInt32());
|
||||
cutscene->commands.push_back(reader->ReadUInt32());
|
||||
cutscene->commands.push_back(reader->ReadUInt32());
|
||||
cutscene->commands.push_back(reader->ReadUInt32());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CS_CMD_RUMBLE: {
|
||||
uint32_t size = reader->ReadUInt32();
|
||||
cutscene->commands.push_back(size);
|
||||
|
||||
for (uint32_t i = 0; i < size; i++) {
|
||||
cutscene->commands.push_back(read_CMD_HH(reader));
|
||||
cutscene->commands.push_back(read_CMD_HBB(reader));
|
||||
cutscene->commands.push_back(read_CMD_BBBB(reader));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0xFFFFFFFF: {
|
||||
cutscene->commands.push_back(reader->ReadUInt32());
|
||||
return cutscene;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return cutscene;
|
||||
}
|
||||
|
||||
#if 0
|
||||
void LUS::CutsceneFactoryV0::ParseFileBinaryOoT(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<Cutscene> cutscene) {
|
||||
while (true) {
|
||||
@ -714,159 +849,5 @@ void LUS::CutsceneFactoryV0::ParseFileBinaryOoT(std::shared_ptr<BinaryReader> re
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LUS::CutsceneFactoryV0::ParseFileBinaryMM(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<Cutscene> cutscene) {
|
||||
while (true) {
|
||||
uint32_t command = reader->ReadUInt32();
|
||||
cutscene->commands.push_back(command);
|
||||
|
||||
if (((command >= CS_CMD_ACTOR_CUE_100) && (command <= CS_CMD_ACTOR_CUE_149)) ||
|
||||
(command == CS_CMD_ACTOR_CUE_201) ||
|
||||
((command >= CS_CMD_ACTOR_CUE_450) && (command <= CS_CMD_ACTOR_CUE_599))) {
|
||||
goto actorCue;
|
||||
}
|
||||
|
||||
switch (command) {
|
||||
case CS_CMD_TEXT: {
|
||||
uint32_t size = reader->ReadUInt32();
|
||||
cutscene->commands.push_back(size);
|
||||
|
||||
for (uint32_t i = 0; i < size; i++) {
|
||||
cutscene->commands.push_back(read_CMD_HH(reader));
|
||||
cutscene->commands.push_back(read_CMD_HH(reader));
|
||||
cutscene->commands.push_back(read_CMD_HH(reader));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CS_CMD_CAMERA_SPLINE: {
|
||||
uint32_t size = reader->ReadUInt32();
|
||||
cutscene->commands.push_back(size);
|
||||
|
||||
while (1) {
|
||||
// We need to store the first half of the header to get the number of entries.
|
||||
uint32_t header1 = read_CMD_HH(reader);
|
||||
|
||||
uint32_t numEntries = header1 & 0xFFFF;
|
||||
|
||||
cutscene->commands.push_back(header1);
|
||||
if (numEntries == 0xFFFF) {
|
||||
break; //Last command is HH(0xFFFF, 0004) which was already read in and pushed into the vector
|
||||
}
|
||||
cutscene->commands.push_back(read_CMD_HH(reader));
|
||||
|
||||
for (size_t j = 0; j < numEntries * 2; j++) {
|
||||
cutscene->commands.push_back(read_CMD_BBH(reader));
|
||||
cutscene->commands.push_back(read_CMD_HH(reader));
|
||||
cutscene->commands.push_back(read_CMD_HH(reader));
|
||||
}
|
||||
|
||||
for (size_t j = 0; j < numEntries; j++) {
|
||||
cutscene->commands.push_back(read_CMD_HH(reader));
|
||||
cutscene->commands.push_back(read_CMD_HH(reader));
|
||||
}
|
||||
}
|
||||
|
||||
//for (uint32_t i = 0; i < (size / 4); i++) {
|
||||
|
||||
//cutscene->commands.push_back(read_CMD_HH(reader));
|
||||
//}
|
||||
break;
|
||||
}
|
||||
case CS_CMD_MISC:
|
||||
case CS_CMD_LIGHT_SETTING:
|
||||
case CS_CMD_TRANSITION:
|
||||
case CS_CMD_MOTION_BLUR:
|
||||
case CS_CMD_GIVE_TATL:
|
||||
case CS_CMD_START_SEQ:
|
||||
case CS_CMD_STOP_SEQ:
|
||||
case CS_CMD_SFX_REVERB_INDEX_2:
|
||||
case CS_CMD_SFX_REVERB_INDEX_1:
|
||||
case CS_CMD_MODIFY_SEQ:
|
||||
case CS_CMD_START_AMBIENCE:
|
||||
case CS_CMD_FADE_OUT_AMBIENCE:
|
||||
case CS_CMD_DESTINATION:
|
||||
case CS_CMD_CHOOSE_CREDITS_SCENES:
|
||||
default: {
|
||||
uint32_t size = reader->ReadUInt32();
|
||||
cutscene->commands.push_back(size);
|
||||
|
||||
for (uint32_t i = 0; i < size; i++) {
|
||||
cutscene->commands.push_back(read_CMD_HH(reader));
|
||||
cutscene->commands.push_back(read_CMD_HH(reader));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CS_CMD_TRANSITION_GENERAL: {
|
||||
uint32_t size = reader->ReadUInt32();
|
||||
cutscene->commands.push_back(size);
|
||||
|
||||
for (uint32_t i = 0; i < size; i++) {
|
||||
cutscene->commands.push_back(read_CMD_HH(reader));
|
||||
cutscene->commands.push_back(read_CMD_HBB(reader));
|
||||
cutscene->commands.push_back(read_CMD_BBBB(reader));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CS_CMD_FADE_OUT_SEQ: {
|
||||
uint32_t size = reader->ReadUInt32();
|
||||
cutscene->commands.push_back(size);
|
||||
|
||||
for (uint32_t i = 0; i < size; i++) {
|
||||
cutscene->commands.push_back(read_CMD_HH(reader));
|
||||
cutscene->commands.push_back(read_CMD_HH(reader));
|
||||
cutscene->commands.push_back(reader->ReadUInt32());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CS_CMD_TIME: {
|
||||
uint32_t size = reader->ReadUInt32();
|
||||
cutscene->commands.push_back(size);
|
||||
|
||||
for (uint32_t i = 0; i < size; i++) {
|
||||
cutscene->commands.push_back(read_CMD_HH(reader));
|
||||
cutscene->commands.push_back(read_CMD_HBB(reader));
|
||||
cutscene->commands.push_back(reader->ReadUInt32());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CS_CMD_PLAYER_CUE: {
|
||||
actorCue:
|
||||
uint32_t size = reader->ReadUInt32();
|
||||
cutscene->commands.push_back(size);
|
||||
for (uint32_t i = 0; i < size; i++) {
|
||||
cutscene->commands.push_back(read_CMD_HH(reader));
|
||||
cutscene->commands.push_back(read_CMD_HH(reader));
|
||||
cutscene->commands.push_back(read_CMD_HH(reader));
|
||||
cutscene->commands.push_back(reader->ReadUInt32());
|
||||
cutscene->commands.push_back(reader->ReadUInt32());
|
||||
cutscene->commands.push_back(reader->ReadUInt32());
|
||||
cutscene->commands.push_back(reader->ReadUInt32());
|
||||
cutscene->commands.push_back(reader->ReadUInt32());
|
||||
cutscene->commands.push_back(reader->ReadUInt32());
|
||||
cutscene->commands.push_back(reader->ReadUInt32());
|
||||
cutscene->commands.push_back(reader->ReadUInt32());
|
||||
cutscene->commands.push_back(reader->ReadUInt32());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CS_CMD_RUMBLE: {
|
||||
uint32_t size = reader->ReadUInt32();
|
||||
cutscene->commands.push_back(size);
|
||||
|
||||
for (uint32_t i = 0; i < size; i++) {
|
||||
cutscene->commands.push_back(read_CMD_HH(reader));
|
||||
cutscene->commands.push_back(read_CMD_HBB(reader));
|
||||
cutscene->commands.push_back(read_CMD_BBBB(reader));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0xFFFFFFFF: {
|
||||
cutscene->commands.push_back(reader->ReadUInt32());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
} // namespace LUS
|
||||
|
@ -1,25 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "Resource.h"
|
||||
#include "ResourceFactory.h"
|
||||
#include "ResourceFactoryBinary.h"
|
||||
|
||||
|
||||
namespace LUS {
|
||||
class Cutscene;
|
||||
class CutsceneFactory : public ResourceFactory
|
||||
{
|
||||
namespace SOH {
|
||||
class ResourceFactoryBinaryCutsceneV0 : public LUS::ResourceFactoryBinary {
|
||||
public:
|
||||
std::shared_ptr<IResource>
|
||||
ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) override;
|
||||
};
|
||||
|
||||
class CutsceneFactoryV0 : public ResourceVersionFactory
|
||||
{
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
|
||||
private:
|
||||
void ParseFileBinaryOoT(std::shared_ptr<BinaryReader> reader,std::shared_ptr<Cutscene> cutscene);
|
||||
void ParseFileBinaryMM(std::shared_ptr<BinaryReader> reader, std::shared_ptr<Cutscene> cutscene);
|
||||
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override;
|
||||
};
|
||||
}; // namespace LUS
|
||||
|
@ -4,38 +4,18 @@
|
||||
#include "spdlog/spdlog.h"
|
||||
#include "../ZAPDTR/ZAPD/ZCKeyFrame.h"
|
||||
|
||||
namespace LUS {
|
||||
|
||||
|
||||
|
||||
std::shared_ptr<IResource> KeyFrameSkelFactory::ReadResource(std::shared_ptr<ResourceInitData> initData,
|
||||
std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<KeyFrameSkel>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<KeyFrameSkelFactoryV0>();
|
||||
break;
|
||||
namespace SOH {
|
||||
std::shared_ptr<LUS::IResource> ResourceFactoryBinaryKeyFrameSkel::ReadResource(std::shared_ptr<LUS::File> file) {
|
||||
if (!FileHasValidFormatAndReader(file)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load Key Frame skel with version {}", resource->GetInitData()->ResourceVersion);
|
||||
}
|
||||
auto skel = std::make_shared<KeyFrameSkel>(file->InitData);
|
||||
auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader);
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void KeyFrameSkelFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) {
|
||||
std::shared_ptr<KeyFrameSkel> skel = std::static_pointer_cast<KeyFrameSkel>(resource);
|
||||
ZKeyframeSkelType skelType;
|
||||
|
||||
ResourceVersionFactory::ParseFileBinary(reader, skel);
|
||||
skel->skelData.limbCount = reader->ReadUByte();
|
||||
skel->skelData.dListCount = reader->ReadUByte();
|
||||
skelType = (ZKeyframeSkelType)reader->ReadUByte();
|
||||
ZKeyframeSkelType skelType = (ZKeyframeSkelType)reader->ReadUByte();
|
||||
uint8_t numLimbs = reader->ReadUByte();
|
||||
|
||||
if (skelType == ZKeyframeSkelType::Normal) {
|
||||
@ -69,39 +49,22 @@ void KeyFrameSkelFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader
|
||||
limbs[i].flags = reader->ReadUByte();
|
||||
limbs[i].callbackIndex = reader->ReadUByte();
|
||||
}
|
||||
skel->skelData.limbsFlex = limbs;
|
||||
skel->skelData.limbsFlex = limbs;
|
||||
}
|
||||
|
||||
return skel;
|
||||
}
|
||||
|
||||
std::shared_ptr<IResource> KeyFrameAnimFactory::ReadResource(std::shared_ptr<ResourceInitData> initData,
|
||||
std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<KeyFrameAnim>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<KeyFrameAnimFactoryV0>();
|
||||
break;
|
||||
std::shared_ptr<LUS::IResource> ResourceFactoryBinaryKeyFrameAnim::ReadResource(std::shared_ptr<LUS::File> file) {
|
||||
if (!FileHasValidFormatAndReader(file)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load Key Frame skel with version {}", resource->GetInitData()->ResourceVersion);
|
||||
}
|
||||
auto anim = std::make_shared<KeyFrameAnim>(file->InitData);
|
||||
auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader);
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void KeyFrameAnimFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) {
|
||||
std::shared_ptr<KeyFrameAnim> anim = std::static_pointer_cast<KeyFrameAnim>(resource);
|
||||
ZKeyframeSkelType skelType;
|
||||
|
||||
ResourceVersionFactory::ParseFileBinary(reader, anim);
|
||||
|
||||
skelType = (ZKeyframeSkelType)reader->ReadUByte();
|
||||
|
||||
uint32_t numBitFlags = reader->ReadUInt32();
|
||||
const ZKeyframeSkelType skelType = (ZKeyframeSkelType)reader->ReadUByte();
|
||||
const uint32_t numBitFlags = reader->ReadUInt32();
|
||||
|
||||
if (skelType == ZKeyframeSkelType::Normal) {
|
||||
anim->animData.bitFlags = new u8[numBitFlags];
|
||||
@ -142,6 +105,7 @@ void KeyFrameAnimFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader
|
||||
anim->animData.unk_10[0] = reader->ReadUByte();
|
||||
|
||||
anim->animData.duration = reader->ReadUInt16();
|
||||
}
|
||||
|
||||
} // namespace LUS
|
||||
return anim;
|
||||
}
|
||||
} // namespace SOH
|
||||
|
@ -1,29 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "Resource.h"
|
||||
#include "ResourceFactory.h"
|
||||
#include "ResourceFactoryBinary.h"
|
||||
|
||||
namespace LUS {
|
||||
class KeyFrameSkelFactory : public ResourceFactory {
|
||||
namespace SOH {
|
||||
class ResourceFactoryBinaryKeyFrameSkel : public LUS::ResourceFactoryBinary {
|
||||
public:
|
||||
std::shared_ptr<IResource> ReadResource(std::shared_ptr<ResourceInitData> initData,
|
||||
std::shared_ptr<BinaryReader> reader) override;
|
||||
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override;
|
||||
};
|
||||
|
||||
class KeyFrameSkelFactoryV0 : public ResourceVersionFactory {
|
||||
class ResourceFactoryBinaryKeyFrameAnim : public LUS::ResourceFactoryBinary {
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
};
|
||||
|
||||
class KeyFrameAnimFactory : public ResourceFactory {
|
||||
public:
|
||||
std::shared_ptr<IResource> ReadResource(std::shared_ptr<ResourceInitData> initData,
|
||||
std::shared_ptr<BinaryReader> reader) override;
|
||||
};
|
||||
|
||||
class KeyFrameAnimFactoryV0 : public ResourceVersionFactory {
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override;
|
||||
};
|
||||
|
||||
};
|
@ -2,82 +2,14 @@
|
||||
#include "2s2h/resource/type/Path.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
namespace LUS {
|
||||
std::shared_ptr<IResource>
|
||||
PathFactory::ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<Path>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<PathFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load Path with version {}", resource->GetInitData()->ResourceVersion);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void LUS::PathFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource) {
|
||||
std::shared_ptr<Path> path = std::static_pointer_cast<Path>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, path);
|
||||
|
||||
path->numPaths = reader->ReadUInt32();
|
||||
path->paths.reserve(path->numPaths);
|
||||
for (uint32_t k = 0; k < path->numPaths; k++) {
|
||||
std::vector<Vec3s> points;
|
||||
uint32_t pointCount = reader->ReadUInt32();
|
||||
points.reserve(pointCount);
|
||||
for (uint32_t i = 0; i < pointCount; i++) {
|
||||
Vec3s point;
|
||||
point.x = reader->ReadInt16();
|
||||
point.y = reader->ReadInt16();
|
||||
point.z = reader->ReadInt16();
|
||||
|
||||
points.push_back(point);
|
||||
}
|
||||
|
||||
PathData pathDataEntry;
|
||||
pathDataEntry.count = pointCount;
|
||||
|
||||
path->paths.push_back(points);
|
||||
pathDataEntry.points = path->paths.back().data();
|
||||
|
||||
path->pathData.push_back(pathDataEntry);
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<IResource> PathFactoryMM::ReadResource(std::shared_ptr<ResourceInitData> initData,
|
||||
std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<Path>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<PathFactoryMMV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load Path with version {}", resource->GetInitData()->ResourceVersion);
|
||||
namespace SOH {
|
||||
std::shared_ptr<LUS::IResource> ResourceFactoryBinaryPathMMV0::ReadResource(std::shared_ptr<LUS::File> file) {
|
||||
if (!FileHasValidFormatAndReader(file)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void LUS::PathFactoryMMV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) {
|
||||
std::shared_ptr<PathMM> path = std::static_pointer_cast<PathMM>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, path);
|
||||
auto path = std::make_shared<PathMM>(file->InitData);
|
||||
auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader);
|
||||
|
||||
path->numPaths = reader->ReadUInt32();
|
||||
path->paths.reserve(path->numPaths);
|
||||
@ -107,7 +39,7 @@ void LUS::PathFactoryMMV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
|
||||
path->pathData.push_back(pathDataEntry);
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
} // namespace LUS
|
||||
} // namespace SOH
|
||||
|
@ -1,31 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "Resource.h"
|
||||
#include "ResourceFactory.h"
|
||||
#include "ResourceFactoryBinary.h"
|
||||
|
||||
namespace LUS {
|
||||
class PathFactory : public ResourceFactory
|
||||
{
|
||||
namespace SOH {
|
||||
class ResourceFactoryBinaryPathMMV0 : public LUS::ResourceFactoryBinary {
|
||||
public:
|
||||
std::shared_ptr<IResource>
|
||||
ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) override;
|
||||
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override;
|
||||
};
|
||||
|
||||
class PathFactoryV0 : public ResourceVersionFactory
|
||||
{
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
};
|
||||
|
||||
class PathFactoryMM : public ResourceFactory {
|
||||
public:
|
||||
std::shared_ptr<IResource> ReadResource(std::shared_ptr<ResourceInitData> initData,
|
||||
std::shared_ptr<BinaryReader> reader) override;
|
||||
};
|
||||
|
||||
class PathFactoryMMV0 : public ResourceVersionFactory {
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
};
|
||||
|
||||
}; // namespace LUS
|
||||
} // namespace SOH
|
||||
|
@ -2,34 +2,15 @@
|
||||
#include "2s2h/resource/type/PlayerAnimation.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
namespace LUS {
|
||||
std::shared_ptr<IResource>
|
||||
PlayerAnimationFactory::ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<PlayerAnimation>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<PlayerAnimationFactoryV0>();
|
||||
break;
|
||||
namespace SOH {
|
||||
std::shared_ptr<LUS::IResource>
|
||||
ResourceFactoryBinaryPlayerAnimationV0::ReadResource(std::shared_ptr<LUS::File> file) {
|
||||
if (!FileHasValidFormatAndReader(file)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (factory == nullptr)
|
||||
{
|
||||
SPDLOG_ERROR("Failed to load PlayerAnimation with version {}", resource->GetInitData()->ResourceVersion);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void LUS::PlayerAnimationFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource)
|
||||
{
|
||||
std::shared_ptr<PlayerAnimation> playerAnimation = std::static_pointer_cast<PlayerAnimation>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, playerAnimation);
|
||||
auto playerAnimation = std::make_shared<PlayerAnimation>(file->InitData);
|
||||
auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader);
|
||||
|
||||
uint32_t numEntries = reader->ReadUInt32();
|
||||
playerAnimation->limbRotData.reserve(numEntries);
|
||||
@ -37,5 +18,7 @@ void LUS::PlayerAnimationFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader
|
||||
for (uint32_t i = 0; i < numEntries; i++) {
|
||||
playerAnimation->limbRotData.push_back(reader->ReadInt16());
|
||||
}
|
||||
|
||||
return playerAnimation;
|
||||
}
|
||||
} // namespace LUS
|
||||
} // namespace SOH
|
||||
|
@ -1,17 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "Resource.h"
|
||||
#include "ResourceFactory.h"
|
||||
#include "ResourceFactoryBinary.h"
|
||||
|
||||
namespace LUS {
|
||||
class PlayerAnimationFactory : public ResourceFactory {
|
||||
namespace SOH {
|
||||
class ResourceFactoryBinaryPlayerAnimationV0 : public LUS::ResourceFactoryBinary {
|
||||
public:
|
||||
std::shared_ptr<IResource>
|
||||
ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) override;
|
||||
};
|
||||
|
||||
class PlayerAnimationFactoryV0 : public ResourceVersionFactory {
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override;
|
||||
};
|
||||
}; // namespace LUS
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "spdlog/spdlog.h"
|
||||
#include "2s2h/resource/type/2shResourceType.h"
|
||||
#include "2s2h/resource/importer/SceneFactory.h"
|
||||
#include "2s2h/resource/type/Scene.h"
|
||||
#include "2s2h/resource/type/scenecommand/SceneCommand.h"
|
||||
@ -32,77 +33,43 @@
|
||||
#include "2s2h/resource/importer/scenecommand/SetMinimapChestsFactory.h"
|
||||
#include "2s2h/resource/importer/scenecommand/SetActorCutsceneListFactory.h"
|
||||
|
||||
namespace LUS {
|
||||
|
||||
std::shared_ptr<IResource>
|
||||
SceneFactory::ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) {
|
||||
if (SceneFactory::sceneCommandFactories.empty()) {
|
||||
SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetLightingSettings] = std::make_shared<SetLightingSettingsFactory>();
|
||||
SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetWind] = std::make_shared<SetWindSettingsFactory>();
|
||||
SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetExitList] = std::make_shared<SetExitListFactory>();
|
||||
SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetTimeSettings] = std::make_shared<SetTimeSettingsFactory>();
|
||||
SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetSkyboxModifier] = std::make_shared<SetSkyboxModifierFactory>();
|
||||
SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetEchoSettings] = std::make_shared<SetEchoSettingsFactory>();
|
||||
SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetSoundSettings] = std::make_shared<SetSoundSettingsFactory>();
|
||||
SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetSkyboxSettings] = std::make_shared<SetSkyboxSettingsFactory>();
|
||||
SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetRoomBehavior] = std::make_shared<SetRoomBehaviorMMFactory>();
|
||||
SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetCsCamera] = std::make_shared<SetCsCameraFactory>();
|
||||
SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetCameraSettings] = std::make_shared<SetCameraSettingsFactory>();
|
||||
SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetRoomList] = std::make_shared<SetRoomListFactory>();
|
||||
SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetCollisionHeader] = std::make_shared<SetCollisionHeaderFactory>();
|
||||
SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetEntranceList] = std::make_shared<SetEntranceListFactory>();
|
||||
SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetSpecialObjects] = std::make_shared<SetSpecialObjectsFactory>();
|
||||
SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetObjectList] = std::make_shared<SetObjectListFactory>();
|
||||
SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetStartPositionList] = std::make_shared<SetStartPositionListFactory>();
|
||||
SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetActorList] = std::make_shared<SetActorListFactory>();
|
||||
SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetTransitionActorList] = std::make_shared<SetTransitionActorListFactory>();
|
||||
SceneFactory::sceneCommandFactories[LUS::SceneCommandID::EndMarker] = std::make_shared<EndMarkerFactory>();
|
||||
SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetAlternateHeaders] = std::make_shared<SetAlternateHeadersFactory>();
|
||||
// TODO should we use a different custom scene command like cutscenes?
|
||||
SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetPathways] = std::make_shared<SetPathwaysMMFactory>();
|
||||
SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetCutscenes] = std::make_shared<SetCutscenesFactory>();
|
||||
SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetLightList] = std::make_shared<SetLightListFactory>();
|
||||
SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetMesh] = std::make_shared<SetMeshFactory>();
|
||||
SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetCutscenesMM] = std::make_shared<SetCutsceneFactoryMM>();
|
||||
SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetAnimatedMaterialList] =
|
||||
std::make_shared<SetAnimatedMaterialListFactory>();
|
||||
SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetMinimapList] =
|
||||
std::make_shared<SetMinimapListFactory>();
|
||||
SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetMinimapChests] =
|
||||
std::make_shared<SetMinimapChestsFactory>();
|
||||
SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetActorCutsceneList] =
|
||||
std::make_shared<SetActorCutsceneListFactory>();
|
||||
}
|
||||
|
||||
auto resource = std::make_shared<Scene>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<SceneFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load Scene with version {}", resource->GetInitData()->ResourceVersion);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
namespace SOH {
|
||||
ResourceFactoryBinarySceneV0::ResourceFactoryBinarySceneV0() {
|
||||
sceneCommandFactories[SceneCommandID::SetLightingSettings] = std::make_shared<SetLightingSettingsFactory>();
|
||||
sceneCommandFactories[SceneCommandID::SetWind] = std::make_shared<SetWindSettingsFactory>();
|
||||
sceneCommandFactories[SceneCommandID::SetExitList] = std::make_shared<SetExitListFactory>();
|
||||
sceneCommandFactories[SceneCommandID::SetTimeSettings] = std::make_shared<SetTimeSettingsFactory>();
|
||||
sceneCommandFactories[SceneCommandID::SetSkyboxModifier] = std::make_shared<SetSkyboxModifierFactory>();
|
||||
sceneCommandFactories[SceneCommandID::SetEchoSettings] = std::make_shared<SetEchoSettingsFactory>();
|
||||
sceneCommandFactories[SceneCommandID::SetSoundSettings] = std::make_shared<SetSoundSettingsFactory>();
|
||||
sceneCommandFactories[SceneCommandID::SetSkyboxSettings] = std::make_shared<SetSkyboxSettingsFactory>();
|
||||
sceneCommandFactories[SceneCommandID::SetRoomBehavior] = std::make_shared<SetRoomBehaviorMMFactory>();
|
||||
sceneCommandFactories[SceneCommandID::SetCsCamera] = std::make_shared<SetCsCameraFactory>();
|
||||
sceneCommandFactories[SceneCommandID::SetCameraSettings] = std::make_shared<SetCameraSettingsFactory>();
|
||||
sceneCommandFactories[SceneCommandID::SetRoomList] = std::make_shared<SetRoomListFactory>();
|
||||
sceneCommandFactories[SceneCommandID::SetCollisionHeader] = std::make_shared<SetCollisionHeaderFactory>();
|
||||
sceneCommandFactories[SceneCommandID::SetEntranceList] = std::make_shared<SetEntranceListFactory>();
|
||||
sceneCommandFactories[SceneCommandID::SetSpecialObjects] = std::make_shared<SetSpecialObjectsFactory>();
|
||||
sceneCommandFactories[SceneCommandID::SetObjectList] = std::make_shared<SetObjectListFactory>();
|
||||
sceneCommandFactories[SceneCommandID::SetStartPositionList] = std::make_shared<SetStartPositionListFactory>();
|
||||
sceneCommandFactories[SceneCommandID::SetActorList] = std::make_shared<SetActorListFactory>();
|
||||
sceneCommandFactories[SceneCommandID::SetTransitionActorList] = std::make_shared<SetTransitionActorListFactory>();
|
||||
sceneCommandFactories[SceneCommandID::EndMarker] = std::make_shared<EndMarkerFactory>();
|
||||
sceneCommandFactories[SceneCommandID::SetAlternateHeaders] = std::make_shared<SetAlternateHeadersFactory>();
|
||||
// TODO should we use a different custom scene command like cutscenes?
|
||||
sceneCommandFactories[SceneCommandID::SetPathways] = std::make_shared<SetPathwaysMMFactory>();
|
||||
//sceneCommandFactories[SceneCommandID::SetCutscenes] = std::make_shared<SetCutsceneFactoryMM>();
|
||||
sceneCommandFactories[SceneCommandID::SetLightList] = std::make_shared<SetLightListFactory>();
|
||||
sceneCommandFactories[SceneCommandID::SetMesh] = std::make_shared<SetMeshFactory>();
|
||||
sceneCommandFactories[SceneCommandID::SetCutscenesMM] = std::make_shared<SetCutsceneFactoryMM>();
|
||||
sceneCommandFactories[SceneCommandID::SetAnimatedMaterialList] = std::make_shared<SetAnimatedMaterialListFactory>();
|
||||
sceneCommandFactories[SceneCommandID::SetMinimapList] = std::make_shared<SetMinimapListFactory>();
|
||||
sceneCommandFactories[SceneCommandID::SetMinimapChests] = std::make_shared<SetMinimapChestsFactory>();
|
||||
sceneCommandFactories[SceneCommandID::SetActorCutsceneList] = std::make_shared<SetActorCutsceneListFactory>();
|
||||
}
|
||||
|
||||
void SceneFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource)
|
||||
{
|
||||
std::shared_ptr<Scene> scene = std::static_pointer_cast<Scene>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, scene);
|
||||
|
||||
ParseSceneCommands(scene, reader);
|
||||
}
|
||||
|
||||
void SceneFactoryV0::ParseSceneCommands(std::shared_ptr<Scene> scene, std::shared_ptr<BinaryReader> reader) {
|
||||
void ResourceFactoryBinarySceneV0::ParseSceneCommands(std::shared_ptr<Scene> scene,
|
||||
std::shared_ptr<LUS::BinaryReader> reader) {
|
||||
uint32_t commandCount = reader->ReadUInt32();
|
||||
scene->commands.reserve(commandCount);
|
||||
|
||||
@ -111,19 +78,20 @@ void SceneFactoryV0::ParseSceneCommands(std::shared_ptr<Scene> scene, std::share
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<ISceneCommand> SceneFactoryV0::ParseSceneCommand(std::shared_ptr<Scene> scene,
|
||||
std::shared_ptr<BinaryReader> reader, uint32_t index) {
|
||||
std::shared_ptr<ISceneCommand>
|
||||
ResourceFactoryBinarySceneV0::ParseSceneCommand(std::shared_ptr<Scene> scene, std::shared_ptr<LUS::BinaryReader> reader,
|
||||
uint32_t index) {
|
||||
SceneCommandID cmdID = (SceneCommandID)reader->ReadInt32();
|
||||
|
||||
reader->Seek(-sizeof(int32_t), SeekOffsetType::Current);
|
||||
reader->Seek(-sizeof(int32_t), LUS::SeekOffsetType::Current);
|
||||
|
||||
std::shared_ptr<ISceneCommand> result = nullptr;
|
||||
std::shared_ptr<SceneCommandFactory> commandFactory = SceneFactory::sceneCommandFactories[cmdID];
|
||||
auto commandFactory = ResourceFactoryBinarySceneV0::sceneCommandFactories[cmdID];
|
||||
|
||||
if (commandFactory != nullptr) {
|
||||
auto initData = std::make_shared<ResourceInitData>();
|
||||
auto initData = std::make_shared<LUS::ResourceInitData>();
|
||||
initData->Id = scene->GetInitData()->Id;
|
||||
initData->Type = ResourceType::SOH_SceneCommand;
|
||||
initData->Type = static_cast<uint32_t>(ResourceType::SOH_SceneCommand);
|
||||
initData->Path = scene->GetInitData()->Path + "/SceneCommand" + std::to_string(index);
|
||||
initData->ResourceVersion = scene->GetInitData()->ResourceVersion;
|
||||
result = std::static_pointer_cast<ISceneCommand>(commandFactory->ReadResource(initData, reader));
|
||||
@ -131,10 +99,23 @@ std::shared_ptr<ISceneCommand> SceneFactoryV0::ParseSceneCommand(std::shared_ptr
|
||||
}
|
||||
|
||||
if (result == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load scene command of type {} in scene {}", (uint32_t)cmdID, scene->GetInitData()->Path);
|
||||
SPDLOG_ERROR("Failed to load scene command of type {} in scene {}", (uint32_t)cmdID,
|
||||
scene->GetInitData()->Path);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace LUS
|
||||
std::shared_ptr<LUS::IResource> ResourceFactoryBinarySceneV0::ReadResource(std::shared_ptr<LUS::File> file) {
|
||||
if (!FileHasValidFormatAndReader(file)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto scene = std::make_shared<Scene>(file->InitData);
|
||||
auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader);
|
||||
|
||||
ParseSceneCommands(scene, reader);
|
||||
|
||||
return scene;
|
||||
};
|
||||
} // namespace SOH
|
||||
|
@ -4,26 +4,25 @@
|
||||
#include "2s2h/resource/type/scenecommand/SceneCommand.h"
|
||||
#include "2s2h/resource/importer/scenecommand/SceneCommandFactory.h"
|
||||
#include "Resource.h"
|
||||
#include "ResourceFactory.h"
|
||||
#include "ResourceFactoryBinary.h"
|
||||
|
||||
namespace LUS {
|
||||
class SceneFactory : public ResourceFactory {
|
||||
namespace SOH {
|
||||
class ResourceFactoryBinarySceneV0 : public LUS::ResourceFactoryBinary {
|
||||
public:
|
||||
std::shared_ptr<IResource>
|
||||
ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) override;
|
||||
ResourceFactoryBinarySceneV0();
|
||||
|
||||
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override;
|
||||
void ParseSceneCommands(std::shared_ptr<Scene> scene, std::shared_ptr<LUS::BinaryReader> reader);
|
||||
|
||||
// Doing something very similar to what we do on the ResourceLoader.
|
||||
// Eventually, scene commands should be moved up to the ResourceLoader as well.
|
||||
// They can not right now because the exporter does not give them a proper resource type enum value,
|
||||
// and the exporter does not export the commands with a proper OTR header.
|
||||
static inline std::unordered_map<SceneCommandID, std::shared_ptr<SceneCommandFactory>> sceneCommandFactories;
|
||||
};
|
||||
static inline std::unordered_map<SceneCommandID, std::shared_ptr<SceneCommandFactoryBinaryV0>>
|
||||
sceneCommandFactories;
|
||||
|
||||
class SceneFactoryV0 : public ResourceVersionFactory {
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
void ParseSceneCommands(std::shared_ptr<Scene> scene, std::shared_ptr<BinaryReader> reader);
|
||||
protected:
|
||||
std::shared_ptr<ISceneCommand> ParseSceneCommand(std::shared_ptr<Scene> scene, std::shared_ptr<BinaryReader> reader, uint32_t index);
|
||||
protected:
|
||||
std::shared_ptr<ISceneCommand> ParseSceneCommand(std::shared_ptr<Scene> scene,
|
||||
std::shared_ptr<LUS::BinaryReader> reader, uint32_t index);
|
||||
};
|
||||
}; // namespace LUS
|
||||
} // namespace SOH
|
@ -3,54 +3,14 @@
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <libultraship/libultraship.h>
|
||||
|
||||
namespace LUS {
|
||||
std::shared_ptr<IResource>
|
||||
SkeletonFactory::ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<Skeleton>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<SkeletonFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load Skeleton with version {}", resource->GetInitData()->ResourceVersion);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
std::shared_ptr<IResource>
|
||||
SkeletonFactory::ReadResourceXML(std::shared_ptr<ResourceInitData> initData, tinyxml2::XMLElement *reader) {
|
||||
auto resource = std::make_shared<Skeleton>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<SkeletonFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load Skeleton with version {}", resource->GetInitData()->ResourceVersion);
|
||||
namespace SOH {
|
||||
std::shared_ptr<LUS::IResource> ResourceFactoryBinarySkeletonV0::ReadResource(std::shared_ptr<LUS::File> file) {
|
||||
if (!FileHasValidFormatAndReader(file)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileXML(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void SkeletonFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource)
|
||||
{
|
||||
std::shared_ptr<Skeleton> skeleton = std::static_pointer_cast<Skeleton>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, skeleton);
|
||||
auto skeleton = std::make_shared<Skeleton>(file->InitData);
|
||||
auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader);
|
||||
|
||||
skeleton->type = (SkeletonType)reader->ReadInt8();
|
||||
skeleton->limbType = (LimbType)reader->ReadInt8();
|
||||
@ -66,17 +26,17 @@ void SkeletonFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
skeleton->limbTable.push_back(limbPath);
|
||||
}
|
||||
|
||||
if (skeleton->type == LUS::SkeletonType::Curve) {
|
||||
if (skeleton->type == SkeletonType::Curve) {
|
||||
skeleton->skeletonData.skelCurveLimbList.limbCount = skeleton->limbCount;
|
||||
skeleton->curveLimbArray.reserve(skeleton->skeletonData.skelCurveLimbList.limbCount);
|
||||
} else if (skeleton->type == LUS::SkeletonType::Flex) {
|
||||
} else if (skeleton->type == SkeletonType::Flex) {
|
||||
skeleton->skeletonData.flexSkeletonHeader.dListCount = skeleton->dListCount;
|
||||
}
|
||||
|
||||
if (skeleton->type == LUS::SkeletonType::Normal) {
|
||||
if (skeleton->type == SkeletonType::Normal) {
|
||||
skeleton->skeletonData.skeletonHeader.limbCount = skeleton->limbCount;
|
||||
skeleton->standardLimbArray.reserve(skeleton->skeletonData.skeletonHeader.limbCount);
|
||||
} else if (skeleton->type == LUS::SkeletonType::Flex) {
|
||||
} else if (skeleton->type == SkeletonType::Flex) {
|
||||
skeleton->skeletonData.flexSkeletonHeader.sh.limbCount = skeleton->limbCount;
|
||||
skeleton->standardLimbArray.reserve(skeleton->skeletonData.flexSkeletonHeader.sh.limbCount);
|
||||
}
|
||||
@ -87,53 +47,63 @@ void SkeletonFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
skeleton->skeletonHeaderSegments.push_back(limb ? limb->GetRawPointer() : nullptr);
|
||||
}
|
||||
|
||||
if (skeleton->type == LUS::SkeletonType::Normal) {
|
||||
if (skeleton->type == SkeletonType::Normal) {
|
||||
skeleton->skeletonData.skeletonHeader.segment = (void**)skeleton->skeletonHeaderSegments.data();
|
||||
} else if (skeleton->type == LUS::SkeletonType::Flex) {
|
||||
} else if (skeleton->type == SkeletonType::Flex) {
|
||||
skeleton->skeletonData.flexSkeletonHeader.sh.segment = (void**)skeleton->skeletonHeaderSegments.data();
|
||||
} else if (skeleton->type == LUS::SkeletonType::Curve) {
|
||||
} else if (skeleton->type == SkeletonType::Curve) {
|
||||
skeleton->skeletonData.skelCurveLimbList.limbs = (SkelCurveLimb**)skeleton->skeletonHeaderSegments.data();
|
||||
} else {
|
||||
SPDLOG_ERROR("unknown skeleton type {}", (uint32_t)skeleton->type);
|
||||
}
|
||||
|
||||
skeleton->skeletonData.skeletonHeader.skeletonType = (uint8_t)skeleton->type;
|
||||
|
||||
return skeleton;
|
||||
}
|
||||
void SkeletonFactoryV0::ParseFileXML(tinyxml2::XMLElement* reader, std::shared_ptr<IResource> resource)
|
||||
{
|
||||
std::shared_ptr<Skeleton> skel = std::static_pointer_cast<Skeleton>(resource);
|
||||
|
||||
std::string skeletonType = reader->Attribute("Type");
|
||||
// std::string skeletonLimbType = reader->Attribute("LimbType");
|
||||
int numLimbs = reader->IntAttribute("LimbCount");
|
||||
int numDLs = reader->IntAttribute("DisplayListCount");
|
||||
|
||||
if (skeletonType == "Flex") {
|
||||
skel->type = SkeletonType::Flex;
|
||||
} else if (skeletonType == "Curve") {
|
||||
skel->type = SkeletonType::Curve;
|
||||
} else if (skeletonType == "Normal") {
|
||||
skel->type = SkeletonType::Normal;
|
||||
std::shared_ptr<LUS::IResource> ResourceFactoryXMLSkeletonV0::ReadResource(std::shared_ptr<LUS::File> file) {
|
||||
if (!FileHasValidFormatAndReader(file)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
skel->type = SkeletonType::Flex;
|
||||
skel->limbType = LimbType::LOD;
|
||||
|
||||
// if (skeletonLimbType == "Standard")
|
||||
// skel->limbType = LimbType::Standard;
|
||||
// else if (skeletonLimbType == "LOD")
|
||||
// skel->limbType = LimbType::LOD;
|
||||
// else if (skeletonLimbType == "Curve")
|
||||
// skel->limbType = LimbType::Curve;
|
||||
// else if (skeletonLimbType == "Skin")
|
||||
// skel->limbType = LimbType::Skin;
|
||||
// else if (skeletonLimbType == "Legacy")
|
||||
// Sskel->limbType = LimbType::Legacy;
|
||||
|
||||
auto skel = std::make_shared<Skeleton>(file->InitData);
|
||||
auto reader = std::get<std::shared_ptr<tinyxml2::XMLDocument>>(file->Reader)->FirstChildElement();
|
||||
auto child = reader->FirstChildElement();
|
||||
|
||||
skel->limbCount = numLimbs;
|
||||
skel->dListCount = numDLs;
|
||||
skel->type = SkeletonType::Flex; // Default to Flex for legacy reasons
|
||||
if (reader->FindAttribute("Type")) {
|
||||
std::string skeletonType = reader->Attribute("Type");
|
||||
|
||||
if (skeletonType == "Flex") {
|
||||
skel->type = SkeletonType::Flex;
|
||||
} else if (skeletonType == "Curve") {
|
||||
skel->type = SkeletonType::Curve;
|
||||
} else if (skeletonType == "Normal") {
|
||||
skel->type = SkeletonType::Normal;
|
||||
}
|
||||
}
|
||||
|
||||
skel->limbType = LimbType::LOD; // Default to LOD for legacy reasons
|
||||
if (reader->FindAttribute("LimbType")) {
|
||||
std::string skeletonLimbType = reader->Attribute("LimbType");
|
||||
|
||||
if (skeletonLimbType == "Standard") {
|
||||
skel->limbType = LimbType::Standard;
|
||||
} else if (skeletonLimbType == "LOD") {
|
||||
skel->limbType = LimbType::LOD;
|
||||
} else if (skeletonLimbType == "Curve") {
|
||||
skel->limbType = LimbType::Curve;
|
||||
} else if (skeletonLimbType == "Skin") {
|
||||
skel->limbType = LimbType::Skin;
|
||||
} else if (skeletonLimbType == "Legacy") {
|
||||
skel->limbType = LimbType::Legacy;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
skel->limbCount = reader->IntAttribute("LimbCount");
|
||||
skel->dListCount = reader->IntAttribute("DisplayListCount");
|
||||
|
||||
while (child != nullptr) {
|
||||
std::string childName = child->Name();
|
||||
@ -153,6 +123,7 @@ void SkeletonFactoryV0::ParseFileXML(tinyxml2::XMLElement* reader, std::shared_p
|
||||
skel->skeletonData.flexSkeletonHeader.sh.segment = (void**)skel->skeletonHeaderSegments.data();
|
||||
skel->skeletonData.flexSkeletonHeader.dListCount = skel->dListCount;
|
||||
skel->skeletonData.skeletonHeader.skeletonType = (uint8_t)skel->type;
|
||||
}
|
||||
|
||||
} // namespace LUS
|
||||
return skel;
|
||||
}
|
||||
} // namespace SOH
|
||||
|
@ -1,23 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "Resource.h"
|
||||
#include "ResourceFactory.h"
|
||||
#include "ResourceFactoryBinary.h"
|
||||
#include "ResourceFactoryXML.h"
|
||||
|
||||
namespace LUS {
|
||||
class SkeletonFactory : public ResourceFactory
|
||||
{
|
||||
namespace SOH {
|
||||
class ResourceFactoryBinarySkeletonV0 : public LUS::ResourceFactoryBinary {
|
||||
public:
|
||||
std::shared_ptr<IResource>
|
||||
ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) override;
|
||||
std::shared_ptr<IResource>
|
||||
ReadResourceXML(std::shared_ptr<ResourceInitData> initData, tinyxml2::XMLElement *reader) override;
|
||||
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override;
|
||||
};
|
||||
|
||||
class SkeletonFactoryV0 : public ResourceVersionFactory
|
||||
{
|
||||
class ResourceFactoryXMLSkeletonV0 : public LUS::ResourceFactoryXML {
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
void ParseFileXML(tinyxml2::XMLElement* reader, std::shared_ptr<IResource> resource) override;
|
||||
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override;
|
||||
};
|
||||
}; // namespace LUS
|
||||
|
||||
} // namespace SOH
|
||||
|
@ -3,54 +3,14 @@
|
||||
#include "spdlog/spdlog.h"
|
||||
#include "libultraship/libultraship.h"
|
||||
|
||||
namespace LUS {
|
||||
std::shared_ptr<IResource>
|
||||
SkeletonLimbFactory::ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<SkeletonLimb>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<SkeletonLimbFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load Skeleton Limb with version {}", resource->GetInitData()->ResourceVersion);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
std::shared_ptr<IResource>
|
||||
SkeletonLimbFactory::ReadResourceXML(std::shared_ptr<ResourceInitData> initData, tinyxml2::XMLElement *reader) {
|
||||
auto resource = std::make_shared<SkeletonLimb>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<SkeletonLimbFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load Skeleton Limb with version {}", resource->GetInitData()->ResourceVersion);
|
||||
namespace SOH {
|
||||
std::shared_ptr<LUS::IResource> ResourceFactoryBinarySkeletonLimbV0::ReadResource(std::shared_ptr<LUS::File> file) {
|
||||
if (!FileHasValidFormatAndReader(file)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileXML(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void LUS::SkeletonLimbFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource)
|
||||
{
|
||||
std::shared_ptr<SkeletonLimb> skeletonLimb = std::static_pointer_cast<SkeletonLimb>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, skeletonLimb);
|
||||
auto skeletonLimb = std::make_shared<SkeletonLimb>(file->InitData);
|
||||
auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader);
|
||||
|
||||
skeletonLimb->limbType = (LimbType)reader->ReadInt8();
|
||||
skeletonLimb->skinSegmentType = (ZLimbSkinType)reader->ReadInt8();
|
||||
@ -124,7 +84,7 @@ void LUS::SkeletonLimbFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> r
|
||||
skeletonLimb->childIndex = reader->ReadUByte();
|
||||
skeletonLimb->siblingIndex = reader->ReadUByte();
|
||||
|
||||
if (skeletonLimb->limbType == LUS::LimbType::LOD) {
|
||||
if (skeletonLimb->limbType == LimbType::LOD) {
|
||||
skeletonLimb->limbData.lodLimb.jointPos.x = skeletonLimb->transX;
|
||||
skeletonLimb->limbData.lodLimb.jointPos.y = skeletonLimb->transY;
|
||||
skeletonLimb->limbData.lodLimb.jointPos.z = skeletonLimb->transZ;
|
||||
@ -132,19 +92,19 @@ void LUS::SkeletonLimbFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> r
|
||||
skeletonLimb->limbData.lodLimb.sibling = skeletonLimb->siblingIndex;
|
||||
|
||||
if (skeletonLimb->dListPtr != "") {
|
||||
auto dList = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(skeletonLimb->dListPtr.c_str());
|
||||
skeletonLimb->limbData.lodLimb.dLists[0] = (Gfx*)(dList ? dList->GetRawPointer() : nullptr);
|
||||
skeletonLimb->dListPtr = "__OTR__" + skeletonLimb->dListPtr;
|
||||
skeletonLimb->limbData.lodLimb.dLists[0] = (Gfx*)skeletonLimb->dListPtr.c_str();
|
||||
} else {
|
||||
skeletonLimb->limbData.lodLimb.dLists[0] = nullptr;
|
||||
}
|
||||
|
||||
if (skeletonLimb->dList2Ptr != "") {
|
||||
auto dList = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(skeletonLimb->dList2Ptr.c_str());
|
||||
skeletonLimb->limbData.lodLimb.dLists[1] = (Gfx*)(dList ? dList->GetRawPointer() : nullptr);
|
||||
skeletonLimb->dList2Ptr = "__OTR__" + skeletonLimb->dList2Ptr;
|
||||
skeletonLimb->limbData.lodLimb.dLists[1] = (Gfx*)skeletonLimb->dList2Ptr.c_str();
|
||||
} else {
|
||||
skeletonLimb->limbData.lodLimb.dLists[1] = nullptr;
|
||||
}
|
||||
} else if (skeletonLimb->limbType == LUS::LimbType::Standard) {
|
||||
} else if (skeletonLimb->limbType == LimbType::Standard) {
|
||||
skeletonLimb->limbData.standardLimb.jointPos.x = skeletonLimb->transX;
|
||||
skeletonLimb->limbData.standardLimb.jointPos.y = skeletonLimb->transY;
|
||||
skeletonLimb->limbData.standardLimb.jointPos.z = skeletonLimb->transZ;
|
||||
@ -153,50 +113,59 @@ void LUS::SkeletonLimbFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> r
|
||||
skeletonLimb->limbData.standardLimb.dList = nullptr;
|
||||
|
||||
if (!skeletonLimb->dListPtr.empty()) {
|
||||
const auto dList = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(skeletonLimb->dListPtr.c_str());
|
||||
skeletonLimb->limbData.standardLimb.dList = (Gfx*)(dList ? dList->GetRawPointer() : nullptr);
|
||||
skeletonLimb->dListPtr = "__OTR__" + skeletonLimb->dListPtr;
|
||||
skeletonLimb->limbData.standardLimb.dList = (Gfx*)skeletonLimb->dListPtr.c_str();
|
||||
}
|
||||
} else if (skeletonLimb->limbType == LUS::LimbType::Curve) {
|
||||
} else if (skeletonLimb->limbType == LimbType::Curve) {
|
||||
skeletonLimb->limbData.skelCurveLimb.firstChildIdx = skeletonLimb->childIndex;
|
||||
skeletonLimb->limbData.skelCurveLimb.nextLimbIdx = skeletonLimb->siblingIndex;
|
||||
skeletonLimb->limbData.skelCurveLimb.dList[0] = nullptr;
|
||||
skeletonLimb->limbData.skelCurveLimb.dList[1] = nullptr;
|
||||
|
||||
if (!skeletonLimb->dListPtr.empty()) {
|
||||
const auto dList = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(skeletonLimb->dListPtr.c_str());
|
||||
skeletonLimb->limbData.skelCurveLimb.dList[0] = (Gfx*)(dList ? dList->GetRawPointer() : nullptr);
|
||||
skeletonLimb->dListPtr = "__OTR__" + skeletonLimb->dListPtr;
|
||||
skeletonLimb->limbData.skelCurveLimb.dList[0] = (Gfx*)skeletonLimb->dListPtr.c_str();
|
||||
}
|
||||
|
||||
if (!skeletonLimb->dList2Ptr.empty()) {
|
||||
const auto dList = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(skeletonLimb->dList2Ptr.c_str());
|
||||
skeletonLimb->limbData.skelCurveLimb.dList[1] = (Gfx*)(dList ? dList->GetRawPointer() : nullptr);
|
||||
skeletonLimb->dList2Ptr = "__OTR__" + skeletonLimb->dList2Ptr;
|
||||
skeletonLimb->limbData.skelCurveLimb.dList[1] = (Gfx*)skeletonLimb->dList2Ptr.c_str();
|
||||
}
|
||||
} else if (skeletonLimb->limbType == LUS::LimbType::Skin) {
|
||||
} else if (skeletonLimb->limbType == LimbType::Skin) {
|
||||
skeletonLimb->limbData.skinLimb.jointPos.x = skeletonLimb->transX;
|
||||
skeletonLimb->limbData.skinLimb.jointPos.y = skeletonLimb->transY;
|
||||
skeletonLimb->limbData.skinLimb.jointPos.z = skeletonLimb->transZ;
|
||||
skeletonLimb->limbData.skinLimb.child = skeletonLimb->childIndex;
|
||||
skeletonLimb->limbData.skinLimb.sibling = skeletonLimb->siblingIndex;
|
||||
|
||||
if (skeletonLimb->skinSegmentType == LUS::ZLimbSkinType::SkinType_DList) {
|
||||
if (skeletonLimb->skinSegmentType == ZLimbSkinType::SkinType_DList) {
|
||||
skeletonLimb->limbData.skinLimb.segmentType = static_cast<int32_t>(skeletonLimb->skinSegmentType);
|
||||
} else if (skeletonLimb->skinSegmentType == LUS::ZLimbSkinType::SkinType_4) {
|
||||
} else if (skeletonLimb->skinSegmentType == ZLimbSkinType::SkinType_4) {
|
||||
skeletonLimb->limbData.skinLimb.segmentType = 4;
|
||||
} else if (skeletonLimb->skinSegmentType == LUS::ZLimbSkinType::SkinType_5) {
|
||||
} else if (skeletonLimb->skinSegmentType == ZLimbSkinType::SkinType_5) {
|
||||
skeletonLimb->limbData.skinLimb.segmentType = 5;
|
||||
} else {
|
||||
skeletonLimb->limbData.skinLimb.segmentType = 0;
|
||||
}
|
||||
|
||||
if (skeletonLimb->skinSegmentType == LUS::ZLimbSkinType::SkinType_DList) {
|
||||
auto res = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(skeletonLimb->skinDList.c_str());
|
||||
skeletonLimb->limbData.skinLimb.segment = res ? res->GetRawPointer() : nullptr;
|
||||
} else if (skeletonLimb->skinSegmentType == LUS::ZLimbSkinType::SkinType_4) {
|
||||
if (skeletonLimb->skinSegmentType == ZLimbSkinType::SkinType_DList) {
|
||||
if (skeletonLimb->skinDList != "") {
|
||||
skeletonLimb->skinDList = "__OTR__" + skeletonLimb->skinDList;
|
||||
skeletonLimb->limbData.skinLimb.segment = (Gfx*)skeletonLimb->skinDList.c_str();
|
||||
} else {
|
||||
skeletonLimb->limbData.skinLimb.segment = nullptr;
|
||||
}
|
||||
} else if (skeletonLimb->skinSegmentType == ZLimbSkinType::SkinType_4) {
|
||||
skeletonLimb->skinAnimLimbData.totalVtxCount = skeletonLimb->skinVtxCnt;
|
||||
skeletonLimb->skinAnimLimbData.limbModifCount = skeletonLimb->skinLimbModifCount;
|
||||
skeletonLimb->skinAnimLimbData.limbModifications = skeletonLimb->skinLimbModifArray.data();
|
||||
auto res = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(skeletonLimb->skinDList2.c_str());
|
||||
skeletonLimb->skinAnimLimbData.dlist = (Gfx*)(res ? res->GetRawPointer() : nullptr);
|
||||
|
||||
if (skeletonLimb->skinDList2 != "") {
|
||||
skeletonLimb->skinDList2 = "__OTR__" + skeletonLimb->skinDList2;
|
||||
skeletonLimb->skinAnimLimbData.dlist = (Gfx*)skeletonLimb->skinDList2.c_str();
|
||||
} else {
|
||||
skeletonLimb->skinAnimLimbData.dlist = nullptr;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < skeletonLimb->skinLimbModifArray.size(); i++) {
|
||||
skeletonLimb->skinAnimLimbData.limbModifications[i].vtxCount = skeletonLimb->skinLimbModifVertexArrays[i].size();
|
||||
@ -211,10 +180,17 @@ void LUS::SkeletonLimbFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> r
|
||||
skeletonLimb->limbData.skinLimb.segment = &skeletonLimb->skinAnimLimbData;
|
||||
}
|
||||
}
|
||||
|
||||
return skeletonLimb;
|
||||
}
|
||||
void SkeletonLimbFactoryV0::ParseFileXML(tinyxml2::XMLElement* reader, std::shared_ptr<IResource> resource)
|
||||
{
|
||||
std::shared_ptr<SkeletonLimb> skelLimb = std::static_pointer_cast<SkeletonLimb>(resource);
|
||||
|
||||
std::shared_ptr<LUS::IResource> ResourceFactoryXMLSkeletonLimbV0::ReadResource(std::shared_ptr<LUS::File> file) {
|
||||
if (!FileHasValidFormatAndReader(file)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto skelLimb = std::make_shared<SkeletonLimb>(file->InitData);
|
||||
auto reader = std::get<std::shared_ptr<tinyxml2::XMLDocument>>(file->Reader)->FirstChildElement();
|
||||
|
||||
std::string limbType = reader->Attribute("Type");
|
||||
|
||||
@ -254,8 +230,8 @@ void SkeletonLimbFactoryV0::ParseFileXML(tinyxml2::XMLElement* reader, std::shar
|
||||
limbData.lodLimb.jointPos.z = skelLimb->transZ;
|
||||
|
||||
if (skelLimb->dListPtr != "") {
|
||||
auto res = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess((const char*)skelLimb->dListPtr.c_str());
|
||||
limbData.lodLimb.dLists[0] = (Gfx*)(res ? res->GetRawPointer() : nullptr);
|
||||
skelLimb->dListPtr = "__OTR__" + skelLimb->dListPtr;
|
||||
limbData.lodLimb.dLists[0] = (Gfx*)skelLimb->dListPtr.c_str();
|
||||
} else {
|
||||
limbData.lodLimb.dLists[0] = nullptr;
|
||||
}
|
||||
@ -266,6 +242,7 @@ void SkeletonLimbFactoryV0::ParseFileXML(tinyxml2::XMLElement* reader, std::shar
|
||||
limbData.lodLimb.sibling = skelLimb->siblingIndex;
|
||||
|
||||
// skelLimb->dList2Ptr = reader->Attribute("DisplayList2");
|
||||
}
|
||||
|
||||
} // namespace LUS
|
||||
return skelLimb;
|
||||
}
|
||||
} // namespace SOH
|
||||
|
@ -1,23 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "Resource.h"
|
||||
#include "ResourceFactory.h"
|
||||
#include "ResourceFactoryBinary.h"
|
||||
#include "ResourceFactoryXML.h"
|
||||
|
||||
namespace LUS {
|
||||
class SkeletonLimbFactory : public ResourceFactory
|
||||
{
|
||||
namespace SOH {
|
||||
class ResourceFactoryBinarySkeletonLimbV0 : public LUS::ResourceFactoryBinary {
|
||||
public:
|
||||
std::shared_ptr<IResource>
|
||||
ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) override;
|
||||
std::shared_ptr<IResource>
|
||||
ReadResourceXML(std::shared_ptr<ResourceInitData> initData, tinyxml2::XMLElement *reader) override;
|
||||
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override;
|
||||
};
|
||||
|
||||
class SkeletonLimbFactoryV0 : public ResourceVersionFactory
|
||||
{
|
||||
class ResourceFactoryXMLSkeletonLimbV0 : public LUS::ResourceFactoryXML {
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
void ParseFileXML(tinyxml2::XMLElement* reader, std::shared_ptr<IResource> resource) override;
|
||||
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override;
|
||||
};
|
||||
}; // namespace LUS
|
||||
|
||||
} // namespace SOH
|
||||
|
@ -1,93 +0,0 @@
|
||||
#include "2s2h/resource/importer/TextFactory.h"
|
||||
#include "2s2h/resource/type/Text.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
namespace LUS {
|
||||
std::shared_ptr<IResource>
|
||||
TextFactory::ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<Text>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<TextFactoryV0>();
|
||||
break;
|
||||
default:
|
||||
// VERSION NOT SUPPORTED
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load Text with version {}", resource->GetInitData()->ResourceVersion);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
std::shared_ptr<IResource>
|
||||
TextFactory::ReadResourceXML(std::shared_ptr<ResourceInitData> initData, tinyxml2::XMLElement *reader) {
|
||||
auto resource = std::make_shared<Text>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<TextFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load Text with version {}", resource->GetInitData()->ResourceVersion);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileXML(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void LUS::TextFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource) {
|
||||
std::shared_ptr<Text> text = std::static_pointer_cast<Text>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, text);
|
||||
|
||||
uint32_t msgCount = reader->ReadUInt32();
|
||||
text->messages.reserve(msgCount);
|
||||
|
||||
for (uint32_t i = 0; i < msgCount; i++) {
|
||||
MessageEntry entry;
|
||||
entry.id = reader->ReadUInt16();
|
||||
entry.textboxType = reader->ReadUByte();
|
||||
entry.textboxYPos = reader->ReadUByte();
|
||||
entry.msg = reader->ReadString();
|
||||
|
||||
text->messages.push_back(entry);
|
||||
}
|
||||
}
|
||||
void TextFactoryV0::ParseFileXML(tinyxml2::XMLElement* reader, std::shared_ptr<IResource> resource) {
|
||||
std::shared_ptr<Text> txt = std::static_pointer_cast<Text>(resource);
|
||||
|
||||
auto child = reader->FirstChildElement();
|
||||
|
||||
while (child != nullptr) {
|
||||
std::string childName = child->Name();
|
||||
|
||||
if (childName == "TextEntry") {
|
||||
MessageEntry entry;
|
||||
entry.id = child->IntAttribute("ID");
|
||||
entry.textboxType = child->IntAttribute("TextboxType");
|
||||
entry.textboxYPos = child->IntAttribute("TextboxYPos");
|
||||
entry.msg = child->Attribute("Message");
|
||||
entry.msg += "\x2";
|
||||
|
||||
txt->messages.push_back(entry);
|
||||
int bp = 0;
|
||||
}
|
||||
|
||||
child = child->NextSiblingElement();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace LUS
|
@ -1,23 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Resource.h"
|
||||
#include "ResourceFactory.h"
|
||||
|
||||
namespace LUS {
|
||||
class TextFactory : public ResourceFactory
|
||||
{
|
||||
public:
|
||||
std::shared_ptr<IResource>
|
||||
ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) override;
|
||||
std::shared_ptr<IResource>
|
||||
ReadResourceXML(std::shared_ptr<ResourceInitData> initData, tinyxml2::XMLElement *reader) override;
|
||||
};
|
||||
|
||||
class TextFactoryV0 : public ResourceVersionFactory
|
||||
{
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
void ParseFileXML(tinyxml2::XMLElement* reader, std::shared_ptr<IResource> resource) override;
|
||||
};
|
||||
}; // namespace LUS
|
||||
|
@ -2,57 +2,16 @@
|
||||
#include "2s2h/resource/type/TextMM.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
namespace LUS {
|
||||
std::shared_ptr<IResource>
|
||||
TextMMFactory::ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<TextMM>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<TextMMFactoryV0>();
|
||||
break;
|
||||
default:
|
||||
// VERSION NOT SUPPORTED
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load Text with version {}", resource->GetInitData()->ResourceVersion);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
std::shared_ptr<IResource> TextMMFactory::ReadResourceXML(std::shared_ptr<ResourceInitData> initData,
|
||||
tinyxml2::XMLElement* reader) {
|
||||
auto resource = std::make_shared<TextMM>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<TextMMFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load Text with version {}", resource->GetInitData()->ResourceVersion);
|
||||
namespace SOH {
|
||||
std::shared_ptr<LUS::IResource> ResourceFactoryBinaryTextMMV0::ReadResource(std::shared_ptr<LUS::File> file) {
|
||||
if (!FileHasValidFormatAndReader(file)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileXML(reader, resource);
|
||||
auto text = std::make_shared<TextMM>(file->InitData);
|
||||
auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void LUS::TextMMFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) {
|
||||
std::shared_ptr<TextMM> text = std::static_pointer_cast<TextMM>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, text);
|
||||
|
||||
uint32_t msgCount = reader->ReadUInt32();
|
||||
const uint32_t msgCount = reader->ReadUInt32();
|
||||
text->messages.reserve(msgCount);
|
||||
|
||||
for (uint32_t i = 0; i < msgCount; i++) {
|
||||
@ -68,9 +27,17 @@ void LUS::TextMMFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
|
||||
text->messages.push_back(entry);
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
void TextMMFactoryV0::ParseFileXML(tinyxml2::XMLElement* reader, std::shared_ptr<IResource> resource) {
|
||||
std::shared_ptr<TextMM> txt = std::static_pointer_cast<TextMM>(resource);
|
||||
|
||||
std::shared_ptr<LUS::IResource> ResourceFactoryXMLTextMMV0::ReadResource(std::shared_ptr<LUS::File> file) {
|
||||
if (!FileHasValidFormatAndReader(file)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto text = std::make_shared<TextMM>(file->InitData);
|
||||
auto reader = std::get<std::shared_ptr<tinyxml2::XMLDocument>>(file->Reader)->FirstChildElement();
|
||||
|
||||
auto child = reader->FirstChildElement();
|
||||
|
||||
@ -82,19 +49,19 @@ void TextMMFactoryV0::ParseFileXML(tinyxml2::XMLElement* reader, std::shared_ptr
|
||||
entry.id = child->IntAttribute("ID");
|
||||
entry.textboxType = child->IntAttribute("TextboxType");
|
||||
entry.textboxYPos = child->IntAttribute("TextboxYPos");
|
||||
|
||||
// BENTODO: MM Unique Fields
|
||||
|
||||
// BENTODO: MM Unique Fields
|
||||
|
||||
entry.msg = child->Attribute("Message");
|
||||
entry.msg += "\x2";
|
||||
|
||||
txt->messages.push_back(entry);
|
||||
text->messages.push_back(entry);
|
||||
int bp = 0;
|
||||
}
|
||||
|
||||
child = child->NextSiblingElement();
|
||||
}
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
} // namespace LUS
|
||||
|
@ -1,10 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include "Resource.h"
|
||||
#include "ResourceFactory.h"
|
||||
#include "ResourceFactoryBinary.h"
|
||||
#include "ResourceFactoryXML.h"
|
||||
|
||||
namespace LUS {
|
||||
class TextMMFactory : public ResourceFactory
|
||||
namespace SOH {
|
||||
class ResourceFactoryBinaryTextMMV0 : public LUS::ResourceFactoryBinary {
|
||||
public:
|
||||
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override;
|
||||
};
|
||||
|
||||
class ResourceFactoryXMLTextMMV0 : public LUS::ResourceFactoryXML {
|
||||
public:
|
||||
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override;
|
||||
};
|
||||
|
||||
#if 0
|
||||
class TextMMFactory : public LUS::ResourceFactoryBinary
|
||||
{
|
||||
public:
|
||||
std::shared_ptr<IResource>
|
||||
@ -12,12 +24,6 @@ class TextMMFactory : public ResourceFactory
|
||||
std::shared_ptr<IResource>
|
||||
ReadResourceXML(std::shared_ptr<ResourceInitData> initData, tinyxml2::XMLElement *reader) override;
|
||||
};
|
||||
|
||||
class TextMMFactoryV0 : public ResourceVersionFactory
|
||||
{
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
void ParseFileXML(tinyxml2::XMLElement* reader, std::shared_ptr<IResource> resource) override;
|
||||
};
|
||||
#endif
|
||||
}; // namespace LUS
|
||||
|
||||
|
@ -3,36 +3,18 @@
|
||||
#include <libultraship/libultraship.h>
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
namespace LUS {
|
||||
namespace SOH {
|
||||
|
||||
std::shared_ptr<IResource> TextureAnimationFactory::ReadResource(std::shared_ptr<ResourceInitData> initData,
|
||||
std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<TextureAnimation>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<TextureAnimationFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load Texture Animation with version {}", resource->GetInitData()->ResourceVersion);
|
||||
std::shared_ptr<LUS::IResource> ResourceFactoryBinaryTextureAnimationV0::ReadResource(std::shared_ptr<LUS::File> file) {
|
||||
if (!FileHasValidFormatAndReader(file)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
auto tAnim = std::make_shared<TextureAnimation>(file->InitData);
|
||||
auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader);
|
||||
|
||||
return resource;
|
||||
}
|
||||
const size_t numEntries = reader->ReadUInt32();
|
||||
|
||||
void LUS::TextureAnimationFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource) {
|
||||
std::shared_ptr<TextureAnimation> tAnim = std::static_pointer_cast<TextureAnimation>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, tAnim);
|
||||
|
||||
size_t numEntries = reader->ReadUInt32();
|
||||
|
||||
for (size_t i = 0; i < numEntries; i++) {
|
||||
AnimatedMaterial anim;
|
||||
anim.segment = reader->ReadInt8();
|
||||
@ -67,7 +49,7 @@ void LUS::TextureAnimationFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReade
|
||||
auto* e = new AnimatedMatColorParams;
|
||||
e->keyFrameLength = reader->ReadUInt16();
|
||||
e->keyFrameCount = reader->ReadUInt16();
|
||||
|
||||
|
||||
size_t frames = reader->ReadUInt32();
|
||||
|
||||
e->keyFrames = new uint16_t[frames];
|
||||
@ -76,7 +58,7 @@ void LUS::TextureAnimationFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReade
|
||||
}
|
||||
size_t primColorSize = reader->ReadUInt32();
|
||||
e->primColors = new F3DPrimColor[primColorSize];
|
||||
|
||||
|
||||
for (size_t i = 0; i < primColorSize; i++) {
|
||||
e->primColors[i].r = reader->ReadUByte();
|
||||
e->primColors[i].g = reader->ReadUByte();
|
||||
@ -123,6 +105,7 @@ void LUS::TextureAnimationFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReade
|
||||
}
|
||||
tAnim->anims.emplace_back(anim);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace LUS
|
||||
return tAnim;
|
||||
}
|
||||
} // namespace LUS
|
||||
|
@ -1,18 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "Resource.h"
|
||||
#include "ResourceFactory.h"
|
||||
#include "ResourceFactoryBinary.h"
|
||||
|
||||
namespace LUS {
|
||||
class TextureAnimationFactory : public ResourceFactory {
|
||||
namespace SOH {
|
||||
class ResourceFactoryBinaryTextureAnimationV0 : public LUS::ResourceFactoryBinary {
|
||||
public:
|
||||
std::shared_ptr<IResource> ReadResource(std::shared_ptr<ResourceInitData> initData,
|
||||
std::shared_ptr<BinaryReader> reader) override;
|
||||
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override;
|
||||
|
||||
};
|
||||
|
||||
class TextureAnimationFactoryV0 : public ResourceVersionFactory {
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
};
|
||||
}; // namespace LUS
|
@ -2,37 +2,13 @@
|
||||
#include "2s2h/resource/type/scenecommand/EndMarker.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
namespace LUS {
|
||||
std::shared_ptr<IResource>
|
||||
EndMarkerFactory::ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<EndMarker>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<EndMarkerFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load EndMarker with version {}", resource->GetInitData()->ResourceVersion);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void LUS::EndMarkerFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource)
|
||||
{
|
||||
std::shared_ptr<EndMarker> endMarker = std::static_pointer_cast<EndMarker>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, endMarker);
|
||||
namespace SOH {
|
||||
std::shared_ptr<LUS::IResource>
|
||||
EndMarkerFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) {
|
||||
auto endMarker = std::make_shared<EndMarker>(initData);
|
||||
|
||||
ReadCommandId(endMarker, reader);
|
||||
|
||||
// This has no data.
|
||||
}
|
||||
|
||||
} // namespace LUS
|
||||
return endMarker;
|
||||
}
|
||||
} // namespace SOH
|
||||
|
@ -2,15 +2,9 @@
|
||||
|
||||
#include "2s2h/resource/importer/scenecommand/SceneCommandFactory.h"
|
||||
|
||||
namespace LUS {
|
||||
class EndMarkerFactory : public SceneCommandFactory {
|
||||
namespace SOH {
|
||||
class EndMarkerFactory : public SceneCommandFactoryBinaryV0 {
|
||||
public:
|
||||
std::shared_ptr<IResource>
|
||||
ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) override;
|
||||
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
|
||||
};
|
||||
|
||||
class EndMarkerFactoryV0 : public SceneCommandVersionFactory {
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
};
|
||||
}; // namespace LUS
|
||||
} // namespace SOH
|
||||
|
@ -2,8 +2,9 @@
|
||||
#include "2s2h/resource/type/scenecommand/SceneCommand.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
namespace LUS {
|
||||
void SceneCommandVersionFactory::ReadCommandId(std::shared_ptr<ISceneCommand> command, std::shared_ptr<BinaryReader> reader) {
|
||||
namespace SOH {
|
||||
void SceneCommandFactoryBinaryV0::ReadCommandId(std::shared_ptr<SOH::ISceneCommand> command,
|
||||
std::shared_ptr<LUS::BinaryReader> reader) {
|
||||
command->cmdId = (SceneCommandID)reader->ReadInt32();
|
||||
}
|
||||
}
|
||||
|
@ -5,11 +5,13 @@
|
||||
#include "ResourceFactory.h"
|
||||
#include "2s2h/resource/type/scenecommand/SceneCommand.h"
|
||||
|
||||
namespace LUS {
|
||||
class SceneCommandFactory : public ResourceFactory {};
|
||||
namespace SOH {
|
||||
class SceneCommandFactoryBinaryV0 {
|
||||
public:
|
||||
virtual std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
|
||||
std::shared_ptr<LUS::BinaryReader> reader) = 0;
|
||||
|
||||
class SceneCommandVersionFactory : public ResourceVersionFactory {
|
||||
protected:
|
||||
void ReadCommandId(std::shared_ptr<ISceneCommand> command, std::shared_ptr<BinaryReader> reader);
|
||||
protected:
|
||||
void ReadCommandId(std::shared_ptr<ISceneCommand> command, std::shared_ptr<LUS::BinaryReader> reader);
|
||||
};
|
||||
}; // namespace LUS
|
||||
} // namespace SOH
|
@ -2,40 +2,16 @@
|
||||
#include "2s2h/resource/type/scenecommand/SetActorCutsceneList.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
namespace LUS {
|
||||
std::shared_ptr<IResource> SetActorCutsceneListFactory::ReadResource(std::shared_ptr<ResourceInitData> initData,
|
||||
std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<SetActorCutsceneList>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<SetActorCutsceneListFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load SetActorList with version {}", resource->GetInitData()->ResourceVersion);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
|
||||
void SetActorCutsceneListFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource) {
|
||||
std::shared_ptr<SetActorCutsceneList> setActorCsList = std::static_pointer_cast<SetActorCutsceneList>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, setActorCsList);
|
||||
|
||||
namespace SOH {
|
||||
std::shared_ptr<LUS::IResource> SetActorCutsceneListFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
|
||||
std::shared_ptr<LUS::BinaryReader> reader) {
|
||||
auto setActorCsList = std::make_shared<SetActorCutsceneList>(initData);
|
||||
ReadCommandId(setActorCsList, reader);
|
||||
|
||||
setActorCsList->numEntries = reader->ReadUInt32();
|
||||
setActorCsList->entries.reserve(setActorCsList->numEntries);
|
||||
uint32_t numEntries = reader->ReadUInt32();
|
||||
setActorCsList->entries.reserve(numEntries);
|
||||
|
||||
for (uint32_t i = 0; i < setActorCsList->numEntries; i++) {
|
||||
for (uint32_t i = 0; i < numEntries; i++) {
|
||||
CutsceneEntry e;
|
||||
e.priority = reader->ReadInt16();
|
||||
e.length = reader->ReadInt16();
|
||||
@ -49,7 +25,6 @@ void SetActorCutsceneListFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader
|
||||
e.letterboxSize = reader->ReadUByte();
|
||||
setActorCsList->entries.emplace_back(e);
|
||||
}
|
||||
|
||||
return setActorCsList;
|
||||
}
|
||||
|
||||
} // namespace LUS
|
@ -2,16 +2,9 @@
|
||||
|
||||
#include "2s2h/resource/importer/scenecommand/SceneCommandFactory.h"
|
||||
|
||||
namespace LUS {
|
||||
class SetActorCutsceneListFactory : public SceneCommandFactory {
|
||||
std::shared_ptr<IResource> ReadResource(std::shared_ptr<ResourceInitData> initData,
|
||||
std::shared_ptr<BinaryReader> reader) override;
|
||||
namespace SOH {
|
||||
class SetActorCutsceneListFactory : public SceneCommandFactoryBinaryV0 {
|
||||
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
|
||||
std::shared_ptr<LUS::BinaryReader> reader) override;
|
||||
};
|
||||
|
||||
class SetActorCutsceneListFactoryV0 : public SceneCommandVersionFactory {
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -2,52 +2,30 @@
|
||||
#include "2s2h/resource/type/scenecommand/SetActorList.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
namespace LUS {
|
||||
std::shared_ptr<IResource>
|
||||
SetActorListFactory::ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<SetActorList>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<SetActorListFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr)
|
||||
{
|
||||
SPDLOG_ERROR("Failed to load SetActorList with version {}", resource->GetInitData()->ResourceVersion);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void LUS::SetActorListFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource) {
|
||||
std::shared_ptr<SetActorList> setActorList = std::static_pointer_cast<SetActorList>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, setActorList);
|
||||
namespace SOH {
|
||||
std::shared_ptr<LUS::IResource>
|
||||
SetActorListFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) {
|
||||
auto setActorList = std::make_shared<SetActorList>(initData);
|
||||
|
||||
ReadCommandId(setActorList, reader);
|
||||
|
||||
setActorList->numActors = reader->ReadUInt32();
|
||||
setActorList->actorList.reserve(setActorList->numActors);
|
||||
for (uint32_t i = 0; i < setActorList->numActors; i++) {
|
||||
ActorEntry entry;
|
||||
ActorEntry entry;
|
||||
|
||||
entry.id = reader->ReadUInt16();
|
||||
entry.pos.x = reader->ReadInt16();
|
||||
entry.pos.y = reader->ReadInt16();
|
||||
entry.pos.z = reader->ReadInt16();
|
||||
entry.rot.x = reader->ReadInt16();
|
||||
entry.rot.y = reader->ReadInt16();
|
||||
entry.rot.z = reader->ReadInt16();
|
||||
entry.params = reader->ReadUInt16();
|
||||
entry.id = reader->ReadUInt16();
|
||||
entry.pos.x = reader->ReadInt16();
|
||||
entry.pos.y = reader->ReadInt16();
|
||||
entry.pos.z = reader->ReadInt16();
|
||||
entry.rot.x = reader->ReadInt16();
|
||||
entry.rot.y = reader->ReadInt16();
|
||||
entry.rot.z = reader->ReadInt16();
|
||||
entry.params = reader->ReadUInt16();
|
||||
|
||||
setActorList->actorList.push_back(entry);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace LUS
|
||||
return setActorList;
|
||||
}
|
||||
} // namespace SOH
|
||||
|
@ -2,15 +2,10 @@
|
||||
|
||||
#include "2s2h/resource/importer/scenecommand/SceneCommandFactory.h"
|
||||
|
||||
namespace LUS {
|
||||
class SetActorListFactory : public SceneCommandFactory {
|
||||
namespace SOH {
|
||||
class SetActorListFactory : public SceneCommandFactoryBinaryV0 {
|
||||
public:
|
||||
std::shared_ptr<IResource>
|
||||
ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) override;
|
||||
std::shared_ptr<LUS::IResource>
|
||||
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
|
||||
};
|
||||
|
||||
class SetActorListFactoryV0 : public SceneCommandVersionFactory {
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
};
|
||||
}; // namespace LUS
|
||||
} // namespace SOH
|
||||
|
@ -1,49 +1,25 @@
|
||||
#include "2s2h/resource/importer/scenecommand/SetAlternateHeadersFactory.h"
|
||||
#include "2s2h/resource/type/scenecommand/SetAlternateHeaders.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
#include "libultraship/libultraship.h"
|
||||
|
||||
namespace LUS {
|
||||
std::shared_ptr<IResource> SetAlternateHeadersFactory::ReadResource(std::shared_ptr<ResourceInitData> initData,
|
||||
std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<SetAlternateHeaders>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<SetAlternateHeadersFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr)
|
||||
{
|
||||
SPDLOG_ERROR("Failed to load SetAlternateHeaders with version {}", resource->GetInitData()->ResourceVersion);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void LUS::SetAlternateHeadersFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource)
|
||||
{
|
||||
std::shared_ptr<SetAlternateHeaders> setAlternateHeaders = std::static_pointer_cast<SetAlternateHeaders>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, setAlternateHeaders);
|
||||
namespace SOH {
|
||||
std::shared_ptr<LUS::IResource> SetAlternateHeadersFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
|
||||
std::shared_ptr<LUS::BinaryReader> reader) {
|
||||
auto setAlternateHeaders = std::make_shared<SetAlternateHeaders>(initData);
|
||||
|
||||
ReadCommandId(setAlternateHeaders, reader);
|
||||
|
||||
setAlternateHeaders->numHeaders = reader->ReadUInt32();
|
||||
setAlternateHeaders->headers.reserve(setAlternateHeaders->numHeaders);
|
||||
for (uint32_t i = 0; i < setAlternateHeaders->numHeaders; i++) {
|
||||
auto headerName = reader->ReadString();
|
||||
if (!headerName.empty()) {
|
||||
setAlternateHeaders->headers.push_back(std::static_pointer_cast<LUS::Scene>(LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(headerName.c_str())));
|
||||
} else {
|
||||
setAlternateHeaders->headers.push_back(nullptr);
|
||||
}
|
||||
auto headerName = reader->ReadString();
|
||||
if (!headerName.empty()) {
|
||||
setAlternateHeaders->headers.push_back(std::static_pointer_cast<Scene>(LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(headerName.c_str())));
|
||||
} else {
|
||||
setAlternateHeaders->headers.push_back(nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace LUS
|
||||
return setAlternateHeaders;
|
||||
}
|
||||
} // namespace SOH
|
||||
|
@ -2,15 +2,10 @@
|
||||
|
||||
#include "2s2h/resource/importer/scenecommand/SceneCommandFactory.h"
|
||||
|
||||
namespace LUS {
|
||||
class SetAlternateHeadersFactory : public SceneCommandFactory {
|
||||
namespace SOH {
|
||||
class SetAlternateHeadersFactory : public SceneCommandFactoryBinaryV0 {
|
||||
public:
|
||||
std::shared_ptr<IResource>
|
||||
ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) override;
|
||||
std::shared_ptr<LUS::IResource>
|
||||
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
|
||||
};
|
||||
|
||||
class SetAlternateHeadersFactoryV0 : public SceneCommandVersionFactory {
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
};
|
||||
}; // namespace LUS
|
||||
} // namespace SOH
|
||||
|
@ -1,41 +1,23 @@
|
||||
#include "2s2h/resource/importer/scenecommand/SetAnimatedMaterialListFactory.h"
|
||||
#include "2s2h/resource/type/scenecommand/SetAnimatedMaterialList.h"
|
||||
#include "2s2h/resource/type/TextureAnimation.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
#include <libultraship/libultraship.h>
|
||||
|
||||
namespace LUS {
|
||||
|
||||
std::shared_ptr<IResource> LUS::SetAnimatedMaterialListFactory::ReadResource(std::shared_ptr<ResourceInitData> initData,
|
||||
std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<SetAnimatedMaterialList>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<SetAnimatedMaterialListFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load SetAnimatedMaterialList with version {}", resource->GetInitData()->ResourceVersion);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void LUS::SetAnimatedMaterialListFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource) {
|
||||
std::shared_ptr<SetAnimatedMaterialList> setAnimatedMat =
|
||||
std::static_pointer_cast<SetAnimatedMaterialList>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, setAnimatedMat);
|
||||
namespace SOH {
|
||||
|
||||
std::shared_ptr<LUS::IResource> SetAnimatedMaterialListFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
|
||||
std::shared_ptr<LUS::BinaryReader> reader) {
|
||||
auto setAnimatedMat = std::make_shared<SetAnimatedMaterialList>(initData);
|
||||
|
||||
ReadCommandId(setAnimatedMat, reader);
|
||||
AnimatedMaterialData* res = (AnimatedMaterialData*)ResourceGetDataByName(reader->ReadString().c_str());
|
||||
setAnimatedMat->mat = res;
|
||||
}
|
||||
|
||||
std::string str = reader->ReadString();
|
||||
const auto data = std::static_pointer_cast<TextureAnimation>(
|
||||
LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(str.c_str()));
|
||||
|
||||
AnimatedMaterial* res = data->GetPointer();
|
||||
setAnimatedMat->mat = res;
|
||||
|
||||
return setAnimatedMat;
|
||||
}
|
||||
} // namespace LUS
|
@ -2,16 +2,10 @@
|
||||
|
||||
#include "2s2h/resource/importer/scenecommand/SceneCommandFactory.h"
|
||||
|
||||
namespace LUS {
|
||||
class SetAnimatedMaterialListFactory : public SceneCommandFactory {
|
||||
namespace SOH {
|
||||
class SetAnimatedMaterialListFactory : public SceneCommandFactoryBinaryV0 {
|
||||
public:
|
||||
std::shared_ptr<IResource> ReadResource(std::shared_ptr<ResourceInitData> initData,
|
||||
std::shared_ptr<BinaryReader> reader) override;
|
||||
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
|
||||
std::shared_ptr<LUS::BinaryReader> reader) override;
|
||||
};
|
||||
|
||||
class SetAnimatedMaterialListFactoryV0 : public SceneCommandVersionFactory {
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -2,38 +2,13 @@
|
||||
#include "2s2h/resource/type/scenecommand/SetCameraSettings.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
namespace LUS {
|
||||
std::shared_ptr<IResource> SetCameraSettingsFactory::ReadResource(std::shared_ptr<ResourceInitData> initData,
|
||||
std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<SetCameraSettings>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<SetCameraSettingsFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load SetCameraSettings with version {}", resource->GetInitData()->ResourceVersion);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void LUS::SetCameraSettingsFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource)
|
||||
{
|
||||
std::shared_ptr<SetCameraSettings> setCameraSettings = std::static_pointer_cast<SetCameraSettings>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, setCameraSettings);
|
||||
namespace SOH {
|
||||
std::shared_ptr<LUS::IResource> SetCameraSettingsFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
|
||||
std::shared_ptr<LUS::BinaryReader> reader) {
|
||||
auto setCameraSettings = std::make_shared<SetCameraSettings>(initData);
|
||||
|
||||
ReadCommandId(setCameraSettings, reader);
|
||||
// BENTODO in MM this scene command is only used as a signal to have the scene system mark an area as visted. We should make a new command factory for this but this is fine for now.
|
||||
//setCameraSettings->settings.cameraMovement = reader->ReadInt8();
|
||||
//setCameraSettings->settings.worldMapArea = reader->ReadInt32();
|
||||
}
|
||||
|
||||
} // namespace LUS
|
||||
return setCameraSettings;
|
||||
}
|
||||
} // namespace SOH
|
||||
|
@ -2,15 +2,10 @@
|
||||
|
||||
#include "2s2h/resource/importer/scenecommand/SceneCommandFactory.h"
|
||||
|
||||
namespace LUS {
|
||||
class SetCameraSettingsFactory : public SceneCommandFactory {
|
||||
namespace SOH {
|
||||
class SetCameraSettingsFactory : public SceneCommandFactoryBinaryV0 {
|
||||
public:
|
||||
std::shared_ptr<IResource>
|
||||
ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) override;
|
||||
};
|
||||
|
||||
class SetCameraSettingsFactoryV0 : public SceneCommandVersionFactory {
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
std::shared_ptr<LUS::IResource>
|
||||
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
|
||||
};
|
||||
}; // namespace LUS
|
||||
|
@ -3,37 +3,16 @@
|
||||
#include "libultraship/libultraship.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
namespace LUS {
|
||||
std::shared_ptr<IResource> SetCollisionHeaderFactory::ReadResource(std::shared_ptr<ResourceInitData> initData,
|
||||
std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<SetCollisionHeader>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<SetCollisionHeaderFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load SetCollisionHeader with version {}", resource->GetInitData()->ResourceVersion);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void LUS::SetCollisionHeaderFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource) {
|
||||
std::shared_ptr<SetCollisionHeader> setCollisionHeader = std::static_pointer_cast<SetCollisionHeader>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, setCollisionHeader);
|
||||
namespace SOH {
|
||||
std::shared_ptr<LUS::IResource> SetCollisionHeaderFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
|
||||
std::shared_ptr<LUS::BinaryReader> reader) {
|
||||
auto setCollisionHeader = std::make_shared<SetCollisionHeader>(initData);
|
||||
|
||||
ReadCommandId(setCollisionHeader, reader);
|
||||
|
||||
setCollisionHeader->fileName = reader->ReadString();
|
||||
setCollisionHeader->collisionHeader = std::static_pointer_cast<CollisionHeader>(LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(setCollisionHeader->fileName.c_str()));
|
||||
}
|
||||
|
||||
} // namespace LUS
|
||||
return setCollisionHeader;
|
||||
}
|
||||
} // namespace SOH
|
||||
|
@ -2,15 +2,10 @@
|
||||
|
||||
#include "2s2h/resource/importer/scenecommand/SceneCommandFactory.h"
|
||||
|
||||
namespace LUS {
|
||||
class SetCollisionHeaderFactory : public SceneCommandFactory {
|
||||
namespace SOH {
|
||||
class SetCollisionHeaderFactory : public SceneCommandFactoryBinaryV0 {
|
||||
public:
|
||||
std::shared_ptr<IResource>
|
||||
ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) override;
|
||||
std::shared_ptr<LUS::IResource>
|
||||
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
|
||||
};
|
||||
|
||||
class SetCollisionHeaderFactoryV0 : public SceneCommandVersionFactory {
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
};
|
||||
}; // namespace LUS
|
||||
} // namespace SOH
|
||||
|
@ -2,36 +2,16 @@
|
||||
#include "2s2h/resource/type/scenecommand/SetCsCamera.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
namespace LUS {
|
||||
std::shared_ptr<IResource>
|
||||
SetCsCameraFactory::ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<SetCsCamera>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<SetCsCameraFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load SetCsCamera with version {}", resource->GetInitData()->ResourceVersion);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void LUS::SetCsCameraFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource) {
|
||||
std::shared_ptr<SetCsCamera> setCsCamera = std::static_pointer_cast<SetCsCamera>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, setCsCamera);
|
||||
|
||||
namespace SOH {
|
||||
std::shared_ptr<LUS::IResource>
|
||||
SetCsCameraFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) {
|
||||
auto setCsCamera = std::make_shared<SetCsCamera>(initData);
|
||||
|
||||
ReadCommandId(setCsCamera, reader);
|
||||
|
||||
size_t camSize = reader->ReadUInt32();
|
||||
|
||||
size_t camSize = reader->ReadUInt32();
|
||||
|
||||
setCsCamera->csCamera.reserve(camSize);
|
||||
|
||||
for (size_t i = 0; i < camSize; i++) {
|
||||
ActorCsCamInfoData data;
|
||||
@ -49,7 +29,7 @@ void LUS::SetCsCameraFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> re
|
||||
}
|
||||
setCsCamera->csCamera.emplace_back(data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return setCsCamera;
|
||||
}
|
||||
} // namespace LUS
|
||||
|
@ -2,15 +2,10 @@
|
||||
|
||||
#include "2s2h/resource/importer/scenecommand/SceneCommandFactory.h"
|
||||
|
||||
namespace LUS {
|
||||
class SetCsCameraFactory : public SceneCommandFactory {
|
||||
namespace SOH {
|
||||
class SetCsCameraFactory : public SceneCommandFactoryBinaryV0 {
|
||||
public:
|
||||
std::shared_ptr<IResource>
|
||||
ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) override;
|
||||
};
|
||||
|
||||
class SetCsCameraFactoryV0 : public SceneCommandVersionFactory {
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
std::shared_ptr<LUS::IResource>
|
||||
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
|
||||
};
|
||||
}; // namespace LUS
|
||||
|
@ -3,69 +3,15 @@
|
||||
#include <libultraship/libultraship.h>
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
namespace LUS {
|
||||
std::shared_ptr<IResource>
|
||||
SetCutscenesFactory::ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<SetCutscenes>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<SetCutscenesFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr)
|
||||
{
|
||||
SPDLOG_ERROR("Failed to load SetCutscenes with version {}", resource->GetInitData()->ResourceVersion);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void LUS::SetCutscenesFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource) {
|
||||
std::shared_ptr<SetCutscenes> setCutscenes = std::static_pointer_cast<SetCutscenes>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, setCutscenes);
|
||||
|
||||
ReadCommandId(setCutscenes, reader);
|
||||
|
||||
setCutscenes->fileName = reader->ReadString();
|
||||
setCutscenes->cutscene = std::static_pointer_cast<Cutscene>(LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(setCutscenes->fileName.c_str()));
|
||||
}
|
||||
|
||||
std::shared_ptr<IResource> SetCutsceneFactoryMM::ReadResource(std::shared_ptr<ResourceInitData> initData,
|
||||
std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<SetCutscenesMM>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<SetCutscenesFactoryMMV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load SetCutscenes with version {}", resource->GetInitData()->ResourceVersion);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void LUS::SetCutscenesFactoryMMV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource) {
|
||||
std::shared_ptr<SetCutscenesMM> setCutscenes = std::static_pointer_cast<SetCutscenesMM>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, setCutscenes);
|
||||
namespace SOH {
|
||||
std::shared_ptr<LUS::IResource> SetCutsceneFactoryMM::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
|
||||
std::shared_ptr<LUS::BinaryReader> reader) {
|
||||
auto setCutscenes = std::make_shared<SetCutscenesMM>(initData);
|
||||
|
||||
ReadCommandId(setCutscenes, reader);
|
||||
|
||||
size_t numCs = reader->ReadUByte();
|
||||
setCutscenes->entries.reserve(numCs);
|
||||
|
||||
for (size_t i = 0; i < numCs; i++) {
|
||||
CutsceneScriptEntry entry;
|
||||
@ -73,9 +19,11 @@ void LUS::SetCutscenesFactoryMMV0::ParseFileBinary(std::shared_ptr<BinaryReader>
|
||||
entry.exit = reader->ReadUInt16();
|
||||
entry.entrance = reader->ReadUByte();
|
||||
entry.flag = reader->ReadUByte();
|
||||
entry.data = ResourceGetDataByName(path.c_str());
|
||||
entry.data = std::static_pointer_cast<Cutscene>(
|
||||
LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(path.c_str()))->GetPointer();
|
||||
setCutscenes->entries.emplace_back(entry);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace LUS
|
||||
return setCutscenes;
|
||||
}
|
||||
} // namespace SOH
|
||||
|
@ -2,27 +2,11 @@
|
||||
|
||||
#include "2s2h/resource/importer/scenecommand/SceneCommandFactory.h"
|
||||
|
||||
namespace LUS {
|
||||
class SetCutscenesFactory : public SceneCommandFactory {
|
||||
namespace SOH {
|
||||
class SetCutsceneFactoryMM : public SceneCommandFactoryBinaryV0 {
|
||||
public:
|
||||
std::shared_ptr<IResource>
|
||||
ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) override;
|
||||
};
|
||||
|
||||
class SetCutscenesFactoryV0 : public SceneCommandVersionFactory {
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
};
|
||||
|
||||
class SetCutsceneFactoryMM : public SceneCommandFactory {
|
||||
public:
|
||||
std::shared_ptr<IResource> ReadResource(std::shared_ptr<ResourceInitData> initData,
|
||||
std::shared_ptr<BinaryReader> reader) override;
|
||||
};
|
||||
|
||||
class SetCutscenesFactoryMMV0 : public SceneCommandVersionFactory {
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
|
||||
std::shared_ptr<LUS::BinaryReader> reader) override;
|
||||
};
|
||||
|
||||
}; // namespace LUS
|
||||
|
@ -2,37 +2,15 @@
|
||||
#include "2s2h/resource/type/scenecommand/SetEchoSettings.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
namespace LUS {
|
||||
std::shared_ptr<IResource>
|
||||
SetEchoSettingsFactory::ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<SetEchoSettings>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<SetEchoSettingsFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load SetEchoSettings with version {}", resource->GetInitData()->ResourceVersion);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void LUS::SetEchoSettingsFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource)
|
||||
{
|
||||
std::shared_ptr<SetEchoSettings> setEchoSettings = std::static_pointer_cast<SetEchoSettings>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, setEchoSettings);
|
||||
namespace SOH {
|
||||
std::shared_ptr<LUS::IResource>
|
||||
SetEchoSettingsFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) {
|
||||
auto setEchoSettings = std::make_shared<SetEchoSettings>(initData);
|
||||
|
||||
ReadCommandId(setEchoSettings, reader);
|
||||
|
||||
setEchoSettings->settings.echo = reader->ReadInt8();
|
||||
}
|
||||
|
||||
} // namespace LUS
|
||||
return setEchoSettings;
|
||||
}
|
||||
} // namespace SOH
|
||||
|
@ -2,15 +2,10 @@
|
||||
|
||||
#include "2s2h/resource/importer/scenecommand/SceneCommandFactory.h"
|
||||
|
||||
namespace LUS {
|
||||
class SetEchoSettingsFactory : public SceneCommandFactory {
|
||||
namespace SOH {
|
||||
class SetEchoSettingsFactory : public SceneCommandFactoryBinaryV0 {
|
||||
public:
|
||||
std::shared_ptr<IResource>
|
||||
ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) override;
|
||||
std::shared_ptr<LUS::IResource>
|
||||
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
|
||||
};
|
||||
|
||||
class SetEchoSettingsFactoryV0 : public SceneCommandVersionFactory {
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
};
|
||||
}; // namespace LUS
|
||||
} // namespace SOH
|
||||
|
@ -2,45 +2,24 @@
|
||||
#include "2s2h/resource/type/scenecommand/SetEntranceList.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
namespace LUS {
|
||||
std::shared_ptr<IResource>
|
||||
SetEntranceListFactory::ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<SetEntranceList>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<SetEntranceListFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load SetEntranceListList with version {}", resource->GetInitData()->ResourceVersion);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void LUS::SetEntranceListFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource) {
|
||||
std::shared_ptr<SetEntranceList> setEntranceList = std::static_pointer_cast<SetEntranceList>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, setEntranceList);
|
||||
namespace SOH {
|
||||
std::shared_ptr<LUS::IResource>
|
||||
SetEntranceListFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) {
|
||||
auto setEntranceList = std::make_shared<SetEntranceList>(initData);
|
||||
|
||||
ReadCommandId(setEntranceList, reader);
|
||||
|
||||
setEntranceList->numEntrances = reader->ReadUInt32();
|
||||
setEntranceList->entrances.reserve(setEntranceList->numEntrances);
|
||||
for (uint32_t i = 0; i < setEntranceList->numEntrances; i++) {
|
||||
EntranceEntry entranceEntry;
|
||||
EntranceEntry entranceEntry;
|
||||
|
||||
entranceEntry.spawn = reader->ReadInt8();
|
||||
entranceEntry.room = reader->ReadInt8();
|
||||
entranceEntry.spawn = reader->ReadInt8();
|
||||
entranceEntry.room = reader->ReadInt8();
|
||||
|
||||
setEntranceList->entrances.push_back(entranceEntry);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace LUS
|
||||
return setEntranceList;
|
||||
}
|
||||
} // namespace SOH
|
||||
|
@ -2,15 +2,10 @@
|
||||
|
||||
#include "2s2h/resource/importer/scenecommand/SceneCommandFactory.h"
|
||||
|
||||
namespace LUS {
|
||||
class SetEntranceListFactory : public SceneCommandFactory {
|
||||
namespace SOH {
|
||||
class SetEntranceListFactory : public SceneCommandFactoryBinaryV0 {
|
||||
public:
|
||||
std::shared_ptr<IResource>
|
||||
ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) override;
|
||||
std::shared_ptr<LUS::IResource>
|
||||
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
|
||||
};
|
||||
|
||||
class SetEntranceListFactoryV0 : public SceneCommandVersionFactory {
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
};
|
||||
}; // namespace LUS
|
||||
} // namespace SOH
|
||||
|
@ -2,40 +2,19 @@
|
||||
#include "2s2h/resource/type/scenecommand/SetExitList.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
namespace LUS {
|
||||
std::shared_ptr<IResource>
|
||||
SetExitListFactory::ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<SetExitList>( initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<SetExitListFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load SetExitList with version {}", resource->GetInitData()->ResourceVersion);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void LUS::SetExitListFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource) {
|
||||
std::shared_ptr<SetExitList> setExitList = std::static_pointer_cast<SetExitList>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, setExitList);
|
||||
namespace SOH {
|
||||
std::shared_ptr<LUS::IResource>
|
||||
SetExitListFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
|
||||
std::shared_ptr<LUS::BinaryReader> reader) {
|
||||
auto setExitList = std::make_shared<SetExitList>(initData);
|
||||
|
||||
ReadCommandId(setExitList, reader);
|
||||
|
||||
|
||||
setExitList->numExits = reader->ReadUInt32();
|
||||
setExitList->exits.reserve(setExitList->numExits);
|
||||
for (uint32_t i = 0; i < setExitList->numExits; i++) {
|
||||
setExitList->exits.push_back(reader->ReadUInt16());
|
||||
}
|
||||
return setExitList;
|
||||
}
|
||||
|
||||
} // namespace LUS
|
||||
|
@ -2,15 +2,10 @@
|
||||
|
||||
#include "2s2h/resource/importer/scenecommand/SceneCommandFactory.h"
|
||||
|
||||
namespace LUS {
|
||||
class SetExitListFactory : public SceneCommandFactory {
|
||||
namespace SOH {
|
||||
class SetExitListFactory : public SceneCommandFactoryBinaryV0 {
|
||||
public:
|
||||
std::shared_ptr<IResource>
|
||||
ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) override;
|
||||
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
|
||||
std::shared_ptr<LUS::BinaryReader> reader) override;
|
||||
};
|
||||
|
||||
class SetExitListFactoryV0 : public SceneCommandVersionFactory {
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
};
|
||||
}; // namespace LUS
|
||||
} // namespace SOH
|
||||
|
@ -2,34 +2,10 @@
|
||||
#include "2s2h/resource/type/scenecommand/SetLightList.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
namespace LUS {
|
||||
std::shared_ptr<IResource>
|
||||
SetLightListFactory::ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<SetLightList>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<SetLightListFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr)
|
||||
{
|
||||
SPDLOG_ERROR("Failed to load SetLightList with version {}", resource->GetInitData()->ResourceVersion);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void LUS::SetLightListFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource)
|
||||
{
|
||||
std::shared_ptr<SetLightList> setLightList = std::static_pointer_cast<SetLightList>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, setLightList);
|
||||
namespace SOH {
|
||||
std::shared_ptr<LUS::IResource>
|
||||
SetLightListFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) {
|
||||
auto setLightList = std::make_shared<SetLightList>(initData);
|
||||
|
||||
ReadCommandId(setLightList, reader);
|
||||
|
||||
@ -40,7 +16,7 @@ void LUS::SetLightListFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> r
|
||||
|
||||
light.type = reader->ReadUByte();
|
||||
|
||||
light.params.point.x = reader->ReadInt16();
|
||||
light.params.point.x = reader->ReadInt16();
|
||||
light.params.point.y = reader->ReadInt16();
|
||||
light.params.point.z = reader->ReadInt16();
|
||||
|
||||
@ -49,10 +25,11 @@ void LUS::SetLightListFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> r
|
||||
light.params.point.color[2] = reader->ReadUByte(); // b
|
||||
|
||||
light.params.point.drawGlow = reader->ReadUByte();
|
||||
light.params.point.radius = reader->ReadInt16();
|
||||
light.params.point.radius = reader->ReadInt16();
|
||||
|
||||
setLightList->lightList.push_back(light);
|
||||
setLightList->lightList.emplace_back(light);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace LUS
|
||||
return setLightList;
|
||||
}
|
||||
} // namespace SOH
|
||||
|
@ -2,15 +2,10 @@
|
||||
|
||||
#include "2s2h/resource/importer/scenecommand/SceneCommandFactory.h"
|
||||
|
||||
namespace LUS {
|
||||
class SetLightListFactory : public SceneCommandFactory {
|
||||
namespace SOH {
|
||||
class SetLightListFactory : public SceneCommandFactoryBinaryV0 {
|
||||
public:
|
||||
std::shared_ptr<IResource>
|
||||
ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) override;
|
||||
std::shared_ptr<LUS::IResource>
|
||||
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
|
||||
};
|
||||
|
||||
class SetLightListFactoryV0 : public SceneCommandVersionFactory {
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
};
|
||||
}; // namespace LUS
|
||||
} // namespace SOH
|
||||
|
@ -2,33 +2,11 @@
|
||||
#include "2s2h/resource/type/scenecommand/SetLightingSettings.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
namespace LUS {
|
||||
std::shared_ptr<IResource> SetLightingSettingsFactory::ReadResource(std::shared_ptr<ResourceInitData> initData,
|
||||
std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<SetLightingSettings>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<SetLightingSettingsFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load SetLightingSettings with version {}", resource->GetInitData()->ResourceVersion);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void LUS::SetLightingSettingsFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource)
|
||||
{
|
||||
std::shared_ptr<SetLightingSettings> setLightingSettings = std::static_pointer_cast<SetLightingSettings>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, setLightingSettings);
|
||||
namespace SOH {
|
||||
std::shared_ptr<LUS::IResource>
|
||||
SetLightingSettingsFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
|
||||
std::shared_ptr<LUS::BinaryReader> reader) {
|
||||
auto setLightingSettings = std::make_shared<SetLightingSettings>(initData);
|
||||
|
||||
ReadCommandId(setLightingSettings, reader);
|
||||
|
||||
@ -65,6 +43,7 @@ void LUS::SetLightingSettingsFactoryV0::ParseFileBinary(std::shared_ptr<BinaryRe
|
||||
lightSettings.fogFar = reader->ReadUInt16();
|
||||
setLightingSettings->settings.push_back(lightSettings);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace LUS
|
||||
return setLightingSettings;
|
||||
}
|
||||
} // namespace SOH
|
||||
|
@ -2,15 +2,10 @@
|
||||
|
||||
#include "2s2h/resource/importer/scenecommand/SceneCommandFactory.h"
|
||||
|
||||
namespace LUS {
|
||||
class SetLightingSettingsFactory : public SceneCommandFactory {
|
||||
namespace SOH {
|
||||
class SetLightingSettingsFactory : public SceneCommandFactoryBinaryV0 {
|
||||
public:
|
||||
std::shared_ptr<IResource>
|
||||
ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) override;
|
||||
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
|
||||
std::shared_ptr<LUS::BinaryReader> reader) override;
|
||||
};
|
||||
|
||||
class SetLightingSettingsFactoryV0 : public SceneCommandVersionFactory {
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
};
|
||||
}; // namespace LUS
|
||||
} // namespace SOH
|
@ -3,34 +3,10 @@
|
||||
#include "spdlog/spdlog.h"
|
||||
#include "libultraship/libultraship.h"
|
||||
|
||||
namespace LUS {
|
||||
std::shared_ptr<IResource>
|
||||
SetMeshFactory::ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<SetMesh>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<SetMeshFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr)
|
||||
{
|
||||
SPDLOG_ERROR("Failed to load SetMesh with version {}", resource->GetInitData()->ResourceVersion);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void LUS::SetMeshFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource)
|
||||
{
|
||||
std::shared_ptr<SetMesh> setMesh = std::static_pointer_cast<SetMesh>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, setMesh);
|
||||
namespace SOH {
|
||||
std::shared_ptr<LUS::IResource>
|
||||
SetMeshFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) {
|
||||
auto setMesh = std::make_shared<SetMesh>(initData);
|
||||
|
||||
ReadCommandId(setMesh, reader);
|
||||
|
||||
@ -46,7 +22,8 @@ void LUS::SetMeshFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader
|
||||
} else if (setMesh->meshHeader.base.type == 2) {
|
||||
setMesh->meshHeader.polygon2.num = polyNum;
|
||||
} else {
|
||||
SPDLOG_ERROR("Tried to load mesh in SetMesh scene header with type that doesn't exist: {}", setMesh->meshHeader.base.type);
|
||||
SPDLOG_ERROR("Tried to load mesh in SetMesh scene header with type that doesn't exist: {}",
|
||||
setMesh->meshHeader.base.type);
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,7 +81,8 @@ void LUS::SetMeshFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader
|
||||
if (setMesh->meshHeader.polygon1.format == 1) {
|
||||
setMesh->meshHeader.polygon1.single.source = image.source;
|
||||
setMesh->meshHeader.polygon1.single.unk_0C = image.unk_0C;
|
||||
setMesh->meshHeader.polygon1.single.tlut = (void*)image.tlut; // OTRTODO: type of bgimage.tlut should be uintptr_t
|
||||
setMesh->meshHeader.polygon1.single.tlut =
|
||||
(void*)image.tlut; // OTRTODO: type of bgimage.tlut should be uintptr_t
|
||||
setMesh->meshHeader.polygon1.single.width = image.width;
|
||||
setMesh->meshHeader.polygon1.single.height = image.height;
|
||||
setMesh->meshHeader.polygon1.single.fmt = image.fmt;
|
||||
@ -133,7 +111,7 @@ void LUS::SetMeshFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader
|
||||
setMesh->dlists.push_back(pType);
|
||||
} else if (setMesh->meshHeader.base.type == 2) {
|
||||
PolygonDlist2 dlist;
|
||||
|
||||
|
||||
int32_t polyType = reader->ReadInt8(); // Unused
|
||||
dlist.pos.x = reader->ReadInt16();
|
||||
dlist.pos.y = reader->ReadInt16();
|
||||
@ -150,7 +128,8 @@ void LUS::SetMeshFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader
|
||||
|
||||
setMesh->dlists2.push_back(dlist);
|
||||
} else {
|
||||
SPDLOG_ERROR("Tried to load mesh in SetMesh scene header with type that doesn't exist: {}", setMesh->meshHeader.base.type);
|
||||
SPDLOG_ERROR("Tried to load mesh in SetMesh scene header with type that doesn't exist: {}",
|
||||
setMesh->meshHeader.base.type);
|
||||
}
|
||||
}
|
||||
|
||||
@ -162,8 +141,10 @@ void LUS::SetMeshFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader
|
||||
setMesh->meshHeader.polygon1.multi.list = setMesh->images.data();
|
||||
setMesh->meshHeader.polygon1.dlist = (Gfx*)setMesh->dlists.data();
|
||||
} else {
|
||||
SPDLOG_ERROR("Tried to load mesh in SetMesh scene header with type that doesn't exist: {}", setMesh->meshHeader.base.type);
|
||||
SPDLOG_ERROR("Tried to load mesh in SetMesh scene header with type that doesn't exist: {}",
|
||||
setMesh->meshHeader.base.type);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace LUS
|
||||
return setMesh;
|
||||
}
|
||||
} // namespace SOH
|
||||
|
@ -2,15 +2,10 @@
|
||||
|
||||
#include "2s2h/resource/importer/scenecommand/SceneCommandFactory.h"
|
||||
|
||||
namespace LUS {
|
||||
class SetMeshFactory : public SceneCommandFactory {
|
||||
namespace SOH {
|
||||
class SetMeshFactory : public SceneCommandFactoryBinaryV0 {
|
||||
public:
|
||||
std::shared_ptr<IResource>
|
||||
ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) override;
|
||||
std::shared_ptr<LUS::IResource>
|
||||
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
|
||||
};
|
||||
|
||||
class SetMeshFactoryV0 : public SceneCommandVersionFactory {
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
};
|
||||
}; // namespace LUS
|
||||
} // namespace SOH
|
||||
|
@ -2,33 +2,11 @@
|
||||
#include "2s2h/resource/type/scenecommand/SetMinimapChests.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
namespace LUS {
|
||||
namespace SOH {
|
||||
|
||||
std::shared_ptr<IResource> SetMinimapChestsFactory::ReadResource(std::shared_ptr<ResourceInitData> initData,
|
||||
std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<SetMinimapChests>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<SetMinimapChestsFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load SetMinimapChestsFactory with version {}", resource->GetInitData()->ResourceVersion);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void SetMinimapChestsFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource) {
|
||||
std::shared_ptr<SetMinimapChests> chests = std::static_pointer_cast<SetMinimapChests>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, chests);
|
||||
std::shared_ptr<LUS::IResource> SetMinimapChestsFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
|
||||
std::shared_ptr<LUS::BinaryReader> reader) {
|
||||
auto chests = std::make_shared<SetMinimapChests>(initData);
|
||||
|
||||
ReadCommandId(chests, reader);
|
||||
|
||||
@ -45,6 +23,7 @@ void SetMinimapChestsFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> re
|
||||
d.unk_8 = reader->ReadUInt16();
|
||||
chests->chests.emplace_back(d);
|
||||
}
|
||||
}
|
||||
|
||||
return chests;
|
||||
}
|
||||
} // namespace LUS
|
@ -2,15 +2,10 @@
|
||||
|
||||
#include "2s2h/resource/importer/scenecommand/SceneCommandFactory.h"
|
||||
|
||||
namespace LUS {
|
||||
class SetMinimapChestsFactory : public SceneCommandFactory {
|
||||
namespace SOH {
|
||||
class SetMinimapChestsFactory : public SceneCommandFactoryBinaryV0 {
|
||||
public:
|
||||
std::shared_ptr<IResource> ReadResource(std::shared_ptr<ResourceInitData> initData,
|
||||
std::shared_ptr<BinaryReader> reader) override;
|
||||
};
|
||||
|
||||
class SetMinimapChestsFactoryV0 : public SceneCommandVersionFactory {
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
|
||||
std::shared_ptr<LUS::BinaryReader> reader) override;
|
||||
};
|
||||
}
|
@ -2,32 +2,10 @@
|
||||
#include "2s2h/resource/type/scenecommand/SetMinimapList.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
namespace LUS {
|
||||
std::shared_ptr<IResource> SetMinimapListFactory::ReadResource(std::shared_ptr<ResourceInitData> initData,
|
||||
std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<SetMinimapList>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<SetMinimapListFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load SetMinimapListFactory with version {}", resource->GetInitData()->ResourceVersion);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
void SetMinimapListFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource) {
|
||||
std::shared_ptr<SetMinimapList> mapList = std::static_pointer_cast<SetMinimapList>(resource);
|
||||
|
||||
ResourceVersionFactory::ParseFileBinary(reader, mapList);
|
||||
namespace SOH {
|
||||
std::shared_ptr<LUS::IResource> SetMinimapListFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
|
||||
std::shared_ptr<LUS::BinaryReader> reader) {
|
||||
auto mapList = std::make_shared<SetMinimapList>(initData);
|
||||
|
||||
ReadCommandId(mapList, reader);
|
||||
|
||||
@ -46,5 +24,8 @@ void SetMinimapListFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> read
|
||||
mapList->entries.emplace_back(data);
|
||||
}
|
||||
mapList->list.entry = mapList->entries.data();
|
||||
|
||||
return mapList;
|
||||
|
||||
}
|
||||
} // namespace LUS
|
||||
|
@ -2,15 +2,10 @@
|
||||
|
||||
#include "2s2h/resource/importer/scenecommand/SceneCommandFactory.h"
|
||||
|
||||
namespace LUS {
|
||||
class SetMinimapListFactory : public SceneCommandFactory {
|
||||
namespace SOH {
|
||||
class SetMinimapListFactory : public SceneCommandFactoryBinaryV0 {
|
||||
public:
|
||||
std::shared_ptr<IResource> ReadResource(std::shared_ptr<ResourceInitData> initData,
|
||||
std::shared_ptr<BinaryReader> reader) override;
|
||||
};
|
||||
|
||||
class SetMinimapListFactoryV0 : public SceneCommandVersionFactory {
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
|
||||
std::shared_ptr<LUS::BinaryReader> reader) override;
|
||||
};
|
||||
}; // namespace LUS
|
@ -2,33 +2,10 @@
|
||||
#include "2s2h/resource/type/scenecommand/SetObjectList.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
namespace LUS {
|
||||
std::shared_ptr<IResource>
|
||||
SetObjectListFactory::ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<SetObjectList>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<SetObjectListFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load SetObjectList with version {}", resource->GetInitData()->ResourceVersion);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void LUS::SetObjectListFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource)
|
||||
{
|
||||
std::shared_ptr<SetObjectList> setObjectList = std::static_pointer_cast<SetObjectList>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, setObjectList);
|
||||
namespace SOH {
|
||||
std::shared_ptr<LUS::IResource>
|
||||
SetObjectListFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) {
|
||||
auto setObjectList = std::make_shared<SetObjectList>(initData);
|
||||
|
||||
ReadCommandId(setObjectList, reader);
|
||||
|
||||
@ -37,6 +14,7 @@ void LUS::SetObjectListFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader>
|
||||
for (uint32_t i = 0; i < setObjectList->numObjects; i++) {
|
||||
setObjectList->objects.push_back(reader->ReadUInt16());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace LUS
|
||||
return setObjectList;
|
||||
}
|
||||
} // namespace SOH
|
||||
|
@ -2,15 +2,10 @@
|
||||
|
||||
#include "2s2h/resource/importer/scenecommand/SceneCommandFactory.h"
|
||||
|
||||
namespace LUS {
|
||||
class SetObjectListFactory : public SceneCommandFactory {
|
||||
namespace SOH {
|
||||
class SetObjectListFactory : public SceneCommandFactoryBinaryV0 {
|
||||
public:
|
||||
std::shared_ptr<IResource>
|
||||
ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) override;
|
||||
std::shared_ptr<LUS::IResource>
|
||||
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
|
||||
};
|
||||
|
||||
class SetObjectListFactoryV0 : public SceneCommandVersionFactory {
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
};
|
||||
}; // namespace LUS
|
||||
} // namespace SOH
|
||||
|
@ -3,70 +3,11 @@
|
||||
#include "spdlog/spdlog.h"
|
||||
#include <libultraship/libultraship.h>
|
||||
|
||||
namespace LUS {
|
||||
std::shared_ptr<IResource>
|
||||
SetPathwaysFactory::ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<SetPathways>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<SetPathwaysFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load SetPathways with version {}", resource->GetInitData()->ResourceVersion);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void LUS::SetPathwaysFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource) {
|
||||
std::shared_ptr<SetPathways> setPathways = std::static_pointer_cast<SetPathways>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, setPathways);
|
||||
|
||||
ReadCommandId(setPathways, reader);
|
||||
|
||||
setPathways->numPaths = reader->ReadUInt32();
|
||||
setPathways->paths.reserve(setPathways->numPaths);
|
||||
for (uint32_t i = 0; i < setPathways->numPaths; i++) {
|
||||
std::string pathFileName = reader->ReadString();
|
||||
auto path = std::static_pointer_cast<Path>(LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(pathFileName.c_str()));
|
||||
setPathways->paths.push_back(path->GetPointer());
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<IResource> SetPathwaysMMFactory::ReadResource(std::shared_ptr<ResourceInitData> initData,
|
||||
std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<SetPathwaysMM>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<SetPathwaysMMFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load SetPathwaysMM with version {}", resource->GetInitData()->ResourceVersion);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void LUS::SetPathwaysMMFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource) {
|
||||
std::shared_ptr<SetPathwaysMM> setPathways = std::static_pointer_cast<SetPathwaysMM>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, setPathways);
|
||||
|
||||
namespace SOH {
|
||||
std::shared_ptr<LUS::IResource> SetPathwaysMMFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
|
||||
std::shared_ptr<LUS::BinaryReader> reader) {
|
||||
auto setPathways = std::make_shared<SetPathwaysMM>(initData);
|
||||
|
||||
ReadCommandId(setPathways, reader);
|
||||
|
||||
setPathways->numPaths = reader->ReadUInt32();
|
||||
@ -77,6 +18,6 @@ void LUS::SetPathwaysMMFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader>
|
||||
LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(pathFileName.c_str()));
|
||||
setPathways->paths.push_back(path->GetPointer());
|
||||
}
|
||||
return setPathways;
|
||||
}
|
||||
|
||||
} // namespace LUS
|
||||
} // namespace SOH
|
||||
|
@ -2,27 +2,10 @@
|
||||
|
||||
#include "2s2h/resource/importer/scenecommand/SceneCommandFactory.h"
|
||||
|
||||
namespace LUS {
|
||||
class SetPathwaysFactory : public SceneCommandFactory {
|
||||
namespace SOH {
|
||||
class SetPathwaysMMFactory : public SceneCommandFactoryBinaryV0 {
|
||||
public:
|
||||
std::shared_ptr<IResource>
|
||||
ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) override;
|
||||
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
|
||||
std::shared_ptr<LUS::BinaryReader> reader) override;
|
||||
};
|
||||
|
||||
class SetPathwaysFactoryV0 : public SceneCommandVersionFactory {
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
};
|
||||
|
||||
class SetPathwaysMMFactory : public SceneCommandFactory {
|
||||
public:
|
||||
std::shared_ptr<IResource> ReadResource(std::shared_ptr<ResourceInitData> initData,
|
||||
std::shared_ptr<BinaryReader> reader) override;
|
||||
};
|
||||
|
||||
class SetPathwaysMMFactoryV0 : public SceneCommandVersionFactory {
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
};
|
||||
|
||||
}; // namespace LUS
|
||||
|
@ -2,68 +2,10 @@
|
||||
#include "2s2h/resource/type/scenecommand/SetRoomBehavior.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
namespace LUS {
|
||||
// OOT
|
||||
#if 0
|
||||
std::shared_ptr<IResource>
|
||||
SetRoomBehaviorFactory::ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<SetRoomBehavior>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<SetRoomBehaviorFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load SetRoomBehavior with version {}", resource->GetInitData()->ResourceVersion);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void LUS::SetRoomBehaviorFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource) {
|
||||
std::shared_ptr<SetRoomBehavior> setRoomBehavior = std::static_pointer_cast<SetRoomBehavior>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, setRoomBehavior);
|
||||
|
||||
ReadCommandId(setRoomBehavior, reader);
|
||||
|
||||
setRoomBehavior->roomBehavior.gameplayFlags = reader->ReadInt8();
|
||||
setRoomBehavior->roomBehavior.gameplayFlags2 = reader->ReadInt32();
|
||||
}
|
||||
#endif
|
||||
// MM
|
||||
|
||||
std::shared_ptr<IResource> SetRoomBehaviorMMFactory::ReadResource(std::shared_ptr<ResourceInitData> initData,
|
||||
std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<SetRoomBehaviorMM>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<SetRoomBehaviorMMFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load SetRoomBehavior with version {}", resource->GetInitData()->ResourceVersion);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void SetRoomBehaviorMMFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource) {
|
||||
std::shared_ptr<SetRoomBehaviorMM> setRoomBehavior = std::static_pointer_cast<SetRoomBehaviorMM>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, setRoomBehavior);
|
||||
namespace SOH {
|
||||
std::shared_ptr<LUS::IResource> SetRoomBehaviorMMFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
|
||||
std::shared_ptr<LUS::BinaryReader> reader) {
|
||||
auto setRoomBehavior = std::make_shared<SetRoomBehaviorMM>(initData);
|
||||
|
||||
ReadCommandId(setRoomBehavior, reader);
|
||||
|
||||
@ -73,6 +15,7 @@ void SetRoomBehaviorMMFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> r
|
||||
setRoomBehavior->roomBehavior.msgCtxUnk = reader->ReadInt8();
|
||||
setRoomBehavior->roomBehavior.enablePointLights = reader->ReadInt8();
|
||||
setRoomBehavior->roomBehavior.kankyoContextUnkE2 = reader->ReadInt8();
|
||||
}
|
||||
|
||||
} // namespace LUS
|
||||
return setRoomBehavior;
|
||||
}
|
||||
} // namespace SOH
|
||||
|
@ -2,27 +2,10 @@
|
||||
|
||||
#include "2s2h/resource/importer/scenecommand/SceneCommandFactory.h"
|
||||
|
||||
namespace LUS {
|
||||
class SetRoomBehaviorFactory : public SceneCommandFactory {
|
||||
namespace SOH {
|
||||
class SetRoomBehaviorMMFactory : public SceneCommandFactoryBinaryV0 {
|
||||
public:
|
||||
std::shared_ptr<IResource>
|
||||
ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) override;
|
||||
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
|
||||
std::shared_ptr<LUS::BinaryReader> reader) override;
|
||||
};
|
||||
|
||||
class SetRoomBehaviorFactoryV0 : public SceneCommandVersionFactory {
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
};
|
||||
|
||||
class SetRoomBehaviorMMFactory : public SceneCommandFactory {
|
||||
public:
|
||||
std::shared_ptr<IResource> ReadResource(std::shared_ptr<ResourceInitData> initData,
|
||||
std::shared_ptr<BinaryReader> reader) override;
|
||||
};
|
||||
|
||||
class SetRoomBehaviorMMFactoryV0 : public SceneCommandVersionFactory {
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
};
|
||||
|
||||
}; // namespace LUS
|
||||
}; // namespace SOH
|
||||
|
@ -2,49 +2,27 @@
|
||||
#include "2s2h/resource/type/scenecommand/SetRoomList.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
namespace LUS {
|
||||
std::shared_ptr<IResource>
|
||||
SetRoomListFactory::ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<SetRoomList>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<SetRoomListFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr)
|
||||
{
|
||||
SPDLOG_ERROR("Failed to load SetRoomList with version {}", resource->GetInitData()->ResourceVersion);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void LUS::SetRoomListFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource) {
|
||||
std::shared_ptr<SetRoomList> setRoomList = std::static_pointer_cast<SetRoomList>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, setRoomList);
|
||||
namespace SOH {
|
||||
std::shared_ptr<LUS::IResource>
|
||||
SetRoomListFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) {
|
||||
auto setRoomList = std::make_shared<SetRoomList>(initData);
|
||||
|
||||
ReadCommandId(setRoomList, reader);
|
||||
|
||||
setRoomList->numRooms = reader->ReadInt32();
|
||||
setRoomList->rooms.reserve(setRoomList->numRooms);
|
||||
for (uint32_t i = 0; i < setRoomList->numRooms; i++) {
|
||||
RomFile room;
|
||||
RomFile room;
|
||||
|
||||
setRoomList->fileNames.push_back(reader->ReadString());
|
||||
setRoomList->fileNames.push_back(reader->ReadString());
|
||||
|
||||
room.fileName = (char*)setRoomList->fileNames.back().c_str();
|
||||
room.vromStart = reader->ReadInt32();
|
||||
room.vromEnd = reader->ReadInt32();
|
||||
room.fileName = (char*)setRoomList->fileNames.back().c_str();
|
||||
room.vromStart = reader->ReadInt32();
|
||||
room.vromEnd = reader->ReadInt32();
|
||||
|
||||
setRoomList->rooms.push_back(room);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace LUS
|
||||
return setRoomList;
|
||||
}
|
||||
} // namespace SOH
|
||||
|
@ -2,15 +2,10 @@
|
||||
|
||||
#include "2s2h/resource/importer/scenecommand/SceneCommandFactory.h"
|
||||
|
||||
namespace LUS {
|
||||
class SetRoomListFactory : public SceneCommandFactory {
|
||||
namespace SOH {
|
||||
class SetRoomListFactory : public SceneCommandFactoryBinaryV0 {
|
||||
public:
|
||||
std::shared_ptr<IResource>
|
||||
ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) override;
|
||||
std::shared_ptr<LUS::IResource>
|
||||
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
|
||||
};
|
||||
|
||||
class SetRoomListFactoryV0 : public SceneCommandVersionFactory {
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
};
|
||||
}; // namespace LUS
|
||||
} // namespace SOH
|
||||
|
@ -2,37 +2,16 @@
|
||||
#include "2s2h/resource/type/scenecommand/SetSkyboxModifier.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
namespace LUS {
|
||||
std::shared_ptr<IResource> SetSkyboxModifierFactory::ReadResource(std::shared_ptr<ResourceInitData> initData,
|
||||
std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<SetSkyboxModifier>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<SetSkyboxModifierFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load SetSkyboxModifier with version {}", resource->GetInitData()->ResourceVersion);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void LUS::SetSkyboxModifierFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource) {
|
||||
std::shared_ptr<SetSkyboxModifier> setSkyboxModifier = std::static_pointer_cast<SetSkyboxModifier>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, setSkyboxModifier);
|
||||
namespace SOH {
|
||||
std::shared_ptr<LUS::IResource> SetSkyboxModifierFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
|
||||
std::shared_ptr<LUS::BinaryReader> reader) {
|
||||
auto setSkyboxModifier = std::make_shared<SetSkyboxModifier>(initData);
|
||||
|
||||
ReadCommandId(setSkyboxModifier, reader);
|
||||
|
||||
setSkyboxModifier->modifier.skyboxDisabled = reader->ReadInt8();
|
||||
setSkyboxModifier->modifier.sunMoonDisabled = reader->ReadInt8();
|
||||
}
|
||||
|
||||
} // namespace LUS
|
||||
return setSkyboxModifier;
|
||||
}
|
||||
} // namespace SOH
|
||||
|
@ -2,15 +2,10 @@
|
||||
|
||||
#include "2s2h/resource/importer/scenecommand/SceneCommandFactory.h"
|
||||
|
||||
namespace LUS {
|
||||
class SetSkyboxModifierFactory : public SceneCommandFactory {
|
||||
namespace SOH {
|
||||
class SetSkyboxModifierFactory : public SceneCommandFactoryBinaryV0 {
|
||||
public:
|
||||
std::shared_ptr<IResource>
|
||||
ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) override;
|
||||
std::shared_ptr<LUS::IResource>
|
||||
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
|
||||
};
|
||||
|
||||
class SetSkyboxModifierFactoryV0 : public SceneCommandVersionFactory {
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
};
|
||||
}; // namespace LUS
|
||||
} // namespace SOH
|
||||
|
@ -2,32 +2,10 @@
|
||||
#include "2s2h/resource/type/scenecommand/SetSkyboxSettings.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
namespace LUS {
|
||||
std::shared_ptr<IResource> SetSkyboxSettingsFactory::ReadResource(std::shared_ptr<ResourceInitData> initData,
|
||||
std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<SetSkyboxSettings>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<SetSkyboxSettingsFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load SetSkyboxSettings with version {}", resource->GetInitData()->ResourceVersion);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void SetSkyboxSettingsFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource) {
|
||||
std::shared_ptr<SetSkyboxSettings> setSkyboxSettings = std::static_pointer_cast<SetSkyboxSettings>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, setSkyboxSettings);
|
||||
namespace SOH {
|
||||
std::shared_ptr<LUS::IResource> SetSkyboxSettingsFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
|
||||
std::shared_ptr<LUS::BinaryReader> reader) {
|
||||
auto setSkyboxSettings = std::make_shared<SetSkyboxSettings>(initData);
|
||||
|
||||
ReadCommandId(setSkyboxSettings, reader);
|
||||
|
||||
@ -35,6 +13,7 @@ void SetSkyboxSettingsFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> r
|
||||
setSkyboxSettings->settings.skyboxId = reader->ReadInt8();
|
||||
setSkyboxSettings->settings.weather = reader->ReadInt8();
|
||||
setSkyboxSettings->settings.indoors = reader->ReadInt8();
|
||||
}
|
||||
|
||||
} // namespace LUS
|
||||
return setSkyboxSettings;
|
||||
}
|
||||
} // namespace SOH
|
||||
|
@ -2,15 +2,10 @@
|
||||
|
||||
#include "2s2h/resource/importer/scenecommand/SceneCommandFactory.h"
|
||||
|
||||
namespace LUS {
|
||||
class SetSkyboxSettingsFactory : public SceneCommandFactory {
|
||||
namespace SOH {
|
||||
class SetSkyboxSettingsFactory : public SceneCommandFactoryBinaryV0 {
|
||||
public:
|
||||
std::shared_ptr<IResource>
|
||||
ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) override;
|
||||
std::shared_ptr<LUS::IResource>
|
||||
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
|
||||
};
|
||||
|
||||
class SetSkyboxSettingsFactoryV0 : public SceneCommandVersionFactory {
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
};
|
||||
}; // namespace LUS
|
||||
} // namespace SOH
|
||||
|
@ -2,38 +2,17 @@
|
||||
#include "2s2h/resource/type/scenecommand/SetSoundSettings.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
namespace LUS {
|
||||
std::shared_ptr<IResource> SetSoundSettingsFactory::ReadResource(std::shared_ptr<ResourceInitData> initData,
|
||||
std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<SetSoundSettings>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<SetSoundSettingsFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load SetSoundSettings with version {}", resource->GetInitData()->ResourceVersion);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void LUS::SetSoundSettingsFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource) {
|
||||
std::shared_ptr<SetSoundSettings> setSoundSettings = std::static_pointer_cast<SetSoundSettings>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, setSoundSettings);
|
||||
namespace SOH {
|
||||
std::shared_ptr<LUS::IResource> SetSoundSettingsFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
|
||||
std::shared_ptr<LUS::BinaryReader> reader) {
|
||||
auto setSoundSettings = std::make_shared<SetSoundSettings>(initData);
|
||||
|
||||
ReadCommandId(setSoundSettings, reader);
|
||||
|
||||
setSoundSettings->settings.reverb = reader->ReadInt8();
|
||||
setSoundSettings->settings.natureAmbienceId = reader->ReadInt8();
|
||||
setSoundSettings->settings.seqId = reader->ReadInt8();
|
||||
}
|
||||
|
||||
} // namespace LUS
|
||||
return setSoundSettings;
|
||||
}
|
||||
} // namespace SOH
|
||||
|
@ -2,15 +2,10 @@
|
||||
|
||||
#include "2s2h/resource/importer/scenecommand/SceneCommandFactory.h"
|
||||
|
||||
namespace LUS {
|
||||
class SetSoundSettingsFactory : public SceneCommandFactory {
|
||||
namespace SOH {
|
||||
class SetSoundSettingsFactory : public SceneCommandFactoryBinaryV0 {
|
||||
public:
|
||||
std::shared_ptr<IResource>
|
||||
ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) override;
|
||||
std::shared_ptr<LUS::IResource>
|
||||
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
|
||||
};
|
||||
|
||||
class SetSoundSettingsFactoryV0 : public SceneCommandVersionFactory {
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
};
|
||||
}; // namespace LUS
|
||||
} // namespace SOH
|
||||
|
@ -2,37 +2,16 @@
|
||||
#include "2s2h/resource/type/scenecommand/SetSpecialObjects.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
namespace LUS {
|
||||
std::shared_ptr<IResource> SetSpecialObjectsFactory::ReadResource(std::shared_ptr<ResourceInitData> initData,
|
||||
std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<SetSpecialObjects>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<SetSpecialObjectsFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr){
|
||||
SPDLOG_ERROR("Failed to load SetSpecialObjects with version {}", resource->GetInitData()->ResourceVersion);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void LUS::SetSpecialObjectsFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource) {
|
||||
std::shared_ptr<SetSpecialObjects> setSpecialObjects = std::static_pointer_cast<SetSpecialObjects>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, setSpecialObjects);
|
||||
namespace SOH {
|
||||
std::shared_ptr<LUS::IResource> SetSpecialObjectsFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
|
||||
std::shared_ptr<LUS::BinaryReader> reader) {
|
||||
auto setSpecialObjects = std::make_shared<SetSpecialObjects>(initData);
|
||||
|
||||
ReadCommandId(setSpecialObjects, reader);
|
||||
|
||||
setSpecialObjects->specialObjects.elfMessage = reader->ReadInt8();
|
||||
setSpecialObjects->specialObjects.globalObject = reader->ReadInt16();
|
||||
}
|
||||
|
||||
} // namespace LUS
|
||||
return setSpecialObjects;
|
||||
}
|
||||
} // namespace SOH
|
||||
|
@ -2,15 +2,10 @@
|
||||
|
||||
#include "2s2h/resource/importer/scenecommand/SceneCommandFactory.h"
|
||||
|
||||
namespace LUS {
|
||||
class SetSpecialObjectsFactory : public SceneCommandFactory {
|
||||
namespace SOH {
|
||||
class SetSpecialObjectsFactory : public SceneCommandFactoryBinaryV0 {
|
||||
public:
|
||||
std::shared_ptr<IResource>
|
||||
ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) override;
|
||||
std::shared_ptr<LUS::IResource>
|
||||
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
|
||||
};
|
||||
|
||||
class SetSpecialObjectsFactoryV0 : public SceneCommandVersionFactory {
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
};
|
||||
}; // namespace LUS
|
||||
} // namespace SOH
|
||||
|
@ -2,54 +2,30 @@
|
||||
#include "2s2h/resource/type/scenecommand/SetStartPositionList.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
namespace LUS {
|
||||
std::shared_ptr<IResource> SetStartPositionListFactory::ReadResource(std::shared_ptr<ResourceInitData> initData,
|
||||
std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<SetStartPositionList>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion)
|
||||
{
|
||||
case 0:
|
||||
factory = std::make_shared<SetStartPositionListFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr)
|
||||
{
|
||||
SPDLOG_ERROR("Failed to load SetStartPositionList with version {}", resource->GetInitData()->ResourceVersion);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void LUS::SetStartPositionListFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource)
|
||||
{
|
||||
std::shared_ptr<SetStartPositionList> setStartPositionList = std::static_pointer_cast<SetStartPositionList>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, setStartPositionList);
|
||||
namespace SOH {
|
||||
std::shared_ptr<LUS::IResource> SetStartPositionListFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
|
||||
std::shared_ptr<LUS::BinaryReader> reader) {
|
||||
auto setStartPositionList = std::make_shared<SetStartPositionList>(initData);
|
||||
|
||||
ReadCommandId(setStartPositionList, reader);
|
||||
|
||||
setStartPositionList->numStartPositions = reader->ReadUInt32();
|
||||
setStartPositionList->startPositions.reserve(setStartPositionList->numStartPositions);
|
||||
for (uint32_t i = 0; i < setStartPositionList->numStartPositions; i++) {
|
||||
ActorEntry entry;
|
||||
ActorEntry entry;
|
||||
|
||||
entry.id = reader->ReadUInt16();
|
||||
entry.pos.x = reader->ReadInt16();
|
||||
entry.pos.y = reader->ReadInt16();
|
||||
entry.pos.z = reader->ReadInt16();
|
||||
entry.rot.x = reader->ReadInt16();
|
||||
entry.rot.y = reader->ReadInt16();
|
||||
entry.rot.z = reader->ReadInt16();
|
||||
entry.params = reader->ReadUInt16();
|
||||
entry.id = reader->ReadUInt16();
|
||||
entry.pos.x = reader->ReadInt16();
|
||||
entry.pos.y = reader->ReadInt16();
|
||||
entry.pos.z = reader->ReadInt16();
|
||||
entry.rot.x = reader->ReadInt16();
|
||||
entry.rot.y = reader->ReadInt16();
|
||||
entry.rot.z = reader->ReadInt16();
|
||||
entry.params = reader->ReadUInt16();
|
||||
|
||||
setStartPositionList->startPositions.push_back(entry);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace LUS
|
||||
return setStartPositionList;
|
||||
}
|
||||
} // namespace SOH
|
||||
|
@ -2,15 +2,10 @@
|
||||
|
||||
#include "2s2h/resource/importer/scenecommand/SceneCommandFactory.h"
|
||||
|
||||
namespace LUS {
|
||||
class SetStartPositionListFactory : public SceneCommandFactory {
|
||||
namespace SOH {
|
||||
class SetStartPositionListFactory : public SceneCommandFactoryBinaryV0 {
|
||||
public:
|
||||
std::shared_ptr<IResource>
|
||||
ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) override;
|
||||
std::shared_ptr<LUS::IResource>
|
||||
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
|
||||
};
|
||||
|
||||
class SetStartPositionListFactoryV0 : public SceneCommandVersionFactory {
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
};
|
||||
}; // namespace LUS
|
||||
} // namespace SOH
|
||||
|
@ -2,38 +2,18 @@
|
||||
#include "2s2h/resource/type/scenecommand/SetTimeSettings.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
namespace LUS {
|
||||
std::shared_ptr<IResource>
|
||||
SetTimeSettingsFactory::ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<SetTimeSettings>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<SetTimeSettingsFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load SetTimeSettings with version {}", resource->GetInitData()->ResourceVersion);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void LUS::SetTimeSettingsFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource) {
|
||||
std::shared_ptr<SetTimeSettings> setTimeSettings = std::static_pointer_cast<SetTimeSettings>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, setTimeSettings);
|
||||
namespace SOH {
|
||||
std::shared_ptr<LUS::IResource> SetTimeSettingsFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
|
||||
std::shared_ptr<LUS::BinaryReader> reader) {
|
||||
auto setTimeSettings = std::make_shared<SetTimeSettings>(initData);
|
||||
|
||||
ReadCommandId(setTimeSettings, reader);
|
||||
|
||||
|
||||
setTimeSettings->settings.hour = reader->ReadInt8();
|
||||
setTimeSettings->settings.minute = reader->ReadInt8();
|
||||
setTimeSettings->settings.timeIncrement = reader->ReadInt8();
|
||||
|
||||
return setTimeSettings;
|
||||
}
|
||||
|
||||
} // namespace LUS
|
||||
|
@ -2,15 +2,10 @@
|
||||
|
||||
#include "2s2h/resource/importer/scenecommand/SceneCommandFactory.h"
|
||||
|
||||
namespace LUS {
|
||||
class SetTimeSettingsFactory : public SceneCommandFactory {
|
||||
namespace SOH {
|
||||
class SetTimeSettingsFactory : public SceneCommandFactoryBinaryV0 {
|
||||
public:
|
||||
std::shared_ptr<IResource>
|
||||
ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) override;
|
||||
std::shared_ptr<LUS::IResource>
|
||||
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
|
||||
};
|
||||
|
||||
class SetTimeSettingsFactoryV0 : public SceneCommandVersionFactory {
|
||||
public:
|
||||
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override;
|
||||
};
|
||||
}; // namespace LUS
|
||||
} // namespace LUS
|
||||
|
@ -2,33 +2,11 @@
|
||||
#include "2s2h/resource/type/scenecommand/SetTransitionActorList.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
namespace LUS {
|
||||
std::shared_ptr<IResource> SetTransitionActorListFactory::ReadResource(std::shared_ptr<ResourceInitData> initData,
|
||||
std::shared_ptr<BinaryReader> reader) {
|
||||
auto resource = std::make_shared<SetTransitionActorList>(initData);
|
||||
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<SetTransitionActorListFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load SetTransitionActorList with version {}", resource->GetInitData()->ResourceVersion);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void LUS::SetTransitionActorListFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
|
||||
std::shared_ptr<IResource> resource) {
|
||||
std::shared_ptr<SetTransitionActorList> setTransitionActorList = std::static_pointer_cast<SetTransitionActorList>(resource);
|
||||
ResourceVersionFactory::ParseFileBinary(reader, setTransitionActorList);
|
||||
|
||||
namespace SOH {
|
||||
std::shared_ptr<LUS::IResource> SetTransitionActorListFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
|
||||
std::shared_ptr<LUS::BinaryReader> reader) {
|
||||
auto setTransitionActorList = std::make_shared<SetTransitionActorList>(initData);
|
||||
|
||||
ReadCommandId(setTransitionActorList, reader);
|
||||
|
||||
setTransitionActorList->numTransitionActors = reader->ReadUInt32();
|
||||
@ -49,6 +27,7 @@ void LUS::SetTransitionActorListFactoryV0::ParseFileBinary(std::shared_ptr<Binar
|
||||
|
||||
setTransitionActorList->transitionActorList.push_back(entry);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace LUS
|
||||
return setTransitionActorList;
|
||||
}
|
||||
} // namespace SOH
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user