Add scene command parsers

This commit is contained in:
Pepe20129 2024-04-18 17:37:56 +02:00
parent 897d3efbd0
commit c27f364df7
56 changed files with 1632 additions and 0 deletions

View File

@ -329,6 +329,7 @@ OTRGlobals::OTRGlobals() {
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); // Is room scene? maybe?
loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryXMLSceneV0>(), RESOURCE_FORMAT_XML, "Room", static_cast<uint32_t>(SOH::ResourceType::SOH_Room), 0); // Is room scene? maybe?
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::ResourceFactoryXMLCollisionHeaderV0>(), RESOURCE_FORMAT_XML, "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);

View File

@ -105,4 +105,127 @@ std::shared_ptr<LUS::IResource> ResourceFactoryBinarySceneV0::ReadResource(std::
return scene;
};
ResourceFactoryXMLSceneV0::ResourceFactoryXMLSceneV0() {
sceneCommandFactories[SceneCommandID::SetLightingSettings] = std::make_shared<SetLightingSettingsFactoryXML>();
sceneCommandFactories[SceneCommandID::SetWind] = std::make_shared<SetWindSettingsFactoryXML>();
sceneCommandFactories[SceneCommandID::SetExitList] = std::make_shared<SetExitListFactoryXML>();
sceneCommandFactories[SceneCommandID::SetTimeSettings] = std::make_shared<SetTimeSettingsFactoryXML>();
sceneCommandFactories[SceneCommandID::SetSkyboxModifier] = std::make_shared<SetSkyboxModifierFactoryXML>();
sceneCommandFactories[SceneCommandID::SetEchoSettings] = std::make_shared<SetEchoSettingsFactoryXML>();
sceneCommandFactories[SceneCommandID::SetSoundSettings] = std::make_shared<SetSoundSettingsFactoryXML>();
sceneCommandFactories[SceneCommandID::SetSkyboxSettings] = std::make_shared<SetSkyboxSettingsFactoryXML>();
sceneCommandFactories[SceneCommandID::SetRoomBehavior] = std::make_shared<SetRoomBehaviorFactoryXML>();
sceneCommandFactories[SceneCommandID::SetCsCamera] = std::make_shared<SetCsCameraFactoryXML>();
sceneCommandFactories[SceneCommandID::SetCameraSettings] = std::make_shared<SetCameraSettingsFactoryXML>();
sceneCommandFactories[SceneCommandID::SetRoomList] = std::make_shared<SetRoomListFactoryXML>();
sceneCommandFactories[SceneCommandID::SetCollisionHeader] = std::make_shared<SetCollisionHeaderFactoryXML>();
sceneCommandFactories[SceneCommandID::SetEntranceList] = std::make_shared<SetEntranceListFactoryXML>();
sceneCommandFactories[SceneCommandID::SetSpecialObjects] = std::make_shared<SetSpecialObjectsFactoryXML>();
sceneCommandFactories[SceneCommandID::SetObjectList] = std::make_shared<SetObjectListFactoryXML>();
sceneCommandFactories[SceneCommandID::SetStartPositionList] = std::make_shared<SetStartPositionListFactoryXML>();
sceneCommandFactories[SceneCommandID::SetActorList] = std::make_shared<SetActorListFactoryXML>();
sceneCommandFactories[SceneCommandID::SetTransitionActorList] = std::make_shared<SetTransitionActorListFactoryXML>();
sceneCommandFactories[SceneCommandID::EndMarker] = std::make_shared<EndMarkerFactoryXML>();
sceneCommandFactories[SceneCommandID::SetAlternateHeaders] = std::make_shared<SetAlternateHeadersFactoryXML>();
sceneCommandFactories[SceneCommandID::SetPathways] = std::make_shared<SetPathwaysFactoryXML>();
sceneCommandFactories[SceneCommandID::SetCutscenes] = std::make_shared<SetCutscenesFactoryXML>();
sceneCommandFactories[SceneCommandID::SetLightList] = std::make_shared<SetLightListFactoryXML>();
sceneCommandFactories[SceneCommandID::SetMesh] = std::make_shared<SetMeshFactoryXML>();
}
std::vector<std::string> commandNames = {
"SetStartPositionList",
"SetActorList",
"SetCsCamera",
"SetCollisionHeader",
"SetRoomList",
"SetWind",
"SetEntranceList",
"SetSpecialObjects",
"SetRoomBehavior",
"Unused09",
"SetMesh",
"SetObjectList",
"SetLightList",
"SetPathways",
"SetTransitionActorList",
"SetLightingSettings",
"SetTimeSettings",
"SetSkyboxSettings",
"SetSkyboxModifier",
"SetExitList",
"EndMarker",
"SetSoundSettings",
"SetEchoSettings",
"SetCutscenes",
"SetAlternateHeaders",
"SetCameraSettings",
};
SceneCommandID GetCommandID(std::string commandName) {
for (int i = 0; i < commandNames.size(); i++) {
if (commandNames[i] == commandName) {
return (SceneCommandID)i;
}
}
return SceneCommandID::Error;
}
void ResourceFactoryXMLSceneV0::ParseSceneCommands(std::shared_ptr<Scene> scene, std::shared_ptr<tinyxml2::XMLDocument> reader) {
auto child = reader->RootElement()->FirstChildElement();
int i = 0;
while (child != nullptr) {
scene->commands.push_back(ParseSceneCommand(scene, child, i));
child = child->NextSiblingElement();
i += 1;
}
}
std::shared_ptr<ISceneCommand> ResourceFactoryXMLSceneV0::ParseSceneCommand(std::shared_ptr<Scene> scene,
tinyxml2::XMLElement* child, uint32_t index) {
std::string commandName = child->Name();
SceneCommandID cmdID = GetCommandID(commandName);
if (cmdID == SceneCommandID::Error) {
SPDLOG_ERROR("Failed to load scene command with name {} in scene {}", commandName, scene->GetInitData()->Path);
return nullptr;
}
std::shared_ptr<ISceneCommand> result = nullptr;
auto commandFactory = ResourceFactoryXMLSceneV0::sceneCommandFactories[cmdID];
if (commandFactory != nullptr) {
auto initData = std::make_shared<LUS::ResourceInitData>();
initData->Id = scene->GetInitData()->Id;
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, child));
// Cache the resource?
}
if (result == nullptr) {
SPDLOG_ERROR("Failed to load scene command of type {} in scene {}", (uint32_t)cmdID, scene->GetInitData()->Path);
}
return result;
}
std::shared_ptr<LUS::IResource> ResourceFactoryXMLSceneV0::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<tinyxml2::XMLDocument>>(file->Reader);
ParseSceneCommands(scene, reader);
return scene;
};
} // namespace SOH

View File

@ -5,6 +5,7 @@
#include "soh/resource/importer/scenecommand/SceneCommandFactory.h"
#include "Resource.h"
#include "ResourceFactoryBinary.h"
#include "ResourceFactoryXML.h"
namespace SOH {
class ResourceFactoryBinarySceneV0 : public LUS::ResourceFactoryBinary {
@ -22,4 +23,20 @@ class ResourceFactoryBinarySceneV0 : public LUS::ResourceFactoryBinary {
protected:
std::shared_ptr<ISceneCommand> ParseSceneCommand(std::shared_ptr<Scene> scene, std::shared_ptr<LUS::BinaryReader> reader, uint32_t index);
};
class ResourceFactoryXMLSceneV0 : public LUS::ResourceFactoryXML {
public:
ResourceFactoryXMLSceneV0();
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override;
void ParseSceneCommands(std::shared_ptr<Scene> scene, std::shared_ptr<tinyxml2::XMLDocument> 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<SceneCommandFactoryXMLV0>> sceneCommandFactories;
protected:
std::shared_ptr<ISceneCommand> ParseSceneCommand(std::shared_ptr<Scene> scene, tinyxml2::XMLElement* child, uint32_t index);
};
} // namespace SOH

View File

@ -9,6 +9,30 @@ EndMarkerFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
ReadCommandId(endMarker, reader);
//LogEndMarkerAsXML(endMarker);
return endMarker;
}
std::shared_ptr<LUS::IResource> EndMarkerFactoryXML::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
tinyxml2::XMLElement* reader) {
auto endMarker = std::make_shared<EndMarker>(initData);
endMarker->cmdId = SceneCommandID::EndMarker;
return endMarker;
}
void LogEndMarkerAsXML(std::shared_ptr<LUS::IResource> resource) {
std::shared_ptr<EndMarker> endMarker = std::static_pointer_cast<EndMarker>(resource);
tinyxml2::XMLDocument doc;
tinyxml2::XMLElement* root = doc.NewElement("EndMarker");
doc.InsertFirstChild(root);
tinyxml2::XMLPrinter printer;
doc.Accept(&printer);
SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr());
}
} // namespace SOH

View File

@ -7,4 +7,12 @@ class EndMarkerFactory : public SceneCommandFactoryBinaryV0 {
public:
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
};
class EndMarkerFactoryXML : public SceneCommandFactoryXMLV0 {
public:
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, tinyxml2::XMLElement* reader) override;
};
void LogEndMarkerAsXML(std::shared_ptr<LUS::IResource> resource);
} // namespace SOH

View File

@ -13,4 +13,12 @@ class SceneCommandFactoryBinaryV0 {
protected:
void ReadCommandId(std::shared_ptr<ISceneCommand> command, std::shared_ptr<LUS::BinaryReader> reader);
};
class SceneCommandFactoryXMLV0 {
public:
virtual std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, tinyxml2::XMLElement* reader) = 0;
protected:
void ReadCommandId(std::shared_ptr<ISceneCommand> command, tinyxml2::XMLElement* reader);
};
} // namespace SOH

View File

