mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-08-30 21:53:15 +00:00
refactor: streamline T6 asset loading
This commit is contained in:
@@ -282,10 +282,10 @@ namespace
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace T6
|
||||
namespace T6::font_icon
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetFontIcon>> CreateCsvFontIconLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
std::unique_ptr<AssetCreator<AssetFontIcon>> CreateCsvLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
{
|
||||
return std::make_unique<CsvFontIconLoader>(memory, searchPath);
|
||||
}
|
||||
} // namespace T6
|
||||
} // namespace T6::font_icon
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace T6
|
||||
namespace T6::font_icon
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetFontIcon>> CreateCsvFontIconLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace T6
|
||||
std::unique_ptr<AssetCreator<AssetFontIcon>> CreateCsvLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace T6::font_icon
|
||||
|
@@ -141,10 +141,10 @@ namespace
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace T6
|
||||
namespace T6::font_icon
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetFontIcon>> CreateJsonFontIconLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
std::unique_ptr<AssetCreator<AssetFontIcon>> CreateJsonLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
{
|
||||
return std::make_unique<JsonFontIconLoader>(memory, searchPath);
|
||||
}
|
||||
} // namespace T6
|
||||
} // namespace T6::font_icon
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace T6
|
||||
namespace T6::font_icon
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetFontIcon>> CreateJsonFontIconLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace T6
|
||||
std::unique_ptr<AssetCreator<AssetFontIcon>> CreateJsonLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace T6::font_icon
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "Game/T6/CommonT6.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "Image/ImageCommon.h"
|
||||
#include "Image/IwiLoader.h"
|
||||
|
||||
#include <cstring>
|
||||
@@ -11,6 +12,7 @@
|
||||
#include <zlib.h>
|
||||
|
||||
using namespace T6;
|
||||
using namespace ::image;
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -25,7 +27,7 @@ namespace
|
||||
|
||||
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
|
||||
{
|
||||
const auto fileName = std::format("images/{}.iwi", assetName);
|
||||
const auto fileName = GetFileNameForAsset(assetName, ".iwi");
|
||||
const auto file = m_search_path.Open(fileName);
|
||||
if (!file.IsOpen())
|
||||
return AssetCreationResult::NoAction();
|
||||
@@ -68,10 +70,10 @@ namespace
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace T6
|
||||
namespace T6::image
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetImage>> CreateImageLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
std::unique_ptr<AssetCreator<AssetImage>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
{
|
||||
return std::make_unique<ImageLoader>(memory, searchPath);
|
||||
}
|
||||
} // namespace T6
|
||||
} // namespace T6::image
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace T6
|
||||
namespace T6::image
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetImage>> CreateImageLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace T6
|
||||
std::unique_ptr<AssetCreator<AssetImage>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace T6::image
|
||||
|
@@ -1,11 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/T6/T6.h"
|
||||
#include "Utils/MemoryManager.h"
|
||||
|
||||
#include <istream>
|
||||
|
||||
namespace T6
|
||||
{
|
||||
bool LoadLeaderboardAsJson(std::istream& stream, LeaderboardDef& leaderboard, MemoryManager& memory);
|
||||
} // namespace T6
|
@@ -1,14 +1,18 @@
|
||||
#include "JsonLeaderboardDefLoader.h"
|
||||
#include "JsonLoaderLeaderboardT6.h"
|
||||
|
||||
#include "Game/T6/CommonT6.h"
|
||||
#include "Game/T6/Leaderboard/JsonLeaderboardDef.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "Leaderboard/LeaderboardCommon.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
using namespace T6;
|
||||
using namespace ::leaderboard;
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -124,13 +128,45 @@ namespace
|
||||
std::istream& m_stream;
|
||||
MemoryManager& m_memory;
|
||||
};
|
||||
|
||||
class LeaderboardLoader final : public AssetCreator<AssetLeaderboard>
|
||||
{
|
||||
public:
|
||||
LeaderboardLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
: m_memory(memory),
|
||||
m_search_path(searchPath)
|
||||
{
|
||||
}
|
||||
|
||||
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
|
||||
{
|
||||
const auto file = m_search_path.Open(GetJsonFileNameForAsset(assetName));
|
||||
if (!file.IsOpen())
|
||||
return AssetCreationResult::NoAction();
|
||||
|
||||
auto* leaderboardDef = m_memory.Alloc<LeaderboardDef>();
|
||||
leaderboardDef->name = m_memory.Dup(assetName.c_str());
|
||||
|
||||
const JsonLoader loader(*file.m_stream, m_memory);
|
||||
if (!loader.Load(*leaderboardDef))
|
||||
{
|
||||
std::cerr << std::format("Failed to load leaderboard \"{}\"\n", assetName);
|
||||
return AssetCreationResult::Failure();
|
||||
}
|
||||
|
||||
return AssetCreationResult::Success(context.AddAsset<AssetLeaderboard>(assetName, leaderboardDef));
|
||||
}
|
||||
|
||||
private:
|
||||
MemoryManager& m_memory;
|
||||
ISearchPath& m_search_path;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace T6
|
||||
namespace T6::leaderboard
|
||||
{
|
||||
bool LoadLeaderboardAsJson(std::istream& stream, LeaderboardDef& leaderboard, MemoryManager& memory)
|
||||
std::unique_ptr<AssetCreator<AssetLeaderboard>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
{
|
||||
const JsonLoader loader(stream, memory);
|
||||
return loader.Load(leaderboard);
|
||||
return std::make_unique<LeaderboardLoader>(memory, searchPath);
|
||||
}
|
||||
} // namespace T6
|
||||
} // namespace T6::leaderboard
|
13
src/ObjLoading/Game/T6/Leaderboard/JsonLoaderLeaderboardT6.h
Normal file
13
src/ObjLoading/Game/T6/Leaderboard/JsonLoaderLeaderboardT6.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "Asset/IAssetCreator.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
#include "Utils/MemoryManager.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace T6::leaderboard
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetLeaderboard>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace T6::leaderboard
|
@@ -1,54 +0,0 @@
|
||||
#include "LoaderLeaderboardT6.h"
|
||||
|
||||
#include "Game/T6/CommonT6.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "JsonLeaderboardDefLoader.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
|
||||
using namespace T6;
|
||||
|
||||
namespace
|
||||
{
|
||||
class LeaderboardLoader final : public AssetCreator<AssetLeaderboard>
|
||||
{
|
||||
public:
|
||||
LeaderboardLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
: m_memory(memory),
|
||||
m_search_path(searchPath)
|
||||
{
|
||||
}
|
||||
|
||||
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
|
||||
{
|
||||
const auto file = m_search_path.Open(std::format("leaderboards/{}.json", assetName));
|
||||
if (!file.IsOpen())
|
||||
return AssetCreationResult::NoAction();
|
||||
|
||||
auto* leaderboardDef = m_memory.Alloc<LeaderboardDef>();
|
||||
leaderboardDef->name = m_memory.Dup(assetName.c_str());
|
||||
|
||||
if (!LoadLeaderboardAsJson(*file.m_stream, *leaderboardDef, m_memory))
|
||||
{
|
||||
std::cerr << std::format("Failed to load leaderboard \"{}\"\n", assetName);
|
||||
return AssetCreationResult::Failure();
|
||||
}
|
||||
|
||||
return AssetCreationResult::Success(context.AddAsset<AssetLeaderboard>(assetName, leaderboardDef));
|
||||
}
|
||||
|
||||
private:
|
||||
MemoryManager& m_memory;
|
||||
ISearchPath& m_search_path;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace T6
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetLeaderboard>> CreateLeaderboardLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
{
|
||||
return std::make_unique<LeaderboardLoader>(memory, searchPath);
|
||||
}
|
||||
} // namespace T6
|
@@ -1,13 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Asset/IAssetCreator.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
#include "Utils/MemoryManager.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace T6
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetLeaderboard>> CreateLeaderboardLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace T6
|
@@ -1,4 +1,4 @@
|
||||
#include "LoaderLocalizeT6.h"
|
||||
#include "LocalizeLoaderT6.h"
|
||||
|
||||
#include "Localize/CommonLocalizeLoader.h"
|
||||
|
||||
@@ -35,10 +35,10 @@ namespace
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace T6
|
||||
namespace T6::localize
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetLocalize>> CreateLocalizeLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
|
||||
std::unique_ptr<AssetCreator<AssetLocalize>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
|
||||
{
|
||||
return std::make_unique<LocalizeLoader>(memory, searchPath, zone);
|
||||
}
|
||||
} // namespace T6
|
||||
} // namespace T6::localize
|
@@ -8,7 +8,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace T6
|
||||
namespace T6::localize
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetLocalize>> CreateLocalizeLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
|
||||
} // namespace T6
|
||||
std::unique_ptr<AssetCreator<AssetLocalize>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
|
||||
} // namespace T6::localize
|
@@ -8,6 +8,7 @@
|
||||
#include <iostream>
|
||||
|
||||
using namespace T6;
|
||||
using namespace ::material;
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -22,7 +23,7 @@ namespace
|
||||
|
||||
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
|
||||
{
|
||||
const auto file = m_search_path.Open(material::GetFileNameForAssetName(assetName));
|
||||
const auto file = m_search_path.Open(GetFileNameForAssetName(assetName));
|
||||
if (!file.IsOpen())
|
||||
return AssetCreationResult::NoAction();
|
||||
|
||||
@@ -45,10 +46,10 @@ namespace
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace T6
|
||||
namespace T6::material
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetMaterial>> CreateMaterialLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
std::unique_ptr<AssetCreator<AssetMaterial>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
{
|
||||
return std::make_unique<MaterialLoader>(memory, searchPath);
|
||||
}
|
||||
} // namespace T6
|
||||
} // namespace T6::material
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace T6
|
||||
namespace T6::material
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetMaterial>> CreateMaterialLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace T6
|
||||
std::unique_ptr<AssetCreator<AssetMaterial>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace T6::material
|
||||
|
@@ -13,8 +13,8 @@
|
||||
#include "Image/IwiTypes.h"
|
||||
#include "Image/LoaderImageT6.h"
|
||||
#include "Image/Texture.h"
|
||||
#include "Leaderboard/LoaderLeaderboardT6.h"
|
||||
#include "Localize/LoaderLocalizeT6.h"
|
||||
#include "Leaderboard/JsonLoaderLeaderboardT6.h"
|
||||
#include "Localize/LocalizeLoaderT6.h"
|
||||
#include "Material/LoaderMaterialT6.h"
|
||||
#include "ObjContainer/IPak/IPak.h"
|
||||
#include "ObjLoading.h"
|
||||
@@ -393,16 +393,16 @@ namespace T6
|
||||
{
|
||||
auto& memory = zone.Memory();
|
||||
|
||||
collection.AddAssetCreator(CreateRawPhysPresetLoader(memory, searchPath, zone));
|
||||
collection.AddAssetCreator(CreateGdtPhysPresetLoader(memory, searchPath, gdt, zone));
|
||||
collection.AddAssetCreator(CreateRawPhysConstraintsLoader(memory, searchPath, zone));
|
||||
collection.AddAssetCreator(CreateGdtPhysConstraintsLoader(memory, searchPath, gdt, zone));
|
||||
collection.AddAssetCreator(phys_preset::CreateRawLoader(memory, searchPath, zone));
|
||||
collection.AddAssetCreator(phys_preset::CreateGdtLoader(memory, gdt, zone));
|
||||
collection.AddAssetCreator(phys_constraints::CreateRawLoader(memory, searchPath, zone));
|
||||
collection.AddAssetCreator(phys_constraints::CreateGdtLoader(memory, searchPath, gdt, zone));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderDestructibleDef>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderXAnim>(memory));
|
||||
collection.AddAssetCreator(xmodel::CreateXModelLoader(memory, searchPath, zone));
|
||||
collection.AddAssetCreator(CreateMaterialLoader(memory, searchPath));
|
||||
collection.AddAssetCreator(material::CreateLoader(memory, searchPath));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderTechniqueSet>(memory));
|
||||
collection.AddAssetCreator(CreateImageLoader(memory, searchPath));
|
||||
collection.AddAssetCreator(image::CreateLoader(memory, searchPath));
|
||||
collection.AddAssetCreator(sound::CreateSoundBankLoader(memory, searchPath));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderSoundPatch>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderClipMapPvs>(memory));
|
||||
@@ -413,11 +413,11 @@ namespace T6
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderGfxWorld>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderLightDef>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderFont>(memory));
|
||||
collection.AddAssetCreator(CreateCsvFontIconLoader(memory, searchPath));
|
||||
collection.AddAssetCreator(CreateJsonFontIconLoader(memory, searchPath));
|
||||
collection.AddAssetCreator(font_icon::CreateCsvLoader(memory, searchPath));
|
||||
collection.AddAssetCreator(font_icon::CreateJsonLoader(memory, searchPath));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderMenuList>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderMenu>(memory));
|
||||
collection.AddAssetCreator(CreateLocalizeLoader(memory, searchPath, zone));
|
||||
collection.AddAssetCreator(localize::CreateLoader(memory, searchPath, zone));
|
||||
collection.AddAssetCreator(weapon::CreateRawLoader(memory, searchPath, zone));
|
||||
collection.AddAssetCreator(weapon::CreateGdtLoader(memory, searchPath, gdt, zone));
|
||||
collection.AddAssetCreator(attachment::CreateRawLoader(memory, searchPath, zone));
|
||||
@@ -428,26 +428,26 @@ namespace T6
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderSoundDriverGlobals>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderFx>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderImpactFx>(memory));
|
||||
collection.AddAssetCreator(CreateRawFileLoader(memory, searchPath));
|
||||
collection.AddAssetCreator(CreateStringTableLoader(memory, searchPath));
|
||||
collection.AddAssetCreator(CreateLeaderboardLoader(memory, searchPath));
|
||||
collection.AddAssetCreator(raw_file::CreateLoader(memory, searchPath));
|
||||
collection.AddAssetCreator(string_table::CreateLoader(memory, searchPath));
|
||||
collection.AddAssetCreator(leaderboard::CreateLoader(memory, searchPath));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderXGlobals>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderDDL>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderGlasses>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderEmblemSet>(memory));
|
||||
collection.AddAssetCreator(CreateScriptLoader(memory, searchPath));
|
||||
collection.AddAssetCreator(CreateRawVehicleLoader(memory, searchPath, zone));
|
||||
collection.AddAssetCreator(CreateGdtVehicleLoader(memory, searchPath, gdt, zone));
|
||||
collection.AddAssetCreator(script::CreateLoader(memory, searchPath));
|
||||
collection.AddAssetCreator(vehicle::CreateRawLoader(memory, searchPath, zone));
|
||||
collection.AddAssetCreator(vehicle::CreateGdtLoader(memory, searchPath, gdt, zone));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderMemoryBlock>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderAddonMapEnts>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderTracer>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderSkinnedVerts>(memory));
|
||||
collection.AddAssetCreator(CreateQdbLoader(memory, searchPath));
|
||||
collection.AddAssetCreator(CreateSlugLoader(memory, searchPath));
|
||||
collection.AddAssetCreator(qdb::CreateLoader(memory, searchPath));
|
||||
collection.AddAssetCreator(slug::CreateLoader(memory, searchPath));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderFootstepTable>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderFootstepFxTable>(memory));
|
||||
collection.AddAssetCreator(CreateRawZBarrierLoader(memory, searchPath, zone));
|
||||
collection.AddAssetCreator(CreateGdtZBarrierLoader(memory, searchPath, gdt, zone));
|
||||
collection.AddAssetCreator(z_barrier::CreateRawLoader(memory, searchPath, zone));
|
||||
collection.AddAssetCreator(z_barrier::CreateGdtLoader(memory, searchPath, gdt, zone));
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
@@ -40,15 +40,14 @@ namespace
|
||||
|
||||
private:
|
||||
IGdtQueryable& m_gdt;
|
||||
InfoStringLoaderPhysConstraints m_info_string_loader;
|
||||
T6::phys_constraints::InfoStringLoader m_info_string_loader;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace T6
|
||||
namespace T6::phys_constraints
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetPhysConstraints>>
|
||||
CreateGdtPhysConstraintsLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone)
|
||||
std::unique_ptr<AssetCreator<AssetPhysConstraints>> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone)
|
||||
{
|
||||
return std::make_unique<GdtLoaderPhysConstraints>(memory, searchPath, gdt, zone);
|
||||
}
|
||||
} // namespace T6
|
||||
} // namespace T6::phys_constraints
|
||||
|
@@ -8,8 +8,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace T6
|
||||
namespace T6::phys_constraints
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetPhysConstraints>>
|
||||
CreateGdtPhysConstraintsLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone);
|
||||
} // namespace T6
|
||||
std::unique_ptr<AssetCreator<AssetPhysConstraints>> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone);
|
||||
} // namespace T6::phys_constraints
|
||||
|
@@ -76,35 +76,38 @@ namespace
|
||||
}
|
||||
} // namespace
|
||||
|
||||
InfoStringLoaderPhysConstraints::InfoStringLoaderPhysConstraints(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
|
||||
: m_memory(memory),
|
||||
m_search_path(searchPath),
|
||||
m_zone(zone)
|
||||
namespace T6::phys_constraints
|
||||
{
|
||||
}
|
||||
|
||||
AssetCreationResult InfoStringLoaderPhysConstraints::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context)
|
||||
{
|
||||
auto* physConstraints = m_memory.Alloc<PhysConstraints>();
|
||||
physConstraints->name = m_memory.Dup(assetName.c_str());
|
||||
|
||||
AssetRegistration<AssetPhysConstraints> registration(assetName, physConstraints);
|
||||
InfoStringToPhysConstraintsConverter converter(infoString,
|
||||
*physConstraints,
|
||||
m_zone.m_script_strings,
|
||||
m_memory,
|
||||
context,
|
||||
registration,
|
||||
phys_constraints_fields,
|
||||
std::extent_v<decltype(phys_constraints_fields)>);
|
||||
if (!converter.Convert())
|
||||
InfoStringLoader::InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
|
||||
: m_memory(memory),
|
||||
m_search_path(searchPath),
|
||||
m_zone(zone)
|
||||
{
|
||||
std::cerr << std::format("Failed to parse phys constraints: \"{}\"\n", assetName);
|
||||
return AssetCreationResult::Failure();
|
||||
}
|
||||
|
||||
CalculatePhysConstraintsFields(*physConstraints, m_zone.m_script_strings);
|
||||
registration.AddScriptString(m_zone.m_script_strings.AddOrGetScriptString(""));
|
||||
AssetCreationResult InfoStringLoader::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context)
|
||||
{
|
||||
auto* physConstraints = m_memory.Alloc<PhysConstraints>();
|
||||
physConstraints->name = m_memory.Dup(assetName.c_str());
|
||||
|
||||
return AssetCreationResult::Success(context.AddAsset(std::move(registration)));
|
||||
}
|
||||
AssetRegistration<AssetPhysConstraints> registration(assetName, physConstraints);
|
||||
InfoStringToPhysConstraintsConverter converter(infoString,
|
||||
*physConstraints,
|
||||
m_zone.m_script_strings,
|
||||
m_memory,
|
||||
context,
|
||||
registration,
|
||||
phys_constraints_fields,
|
||||
std::extent_v<decltype(phys_constraints_fields)>);
|
||||
if (!converter.Convert())
|
||||
{
|
||||
std::cerr << std::format("Failed to parse phys constraints: \"{}\"\n", assetName);
|
||||
return AssetCreationResult::Failure();
|
||||
}
|
||||
|
||||
CalculatePhysConstraintsFields(*physConstraints, m_zone.m_script_strings);
|
||||
registration.AddScriptString(m_zone.m_script_strings.AddOrGetScriptString(""));
|
||||
|
||||
return AssetCreationResult::Success(context.AddAsset(std::move(registration)));
|
||||
}
|
||||
} // namespace T6::phys_constraints
|
||||
|
@@ -4,12 +4,12 @@
|
||||
#include "Asset/AssetCreationResult.h"
|
||||
#include "InfoString/InfoString.h"
|
||||
|
||||
namespace T6
|
||||
namespace T6::phys_constraints
|
||||
{
|
||||
class InfoStringLoaderPhysConstraints
|
||||
class InfoStringLoader
|
||||
{
|
||||
public:
|
||||
InfoStringLoaderPhysConstraints(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
|
||||
InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
|
||||
|
||||
AssetCreationResult CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context);
|
||||
|
||||
@@ -18,4 +18,4 @@ namespace T6
|
||||
ISearchPath& m_search_path;
|
||||
Zone& m_zone;
|
||||
};
|
||||
} // namespace T6
|
||||
} // namespace T6::phys_constraints
|
||||
|
@@ -11,6 +11,7 @@
|
||||
#include <iostream>
|
||||
|
||||
using namespace T6;
|
||||
using namespace ::phys_constraints;
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -25,7 +26,7 @@ namespace
|
||||
|
||||
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
|
||||
{
|
||||
const auto fileName = phys_constraints::GetFileNameForAssetName(assetName);
|
||||
const auto fileName = GetFileNameForAssetName(assetName);
|
||||
const auto file = m_search_path.Open(fileName);
|
||||
if (!file.IsOpen())
|
||||
return AssetCreationResult::NoAction();
|
||||
@@ -42,14 +43,14 @@ namespace
|
||||
|
||||
private:
|
||||
ISearchPath& m_search_path;
|
||||
InfoStringLoaderPhysConstraints m_info_string_loader;
|
||||
T6::phys_constraints::InfoStringLoader m_info_string_loader;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace T6
|
||||
namespace T6::phys_constraints
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetPhysConstraints>> CreateRawPhysConstraintsLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
|
||||
std::unique_ptr<AssetCreator<AssetPhysConstraints>> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
|
||||
{
|
||||
return std::make_unique<RawLoaderPhysConstraints>(memory, searchPath, zone);
|
||||
}
|
||||
} // namespace T6
|
||||
} // namespace T6::phys_constraints
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace T6
|
||||
namespace T6::phys_constraints
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetPhysConstraints>> CreateRawPhysConstraintsLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
|
||||
} // namespace T6
|
||||
std::unique_ptr<AssetCreator<AssetPhysConstraints>> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
|
||||
} // namespace T6::phys_constraints
|
||||
|
@@ -16,15 +16,15 @@ namespace
|
||||
class GdtLoaderPhysPreset final : public AssetCreator<AssetPhysPreset>
|
||||
{
|
||||
public:
|
||||
GdtLoaderPhysPreset(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone)
|
||||
GdtLoaderPhysPreset(MemoryManager& memory, IGdtQueryable& gdt, Zone& zone)
|
||||
: m_gdt(gdt),
|
||||
m_info_string_loader(memory, searchPath, zone)
|
||||
m_info_string_loader(memory, zone)
|
||||
{
|
||||
}
|
||||
|
||||
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
|
||||
{
|
||||
const auto* gdtEntry = m_gdt.GetGdtEntryByGdfAndName(ObjConstants::GDF_FILENAME_WEAPON, assetName);
|
||||
const auto* gdtEntry = m_gdt.GetGdtEntryByGdfAndName(ObjConstants::GDF_FILENAME_PHYS_PRESET, assetName);
|
||||
if (gdtEntry == nullptr)
|
||||
return AssetCreationResult::NoAction();
|
||||
|
||||
@@ -40,14 +40,14 @@ namespace
|
||||
|
||||
private:
|
||||
IGdtQueryable& m_gdt;
|
||||
InfoStringLoaderPhysPreset m_info_string_loader;
|
||||
T6::phys_preset::InfoStringLoader m_info_string_loader;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace T6
|
||||
namespace T6::phys_preset
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetPhysPreset>> CreateGdtPhysPresetLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone)
|
||||
std::unique_ptr<AssetCreator<AssetPhysPreset>> CreateGdtLoader(MemoryManager& memory, IGdtQueryable& gdt, Zone& zone)
|
||||
{
|
||||
return std::make_unique<GdtLoaderPhysPreset>(memory, searchPath, gdt, zone);
|
||||
return std::make_unique<GdtLoaderPhysPreset>(memory, gdt, zone);
|
||||
}
|
||||
} // namespace T6
|
||||
} // namespace T6::phys_preset
|
||||
|
@@ -8,7 +8,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace T6
|
||||
namespace T6::phys_preset
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetPhysPreset>> CreateGdtPhysPresetLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone);
|
||||
} // namespace T6
|
||||
std::unique_ptr<AssetCreator<AssetPhysPreset>> CreateGdtLoader(MemoryManager& memory, IGdtQueryable& gdt, Zone& zone);
|
||||
} // namespace T6::phys_preset
|
||||
|
@@ -60,31 +60,39 @@ namespace
|
||||
}
|
||||
} // namespace
|
||||
|
||||
InfoStringLoaderPhysPreset::InfoStringLoaderPhysPreset(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
|
||||
: m_memory(memory),
|
||||
m_search_path(searchPath),
|
||||
m_zone(zone)
|
||||
namespace T6::phys_preset
|
||||
{
|
||||
}
|
||||
|
||||
AssetCreationResult InfoStringLoaderPhysPreset::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context)
|
||||
{
|
||||
auto* physPreset = m_memory.Alloc<PhysPreset>();
|
||||
physPreset->name = m_memory.Dup(assetName.c_str());
|
||||
|
||||
AssetRegistration<AssetPhysPreset> registration(assetName, physPreset);
|
||||
|
||||
PhysPresetInfo physPresetInfo;
|
||||
memset(&physPresetInfo, 0, sizeof(physPresetInfo));
|
||||
InfoStringToPhysPresetConverter converter(
|
||||
infoString, physPresetInfo, m_zone.m_script_strings, m_memory, context, registration, phys_preset_fields, std::extent_v<decltype(phys_preset_fields)>);
|
||||
if (!converter.Convert())
|
||||
InfoStringLoader::InfoStringLoader(MemoryManager& memory, Zone& zone)
|
||||
: m_memory(memory),
|
||||
m_zone(zone)
|
||||
{
|
||||
std::cerr << std::format("Failed to parse phys preset: \"{}\"\n", assetName);
|
||||
return AssetCreationResult::Failure();
|
||||
}
|
||||
|
||||
CopyFromPhysPresetInfo(physPresetInfo, *physPreset);
|
||||
AssetCreationResult InfoStringLoader::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context)
|
||||
{
|
||||
auto* physPreset = m_memory.Alloc<PhysPreset>();
|
||||
physPreset->name = m_memory.Dup(assetName.c_str());
|
||||
|
||||
return AssetCreationResult::Success(context.AddAsset(std::move(registration)));
|
||||
}
|
||||
AssetRegistration<AssetPhysPreset> registration(assetName, physPreset);
|
||||
|
||||
PhysPresetInfo physPresetInfo;
|
||||
memset(&physPresetInfo, 0, sizeof(physPresetInfo));
|
||||
InfoStringToPhysPresetConverter converter(infoString,
|
||||
physPresetInfo,
|
||||
m_zone.m_script_strings,
|
||||
m_memory,
|
||||
context,
|
||||
registration,
|
||||
phys_preset_fields,
|
||||
std::extent_v<decltype(phys_preset_fields)>);
|
||||
if (!converter.Convert())
|
||||
{
|
||||
std::cerr << std::format("Failed to parse phys preset: \"{}\"\n", assetName);
|
||||
return AssetCreationResult::Failure();
|
||||
}
|
||||
|
||||
CopyFromPhysPresetInfo(physPresetInfo, *physPreset);
|
||||
|
||||
return AssetCreationResult::Success(context.AddAsset(std::move(registration)));
|
||||
}
|
||||
} // namespace T6::phys_preset
|
||||
|
@@ -4,18 +4,17 @@
|
||||
#include "Asset/AssetCreationResult.h"
|
||||
#include "InfoString/InfoString.h"
|
||||
|
||||
namespace T6
|
||||
namespace T6::phys_preset
|
||||
{
|
||||
class InfoStringLoaderPhysPreset
|
||||
class InfoStringLoader
|
||||
{
|
||||
public:
|
||||
InfoStringLoaderPhysPreset(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
|
||||
InfoStringLoader(MemoryManager& memory, Zone& zone);
|
||||
|
||||
AssetCreationResult CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context);
|
||||
|
||||
private:
|
||||
MemoryManager& m_memory;
|
||||
ISearchPath& m_search_path;
|
||||
Zone& m_zone;
|
||||
};
|
||||
} // namespace T6
|
||||
} // namespace T6::phys_preset
|
||||
|
@@ -11,6 +11,7 @@
|
||||
#include <iostream>
|
||||
|
||||
using namespace T6;
|
||||
using namespace ::phys_preset;
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -19,13 +20,13 @@ namespace
|
||||
public:
|
||||
RawLoaderPhysPreset(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
|
||||
: m_search_path(searchPath),
|
||||
m_info_string_loader(memory, searchPath, zone)
|
||||
m_info_string_loader(memory, zone)
|
||||
{
|
||||
}
|
||||
|
||||
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
|
||||
{
|
||||
const auto fileName = phys_preset::GetFileNameForAssetName(assetName);
|
||||
const auto fileName = GetFileNameForAssetName(assetName);
|
||||
const auto file = m_search_path.Open(fileName);
|
||||
if (!file.IsOpen())
|
||||
return AssetCreationResult::NoAction();
|
||||
@@ -42,14 +43,14 @@ namespace
|
||||
|
||||
private:
|
||||
ISearchPath& m_search_path;
|
||||
InfoStringLoaderPhysPreset m_info_string_loader;
|
||||
T6::phys_preset::InfoStringLoader m_info_string_loader;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace T6
|
||||
namespace T6::phys_preset
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetPhysPreset>> CreateRawPhysPresetLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
|
||||
std::unique_ptr<AssetCreator<AssetPhysPreset>> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
|
||||
{
|
||||
return std::make_unique<RawLoaderPhysPreset>(memory, searchPath, zone);
|
||||
}
|
||||
} // namespace T6
|
||||
} // namespace T6::phys_preset
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace T6
|
||||
namespace T6::phys_preset
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetPhysPreset>> CreateRawPhysPresetLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
|
||||
} // namespace T6
|
||||
std::unique_ptr<AssetCreator<AssetPhysPreset>> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
|
||||
} // namespace T6::phys_preset
|
||||
|
@@ -44,10 +44,10 @@ namespace
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace T6
|
||||
namespace T6::qdb
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetQdb>> CreateQdbLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
std::unique_ptr<AssetCreator<AssetQdb>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
{
|
||||
return std::make_unique<QdbLoader>(memory, searchPath);
|
||||
}
|
||||
} // namespace T6
|
||||
} // namespace T6::qdb
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace T6
|
||||
namespace T6::qdb
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetQdb>> CreateQdbLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace T6
|
||||
std::unique_ptr<AssetCreator<AssetQdb>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace T6::qdb
|
||||
|
@@ -114,10 +114,10 @@ namespace
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace T6
|
||||
namespace T6::raw_file
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetRawFile>> CreateRawFileLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
std::unique_ptr<AssetCreator<AssetRawFile>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
{
|
||||
return std::make_unique<RawFileLoader>(memory, searchPath);
|
||||
}
|
||||
} // namespace T6
|
||||
} // namespace T6::raw_file
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace T6
|
||||
namespace T6::raw_file
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetRawFile>> CreateRawFileLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace T6
|
||||
std::unique_ptr<AssetCreator<AssetRawFile>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace T6::raw_file
|
||||
|
@@ -44,10 +44,10 @@ namespace
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace T6
|
||||
namespace T6::script
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetScript>> CreateScriptLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
std::unique_ptr<AssetCreator<AssetScript>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
{
|
||||
return std::make_unique<ScriptLoader>(memory, searchPath);
|
||||
}
|
||||
} // namespace T6
|
||||
} // namespace T6::script
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace T6
|
||||
namespace T6::script
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetScript>> CreateScriptLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace T6
|
||||
std::unique_ptr<AssetCreator<AssetScript>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace T6::script
|
||||
|
@@ -44,10 +44,10 @@ namespace
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace T6
|
||||
namespace T6::slug
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetSlug>> CreateSlugLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
std::unique_ptr<AssetCreator<AssetSlug>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
{
|
||||
return std::make_unique<SlugLoader>(memory, searchPath);
|
||||
}
|
||||
} // namespace T6
|
||||
} // namespace T6::slug
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace T6
|
||||
namespace T6::slug
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetSlug>> CreateSlugLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace T6
|
||||
std::unique_ptr<AssetCreator<AssetSlug>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace T6::slug
|
||||
|
@@ -8,6 +8,7 @@
|
||||
#include <cstring>
|
||||
|
||||
using namespace T6;
|
||||
using namespace ::string_table;
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -26,7 +27,7 @@ namespace
|
||||
if (!file.IsOpen())
|
||||
return AssetCreationResult::NoAction();
|
||||
|
||||
string_table::StringTableLoaderV3<StringTable, Common::Com_HashString> loader;
|
||||
StringTableLoaderV3<StringTable, Common::Com_HashString> loader;
|
||||
auto* stringTable = loader.LoadFromStream(assetName, m_memory, *file.m_stream);
|
||||
|
||||
return AssetCreationResult::Success(context.AddAsset<AssetStringTable>(assetName, stringTable));
|
||||
@@ -38,10 +39,10 @@ namespace
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace T6
|
||||
namespace T6::string_table
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetStringTable>> CreateStringTableLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
std::unique_ptr<AssetCreator<AssetStringTable>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
{
|
||||
return std::make_unique<StringTableLoader>(memory, searchPath);
|
||||
}
|
||||
} // namespace T6
|
||||
} // namespace T6::string_table
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace T6
|
||||
namespace T6::string_table
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetStringTable>> CreateStringTableLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace T6
|
||||
std::unique_ptr<AssetCreator<AssetStringTable>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace T6::string_table
|
||||
|
@@ -40,14 +40,14 @@ namespace
|
||||
|
||||
private:
|
||||
IGdtQueryable& m_gdt;
|
||||
InfoStringLoaderTracer m_info_string_loader;
|
||||
T6::tracer::InfoStringLoader m_info_string_loader;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace T6
|
||||
namespace T6::tracer
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetTracer>> CreateGdtTracerLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone)
|
||||
std::unique_ptr<AssetCreator<AssetTracer>> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone)
|
||||
{
|
||||
return std::make_unique<GdtLoaderTracer>(memory, searchPath, gdt, zone);
|
||||
}
|
||||
} // namespace T6
|
||||
} // namespace T6::tracer
|
||||
|
@@ -8,7 +8,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace T6
|
||||
namespace T6::tracer
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetTracer>> CreateGdtTracerLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone);
|
||||
} // namespace T6
|
||||
std::unique_ptr<AssetCreator<AssetTracer>> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone);
|
||||
} // namespace T6::tracer
|
||||
|
@@ -3,6 +3,7 @@
|
||||
#include "Game/T6/InfoString/InfoStringToStructConverter.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "Game/T6/Tracer/TracerFields.h"
|
||||
#include "Tracer/TracerCommon.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
@@ -11,6 +12,7 @@
|
||||
#include <limits>
|
||||
|
||||
using namespace T6;
|
||||
using namespace ::tracer;
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -46,27 +48,31 @@ namespace
|
||||
};
|
||||
} // namespace
|
||||
|
||||
InfoStringLoaderTracer::InfoStringLoaderTracer(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
|
||||
: m_memory(memory),
|
||||
m_search_path(searchPath),
|
||||
m_zone(zone)
|
||||
namespace T6::tracer
|
||||
{
|
||||
}
|
||||
|
||||
AssetCreationResult InfoStringLoaderTracer::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context)
|
||||
{
|
||||
auto* tracer = m_memory.Alloc<TracerDef>();
|
||||
tracer->name = m_memory.Dup(assetName.c_str());
|
||||
|
||||
AssetRegistration<AssetTracer> registration(assetName, tracer);
|
||||
|
||||
InfoStringToTracerConverter converter(
|
||||
infoString, *tracer, m_zone.m_script_strings, m_memory, context, registration, tracer_fields, std::extent_v<decltype(tracer_fields)>);
|
||||
if (!converter.Convert())
|
||||
InfoStringLoader::InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
|
||||
: m_memory(memory),
|
||||
m_search_path(searchPath),
|
||||
m_zone(zone)
|
||||
{
|
||||
std::cerr << std::format("Failed to parse tracer: \"{}\"\n", assetName);
|
||||
return AssetCreationResult::Failure();
|
||||
}
|
||||
|
||||
return AssetCreationResult::Success(context.AddAsset(std::move(registration)));
|
||||
}
|
||||
AssetCreationResult InfoStringLoader::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context)
|
||||
{
|
||||
auto* tracer = m_memory.Alloc<TracerDef>();
|
||||
tracer->name = m_memory.Dup(assetName.c_str());
|
||||
|
||||
AssetRegistration<AssetTracer> registration(assetName, tracer);
|
||||
|
||||
InfoStringToTracerConverter converter(
|
||||
infoString, *tracer, m_zone.m_script_strings, m_memory, context, registration, tracer_fields, std::extent_v<decltype(tracer_fields)>);
|
||||
if (!converter.Convert())
|
||||
{
|
||||
std::cerr << std::format("Failed to parse tracer: \"{}\"\n", assetName);
|
||||
return AssetCreationResult::Failure();
|
||||
}
|
||||
|
||||
return AssetCreationResult::Success(context.AddAsset(std::move(registration)));
|
||||
}
|
||||
|
||||
} // namespace T6::tracer
|
||||
|
@@ -4,12 +4,12 @@
|
||||
#include "Asset/AssetCreationResult.h"
|
||||
#include "InfoString/InfoString.h"
|
||||
|
||||
namespace T6
|
||||
namespace T6::tracer
|
||||
{
|
||||
class InfoStringLoaderTracer
|
||||
class InfoStringLoader
|
||||
{
|
||||
public:
|
||||
InfoStringLoaderTracer(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
|
||||
InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
|
||||
|
||||
AssetCreationResult CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context);
|
||||
|
||||
@@ -18,4 +18,4 @@ namespace T6
|
||||
ISearchPath& m_search_path;
|
||||
Zone& m_zone;
|
||||
};
|
||||
} // namespace T6
|
||||
} // namespace T6::tracer
|
||||
|
@@ -43,14 +43,14 @@ namespace
|
||||
|
||||
private:
|
||||
ISearchPath& m_search_path;
|
||||
InfoStringLoaderTracer m_info_string_loader;
|
||||
T6::tracer::InfoStringLoader m_info_string_loader;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace T6
|
||||
namespace T6::tracer
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetTracer>> CreateRawTracerLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
|
||||
std::unique_ptr<AssetCreator<AssetTracer>> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
|
||||
{
|
||||
return std::make_unique<RawLoaderTracer>(memory, searchPath, zone);
|
||||
}
|
||||
} // namespace T6
|
||||
} // namespace T6::tracer
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace T6
|
||||
namespace T6::tracer
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetTracer>> CreateRawTracerLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
|
||||
} // namespace T6
|
||||
std::unique_ptr<AssetCreator<AssetTracer>> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
|
||||
} // namespace T6::tracer
|
||||
|
@@ -40,14 +40,14 @@ namespace
|
||||
|
||||
private:
|
||||
IGdtQueryable& m_gdt;
|
||||
InfoStringLoaderVehicle m_info_string_loader;
|
||||
T6::vehicle::InfoStringLoader m_info_string_loader;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace T6
|
||||
namespace T6::vehicle
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetVehicle>> CreateGdtVehicleLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone)
|
||||
std::unique_ptr<AssetCreator<AssetVehicle>> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone)
|
||||
{
|
||||
return std::make_unique<GdtLoaderVehicle>(memory, searchPath, gdt, zone);
|
||||
}
|
||||
} // namespace T6
|
||||
} // namespace T6::vehicle
|
||||
|
@@ -8,7 +8,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace T6
|
||||
namespace T6::vehicle
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetVehicle>> CreateGdtVehicleLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone);
|
||||
} // namespace T6
|
||||
std::unique_ptr<AssetCreator<AssetVehicle>> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone);
|
||||
} // namespace T6::vehicle
|
||||
|
@@ -107,27 +107,30 @@ namespace
|
||||
};
|
||||
} // namespace
|
||||
|
||||
InfoStringLoaderVehicle::InfoStringLoaderVehicle(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
|
||||
: m_memory(memory),
|
||||
m_search_path(searchPath),
|
||||
m_zone(zone)
|
||||
namespace T6::vehicle
|
||||
{
|
||||
}
|
||||
|
||||
AssetCreationResult InfoStringLoaderVehicle::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context)
|
||||
{
|
||||
auto* vehicleDef = m_memory.Alloc<VehicleDef>();
|
||||
vehicleDef->name = m_memory.Dup(assetName.c_str());
|
||||
|
||||
AssetRegistration<AssetVehicle> registration(assetName, vehicleDef);
|
||||
|
||||
InfoStringToVehicleConverter converter(
|
||||
infoString, *vehicleDef, m_zone.m_script_strings, m_memory, context, registration, vehicle_fields, std::extent_v<decltype(vehicle_fields)>);
|
||||
if (!converter.Convert())
|
||||
InfoStringLoader::InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
|
||||
: m_memory(memory),
|
||||
m_search_path(searchPath),
|
||||
m_zone(zone)
|
||||
{
|
||||
std::cerr << std::format("Failed to parse vehicle: \"{}\"\n", assetName);
|
||||
return AssetCreationResult::Failure();
|
||||
}
|
||||
|
||||
return AssetCreationResult::Success(context.AddAsset(std::move(registration)));
|
||||
}
|
||||
AssetCreationResult InfoStringLoader::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context)
|
||||
{
|
||||
auto* vehicleDef = m_memory.Alloc<VehicleDef>();
|
||||
vehicleDef->name = m_memory.Dup(assetName.c_str());
|
||||
|
||||
AssetRegistration<AssetVehicle> registration(assetName, vehicleDef);
|
||||
|
||||
InfoStringToVehicleConverter converter(
|
||||
infoString, *vehicleDef, m_zone.m_script_strings, m_memory, context, registration, vehicle_fields, std::extent_v<decltype(vehicle_fields)>);
|
||||
if (!converter.Convert())
|
||||
{
|
||||
std::cerr << std::format("Failed to parse vehicle: \"{}\"\n", assetName);
|
||||
return AssetCreationResult::Failure();
|
||||
}
|
||||
|
||||
return AssetCreationResult::Success(context.AddAsset(std::move(registration)));
|
||||
}
|
||||
} // namespace T6::vehicle
|
||||
|
@@ -4,12 +4,12 @@
|
||||
#include "Asset/AssetCreationResult.h"
|
||||
#include "InfoString/InfoString.h"
|
||||
|
||||
namespace T6
|
||||
namespace T6::vehicle
|
||||
{
|
||||
class InfoStringLoaderVehicle
|
||||
class InfoStringLoader
|
||||
{
|
||||
public:
|
||||
InfoStringLoaderVehicle(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
|
||||
InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
|
||||
|
||||
AssetCreationResult CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context);
|
||||
|
||||
@@ -18,4 +18,4 @@ namespace T6
|
||||
ISearchPath& m_search_path;
|
||||
Zone& m_zone;
|
||||
};
|
||||
} // namespace T6
|
||||
} // namespace T6::vehicle
|
||||
|
@@ -43,14 +43,14 @@ namespace
|
||||
|
||||
private:
|
||||
ISearchPath& m_search_path;
|
||||
InfoStringLoaderVehicle m_info_string_loader;
|
||||
T6::vehicle::InfoStringLoader m_info_string_loader;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace T6
|
||||
namespace T6::vehicle
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetVehicle>> CreateRawVehicleLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
|
||||
std::unique_ptr<AssetCreator<AssetVehicle>> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
|
||||
{
|
||||
return std::make_unique<RawLoaderVehicle>(memory, searchPath, zone);
|
||||
}
|
||||
} // namespace T6
|
||||
} // namespace T6::vehicle
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace T6
|
||||
namespace T6::vehicle
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetVehicle>> CreateRawVehicleLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
|
||||
} // namespace T6
|
||||
std::unique_ptr<AssetCreator<AssetVehicle>> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
|
||||
} // namespace T6::vehicle
|
||||
|
@@ -40,14 +40,14 @@ namespace
|
||||
|
||||
private:
|
||||
IGdtQueryable& m_gdt;
|
||||
InfoStringLoaderZBarrier m_info_string_loader;
|
||||
T6::z_barrier::InfoStringLoader m_info_string_loader;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace T6
|
||||
namespace T6::z_barrier
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetZBarrier>> CreateGdtZBarrierLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone)
|
||||
std::unique_ptr<AssetCreator<AssetZBarrier>> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone)
|
||||
{
|
||||
return std::make_unique<GdtLoaderZBarrier>(memory, searchPath, gdt, zone);
|
||||
}
|
||||
} // namespace T6
|
||||
} // namespace T6::z_barrier
|
||||
|
@@ -8,7 +8,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace T6
|
||||
namespace T6::z_barrier
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetZBarrier>> CreateGdtZBarrierLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone);
|
||||
} // namespace T6
|
||||
std::unique_ptr<AssetCreator<AssetZBarrier>> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone);
|
||||
} // namespace T6::z_barrier
|
||||
|
@@ -55,29 +55,32 @@ namespace
|
||||
}
|
||||
} // namespace
|
||||
|
||||
InfoStringLoaderZBarrier::InfoStringLoaderZBarrier(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
|
||||
: m_memory(memory),
|
||||
m_search_path(searchPath),
|
||||
m_zone(zone)
|
||||
namespace T6::z_barrier
|
||||
{
|
||||
}
|
||||
|
||||
AssetCreationResult InfoStringLoaderZBarrier::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context)
|
||||
{
|
||||
auto* zbarrier = m_memory.Alloc<ZBarrierDef>();
|
||||
zbarrier->name = m_memory.Dup(assetName.c_str());
|
||||
|
||||
AssetRegistration<AssetZBarrier> registration(assetName, zbarrier);
|
||||
|
||||
InfoStringToZBarrierConverter converter(
|
||||
infoString, *zbarrier, m_zone.m_script_strings, m_memory, context, registration, zbarrier_fields, std::extent_v<decltype(zbarrier_fields)>);
|
||||
if (!converter.Convert())
|
||||
InfoStringLoader::InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
|
||||
: m_memory(memory),
|
||||
m_search_path(searchPath),
|
||||
m_zone(zone)
|
||||
{
|
||||
std::cerr << std::format("Failed to parse zbarrier: \"{}\"\n", assetName);
|
||||
return AssetCreationResult::Failure();
|
||||
}
|
||||
|
||||
CalculateZBarrierFields(*zbarrier);
|
||||
AssetCreationResult InfoStringLoader::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context)
|
||||
{
|
||||
auto* zbarrier = m_memory.Alloc<ZBarrierDef>();
|
||||
zbarrier->name = m_memory.Dup(assetName.c_str());
|
||||
|
||||
return AssetCreationResult::Success(context.AddAsset(std::move(registration)));
|
||||
}
|
||||
AssetRegistration<AssetZBarrier> registration(assetName, zbarrier);
|
||||
|
||||
InfoStringToZBarrierConverter converter(
|
||||
infoString, *zbarrier, m_zone.m_script_strings, m_memory, context, registration, zbarrier_fields, std::extent_v<decltype(zbarrier_fields)>);
|
||||
if (!converter.Convert())
|
||||
{
|
||||
std::cerr << std::format("Failed to parse zbarrier: \"{}\"\n", assetName);
|
||||
return AssetCreationResult::Failure();
|
||||
}
|
||||
|
||||
CalculateZBarrierFields(*zbarrier);
|
||||
|
||||
return AssetCreationResult::Success(context.AddAsset(std::move(registration)));
|
||||
}
|
||||
} // namespace T6::z_barrier
|
||||
|
@@ -4,12 +4,12 @@
|
||||
#include "Asset/AssetCreationResult.h"
|
||||
#include "InfoString/InfoString.h"
|
||||
|
||||
namespace T6
|
||||
namespace T6::z_barrier
|
||||
{
|
||||
class InfoStringLoaderZBarrier
|
||||
class InfoStringLoader
|
||||
{
|
||||
public:
|
||||
InfoStringLoaderZBarrier(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
|
||||
InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
|
||||
|
||||
AssetCreationResult CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context);
|
||||
|
||||
@@ -18,4 +18,4 @@ namespace T6
|
||||
ISearchPath& m_search_path;
|
||||
Zone& m_zone;
|
||||
};
|
||||
} // namespace T6
|
||||
} // namespace T6::z_barrier
|
||||
|
@@ -43,14 +43,14 @@ namespace
|
||||
|
||||
private:
|
||||
ISearchPath& m_search_path;
|
||||
InfoStringLoaderZBarrier m_info_string_loader;
|
||||
T6::z_barrier::InfoStringLoader m_info_string_loader;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace T6
|
||||
namespace T6::z_barrier
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetZBarrier>> CreateRawZBarrierLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
|
||||
std::unique_ptr<AssetCreator<AssetZBarrier>> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
|
||||
{
|
||||
return std::make_unique<RawLoaderZBarrier>(memory, searchPath, zone);
|
||||
}
|
||||
} // namespace T6
|
||||
} // namespace T6::z_barrier
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace T6
|
||||
namespace T6::z_barrier
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetZBarrier>> CreateRawZBarrierLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
|
||||
} // namespace T6
|
||||
std::unique_ptr<AssetCreator<AssetZBarrier>> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
|
||||
} // namespace T6::z_barrier
|
||||
|
@@ -26,7 +26,7 @@ namespace
|
||||
IgnoredAssetLookup ignoredAssetLookup;
|
||||
AssetCreationContext context(zone, &creatorCollection, &ignoredAssetLookup);
|
||||
|
||||
auto loader = CreateStringTableLoader(memory, searchPath);
|
||||
auto loader = string_table::CreateLoader(memory, searchPath);
|
||||
auto result = loader->CreateAsset("mp/cooltable.csv", context);
|
||||
REQUIRE(result.HasBeenSuccessful());
|
||||
|
||||
|
@@ -90,7 +90,7 @@ namespace
|
||||
GivenMaterial("ui_button_xenon_lstick_anim_d", context, memory);
|
||||
GivenMaterial("xenonbutton_ls", context, memory);
|
||||
|
||||
auto loader = CreateJsonFontIconLoader(memory, searchPath);
|
||||
auto loader = font_icon::CreateJsonLoader(memory, searchPath);
|
||||
auto result = loader->CreateAsset("fonticon/test.csv", context);
|
||||
REQUIRE(result.HasBeenSuccessful());
|
||||
|
||||
|
@@ -253,7 +253,7 @@ namespace
|
||||
GivenImage("~-gmetal_ac_duct_c", context, memory);
|
||||
GivenTechset("wpc_lit_sm_r0c0n0s0_1zzj1138", context, memory);
|
||||
|
||||
auto loader = CreateMaterialLoader(memory, searchPath);
|
||||
auto loader = material::CreateLoader(memory, searchPath);
|
||||
auto result = loader->CreateAsset("wpc/metal_ac_duct", context);
|
||||
REQUIRE(result.HasBeenSuccessful());
|
||||
|
||||
|
Reference in New Issue
Block a user