metaforce/Runtime/MP1/CTweaks.cpp

131 lines
5.1 KiB
C++
Raw Normal View History

2016-03-04 23:04:53 +00:00
#include "logvisor/logvisor.hpp"
2015-08-17 05:26:58 +00:00
#include "CTweaks.hpp"
2015-08-28 00:11:31 +00:00
#include "CResFactory.hpp"
#include "CResLoader.hpp"
#include "GameGlobalObjects.hpp"
#include "Editor/ProjectManager.hpp"
#include "Editor/ProjectResourceFactoryMP1.hpp"
#include "DataSpec/DNAMP1/Tweaks/CTweakGame.hpp"
2015-08-29 01:30:47 +00:00
#include "DataSpec/DNAMP1/Tweaks/CTweakPlayer.hpp"
2015-08-28 00:11:31 +00:00
#include "DataSpec/DNAMP1/Tweaks/CTweakPlayerControl.hpp"
#include "DataSpec/DNAMP1/Tweaks/CTweakGunRes.hpp"
#include "DataSpec/DNAMP1/Tweaks/CTweakPlayerRes.hpp"
2016-09-16 20:18:03 +00:00
#include "DataSpec/DNAMP1/Tweaks/CTweakSlideShow.hpp"
2017-01-26 10:06:18 +00:00
#include "DataSpec/DNAMP1/Tweaks/CTweakAutoMapper.hpp"
#include "DataSpec/DNAMP1/Tweaks/CTweakTargeting.hpp"
#include "DataSpec/DNAMP1/Tweaks/CTweakGui.hpp"
#include "DataSpec/DNAMP1/Tweaks/CTweakParticle.hpp"
#include "DataSpec/DNAMP1/Tweaks/CTweakBall.hpp"
#include "DataSpec/DNAMP1/Tweaks/CTweakGuiColors.hpp"
#include "DataSpec/DNAMP1/Tweaks/CTweakPlayerGun.hpp"
#include "World/CPlayerCameraBob.hpp"
2015-08-17 05:26:58 +00:00
2016-03-04 23:04:53 +00:00
namespace urde
{
2015-08-28 00:11:31 +00:00
2015-08-27 00:23:46 +00:00
namespace MP1
{
2016-03-05 00:03:41 +00:00
static logvisor::Module Log("MP1::CTweaks");
2015-08-28 00:11:31 +00:00
static const SObjectTag& IDFromFactory(CResFactory& factory, const char* name)
{
const SObjectTag* tag = factory.GetResourceIdByName(name);
if (!tag)
2016-03-04 23:04:53 +00:00
Log.report(logvisor::Fatal, "Tweak Asset not found when loading... '%s'", name);
2015-08-28 00:11:31 +00:00
return *tag;
}
2015-08-17 05:26:58 +00:00
void CTweaks::RegisterTweaks()
{
2016-09-16 20:18:03 +00:00
ProjectResourceFactoryMP1& factory = ProjectManager::g_SharedManager->resourceFactoryMP1();
std::experimental::optional<CMemoryInStream> strm;
const SObjectTag* tag;
2015-08-29 01:30:47 +00:00
/* Particle */
2017-01-26 10:06:18 +00:00
tag = factory.GetResourceIdByName("Particle");
strm.emplace(factory.LoadResourceSync(*tag).release(), factory.ResourceSize(*tag));
g_tweakParticle = new DataSpec::DNAMP1::CTweakParticle(*strm);
/* Player */
tag = factory.GetResourceIdByName("Player");
strm.emplace(factory.LoadResourceSync(*tag).release(), factory.ResourceSize(*tag));
g_tweakPlayer = new DataSpec::DNAMP1::CTweakPlayer(*strm);
2015-08-29 01:30:47 +00:00
/* CameraBob */
tag = factory.GetResourceIdByName("CameraBob");
strm.emplace(factory.LoadResourceSync(*tag).release(), factory.ResourceSize(*tag));
CPlayerCameraBob::ReadTweaks(*strm);
/* Ball */
2017-01-26 10:06:18 +00:00
tag = factory.GetResourceIdByName("Ball");
strm.emplace(factory.LoadResourceSync(*tag).release(), factory.ResourceSize(*tag));
g_tweakBall = new DataSpec::DNAMP1::CTweakBall(*strm);
/* PlayerGun */
tag = factory.GetResourceIdByName("PlayerGun");
strm.emplace(factory.LoadResourceSync(*tag).release(), factory.ResourceSize(*tag));
g_tweakPlayerGun = new DataSpec::DNAMP1::CTweakPlayerGun(*strm);
/* Targeting */
2017-01-26 10:06:18 +00:00
tag = factory.GetResourceIdByName("Targeting");
strm.emplace(factory.LoadResourceSync(*tag).release(), factory.ResourceSize(*tag));
g_tweakTargeting = new DataSpec::DNAMP1::CTweakTargeting(*strm);
/* Game */
tag = factory.GetResourceIdByName("Game");
strm.emplace(factory.LoadResourceSync(*tag).release(), factory.ResourceSize(*tag));
g_tweakGame = new DataSpec::DNAMP1::CTweakGame(*strm);
/* GuiColors */
2017-01-26 10:06:18 +00:00
tag = factory.GetResourceIdByName("GuiColors");
strm.emplace(factory.LoadResourceSync(*tag).release(), factory.ResourceSize(*tag));
g_tweakGuiColors = new DataSpec::DNAMP1::CTweakGuiColors(*strm);
/* AutoMapper */
2017-01-26 10:06:18 +00:00
tag = factory.GetResourceIdByName("AutoMapper");
strm.emplace(factory.LoadResourceSync(*tag).release(), factory.ResourceSize(*tag));
g_tweakAutoMapper = new DataSpec::DNAMP1::CTweakAutoMapper(*strm);
/* Gui */
2017-01-26 10:06:18 +00:00
tag = factory.GetResourceIdByName("Gui");
strm.emplace(factory.LoadResourceSync(*tag).release(), factory.ResourceSize(*tag));
g_tweakGui = new DataSpec::DNAMP1::CTweakGui(*strm);
/* PlayerControls */
2017-01-26 10:06:18 +00:00
tag = factory.GetResourceIdByName("PlayerControls");
strm.emplace(factory.LoadResourceSync(*tag).release(), factory.ResourceSize(*tag));
g_tweakPlayerControl = new DataSpec::DNAMP1::CTweakPlayerControl(*strm);
/* PlayerControls2 */
2017-01-26 10:06:18 +00:00
tag = factory.GetResourceIdByName("PlayerControls2");
strm.emplace(factory.LoadResourceSync(*tag).release(), factory.ResourceSize(*tag));
g_tweakPlayerControlAlt = new DataSpec::DNAMP1::CTweakPlayerControl(*strm);
g_currentPlayerControl = g_tweakPlayerControl;
/* SlideShow */
tag = factory.GetResourceIdByName("SlideShow");
strm.emplace(factory.LoadResourceSync(*tag).release(), factory.ResourceSize(*tag));
g_tweakSlideShow = new DataSpec::DNAMP1::CTweakSlideShow(*strm);
2015-08-17 05:26:58 +00:00
}
void CTweaks::RegisterResourceTweaks()
{
ProjectResourceFactoryMP1& factory = ProjectManager::g_SharedManager->resourceFactoryMP1();
std::experimental::optional<CMemoryInStream> strm;
const SObjectTag* tag = factory.GetResourceIdByName("GunRes");
strm.emplace(factory.LoadResourceSync(*tag).release(), factory.ResourceSize(*tag));
g_tweakGunRes = new DataSpec::DNAMP1::CTweakGunRes(*strm);
2016-09-18 23:47:48 +00:00
g_tweakGunRes->ResolveResources(factory);
tag = factory.GetResourceIdByName("PlayerRes");
strm.emplace(factory.LoadResourceSync(*tag).release(), factory.ResourceSize(*tag));
g_tweakPlayerRes = new DataSpec::DNAMP1::CTweakPlayerRes(*strm);
2016-09-18 23:47:48 +00:00
g_tweakPlayerRes->ResolveResources(factory);
2015-08-17 05:26:58 +00:00
}
}
2015-08-27 00:23:46 +00:00
}