@ -26,6 +26,65 @@ SetActorListFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initDat
setActorList->actorList.push_back(entry);
}
//LogActorListAsXML(setActorList);
return setActorList;
}
std::shared_ptr<LUS::IResource> SetActorListFactoryXML::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
tinyxml2::XMLElement* reader) {
auto setActorList = std::make_shared<SetActorList>(initData);
setActorList->cmdId = SceneCommandID::SetActorList;
auto child = reader->FirstChildElement();
while (child != nullptr) {
std::string childName = child->Name();
if (childName == "ActorEntry") {
ActorEntry entry;
entry.id = child->IntAttribute("Id");
entry.pos.x = child->IntAttribute("PosX");
entry.pos.y = child->IntAttribute("PosY");
entry.pos.z = child->IntAttribute("PosZ");
entry.rot.x = child->IntAttribute("RotX");
entry.rot.y = child->IntAttribute("RotY");
entry.rot.z = child->IntAttribute("RotZ");
entry.params = child->IntAttribute("Params");
setActorList->actorList.push_back(entry);
}
child = child->NextSiblingElement();
}
setActorList->numActors = setActorList->actorList.size();
return setActorList;
}
void LogActorListAsXML(std::shared_ptr<LUS::IResource> resource) {
std::shared_ptr<SetActorList> setActorList = std::static_pointer_cast<SetActorList>(resource);
tinyxml2::XMLDocument doc;
tinyxml2::XMLElement* root = doc.NewElement("SetActorList");
doc.InsertFirstChild(root);
for (size_t i = 0; i < setActorList->numActors; i++) {
tinyxml2::XMLElement* entry = doc.NewElement("ActorEntry");
entry->SetAttribute("Id", setActorList->actorList[i].id);
entry->SetAttribute("PosX", setActorList->actorList[i].pos.x);
entry->SetAttribute("PosY", setActorList->actorList[i].pos.y);
entry->SetAttribute("PosZ", setActorList->actorList[i].pos.z);
entry->SetAttribute("RotX", setActorList->actorList[i].rot.x);
entry->SetAttribute("RotY", setActorList->actorList[i].rot.y);
entry->SetAttribute("RotZ", setActorList->actorList[i].rot.z);
entry->SetAttribute("Params", setActorList->actorList[i].params);
root->InsertEndChild(entry);
}
tinyxml2::XMLPrinter printer;
doc.Accept(&printer);
SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr());
}
} // namespace SOH

View File

@ -8,4 +8,12 @@ class SetActorListFactory : public SceneCommandFactoryBinaryV0 {
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
};
class SetActorListFactoryXML : public SceneCommandFactoryXMLV0 {
public:
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, tinyxml2::XMLElement* reader) override;
};
void LogActorListAsXML(std::shared_ptr<LUS::IResource> resource);
} // namespace SOH

View File

@ -21,6 +21,50 @@ std::shared_ptr<LUS::IResource> SetAlternateHeadersFactory::ReadResource(std::sh
}
}
//LogAlternateHeadersAsXML(setAlternateHeaders);
return setAlternateHeaders;
}
std::shared_ptr<LUS::IResource> SetAlternateHeadersFactoryXML::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
tinyxml2::XMLElement* reader) {
auto setAlternateHeaders = std::make_shared<SetAlternateHeaders>(initData);
setAlternateHeaders->cmdId = SceneCommandID::SetAlternateHeaders;
auto child = reader->FirstChildElement();
while (child != nullptr) {
std::string childName = child->Name();
if (childName == "AlternateHeader") {
for (uint32_t i = 0; i < setAlternateHeaders->numHeaders; i++) {
auto headerName = std::string(child->Attribute("HeaderName"));
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);
}
}
}
child = child->NextSiblingElement();
}
setAlternateHeaders->numHeaders = setAlternateHeaders->headers.size();
return setAlternateHeaders;
}
void LogAlternateHeadersAsXML(std::shared_ptr<LUS::IResource> resource) {
std::shared_ptr<SetAlternateHeaders> setAlternateHeaders = std::static_pointer_cast<SetAlternateHeaders>(resource);
tinyxml2::XMLDocument doc;
tinyxml2::XMLElement* root = doc.NewElement("SetAlternateHeaders");
doc.InsertFirstChild(root);
tinyxml2::XMLPrinter printer;
doc.Accept(&printer);
SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr());
}
} // namespace SOH

View File

@ -8,4 +8,10 @@ class SetAlternateHeadersFactory : public SceneCommandFactoryBinaryV0 {
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
};
class SetAlternateHeadersFactoryXML : public SceneCommandFactoryXMLV0 {
public:
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, tinyxml2::XMLElement* reader) override;
};
} // namespace SOH

View File

@ -12,6 +12,36 @@ std::shared_ptr<LUS::IResource> SetCameraSettingsFactory::ReadResource(std::shar
setCameraSettings->settings.cameraMovement = reader->ReadInt8();
setCameraSettings->settings.worldMapArea = reader->ReadInt32();
//LogCameraSettingsAsXML(setCameraSettings);
return setCameraSettings;
}
std::shared_ptr<LUS::IResource> SetCameraSettingsFactoryXML::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
tinyxml2::XMLElement* reader) {
auto setCameraSettings = std::make_shared<SetCameraSettings>(initData);
setCameraSettings->cmdId = SceneCommandID::SetCameraSettings;
setCameraSettings->settings.cameraMovement = reader->IntAttribute("CameraMovement");
setCameraSettings->settings.worldMapArea = reader->IntAttribute("WorldMapArea");
return setCameraSettings;
}
void LogCameraSettingsAsXML(std::shared_ptr<LUS::IResource> resource) {
std::shared_ptr<SetCameraSettings> setCameraSettings = std::static_pointer_cast<SetCameraSettings>(resource);
tinyxml2::XMLDocument doc;
tinyxml2::XMLElement* root = doc.NewElement("SetCameraSettings");
doc.InsertFirstChild(root);
root->SetAttribute("CameraMovement", setCameraSettings->settings.cameraMovement);
root->SetAttribute("WorldMapArea", setCameraSettings->settings.worldMapArea);
tinyxml2::XMLPrinter printer;
doc.Accept(&printer);
SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr());
}
} // namespace SOH

View File

@ -8,4 +8,12 @@ class SetCameraSettingsFactory : public SceneCommandFactoryBinaryV0 {
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
};
class SetCameraSettingsFactoryXML : public SceneCommandFactoryXMLV0 {
public:
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, tinyxml2::XMLElement* reader) override;
};
void LogCameraSettingsAsXML(std::shared_ptr<LUS::IResource> resource);
} // namespace SOH

View File

@ -13,6 +13,35 @@ std::shared_ptr<LUS::IResource> SetCollisionHeaderFactory::ReadResource(std::sha
setCollisionHeader->fileName = reader->ReadString();
setCollisionHeader->collisionHeader = std::static_pointer_cast<CollisionHeader>(LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(setCollisionHeader->fileName.c_str()));
//LogSetCollisionHeaderAsXML(setCollisionHeader);
return setCollisionHeader;
}
std::shared_ptr<LUS::IResource> SetCollisionHeaderFactoryXML::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
tinyxml2::XMLElement* reader) {
auto setCollisionHeader = std::make_shared<SetCollisionHeader>(initData);
setCollisionHeader->cmdId = SceneCommandID::SetCollisionHeader;
setCollisionHeader->fileName = reader->Attribute("FileName");
setCollisionHeader->collisionHeader = std::static_pointer_cast<CollisionHeader>(LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(setCollisionHeader->fileName.c_str()));
return setCollisionHeader;
}
void LogSetCollisionHeaderAsXML(std::shared_ptr<LUS::IResource> resource) {
std::shared_ptr<SetCollisionHeader> setCollisionHeader = std::static_pointer_cast<SetCollisionHeader>(resource);
tinyxml2::XMLDocument doc;
tinyxml2::XMLElement* root = doc.NewElement("SetCollisionHeader");
doc.InsertFirstChild(root);
root->SetAttribute("FileName", setCollisionHeader->fileName.c_str());
tinyxml2::XMLPrinter printer;
doc.Accept(&printer);
SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr());
}
} // namespace SOH

View File

@ -8,4 +8,12 @@ class SetCollisionHeaderFactory : public SceneCommandFactoryBinaryV0 {
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
};
class SetCollisionHeaderFactoryXML : public SceneCommandFactoryXMLV0 {
public:
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, tinyxml2::XMLElement* reader) override;
};
void LogSetCollisionHeaderAsXML(std::shared_ptr<LUS::IResource> resource);
} // namespace SOH

View File

@ -14,6 +14,30 @@ SetCsCameraFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData
// OTRTODO: FINISH!
//LogCsCameraAsXML(setCsCamera);
return setCsCamera;
}
std::shared_ptr<LUS::IResource> SetCsCameraFactoryXML::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
tinyxml2::XMLElement* reader) {
auto setCsCamera = std::make_shared<SetCsCamera>(initData);
setCsCamera->cmdId = SceneCommandID::SetCsCamera;
return setCsCamera;
}
void LogCsCameraAsXML(std::shared_ptr<LUS::IResource> resource) {
std::shared_ptr<SetCsCamera> setCsCamera = std::static_pointer_cast<SetCsCamera>(resource);
tinyxml2::XMLDocument doc;
tinyxml2::XMLElement* root = doc.NewElement("SetCsCamera");
doc.InsertFirstChild(root);
tinyxml2::XMLPrinter printer;
doc.Accept(&printer);
SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr());
}
} // namespace SOH

View File

@ -8,4 +8,12 @@ class SetCsCameraFactory : public SceneCommandFactoryBinaryV0 {
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
};
class SetCsCameraFactoryXML : public SceneCommandFactoryXMLV0 {
public:
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, tinyxml2::XMLElement* reader) override;
};
void LogCsCameraAsXML(std::shared_ptr<LUS::IResource> resource);
} // namespace SOH

