metaforce/Runtime/MP1/CTweaks.cpp

66 lines
2.3 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"
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()
{
#if 0
2015-08-28 00:11:31 +00:00
CResFactory& factory = *g_ResFactory;
CResLoader& loader = factory.GetLoader();
std::unique_ptr<CInputStream> strm;
strm.reset(loader.LoadNewResourceSync(IDFromFactory(factory, "Game"), nullptr));
2016-03-19 19:19:43 +00:00
TOneStatic<DataSpec::DNAMP1::CTweakGame> game(*strm);
g_tweakGame = game.GetAllocSpace();
2015-08-29 01:30:47 +00:00
strm.reset(loader.LoadNewResourceSync(IDFromFactory(factory, "Player"), nullptr));
2016-03-19 19:19:43 +00:00
TOneStatic<DataSpec::DNAMP1::CTweakPlayer> player(*strm);
2015-08-29 01:30:47 +00:00
g_tweakPlayer = player.GetAllocSpace();
2015-08-28 00:11:31 +00:00
strm.reset(loader.LoadNewResourceSync(IDFromFactory(factory, "PlayerControls"), nullptr));
2016-03-19 19:19:43 +00:00
TOneStatic<DataSpec::DNAMP1::CTweakPlayerControl> playerControl(*strm);
2015-08-28 00:11:31 +00:00
g_tweakPlayerControl = playerControl.GetAllocSpace();
#endif
2015-08-17 05:26:58 +00:00
}
void CTweaks::RegisterResourceTweaks()
{
ProjectResourceFactoryMP1& factory = ProjectManager::g_SharedManager->resourceFactoryMP1();
std::experimental::optional<CMemoryInStream> strm;
2016-08-31 23:08:09 +00:00
SObjectTag tag = factory.ProjectResourceFactoryBase::TagFromPath(_S("MP1/Tweaks/GunRes.yaml"));
strm.emplace(factory.LoadResourceSync(tag).release(), factory.ResourceSize(tag));
g_tweakGunRes = new DataSpec::DNAMP1::CTweakGunRes(*strm);
2016-08-31 23:08:09 +00:00
tag = factory.ProjectResourceFactoryBase::TagFromPath(_S("MP1/Tweaks/PlayerRes.yaml"));
strm.emplace(factory.LoadResourceSync(tag).release(), factory.ResourceSize(tag));
g_tweakPlayerRes = new DataSpec::DNAMP1::CTweakPlayerRes(*strm);
2015-08-17 05:26:58 +00:00
}
}
2015-08-27 00:23:46 +00:00
}