From d104c7eb45a5be56e4dacd9c95f96492858eefed Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Wed, 31 Aug 2016 13:43:41 -0700 Subject: [PATCH] Implement CTweaks::RegisterResourceTweaks --- DataSpec/DNAMP1/Tweaks/CTweakGunRes.hpp | 3 +++ DataSpec/DNAMP1/Tweaks/CTweakPlayerRes.hpp | 3 +++ Runtime/MP1/CTweaks.cpp | 22 ++++++++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/DataSpec/DNAMP1/Tweaks/CTweakGunRes.hpp b/DataSpec/DNAMP1/Tweaks/CTweakGunRes.hpp index b20de0fad..b0711ec61 100644 --- a/DataSpec/DNAMP1/Tweaks/CTweakGunRes.hpp +++ b/DataSpec/DNAMP1/Tweaks/CTweakGunRes.hpp @@ -113,6 +113,9 @@ struct CTweakGunRes : ITweakGunRes const std::string& GetGrappleHitParticle() const { return m_grappleHit; } const std::string& GetGrappleMuzzleParticle() const { return m_grappleMuzzle; } const std::string& GetGrappleSwooshParticle() const { return m_grappleSwoosh; } + + CTweakGunRes() = default; + CTweakGunRes(athena::io::IStreamReader& in) { read(in); } }; } diff --git a/DataSpec/DNAMP1/Tweaks/CTweakPlayerRes.hpp b/DataSpec/DNAMP1/Tweaks/CTweakPlayerRes.hpp index 5ade36405..b87c30496 100644 --- a/DataSpec/DNAMP1/Tweaks/CTweakPlayerRes.hpp +++ b/DataSpec/DNAMP1/Tweaks/CTweakPlayerRes.hpp @@ -127,6 +127,9 @@ struct CTweakPlayerRes : ITweakPlayerRes const std::string& GetWaveBeamCineModel() const { return m_cineWave; } const std::string& GetPlasmaBeamCineModel() const { return m_cinePlasma; } const std::string& GetPhazonBeamCineModel() const { return m_cinePhazon; } + + CTweakPlayerRes() = default; + CTweakPlayerRes(athena::io::IStreamReader& in) { read(in); } }; } diff --git a/Runtime/MP1/CTweaks.cpp b/Runtime/MP1/CTweaks.cpp index 141024aaa..4ce5c9b88 100644 --- a/Runtime/MP1/CTweaks.cpp +++ b/Runtime/MP1/CTweaks.cpp @@ -3,9 +3,13 @@ #include "CResFactory.hpp" #include "CResLoader.hpp" #include "GameGlobalObjects.hpp" +#include "Editor/ProjectManager.hpp" +#include "Editor/ProjectResourceFactoryMP1.hpp" #include "DataSpec/DNAMP1/Tweaks/CTweakGame.hpp" #include "DataSpec/DNAMP1/Tweaks/CTweakPlayer.hpp" #include "DataSpec/DNAMP1/Tweaks/CTweakPlayerControl.hpp" +#include "DataSpec/DNAMP1/Tweaks/CTweakGunRes.hpp" +#include "DataSpec/DNAMP1/Tweaks/CTweakPlayerRes.hpp" namespace urde { @@ -45,6 +49,24 @@ void CTweaks::RegisterTweaks() void CTweaks::RegisterResourceTweaks() { +#if 0 + CResFactory& factory = *dynamic_cast(g_ResFactory); + CResLoader& loader = factory.GetLoader(); + std::unique_ptr strm; + strm.reset(loader.LoadNewResourceSync(IDFromFactory(factory, "GunRes"))); + g_tweakGunRes = new DataSpec::DNAMP1::CTweakGunRes(*strm); + strm.reset(loader.LoadNewResourceSync(IDFromFactory(factory, "PlayerRes"), nullptr)); + g_tweakPlayerRes = new DataSpec::DNAMP1::CTweakPlayerRes(*strm); +#else + ProjectResourceFactoryMP1& factory = ProjectManager::g_SharedManager->resourceFactoryMP1(); + std::unique_ptr strm; + SObjectTag tag = *factory.GetResourceIdByName("GunRes"); + strm.reset(new CMemoryInStream(factory.LoadResourceSync(tag).release(), factory.ResourceSize(tag))); + g_tweakGunRes = new DataSpec::DNAMP1::CTweakGunRes(*strm); + tag = *factory.GetResourceIdByName("GunRes"); + strm.reset(new CMemoryInStream(factory.LoadResourceSync(tag).release(), factory.ResourceSize(tag))); + g_tweakPlayerRes = new DataSpec::DNAMP1::CTweakPlayerRes(*strm); +#endif } }