View File

@ -13,6 +13,35 @@ SetCutscenesFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initDat
setCutscenes->fileName = reader->ReadString();
setCutscenes->cutscene = std::static_pointer_cast<Cutscene>(LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(setCutscenes->fileName.c_str()));
//LogCutscenesAsXML(setCutscenes);
return setCutscenes;
}
std::shared_ptr<LUS::IResource> SetCutscenesFactoryXML::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
tinyxml2::XMLElement* reader) {
auto setCutscenes = std::make_shared<SetCutscenes>(initData);
setCutscenes->cmdId = SceneCommandID::SetCutscenes;
setCutscenes->fileName = reader->Attribute("FileName");
setCutscenes->cutscene = std::static_pointer_cast<Cutscene>(LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(setCutscenes->fileName.c_str()));
return setCutscenes;
}
void LogCutscenesAsXML(std::shared_ptr<LUS::IResource> resource) {
std::shared_ptr<SetCutscenes> setCutscenes = std::static_pointer_cast<SetCutscenes>(resource);
tinyxml2::XMLDocument doc;
tinyxml2::XMLElement* root = doc.NewElement("SetCutscenes");
doc.InsertFirstChild(root);
root->SetAttribute("FileName", setCutscenes->fileName.c_str());
tinyxml2::XMLPrinter printer;
doc.Accept(&printer);
SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr());
}
} // namespace SOH

View File

@ -8,4 +8,12 @@ class SetCutscenesFactory : public SceneCommandFactoryBinaryV0 {
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
};
class SetCutscenesFactoryXML : public SceneCommandFactoryXMLV0 {
public:
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, tinyxml2::XMLElement* reader) override;
};
void LogCutscenesAsXML(std::shared_ptr<LUS::IResource> resource);
} // namespace SOH

View File

@ -11,6 +11,34 @@ SetEchoSettingsFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> init
setEchoSettings->settings.echo = reader->ReadInt8();
//LogEchoSettingsAsXML(setEchoSettings);
return setEchoSettings;
}
std::shared_ptr<LUS::IResource> SetEchoSettingsFactoryXML::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
tinyxml2::XMLElement* reader) {
auto setEchoSettings = std::make_shared<SetEchoSettings>(initData);
setEchoSettings->cmdId = SceneCommandID::SetEchoSettings;
setEchoSettings->settings.echo = reader->IntAttribute("Echo");
return setEchoSettings;
}
void LogEchoSettingsAsXML(std::shared_ptr<LUS::IResource> resource) {
std::shared_ptr<SetEchoSettings> setEchoSettings = std::static_pointer_cast<SetEchoSettings>(resource);
tinyxml2::XMLDocument doc;
tinyxml2::XMLElement* root = doc.NewElement("SetEchoSettings");
doc.InsertFirstChild(root);
root->SetAttribute("Echo", setEchoSettings->settings.echo);
tinyxml2::XMLPrinter printer;
doc.Accept(&printer);
SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr());
}
} // namespace SOH

View File

@ -8,4 +8,12 @@ class SetEchoSettingsFactory : public SceneCommandFactoryBinaryV0 {
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
};
class SetEchoSettingsFactoryXML : public SceneCommandFactoryXMLV0 {
public:
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, tinyxml2::XMLElement* reader) override;
};
void LogEchoSettingsAsXML(std::shared_ptr<LUS::IResource> resource);
} // namespace SOH

View File

@ -20,6 +20,53 @@ SetEntranceListFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> init
setEntranceList->entrances.push_back(entranceEntry);
}
//LogEntranceListAsXML(setEntranceList);
return setEntranceList;
}
std::shared_ptr<LUS::IResource> SetEntranceListFactoryXML::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
tinyxml2::XMLElement* reader) {
auto setEntranceList = std::make_shared<SetEntranceList>(initData);
setEntranceList->cmdId = SceneCommandID::SetEntranceList;
auto child = reader->FirstChildElement();
while (child != nullptr) {
std::string childName = child->Name();
if (childName == "EntranceEntry") {
EntranceEntry entry;
entry.spawn = child->IntAttribute("Spawn");
entry.room = child->IntAttribute("Room");
setEntranceList->entrances.push_back(entry);
}
child = child->NextSiblingElement();
}
setEntranceList->numEntrances = setEntranceList->entrances.size();
return setEntranceList;
}
void LogEntranceListAsXML(std::shared_ptr<LUS::IResource> resource) {
std::shared_ptr<SetEntranceList> setEntranceList = std::static_pointer_cast<SetEntranceList>(resource);
tinyxml2::XMLDocument doc;
tinyxml2::XMLElement* root = doc.NewElement("SetEntranceList");
doc.InsertFirstChild(root);
for (size_t i = 0; i < setEntranceList->numEntrances; i++) {
tinyxml2::XMLElement* entry = doc.NewElement("EntranceEntry");
entry->SetAttribute("Spawn", setEntranceList->entrances[i].spawn);
entry->SetAttribute("Room", setEntranceList->entrances[i].room);
root->InsertEndChild(entry);
}
tinyxml2::XMLPrinter printer;
doc.Accept(&printer);
SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr());
}
} // namespace SOH

View File

@ -8,4 +8,12 @@ class SetEntranceListFactory : public SceneCommandFactoryBinaryV0 {
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
};
class SetEntranceListFactoryXML : public SceneCommandFactoryXMLV0 {
public:
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, tinyxml2::XMLElement* reader) override;
};
void LogEntranceListAsXML(std::shared_ptr<LUS::IResource> resource);
} // namespace SOH

View File

@ -15,6 +15,49 @@ SetExitListFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData
setExitList->exits.push_back(reader->ReadUInt16());
}
//LogExitListAsXML(setExitList);
return setExitList;
}
std::shared_ptr<LUS::IResource> SetExitListFactoryXML::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
tinyxml2::XMLElement* reader) {
auto setExitList = std::make_shared<SetExitList>(initData);
setExitList->cmdId = SceneCommandID::SetExitList;
auto child = reader->FirstChildElement();
while (child != nullptr) {
std::string childName = child->Name();
if (childName == "ExitEntry") {
setExitList->exits.push_back(child->IntAttribute("Id"));
}
child = child->NextSiblingElement();
}
setExitList->numExits = setExitList->exits.size();
return setExitList;
}
void LogExitListAsXML(std::shared_ptr<LUS::IResource> resource) {
std::shared_ptr<SetExitList> setExitList = std::static_pointer_cast<SetExitList>(resource);
tinyxml2::XMLDocument doc;
tinyxml2::XMLElement* root = doc.NewElement("SetExitList");
doc.InsertFirstChild(root);
for (size_t i = 0; i < setExitList->numExits; i++) {
tinyxml2::XMLElement* entry = doc.NewElement("ExitEntry");
entry->SetAttribute("Id", setExitList->exits[i]);
root->InsertEndChild(entry);
}
tinyxml2::XMLPrinter printer;
doc.Accept(&printer);
SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr());
}
} // namespace SOH

View File

@ -8,4 +8,12 @@ class SetExitListFactory : public SceneCommandFactoryBinaryV0 {
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
};
class SetExitListFactoryXML : public SceneCommandFactoryXMLV0 {
public:
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, tinyxml2::XMLElement* reader) override;
};
void LogExitListAsXML(std::shared_ptr<LUS::IResource> resource);
} // namespace SOH

View File

@ -30,6 +30,85 @@ SetLightListFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initDat
setLightList->lightList.push_back(light);
}
//LogLightListAsXML(setLightList);
return setLightList;
}
std::shared_ptr<LUS::IResource> SetLightListFactoryXML::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
tinyxml2::XMLElement* reader) {
auto setLightList = std::make_shared<SetLightList>(initData);
setLightList->cmdId = SceneCommandID::SetLightList;
auto child = reader->FirstChildElement();
while (child != nullptr) {
std::string childName = child->Name();
if (childName == "LightInfo") {
LightInfo light;
light.type = child->IntAttribute("Type");
if (false/*light.type == LIGHT_DIRECTIONAL*/) {
light.params.dir.x = child->IntAttribute("X");
light.params.dir.y = child->IntAttribute("Y");
light.params.dir.z = child->IntAttribute("Z");
light.params.dir.color[0] = child->IntAttribute("ColorR");
light.params.dir.color[1] = child->IntAttribute("ColorG");
light.params.dir.color[2] = child->IntAttribute("ColorB");
} else {
light.params.point.x = child->IntAttribute("X");
light.params.point.y = child->IntAttribute("Y");
light.params.point.z = child->IntAttribute("Z");
light.params.point.color[0] = child->IntAttribute("ColorR");
light.params.point.color[1] = child->IntAttribute("ColorG");
light.params.point.color[2] = child->IntAttribute("ColorB");
light.params.point.drawGlow = child->IntAttribute("DrawGlow");
light.params.point.radius = child->IntAttribute("Radius");
}
setLightList->lightList.push_back(light);
}
child = child->NextSiblingElement();
}
setLightList->numLights = setLightList->lightList.size();
return setLightList;
}
void LogLightListAsXML(std::shared_ptr<LUS::IResource> resource) {
std::shared_ptr<SetLightList> setLightList = std::static_pointer_cast<SetLightList>(resource);
tinyxml2::XMLDocument doc;
tinyxml2::XMLElement* root = doc.NewElement("SetLightList");
doc.InsertFirstChild(root);
for (size_t i = 0; i < setLightList->numLights; i++) {
tinyxml2::XMLElement* light = doc.NewElement("LightInfo");
light->SetAttribute("Type", setLightList->lightList[i].type);
if (false/*setLightList->lightList[i].type == LIGHT_DIRECTIONAL*/) {
light->SetAttribute("X", setLightList->lightList[i].params.dir.x);
light->SetAttribute("Y", setLightList->lightList[i].params.dir.y);
light->SetAttribute("Z", setLightList->lightList[i].params.dir.z);
light->SetAttribute("ColorR", setLightList->lightList[i].params.dir.color[0]);
light->SetAttribute("ColorG", setLightList->lightList[i].params.dir.color[1]);
light->SetAttribute("ColorB", setLightList->lightList[i].params.dir.color[2]);
} else {
light->SetAttribute("X", setLightList->lightList[i].params.point.x);
light->SetAttribute("Y", setLightList->lightList[i].params.point.y);
light->SetAttribute("Z", setLightList->lightList[i].params.point.z);
light->SetAttribute("ColorR", setLightList->lightList[i].params.point.color[0]);
light->SetAttribute("ColorG", setLightList->lightList[i].params.point.color[1]);
light->SetAttribute("ColorB", setLightList->lightList[i].params.point.color[2]);
light->SetAttribute("DrawGlow", setLightList->lightList[i].params.point.drawGlow);
light->SetAttribute("Radius", setLightList->lightList[i].params.point.radius);
}
root->InsertEndChild(light);
}
tinyxml2::XMLPrinter printer;
doc.Accept(&printer);
SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr());
}
} // namespace SOH

View File

@ -8,4 +8,12 @@ class SetLightListFactory : public SceneCommandFactoryBinaryV0 {
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
};
class SetLightListFactoryXML : public SceneCommandFactoryXMLV0 {
public:
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, tinyxml2::XMLElement* reader) override;
};
void LogLightListAsXML(std::shared_ptr<LUS::IResource> resource);
} // namespace SOH

View File

@ -43,6 +43,94 @@ std::shared_ptr<LUS::IResource> SetLightingSettingsFactory::ReadResource(std::sh
setLightingSettings->settings.push_back(lightSettings);
}
//LogLightingSettingsAsXML(setLightingSettings);
return setLightingSettings;
}
std::shared_ptr<LUS::IResource> SetLightingSettingsFactoryXML::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
tinyxml2::XMLElement* reader) {
auto setLightingSettings = std::make_shared<SetLightingSettings>(initData);
setLightingSettings->cmdId = SceneCommandID::SetLightingSettings;
auto child = reader->FirstChildElement();
while (child != nullptr) {
std::string childName = child->Name();
if (childName == "LightingSetting") {
EnvLightSettings lightSettings;
lightSettings.ambientColor[0] = child->IntAttribute("AmbientColorR");
lightSettings.ambientColor[1] = child->IntAttribute("AmbientColorG");
lightSettings.ambientColor[2] = child->IntAttribute("AmbientColorB");
lightSettings.light1Dir[0] = child->IntAttribute("Light1DirX");
lightSettings.light1Dir[1] = child->IntAttribute("Light1DirY");
lightSettings.light1Dir[2] = child->IntAttribute("Light1DirZ");
lightSettings.light1Color[0] = child->IntAttribute("Light1ColorR");
lightSettings.light1Color[1] = child->IntAttribute("Light1ColorG");
lightSettings.light1Color[2] = child->IntAttribute("Light1ColorB");
lightSettings.light2Dir[0] = child->IntAttribute("Light2DirX");
lightSettings.light2Dir[1] = child->IntAttribute("Light2DirY");
lightSettings.light2Dir[2] = child->IntAttribute("Light2DirZ");
lightSettings.light2Color[0] = child->IntAttribute("Light2ColorR");
lightSettings.light2Color[1] = child->IntAttribute("Light2ColorG");
lightSettings.light2Color[2] = child->IntAttribute("Light2ColorB");
lightSettings.fogColor[0] = child->IntAttribute("FogColorR");
lightSettings.fogColor[1] = child->IntAttribute("FogColorG");
lightSettings.fogColor[2] = child->IntAttribute("FogColorB");
lightSettings.fogNear = child->IntAttribute("FogNear");
lightSettings.fogFar = child->IntAttribute("FogFar");
setLightingSettings->settings.push_back(lightSettings);
}
child = child->NextSiblingElement();
}
return setLightingSettings;
}
void LogLightingSettingsAsXML(std::shared_ptr<LUS::IResource> resource) {
std::shared_ptr<SetLightingSettings> setLightingSettings = std::static_pointer_cast<SetLightingSettings>(resource);
tinyxml2::XMLDocument doc;
tinyxml2::XMLElement* root = doc.NewElement("SetLightingSettings");
doc.InsertFirstChild(root);
for (size_t i = 0; i < setLightingSettings->settings.size(); i++) {
tinyxml2::XMLElement* entry = doc.NewElement("LightingSetting");
entry->SetAttribute("AmbientColorR", setLightingSettings->settings[i].ambientColor[0]);
entry->SetAttribute("AmbientColorG", setLightingSettings->settings[i].ambientColor[1]);
entry->SetAttribute("AmbientColorB", setLightingSettings->settings[i].ambientColor[2]);
entry->SetAttribute("Light1DirX", setLightingSettings->settings[i].light1Dir[0]);
entry->SetAttribute("Light1DirY", setLightingSettings->settings[i].light1Dir[1]);
entry->SetAttribute("Light1DirZ", setLightingSettings->settings[i].light1Dir[2]);
entry->SetAttribute("Light1ColorR", setLightingSettings->settings[i].light1Color[0]);
entry->SetAttribute("Light1ColorG", setLightingSettings->settings[i].light1Color[1]);
entry->SetAttribute("Light1ColorB", setLightingSettings->settings[i].light1Color[2]);
entry->SetAttribute("Light2DirX", setLightingSettings->settings[i].light2Dir[0]);
entry->SetAttribute("Light2DirY", setLightingSettings->settings[i].light2Dir[1]);
entry->SetAttribute("Light2DirZ", setLightingSettings->settings[i].light2Dir[2]);
entry->SetAttribute("Light2ColorR", setLightingSettings->settings[i].light2Color[0]);
entry->SetAttribute("Light2ColorG", setLightingSettings->settings[i].light2Color[1]);
entry->SetAttribute("Light2ColorB", setLightingSettings->settings[i].light2Color[2]);
entry->SetAttribute("FogColorR", setLightingSettings->settings[i].fogColor[0]);
entry->SetAttribute("FogColorG", setLightingSettings->settings[i].fogColor[1]);
entry->SetAttribute("FogColorB", setLightingSettings->settings[i].fogColor[2]);
entry->SetAttribute("FogNear", setLightingSettings->settings[i].fogNear);
entry->SetAttribute("FogFar", setLightingSettings->settings[i].fogFar);
root->InsertEndChild(entry);
}
tinyxml2::XMLPrinter printer;
doc.Accept(&printer);
SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr());
}
} // namespace SOH

View File

@ -8,4 +8,12 @@ class SetLightingSettingsFactory : public SceneCommandFactoryBinaryV0 {
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
};
class SetLightingSettingsFactoryXML : public SceneCommandFactoryXMLV0 {
public:
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, tinyxml2::XMLElement* reader) override;
};
void LogLightingSettingsAsXML(std::shared_ptr<LUS::IResource> resource);
} // namespace SOH

View File

@ -45,6 +45,8 @@ SetMeshFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, st
dlist.opa = meshOpa != "" ? (Gfx*)(opaRes ? opaRes->GetRawPointer() : nullptr) : 0;
dlist.xlu = meshXlu != "" ? (Gfx*)(xluRes ? xluRes->GetRawPointer() : nullptr) : 0;
setMesh->opaPaths.push_back(meshOpa);
setMesh->xluPaths.push_back(meshXlu);
setMesh->dlists.push_back(dlist);
} else if (setMesh->meshHeader.base.type == 1) {
PolygonDlist pType;
@ -106,6 +108,8 @@ SetMeshFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, st
pType.opa = meshOpa != "" ? (Gfx*)(opaRes ? opaRes->GetRawPointer() : nullptr) : 0;
pType.xlu = meshXlu != "" ? (Gfx*)(xluRes ? xluRes->GetRawPointer() : nullptr) : 0;
setMesh->opaPaths.push_back(meshOpa);
setMesh->xluPaths.push_back(meshXlu);
setMesh->dlists.push_back(pType);
} else if (setMesh->meshHeader.base.type == 2) {
PolygonDlist2 dlist;
@ -124,6 +128,8 @@ SetMeshFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, st
dlist.opa = (Gfx*)(opaRes ? opaRes->GetRawPointer() : nullptr);
dlist.xlu = (Gfx*)(xluRes ? xluRes->GetRawPointer() : nullptr);
setMesh->opaPaths.push_back(meshOpa);
setMesh->xluPaths.push_back(meshXlu);
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);
@ -141,6 +147,274 @@ SetMeshFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, st
SPDLOG_ERROR("Tried to load mesh in SetMesh scene header with type that doesn't exist: {}", setMesh->meshHeader.base.type);
}
//LogMeshAsXML(setMesh);
return setMesh;
}
std::shared_ptr<LUS::IResource> SetMeshFactoryXML::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
tinyxml2::XMLElement* reader) {
auto setMesh = std::make_shared<SetMesh>(initData);
setMesh->cmdId = SceneCommandID::SetMesh;
setMesh->data = reader->IntAttribute("Data");
setMesh->meshHeader.base.type = reader->IntAttribute("MeshHeaderType");
int32_t polyNum = 1;
if (setMesh->meshHeader.base.type != 1) {
polyNum = reader->IntAttribute("PolyNum");
if (setMesh->meshHeader.base.type == 0) {
setMesh->meshHeader.polygon0.num = polyNum;
} 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);
}
}
if (setMesh->meshHeader.base.type == 2) {
setMesh->dlists2.reserve(polyNum);
} else {
setMesh->dlists.reserve(setMesh->meshHeader.polygon0.num);
}
auto child = reader->FirstChildElement();
while (child != nullptr) {
std::string childName = child->Name();
if (childName != "Polygon") {
child = child->NextSiblingElement();
continue;
}
if (setMesh->meshHeader.base.type == 0) {
PolygonDlist dlist;
int32_t polyType = child->IntAttribute("PolyType"); // Unused
std::string meshOpa = child->Attribute("MeshOpa");
std::string meshXlu = child->Attribute("MeshXlu");
auto opaRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshOpa.c_str());
auto xluRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshXlu.c_str());
dlist.opa = meshOpa != "" ? (Gfx*)(opaRes ? opaRes->GetRawPointer() : nullptr) : 0;
dlist.xlu = meshXlu != "" ? (Gfx*)(xluRes ? xluRes->GetRawPointer() : nullptr) : 0;
setMesh->opaPaths.push_back(meshOpa);
setMesh->xluPaths.push_back(meshXlu);
setMesh->dlists.push_back(dlist);
} else if (setMesh->meshHeader.base.type == 1) {
PolygonDlist pType;
setMesh->meshHeader.polygon1.format = child->IntAttribute("Format");
std::string imgOpa = child->Attribute("ImgOpa");
std::string imgXlu = child->Attribute("ImgXlu");
auto opaRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(imgOpa.c_str());
auto xluRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(imgXlu.c_str());
pType.opa = imgOpa != "" ? (Gfx*)(opaRes ? opaRes->GetRawPointer() : nullptr) : 0;
pType.xlu = imgXlu != "" ? (Gfx*)(xluRes ? xluRes->GetRawPointer() : nullptr) : 0;
int32_t bgImageCount = child->IntAttribute("BgImageCount");
setMesh->images.reserve(bgImageCount);
auto grandChild = child->FirstChildElement();
while (grandChild != nullptr) {
std::string grandChildName = grandChild->Name();
if (grandChildName != "BgImage") {
grandChild = grandChild->NextSiblingElement();
continue;
}
BgImage image;
image.unk_00 = grandChild->IntAttribute("Unknown_00");
image.id = grandChild->IntAttribute("Id");
std::string imagePath = "__OTR__" + std::string(grandChild->Attribute("ImagePath"));
setMesh->imagePaths.push_back(imagePath);
image.source = (void*)setMesh->imagePaths.back().c_str();
image.unk_0C = grandChild->IntAttribute("Unknown_0C");
image.tlut = grandChild->IntAttribute("TLUT");
image.width = grandChild->IntAttribute("Width");
image.height = grandChild->IntAttribute("Height");
image.fmt = grandChild->IntAttribute("Fmt");
image.siz = grandChild->IntAttribute("Siz");
image.mode0 = grandChild->IntAttribute("Mode0");
image.tlutCount = grandChild->IntAttribute("TLUTCount");
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.width = image.width;
setMesh->meshHeader.polygon1.single.height = image.height;
setMesh->meshHeader.polygon1.single.fmt = image.fmt;
setMesh->meshHeader.polygon1.single.siz = image.siz;
setMesh->meshHeader.polygon1.single.mode0 = image.mode0;
setMesh->meshHeader.polygon1.single.tlutCount = image.tlutCount;
} else {
setMesh->images.push_back(image);
}
grandChild = grandChild->NextSiblingElement();
}
if (setMesh->meshHeader.polygon1.format != 1) {
setMesh->meshHeader.polygon1.multi.count = bgImageCount;
}
int32_t polyType = child->IntAttribute("PolyType"); // Unused??
std::string meshOpa = child->Attribute("MeshOpa");
std::string meshXlu = child->Attribute("MeshXlu");
opaRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshOpa.c_str());
xluRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshXlu.c_str());
pType.opa = meshOpa != "" ? (Gfx*)(opaRes ? opaRes->GetRawPointer() : nullptr) : 0;
pType.xlu = meshXlu != "" ? (Gfx*)(xluRes ? xluRes->GetRawPointer() : nullptr) : 0;
setMesh->opaPaths.push_back(meshOpa);
setMesh->xluPaths.push_back(meshXlu);
setMesh->dlists.push_back(pType);
} else if (setMesh->meshHeader.base.type == 2) {
PolygonDlist2 dlist;
int32_t polyType = child->IntAttribute("PolyType"); // Unused
dlist.pos.x = child->IntAttribute("PosX");
dlist.pos.y = child->IntAttribute("PosY");
dlist.pos.z = child->IntAttribute("PosZ");
dlist.unk_06 = child->IntAttribute("Unknown");
std::string meshOpa = child->Attribute("MeshOpa");
std::string meshXlu = child->Attribute("MeshXlu");
auto opaRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshOpa.c_str());
auto xluRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshXlu.c_str());
dlist.opa = meshOpa != "" ? (Gfx*)(opaRes ? opaRes->GetRawPointer() : nullptr) : 0;
dlist.xlu = meshXlu != "" ? (Gfx*)(xluRes ? xluRes->GetRawPointer() : nullptr) : 0;
setMesh->opaPaths.push_back(meshOpa);
setMesh->xluPaths.push_back(meshXlu);
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);
}
child = child->NextSiblingElement();
}
if (setMesh->meshHeader.base.type == 2) {
setMesh->meshHeader.polygon2.start = setMesh->dlists2.data();
} else if (setMesh->meshHeader.base.type == 0) {
setMesh->meshHeader.polygon0.start = setMesh->dlists.data();
} else if (setMesh->meshHeader.base.type == 1) {
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);
}
return setMesh;
}
void LogMeshAsXML(std::shared_ptr<LUS::IResource> resource) {
std::shared_ptr<SetMesh> setMesh = std::static_pointer_cast<SetMesh>(resource);
tinyxml2::XMLDocument doc;
tinyxml2::XMLElement* root = doc.NewElement("SetMesh");
doc.InsertFirstChild(root);
root->SetAttribute("Data", setMesh->data);
root->SetAttribute("MeshHeaderType", setMesh->meshHeader.base.type);
if (setMesh->meshHeader.base.type == 0) {
root->SetAttribute("PolyNum", setMesh->meshHeader.polygon0.num);
PolygonDlist* dlist = (PolygonDlist*)setMesh->meshHeader.polygon0.start;
for (int i = 0; i < setMesh->meshHeader.polygon0.num; i += 1) {
tinyxml2::XMLElement* polygon = doc.NewElement("Polygon");
polygon->SetAttribute("PolyType", "0");
polygon->SetAttribute("MeshOpa", setMesh->opaPaths[i].c_str());
polygon->SetAttribute("MeshXlu", setMesh->xluPaths[i].c_str());
root->InsertEndChild(polygon);
}
dlist += 1;
} else if (setMesh->meshHeader.base.type == 1) {
root->SetAttribute("PolyNum", "1");
tinyxml2::XMLElement* polygon = doc.NewElement("Polygon");
polygon->SetAttribute("Format", setMesh->meshHeader.polygon1.format);
polygon->SetAttribute("ImgOpa", "");
polygon->SetAttribute("ImgXlu", "");
if (setMesh->meshHeader.polygon1.format == 1) {
polygon->SetAttribute("BgImageCount", "0");
} else {
polygon->SetAttribute("BgImageCount", setMesh->meshHeader.polygon1.multi.count);
}
polygon->SetAttribute("PolyType", "0");
polygon->SetAttribute("MeshOpa", setMesh->opaPaths[0].c_str());
polygon->SetAttribute("MeshXlu", setMesh->xluPaths[0].c_str());
root->InsertEndChild(polygon);
BgImage* image = setMesh->meshHeader.polygon1.multi.list;
int count = setMesh->meshHeader.polygon1.format == 1 ? 1 : setMesh->meshHeader.polygon1.multi.count;
for (int i = 0; i < count; i += 1) {
tinyxml2::XMLElement* bgImage = doc.NewElement("BgImage");
if (setMesh->meshHeader.polygon1.format == 1) {
bgImage->SetAttribute("Unknown_00", image->unk_00);
bgImage->SetAttribute("Id", image->id);
bgImage->SetAttribute("ImagePath", setMesh->imagePaths[i].c_str());
bgImage->SetAttribute("Unknown_0C", setMesh->meshHeader.polygon1.single.unk_0C);
bgImage->SetAttribute("TLUT", setMesh->meshHeader.polygon1.single.tlut);
bgImage->SetAttribute("Width", setMesh->meshHeader.polygon1.single.width);
bgImage->SetAttribute("Height", setMesh->meshHeader.polygon1.single.height);
bgImage->SetAttribute("Fmt", setMesh->meshHeader.polygon1.single.fmt);
bgImage->SetAttribute("Siz", setMesh->meshHeader.polygon1.single.siz);
bgImage->SetAttribute("Mode0", setMesh->meshHeader.polygon1.single.mode0);
bgImage->SetAttribute("TLUTCount", setMesh->meshHeader.polygon1.single.tlutCount);
} else {
bgImage->SetAttribute("Unknown_00", image->unk_00);
bgImage->SetAttribute("Id", image->id);
bgImage->SetAttribute("ImagePath", setMesh->imagePaths[i].c_str());
bgImage->SetAttribute("Unknown_0C", image->unk_0C);
bgImage->SetAttribute("TLUT", image->tlut);
bgImage->SetAttribute("Width", image->width);
bgImage->SetAttribute("Height", image->height);
bgImage->SetAttribute("Fmt", image->fmt);
bgImage->SetAttribute("Siz", image->siz);
bgImage->SetAttribute("Mode0", image->mode0);
bgImage->SetAttribute("TLUTCount", image->tlutCount);
}
polygon->InsertEndChild(bgImage);
image += 1;
}
} else if (setMesh->meshHeader.base.type == 2) {
root->SetAttribute("PolyNum", setMesh->meshHeader.polygon2.num);
PolygonDlist2* dlist = (PolygonDlist2*)setMesh->meshHeader.polygon2.start;
for (int i = 0; i < setMesh->meshHeader.polygon2.num; i += 1) {
tinyxml2::XMLElement* polygon = doc.NewElement("Polygon");
polygon->SetAttribute("PolyType", "0");
polygon->SetAttribute("PosX", dlist->pos.x);
polygon->SetAttribute("PosY", dlist->pos.y);
polygon->SetAttribute("PosZ", dlist->pos.z);
polygon->SetAttribute("Unknown", dlist->unk_06);
polygon->SetAttribute("MeshOpa", setMesh->opaPaths[i].c_str());
polygon->SetAttribute("MeshXlu", setMesh->xluPaths[i].c_str());
root->InsertEndChild(polygon);
dlist += 1;
}
}
tinyxml2::XMLPrinter printer;
doc.Accept(&printer);
SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr());
}
} // namespace SOH

View File

@ -8,4 +8,12 @@ class SetMeshFactory : public SceneCommandFactoryBinaryV0 {
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
};
class SetMeshFactoryXML : public SceneCommandFactoryXMLV0 {
public:
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, tinyxml2::XMLElement* reader) override;
};
void LogMeshAsXML(std::shared_ptr<LUS::IResource> resource);
} // namespace SOH

View File

@ -15,6 +15,49 @@ SetObjectListFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initDa
setObjectList->objects.push_back(reader->ReadUInt16());
}
//LogObjectListAsXML(setObjectList);
return setObjectList;
}
std::shared_ptr<LUS::IResource> SetObjectListFactoryXML::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
tinyxml2::XMLElement* reader) {
auto setObjectList = std::make_shared<SetObjectList>(initData);
setObjectList->cmdId = SceneCommandID::SetObjectList;
auto child = reader->FirstChildElement();
while (child != nullptr) {
std::string childName = child->Name();
if (childName == "ObjectEntry") {
setObjectList->objects.push_back(child->IntAttribute("Id"));
}
child = child->NextSiblingElement();
}
setObjectList->numObjects = setObjectList->objects.size();
return setObjectList;
}
void LogObjectListAsXML(std::shared_ptr<LUS::IResource> resource) {
std::shared_ptr<SetObjectList> setObjectList = std::static_pointer_cast<SetObjectList>(resource);
tinyxml2::XMLDocument doc;
tinyxml2::XMLElement* root = doc.NewElement("SetObjectList");
doc.InsertFirstChild(root);
for (size_t i = 0; i < setObjectList->numObjects; i++) {
tinyxml2::XMLElement* entry = doc.NewElement("ObjectEntry");
entry->SetAttribute("Id", setObjectList->objects[i]);
root->InsertEndChild(entry);
}
tinyxml2::XMLPrinter printer;
doc.Accept(&printer);
SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr());
}
} // namespace SOH

View File

@ -8,4 +8,12 @@ class SetObjectListFactory : public SceneCommandFactoryBinaryV0 {
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
};
class SetObjectListFactoryXML : public SceneCommandFactoryXMLV0 {
public:
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, tinyxml2::XMLElement* reader) override;
};
void LogObjectListAsXML(std::shared_ptr<LUS::IResource> resource);
} // namespace SOH

View File

@ -18,6 +18,52 @@ SetPathwaysFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData
setPathways->paths.push_back(path->GetPointer());
}
//LogPathwaysAsXML(setPathways);
return setPathways;
}
std::shared_ptr<LUS::IResource> SetPathwaysFactoryXML::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
tinyxml2::XMLElement* reader) {
auto setPathways = std::make_shared<SetPathways>(initData);
setPathways->cmdId = SceneCommandID::SetPathways;
auto child = reader->FirstChildElement();
while (child != nullptr) {
std::string childName = child->Name();
if (childName == "Pathway") {
std::string pathFileName = child->Attribute("FilePath");
auto path = std::static_pointer_cast<Path>(LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(pathFileName.c_str()));
setPathways->paths.push_back(path->GetPointer());
setPathways->pathFileNames.push_back(pathFileName);
}
child = child->NextSiblingElement();
}
setPathways->numPaths = setPathways->paths.size();
return setPathways;
}
void LogPathwaysAsXML(std::shared_ptr<LUS::IResource> resource) {
std::shared_ptr<SetPathways> setPathways = std::static_pointer_cast<SetPathways>(resource);
tinyxml2::XMLDocument doc;
tinyxml2::XMLElement* root = doc.NewElement("SetPathways");
doc.InsertFirstChild(root);
for (size_t i = 0; i < setPathways->pathFileNames.size(); i++) {
tinyxml2::XMLElement* pathway = doc.NewElement("Pathway");
pathway->SetAttribute("FilePath", setPathways->pathFileNames[i].c_str());
root->InsertEndChild(pathway);
}
tinyxml2::XMLPrinter printer;
doc.Accept(&printer);
SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr());
}
} // namespace SOH

View File

@ -8,4 +8,12 @@ class SetPathwaysFactory : public SceneCommandFactoryBinaryV0 {
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
};
class SetPathwaysFactoryXML : public SceneCommandFactoryXMLV0 {
public:
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, tinyxml2::XMLElement* reader) override;
};
void LogPathwaysAsXML(std::shared_ptr<LUS::IResource> resource);
} // namespace SOH

View File

@ -12,6 +12,36 @@ SetRoomBehaviorFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> init
setRoomBehavior->roomBehavior.gameplayFlags = reader->ReadInt8();
setRoomBehavior->roomBehavior.gameplayFlags2 = reader->ReadInt32();
//LogRoomBehaviorAsXML(setRoomBehavior);
return setRoomBehavior;
}
std::shared_ptr<LUS::IResource> SetRoomBehaviorFactoryXML::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
tinyxml2::XMLElement* reader) {
auto setRoomBehavior = std::make_shared<SetRoomBehavior>(initData);
setRoomBehavior->cmdId = SceneCommandID::SetRoomBehavior;
setRoomBehavior->roomBehavior.gameplayFlags = reader->IntAttribute("GameplayFlags1");
setRoomBehavior->roomBehavior.gameplayFlags2 = reader->IntAttribute("GameplayFlags2");
return setRoomBehavior;
}
void LogRoomBehaviorAsXML(std::shared_ptr<LUS::IResource> resource) {
std::shared_ptr<SetRoomBehavior> setRoomBehavior = std::static_pointer_cast<SetRoomBehavior>(resource);
tinyxml2::XMLDocument doc;
tinyxml2::XMLElement* root = doc.NewElement("SetRoomBehavior");
doc.InsertFirstChild(root);
root->SetAttribute("GameplayFlags1", setRoomBehavior->roomBehavior.gameplayFlags);
root->SetAttribute("GameplayFlags2", setRoomBehavior->roomBehavior.gameplayFlags2);
tinyxml2::XMLPrinter printer;
doc.Accept(&printer);
SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr());
}
} // namespace SOH

View File

@ -8,4 +8,12 @@ class SetRoomBehaviorFactory : public SceneCommandFactoryBinaryV0 {
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
};
class SetRoomBehaviorFactoryXML : public SceneCommandFactoryXMLV0 {
public:
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, tinyxml2::XMLElement* reader) override;
};
void LogRoomBehaviorAsXML(std::shared_ptr<LUS::IResource> resource);
} // namespace SOH

View File

@ -23,6 +23,57 @@ SetRoomListFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData
setRoomList->rooms.push_back(room);
}
//LogRoomListAsXML(setRoomList);
return setRoomList;
}
std::shared_ptr<LUS::IResource> SetRoomListFactoryXML::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
tinyxml2::XMLElement* reader) {
auto setRoomList = std::make_shared<SetRoomList>(initData);
setRoomList->cmdId = SceneCommandID::SetRoomList;
auto child = reader->FirstChildElement();
while (child != nullptr) {
std::string childName = child->Name();
if (childName == "RoomEntry") {
RomFile room;
setRoomList->fileNames.push_back(child->Attribute("Path"));
room.fileName = (char*)setRoomList->fileNames.back().c_str();
room.vromStart = child->IntAttribute("VromStart");
room.vromEnd = child->IntAttribute("VromEnd");
setRoomList->rooms.push_back(room);
}
child = child->NextSiblingElement();
}
setRoomList->numRooms = setRoomList->rooms.size();
return setRoomList;
}
void LogRoomListAsXML(std::shared_ptr<LUS::IResource> resource) {
std::shared_ptr<SetRoomList> setRoomList = std::static_pointer_cast<SetRoomList>(resource);
tinyxml2::XMLDocument doc;
tinyxml2::XMLElement* root = doc.NewElement("SetRoomList");
doc.InsertFirstChild(root);
for (size_t i = 0; i < setRoomList->numRooms; i++) {
tinyxml2::XMLElement* entry = doc.NewElement("RoomEntry");
entry->SetAttribute("Path", setRoomList->fileNames[i].c_str());
root->InsertEndChild(entry);
}
tinyxml2::XMLPrinter printer;
doc.Accept(&printer);
SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr());
}
} // namespace SOH

View File

@ -8,4 +8,12 @@ class SetRoomListFactory : public SceneCommandFactoryBinaryV0 {
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
};
class SetRoomListFactoryXML : public SceneCommandFactoryXMLV0 {
public:
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, tinyxml2::XMLElement* reader) override;
};
void LogRoomListAsXML(std::shared_ptr<LUS::IResource> resource);
} // namespace SOH

View File

@ -12,6 +12,36 @@ std::shared_ptr<LUS::IResource> SetSkyboxModifierFactory::ReadResource(std::shar
setSkyboxModifier->modifier.skyboxDisabled = reader->ReadInt8();
setSkyboxModifier->modifier.sunMoonDisabled = reader->ReadInt8();
//LogSkyboxModifierAsXML(setSkyboxModifier);
return setSkyboxModifier;
}
std::shared_ptr<LUS::IResource> SetSkyboxModifierFactoryXML::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
tinyxml2::XMLElement* reader) {
auto setSkyboxModifier = std::make_shared<SetSkyboxModifier>(initData);
setSkyboxModifier->cmdId = SceneCommandID::SetSkyboxModifier;
setSkyboxModifier->modifier.skyboxDisabled = reader->IntAttribute("SkyboxDisabled");
setSkyboxModifier->modifier.sunMoonDisabled = reader->IntAttribute("SunMoonDisabled");
return setSkyboxModifier;
}
void LogSkyboxModifierAsXML(std::shared_ptr<LUS::IResource> resource) {
std::shared_ptr<SetSkyboxModifier> setSkyboxModifier = std::static_pointer_cast<SetSkyboxModifier>(resource);
tinyxml2::XMLDocument doc;
tinyxml2::XMLElement* root = doc.NewElement("SetSkyboxModifier");
doc.InsertFirstChild(root);
root->SetAttribute("SkyboxDisabled", setSkyboxModifier->modifier.skyboxDisabled);
root->SetAttribute("SunMoonDisabled", setSkyboxModifier->modifier.sunMoonDisabled);
tinyxml2::XMLPrinter printer;
doc.Accept(&printer);
SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr());
}
} // namespace SOH

View File

@ -8,4 +8,12 @@ class SetSkyboxModifierFactory : public SceneCommandFactoryBinaryV0 {
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
};
class SetSkyboxModifierFactoryXML : public SceneCommandFactoryXMLV0 {
public:
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, tinyxml2::XMLElement* reader) override;
};
void LogSkyboxModifierAsXML(std::shared_ptr<LUS::IResource> resource);
} // namespace SOH

View File

@ -14,6 +14,40 @@ std::shared_ptr<LUS::IResource> SetSkyboxSettingsFactory::ReadResource(std::shar
setSkyboxSettings->settings.weather = reader->ReadInt8();
setSkyboxSettings->settings.indoors = reader->ReadInt8();
//LogSkyboxSettingsAsXML(setSkyboxSettings);
return setSkyboxSettings;
}
std::shared_ptr<LUS::IResource> SetSkyboxSettingsFactoryXML::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
tinyxml2::XMLElement* reader) {
auto setSkyboxSettings = std::make_shared<SetSkyboxSettings>(initData);
setSkyboxSettings->cmdId = SceneCommandID::SetSkyboxSettings;
setSkyboxSettings->settings.unk = reader->IntAttribute("Unknown");
setSkyboxSettings->settings.skyboxId = reader->IntAttribute("SkyboxId");
setSkyboxSettings->settings.weather = reader->IntAttribute("Weather");
setSkyboxSettings->settings.indoors = reader->IntAttribute("Indoors");
return setSkyboxSettings;
}
void LogSkyboxSettingsAsXML(std::shared_ptr<LUS::IResource> resource) {
std::shared_ptr<SetSkyboxSettings> setSkyboxSettings = std::static_pointer_cast<SetSkyboxSettings>(resource);
tinyxml2::XMLDocument doc;
tinyxml2::XMLElement* root = doc.NewElement("SetSkyboxSettings");
doc.InsertFirstChild(root);
root->SetAttribute("Unknown", setSkyboxSettings->settings.unk);
root->SetAttribute("SkyboxId", setSkyboxSettings->settings.skyboxId);
root->SetAttribute("Weather", setSkyboxSettings->settings.weather);
root->SetAttribute("Indoors", setSkyboxSettings->settings.indoors);
tinyxml2::XMLPrinter printer;
doc.Accept(&printer);
SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr());
}
} // namespace SOH

View File

@ -8,4 +8,12 @@ class SetSkyboxSettingsFactory : public SceneCommandFactoryBinaryV0 {
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
};
class SetSkyboxSettingsFactoryXML : public SceneCommandFactoryXMLV0 {
public:
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, tinyxml2::XMLElement* reader) override;
};
void LogSkyboxSettingsAsXML(std::shared_ptr<LUS::IResource> resource);
} // namespace SOH

View File

@ -13,6 +13,38 @@ std::shared_ptr<LUS::IResource> SetSoundSettingsFactory::ReadResource(std::share
setSoundSettings->settings.natureAmbienceId = reader->ReadInt8();
setSoundSettings->settings.seqId = reader->ReadInt8();
//LogSoundSettingsAsXML(setSoundSettings);
return setSoundSettings;
}
std::shared_ptr<LUS::IResource> SetSoundSettingsFactoryXML::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
tinyxml2::XMLElement* reader) {
auto setSoundSettings = std::make_shared<SetSoundSettings>(initData);
setSoundSettings->cmdId = SceneCommandID::SetSoundSettings;
setSoundSettings->settings.reverb = reader->IntAttribute("Reverb");
setSoundSettings->settings.natureAmbienceId = reader->IntAttribute("NatureAmbienceId");
setSoundSettings->settings.seqId = reader->IntAttribute("SeqId");
return setSoundSettings;
}
void LogSoundSettingsAsXML(std::shared_ptr<LUS::IResource> resource) {
std::shared_ptr<SetSoundSettings> setSoundSettings = std::static_pointer_cast<SetSoundSettings>(resource);
tinyxml2::XMLDocument doc;
tinyxml2::XMLElement* root = doc.NewElement("SetSoundSettings");
doc.InsertFirstChild(root);
root->SetAttribute("Reverb", setSoundSettings->settings.reverb);
root->SetAttribute("NatureAmbienceId", setSoundSettings->settings.natureAmbienceId);
root->SetAttribute("SeqId", setSoundSettings->settings.seqId);
tinyxml2::XMLPrinter printer;
doc.Accept(&printer);
SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr());
}
} // namespace SOH

View File

@ -8,4 +8,12 @@ class SetSoundSettingsFactory : public SceneCommandFactoryBinaryV0 {
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
};
class SetSoundSettingsFactoryXML : public SceneCommandFactoryXMLV0 {
public:
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, tinyxml2::XMLElement* reader) override;
};
void LogSoundSettingsAsXML(std::shared_ptr<LUS::IResource> resource);
} // namespace SOH

View File

@ -12,6 +12,36 @@ std::shared_ptr<LUS::IResource> SetSpecialObjectsFactory::ReadResource(std::shar
setSpecialObjects->specialObjects.elfMessage = reader->ReadInt8();
setSpecialObjects->specialObjects.globalObject = reader->ReadInt16();
//LogSpecialObjectsAsXML(setSpecialObjects);
return setSpecialObjects;
}
std::shared_ptr<LUS::IResource> SetSpecialObjectsFactoryXML::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
tinyxml2::XMLElement* reader) {
auto setSpecialObjects = std::make_shared<SetSpecialObjects>(initData);
setSpecialObjects->cmdId = SceneCommandID::SetSpecialObjects;
setSpecialObjects->specialObjects.elfMessage = reader->IntAttribute("ElfMessage");
setSpecialObjects->specialObjects.globalObject = reader->IntAttribute("GlobalObject");
return setSpecialObjects;
}
void LogSpecialObjectsAsXML(std::shared_ptr<LUS::IResource> resource) {
std::shared_ptr<SetSpecialObjects> setSpecialObjects = std::static_pointer_cast<SetSpecialObjects>(resource);
tinyxml2::XMLDocument doc;
tinyxml2::XMLElement* root = doc.NewElement("SetSpecialObjects");
doc.InsertFirstChild(root);
root->SetAttribute("ElfMessage", setSpecialObjects->specialObjects.elfMessage);
root->SetAttribute("GlobalObject", setSpecialObjects->specialObjects.globalObject);
tinyxml2::XMLPrinter printer;
doc.Accept(&printer);
SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr());
}
} // namespace SOH

View File

@ -8,4 +8,12 @@ class SetSpecialObjectsFactory : public SceneCommandFactoryBinaryV0 {
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
};
class SetSpecialObjectsFactoryXML : public SceneCommandFactoryXMLV0 {
public:
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, tinyxml2::XMLElement* reader) override;
};
void LogSpecialObjectsAsXML(std::shared_ptr<LUS::IResource> resource);
} // namespace SOH

View File

@ -26,6 +26,65 @@ std::shared_ptr<LUS::IResource> SetStartPositionListFactory::ReadResource(std::s
setStartPositionList->startPositions.push_back(entry);
}
//LogStartPositionListAsXML(setStartPositionList);
return setStartPositionList;
}
std::shared_ptr<LUS::IResource> SetStartPositionListFactoryXML::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
tinyxml2::XMLElement* reader) {
auto setStartPositionList = std::make_shared<SetStartPositionList>(initData);
setStartPositionList->cmdId = SceneCommandID::SetStartPositionList;
auto child = reader->FirstChildElement();
while (child != nullptr) {
std::string childName = child->Name();
if (childName == "StartPositionEntry") {
ActorEntry entry;
entry.id = child->IntAttribute("Id");
entry.pos.x = child->IntAttribute("PosX");
entry.pos.y = child->IntAttribute("PosY");
entry.pos.z = child->IntAttribute("PosZ");
entry.rot.x = child->IntAttribute("RotX");
entry.rot.y = child->IntAttribute("RotY");
entry.rot.z = child->IntAttribute("RotZ");
entry.params = child->IntAttribute("Params");
setStartPositionList->startPositions.push_back(entry);
}
child = child->NextSiblingElement();
}
setStartPositionList->numStartPositions = setStartPositionList->startPositions.size();
return setStartPositionList;
}
void LogStartPositionListAsXML(std::shared_ptr<LUS::IResource> resource) {
std::shared_ptr<SetStartPositionList> setStartPositionList = std::static_pointer_cast<SetStartPositionList>(resource);
tinyxml2::XMLDocument doc;
tinyxml2::XMLElement* root = doc.NewElement("SetStartPositionList");
doc.InsertFirstChild(root);
for (size_t i = 0; i < setStartPositionList->numStartPositions; i++) {
tinyxml2::XMLElement* entry = doc.NewElement("StartPositionEntry");
entry->SetAttribute("Id", setStartPositionList->startPositions[i].id);
entry->SetAttribute("PosX", setStartPositionList->startPositions[i].pos.x);
entry->SetAttribute("PosY", setStartPositionList->startPositions[i].pos.y);
entry->SetAttribute("PosZ", setStartPositionList->startPositions[i].pos.z);
entry->SetAttribute("RotX", setStartPositionList->startPositions[i].rot.x);
entry->SetAttribute("RotY", setStartPositionList->startPositions[i].rot.y);
entry->SetAttribute("RotZ", setStartPositionList->startPositions[i].rot.z);
entry->SetAttribute("Params", setStartPositionList->startPositions[i].params);
root->InsertEndChild(entry);
}
tinyxml2::XMLPrinter printer;
doc.Accept(&printer);
SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr());
}
} // namespace SOH

View File

@ -8,4 +8,12 @@ class SetStartPositionListFactory : public SceneCommandFactoryBinaryV0 {
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
};
class SetStartPositionListFactoryXML : public SceneCommandFactoryXMLV0 {
public:
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, tinyxml2::XMLElement* reader) override;
};
void LogStartPositionListAsXML(std::shared_ptr<LUS::IResource> resource);
} // namespace SOH

View File

@ -13,6 +13,38 @@ SetTimeSettingsFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> init
setTimeSettings->settings.minute = reader->ReadInt8();
setTimeSettings->settings.timeIncrement = reader->ReadInt8();
//LogTimeSettingsAsXML(setTimeSettings);
return setTimeSettings;
}
std::shared_ptr<LUS::IResource> SetTimeSettingsFactoryXML::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
tinyxml2::XMLElement* reader) {
auto setTimeSettings = std::make_shared<SetTimeSettings>(initData);
setTimeSettings->cmdId = SceneCommandID::SetTimeSettings;
setTimeSettings->settings.hour = reader->IntAttribute("Hour");
setTimeSettings->settings.minute = reader->IntAttribute("Minute");
setTimeSettings->settings.timeIncrement = reader->IntAttribute("TimeIncrement");
return setTimeSettings;
}
void LogTimeSettingsAsXML(std::shared_ptr<LUS::IResource> resource) {
std::shared_ptr<SetTimeSettings> setTimeSettings = std::static_pointer_cast<SetTimeSettings>(resource);
tinyxml2::XMLDocument doc;
tinyxml2::XMLElement* root = doc.NewElement("SetTimeSettings");
doc.InsertFirstChild(root);
root->SetAttribute("Hour", setTimeSettings->settings.hour);
root->SetAttribute("Minute", setTimeSettings->settings.minute);
root->SetAttribute("TimeIncrement", setTimeSettings->settings.timeIncrement);
tinyxml2::XMLPrinter printer;
doc.Accept(&printer);
SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr());
}
} // namespace SOH

View File

@ -8,4 +8,12 @@ class SetTimeSettingsFactory : public SceneCommandFactoryBinaryV0 {
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
};
class SetTimeSettingsFactoryXML : public SceneCommandFactoryXMLV0 {
public:
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, tinyxml2::XMLElement* reader) override;
};
void LogTimeSettingsAsXML(std::shared_ptr<LUS::IResource> resource);
} // namespace SOH

View File

@ -28,6 +28,69 @@ std::shared_ptr<LUS::IResource> SetTransitionActorListFactory::ReadResource(std:
setTransitionActorList->transitionActorList.push_back(entry);
}
//LogTransitionActorListAsXML(setTransitionActorList);
return setTransitionActorList;
}
std::shared_ptr<LUS::IResource> SetTransitionActorListFactoryXML::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
tinyxml2::XMLElement* reader) {
auto setTransitionActorList = std::make_shared<SetTransitionActorList>(initData);
setTransitionActorList->cmdId = SceneCommandID::SetTransitionActorList;
auto child = reader->FirstChildElement();
while (child != nullptr) {
std::string childName = child->Name();
if (childName == "TransitionActorEntry") {
TransitionActorEntry entry;
entry.sides[0].room = child->IntAttribute("FrontSideRoom");
entry.sides[0].effects = child->IntAttribute("FrontSideEffects");
entry.sides[1].room = child->IntAttribute("BackSideRoom");
entry.sides[1].effects = child->IntAttribute("BackSideEffects");
entry.id = child->IntAttribute("Id");
entry.pos.x = child->IntAttribute("PosX");
entry.pos.y = child->IntAttribute("PosY");
entry.pos.z = child->IntAttribute("PosZ");
entry.rotY = child->IntAttribute("RotY");
entry.params = child->IntAttribute("Params");
setTransitionActorList->transitionActorList.push_back(entry);
}
child = child->NextSiblingElement();
}
setTransitionActorList->numTransitionActors = setTransitionActorList->transitionActorList.size();
return setTransitionActorList;
}
void LogTransitionActorListAsXML(std::shared_ptr<LUS::IResource> resource) {
std::shared_ptr<SetTransitionActorList> setTransitionActorList = std::static_pointer_cast<SetTransitionActorList>(resource);
tinyxml2::XMLDocument doc;
tinyxml2::XMLElement* root = doc.NewElement("SetTransitionActorList");
doc.InsertFirstChild(root);
for (size_t i = 0; i < setTransitionActorList->numTransitionActors; i++) {
tinyxml2::XMLElement* entry = doc.NewElement("TransitionActorEntry");
entry->SetAttribute("FrontSideRoom", setTransitionActorList->transitionActorList[i].sides[0].room);
entry->SetAttribute("FrontSideEffects", setTransitionActorList->transitionActorList[i].sides[0].effects);
entry->SetAttribute("BackSideRoom", setTransitionActorList->transitionActorList[i].sides[1].room);
entry->SetAttribute("BackSideEffects", setTransitionActorList->transitionActorList[i].sides[1].effects);
entry->SetAttribute("Id", setTransitionActorList->transitionActorList[i].id);
entry->SetAttribute("PosX", setTransitionActorList->transitionActorList[i].pos.x);
entry->SetAttribute("PosY", setTransitionActorList->transitionActorList[i].pos.y);
entry->SetAttribute("PosZ", setTransitionActorList->transitionActorList[i].pos.z);
entry->SetAttribute("RotY", setTransitionActorList->transitionActorList[i].rotY);
entry->SetAttribute("Params", setTransitionActorList->transitionActorList[i].params);
root->InsertEndChild(entry);
}
tinyxml2::XMLPrinter printer;
doc.Accept(&printer);
SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr());
}
} // namespace SOH

View File

@ -8,4 +8,12 @@ class SetTransitionActorListFactory : public SceneCommandFactoryBinaryV0 {
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
};
class SetTransitionActorListFactoryXML : public SceneCommandFactoryXMLV0 {
public:
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, tinyxml2::XMLElement* reader) override;
};
void LogTransitionActorListAsXML(std::shared_ptr<LUS::IResource> resource);
} // namespace SOH

View File

@ -14,6 +14,40 @@ SetWindSettingsFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> init
setWind->settings.windSouth = reader->ReadInt8();
setWind->settings.windSpeed = reader->ReadUByte();
//LogWindSettingsAsXML(setWind);
return setWind;
}
std::shared_ptr<LUS::IResource> SetWindSettingsFactoryXML::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData,
tinyxml2::XMLElement* reader) {
auto setWind = std::make_shared<SetWindSettings>(initData);
setWind->cmdId = SceneCommandID::SetWind;
setWind->settings.windWest = reader->IntAttribute("WindWest");
setWind->settings.windVertical = reader->IntAttribute("WindVertical");
setWind->settings.windSouth = reader->IntAttribute("WindSouth");
setWind->settings.windSpeed = reader->IntAttribute("WindSpeed");
return setWind;
}
void LogWindSettingsAsXML(std::shared_ptr<LUS::IResource> resource) {
std::shared_ptr<SetWindSettings> setWindSettings = std::static_pointer_cast<SetWindSettings>(resource);
tinyxml2::XMLDocument doc;
tinyxml2::XMLElement* root = doc.NewElement("SetWindSettings");
doc.InsertFirstChild(root);
root->SetAttribute("WindWest", setWindSettings->settings.windWest);
root->SetAttribute("WindVertical", setWindSettings->settings.windVertical);
root->SetAttribute("WindSouth", setWindSettings->settings.windSouth);
root->SetAttribute("WindSpeed", setWindSettings->settings.windSpeed);
tinyxml2::XMLPrinter printer;
doc.Accept(&printer);
SPDLOG_INFO("{}: {}", resource->GetInitData()->Path, printer.CStr());
}
} // namespace SOH

View File

@ -8,4 +8,12 @@ class SetWindSettingsFactory : public SceneCommandFactoryBinaryV0 {
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
};
class SetWindSettingsFactoryXML : public SceneCommandFactoryXMLV0 {
public:
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, tinyxml2::XMLElement* reader) override;
};
void LogWindSettingsAsXML(std::shared_ptr<LUS::IResource> resource);
} // namespace SOH

View File

@ -94,6 +94,8 @@ class SetMesh : public SceneCommand<MeshHeader> {
uint8_t data;
uint8_t meshHeaderType;
std::vector<std::string> opaPaths;
std::vector<std::string> xluPaths;
std::vector<PolygonDlist> dlists;
std::vector<PolygonDlist2> dlists2;
std::vector<std::string> imagePaths;

View File

@ -18,6 +18,7 @@ class SetPathways : public SceneCommand<PathData*> {
size_t GetPointerSize();
uint32_t numPaths;
std::vector<std::string> pathFileNames;
std::vector<PathData*> paths;
};
}; // namespace LUS