mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-08-30 21:53:15 +00:00
refactor: streamline IW4 asset loading
This commit is contained in:
11
src/ObjCommon/Sound/SoundCurveCommon.cpp
Normal file
11
src/ObjCommon/Sound/SoundCurveCommon.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#include "SoundCurveCommon.h"
|
||||
|
||||
#include <format>
|
||||
|
||||
namespace sound_curve
|
||||
{
|
||||
std::string GetFileNameForAssetName(const std::string& assetName)
|
||||
{
|
||||
return std::format("soundaliases/{}.vfcurve", assetName);
|
||||
}
|
||||
} // namespace sound_curve
|
8
src/ObjCommon/Sound/SoundCurveCommon.h
Normal file
8
src/ObjCommon/Sound/SoundCurveCommon.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace sound_curve
|
||||
{
|
||||
std::string GetFileNameForAssetName(const std::string& assetName);
|
||||
}
|
@@ -5,6 +5,7 @@
|
||||
#include "Game/IW4/Shader/LoaderVertexShaderIW4.h"
|
||||
#include "Game/IW4/TechsetConstantsIW4.h"
|
||||
#include "Shader/D3D9ShaderAnalyser.h"
|
||||
#include "Shader/ShaderCommon.h"
|
||||
#include "StateMap/StateMapReader.h"
|
||||
#include "Techset/TechniqueFileReader.h"
|
||||
#include "Techset/TechniqueStateMapCache.h"
|
||||
@@ -460,7 +461,8 @@ namespace
|
||||
|
||||
if (pass.m_vertex_shader->Asset()->name && pass.m_vertex_shader->Asset()->name[0] == ',')
|
||||
{
|
||||
pass.m_vertex_shader_info = m_shader_info_cache.LoadShaderInfoFromDisk(m_search_path, GetVertexShaderFileName(vertexShaderName));
|
||||
pass.m_vertex_shader_info =
|
||||
m_shader_info_cache.LoadShaderInfoFromDisk(m_search_path, ::shader::GetFileNameForVertexShaderAssetName(vertexShaderName));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -495,7 +497,8 @@ namespace
|
||||
|
||||
if (pass.m_pixel_shader->Asset()->name && pass.m_pixel_shader->Asset()->name[0] == ',')
|
||||
{
|
||||
pass.m_pixel_shader_info = m_shader_info_cache.LoadShaderInfoFromDisk(m_search_path, GetPixelShaderFileName(pixelShaderName));
|
||||
pass.m_pixel_shader_info =
|
||||
m_shader_info_cache.LoadShaderInfoFromDisk(m_search_path, ::shader::GetFileNameForPixelShaderAssetName(pixelShaderName));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -1,114 +0,0 @@
|
||||
#include "JsonLeaderboardDefLoader.h"
|
||||
|
||||
#include "Game/IW4/CommonIW4.h"
|
||||
#include "Game/IW4/Leaderboard/JsonLeaderboardDef.h"
|
||||
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
using namespace IW4;
|
||||
|
||||
namespace
|
||||
{
|
||||
class JsonLoader
|
||||
{
|
||||
public:
|
||||
JsonLoader(std::istream& stream, MemoryManager& memory)
|
||||
: m_stream(stream),
|
||||
m_memory(memory)
|
||||
{
|
||||
}
|
||||
|
||||
bool Load(LeaderboardDef& leaderboardDef) const
|
||||
{
|
||||
try
|
||||
{
|
||||
const auto jRoot = json::parse(m_stream);
|
||||
std::string type;
|
||||
unsigned version;
|
||||
|
||||
jRoot.at("_type").get_to(type);
|
||||
jRoot.at("_version").get_to(version);
|
||||
|
||||
if (type != "leaderboard" || version != 1u)
|
||||
{
|
||||
std::cerr << std::format("Tried to load leaderboard \"{}\" but did not find expected type leaderboard of version 1\n", leaderboardDef.name);
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto jLeaderboard = jRoot.get<JsonLeaderboardDef>();
|
||||
return CreateLeaderboardFromJson(jLeaderboard, leaderboardDef);
|
||||
}
|
||||
catch (const json::exception& e)
|
||||
{
|
||||
std::cerr << std::format("Failed to parse json of leaderboard: {}\n", e.what());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
bool CreateColumnDefFromJson(const JsonColumnDef& jColumn, LbColumnDef& lbColumnDef, LeaderboardDef& leaderboardDef) const
|
||||
{
|
||||
lbColumnDef.name = m_memory.Dup(jColumn.name.c_str());
|
||||
|
||||
lbColumnDef.id = jColumn.colId;
|
||||
lbColumnDef.propertyId = jColumn.propertyId.value_or(0);
|
||||
lbColumnDef.hidden = jColumn.hidden.value_or(false);
|
||||
|
||||
if (jColumn.statName)
|
||||
lbColumnDef.statName = m_memory.Dup(jColumn.statName->c_str());
|
||||
else
|
||||
lbColumnDef.statName = nullptr;
|
||||
|
||||
lbColumnDef.type = jColumn.type;
|
||||
|
||||
lbColumnDef.precision = jColumn.precision.value_or(0);
|
||||
lbColumnDef.agg = jColumn.aggregationFunction;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CreateLeaderboardFromJson(const JsonLeaderboardDef& jLeaderboardDef, LeaderboardDef& leaderboardDef) const
|
||||
{
|
||||
leaderboardDef.id = jLeaderboardDef.id;
|
||||
|
||||
leaderboardDef.xpColId = jLeaderboardDef.xpColId.value_or(-1);
|
||||
leaderboardDef.prestigeColId = jLeaderboardDef.prestigeColId.value_or(-1);
|
||||
|
||||
if (!jLeaderboardDef.columns.empty())
|
||||
{
|
||||
leaderboardDef.columnCount = static_cast<int>(jLeaderboardDef.columns.size());
|
||||
leaderboardDef.columns = m_memory.Alloc<LbColumnDef>(leaderboardDef.columnCount);
|
||||
|
||||
for (auto i = 0; i < leaderboardDef.columnCount; i++)
|
||||
{
|
||||
if (!CreateColumnDefFromJson(jLeaderboardDef.columns[i], leaderboardDef.columns[i], leaderboardDef))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
leaderboardDef.columnCount = 0;
|
||||
leaderboardDef.columns = nullptr;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::istream& m_stream;
|
||||
MemoryManager& m_memory;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace IW4
|
||||
{
|
||||
bool LoadLeaderboardAsJson(std::istream& stream, LeaderboardDef& leaderboard, MemoryManager* memory)
|
||||
{
|
||||
const JsonLoader loader(stream, *memory);
|
||||
|
||||
return loader.Load(leaderboard);
|
||||
}
|
||||
} // namespace IW4
|
@@ -1,11 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "Utils/MemoryManager.h"
|
||||
|
||||
#include <istream>
|
||||
|
||||
namespace IW4
|
||||
{
|
||||
bool LoadLeaderboardAsJson(std::istream& stream, LeaderboardDef& leaderboard, MemoryManager* memory);
|
||||
} // namespace IW4
|
@@ -1,17 +1,110 @@
|
||||
#include "LoaderLeaderboardIW4.h"
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "JsonLeaderboardDefLoader.h"
|
||||
#include "Game/IW4/Leaderboard/JsonLeaderboardDef.h"
|
||||
#include "Leaderboard/LeaderboardCommon.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
using namespace IW4;
|
||||
using namespace ::leaderboard;
|
||||
|
||||
namespace
|
||||
{
|
||||
class JsonLoader
|
||||
{
|
||||
public:
|
||||
JsonLoader(std::istream& stream, MemoryManager& memory)
|
||||
: m_stream(stream),
|
||||
m_memory(memory)
|
||||
{
|
||||
}
|
||||
|
||||
bool Load(LeaderboardDef& leaderboardDef) const
|
||||
{
|
||||
try
|
||||
{
|
||||
const auto jRoot = json::parse(m_stream);
|
||||
std::string type;
|
||||
unsigned version;
|
||||
|
||||
jRoot.at("_type").get_to(type);
|
||||
jRoot.at("_version").get_to(version);
|
||||
|
||||
if (type != "leaderboard" || version != 1u)
|
||||
{
|
||||
std::cerr << std::format("Tried to load leaderboard \"{}\" but did not find expected type leaderboard of version 1\n", leaderboardDef.name);
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto jLeaderboard = jRoot.get<JsonLeaderboardDef>();
|
||||
return CreateLeaderboardFromJson(jLeaderboard, leaderboardDef);
|
||||
}
|
||||
catch (const json::exception& e)
|
||||
{
|
||||
std::cerr << std::format("Failed to parse json of leaderboard: {}\n", e.what());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
bool CreateColumnDefFromJson(const JsonColumnDef& jColumn, LbColumnDef& lbColumnDef, LeaderboardDef& leaderboardDef) const
|
||||
{
|
||||
lbColumnDef.name = m_memory.Dup(jColumn.name.c_str());
|
||||
|
||||
lbColumnDef.id = jColumn.colId;
|
||||
lbColumnDef.propertyId = jColumn.propertyId.value_or(0);
|
||||
lbColumnDef.hidden = jColumn.hidden.value_or(false);
|
||||
|
||||
if (jColumn.statName)
|
||||
lbColumnDef.statName = m_memory.Dup(jColumn.statName->c_str());
|
||||
else
|
||||
lbColumnDef.statName = nullptr;
|
||||
|
||||
lbColumnDef.type = jColumn.type;
|
||||
|
||||
lbColumnDef.precision = jColumn.precision.value_or(0);
|
||||
lbColumnDef.agg = jColumn.aggregationFunction;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CreateLeaderboardFromJson(const JsonLeaderboardDef& jLeaderboardDef, LeaderboardDef& leaderboardDef) const
|
||||
{
|
||||
leaderboardDef.id = jLeaderboardDef.id;
|
||||
|
||||
leaderboardDef.xpColId = jLeaderboardDef.xpColId.value_or(-1);
|
||||
leaderboardDef.prestigeColId = jLeaderboardDef.prestigeColId.value_or(-1);
|
||||
|
||||
if (!jLeaderboardDef.columns.empty())
|
||||
{
|
||||
leaderboardDef.columnCount = static_cast<int>(jLeaderboardDef.columns.size());
|
||||
leaderboardDef.columns = m_memory.Alloc<LbColumnDef>(leaderboardDef.columnCount);
|
||||
|
||||
for (auto i = 0; i < leaderboardDef.columnCount; i++)
|
||||
{
|
||||
if (!CreateColumnDefFromJson(jLeaderboardDef.columns[i], leaderboardDef.columns[i], leaderboardDef))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
leaderboardDef.columnCount = 0;
|
||||
leaderboardDef.columns = nullptr;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::istream& m_stream;
|
||||
MemoryManager& m_memory;
|
||||
};
|
||||
|
||||
class LeaderboardLoader final : public AssetCreator<AssetLeaderboard>
|
||||
{
|
||||
public:
|
||||
@@ -23,14 +116,15 @@ namespace
|
||||
|
||||
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
|
||||
{
|
||||
const auto file = m_search_path.Open(leaderboard::GetJsonFileNameForAsset(assetName));
|
||||
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());
|
||||
|
||||
if (!LoadLeaderboardAsJson(*file.m_stream, *leaderboardDef, &m_memory))
|
||||
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();
|
||||
@@ -45,10 +139,10 @@ namespace
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace IW4
|
||||
namespace IW4::leaderboard
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetLeaderboard>> CreateLeaderboardLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
std::unique_ptr<AssetCreator<AssetLeaderboard>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
{
|
||||
return std::make_unique<LeaderboardLoader>(memory, searchPath);
|
||||
}
|
||||
} // namespace IW4
|
||||
} // namespace IW4::leaderboard
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace IW4
|
||||
namespace IW4::leaderboard
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetLeaderboard>> CreateLeaderboardLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace IW4
|
||||
std::unique_ptr<AssetCreator<AssetLeaderboard>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace IW4::leaderboard
|
||||
|
@@ -68,10 +68,10 @@ namespace
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace IW4
|
||||
namespace IW4::light_def
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetLightDef>> CreateLightDefLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
std::unique_ptr<AssetCreator<AssetLightDef>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
{
|
||||
return std::make_unique<LoaderLightDef>(memory, searchPath);
|
||||
}
|
||||
} // namespace IW4
|
||||
} // namespace IW4::light_def
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace IW4
|
||||
namespace IW4::light_def
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetLightDef>> CreateLightDefLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace IW4
|
||||
std::unique_ptr<AssetCreator<AssetLightDef>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace IW4::light_def
|
||||
|
@@ -35,10 +35,10 @@ namespace
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace IW4
|
||||
namespace IW4::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 IW4
|
||||
} // namespace IW4::localize
|
||||
|
@@ -8,7 +8,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace IW4
|
||||
namespace IW4::localize
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetLocalize>> CreateLocalizeLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
|
||||
} // namespace IW4
|
||||
std::unique_ptr<AssetCreator<AssetLocalize>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
|
||||
} // namespace IW4::localize
|
||||
|
@@ -8,6 +8,7 @@
|
||||
#include <iostream>
|
||||
|
||||
using namespace IW4;
|
||||
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 IW4
|
||||
namespace IW4::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 IW4
|
||||
} // namespace IW4::material
|
||||
|
@@ -6,7 +6,7 @@
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
#include "Utils/MemoryManager.h"
|
||||
|
||||
namespace IW4
|
||||
namespace IW4::material
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetMaterial>> CreateMaterialLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace IW4
|
||||
std::unique_ptr<AssetCreator<AssetMaterial>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace IW4::material
|
||||
|
@@ -11,6 +11,7 @@
|
||||
#include <iostream>
|
||||
|
||||
using namespace IW4;
|
||||
using namespace ::menu;
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -28,7 +29,7 @@ namespace
|
||||
std::vector<menuDef_t*> menus;
|
||||
AssetRegistration<AssetMenuList> registration(assetName);
|
||||
|
||||
auto& zoneState = context.GetZoneAssetCreationState<menu::MenuAssetZoneState>();
|
||||
auto& zoneState = context.GetZoneAssetCreationState<MenuAssetZoneState>();
|
||||
auto& conversionState = context.GetZoneAssetCreationState<MenuConversionZoneState>();
|
||||
|
||||
std::deque<std::string> menuLoadQueue;
|
||||
@@ -80,7 +81,7 @@ namespace
|
||||
private:
|
||||
bool LoadMenuFileFromQueue(const std::string& menuFilePath,
|
||||
AssetCreationContext& context,
|
||||
menu::MenuAssetZoneState& zoneState,
|
||||
MenuAssetZoneState& zoneState,
|
||||
MenuConversionZoneState& conversionState,
|
||||
std::vector<menuDef_t*>& menus,
|
||||
AssetRegistration<AssetMenuList>& registration) const
|
||||
@@ -121,8 +122,8 @@ namespace
|
||||
|
||||
bool ProcessParsedResults(const std::string& fileName,
|
||||
AssetCreationContext& context,
|
||||
menu::ParsingResult& parsingResult,
|
||||
menu::MenuAssetZoneState& zoneState,
|
||||
ParsingResult& parsingResult,
|
||||
MenuAssetZoneState& zoneState,
|
||||
MenuConversionZoneState& conversionState,
|
||||
std::vector<menuDef_t*>& menus,
|
||||
AssetRegistration<AssetMenuList>& registration) const
|
||||
@@ -196,10 +197,9 @@ namespace
|
||||
menuList.menus = nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<menu::ParsingResult>
|
||||
ParseMenuFile(std::istream& stream, const std::string& menuFileName, const menu::MenuAssetZoneState& zoneState) const
|
||||
std::unique_ptr<ParsingResult> ParseMenuFile(std::istream& stream, const std::string& menuFileName, const MenuAssetZoneState& zoneState) const
|
||||
{
|
||||
menu::MenuFileReader reader(stream, menuFileName, menu::FeatureLevel::IW4, m_search_path);
|
||||
MenuFileReader reader(stream, menuFileName, FeatureLevel::IW4, m_search_path);
|
||||
|
||||
reader.IncludeZoneState(zoneState);
|
||||
reader.SetPermissiveMode(ObjLoading::Configuration.MenuPermissiveParsing);
|
||||
@@ -212,10 +212,10 @@ namespace
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace IW4
|
||||
namespace IW4::menu
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetMenuList>> CreateMenuListLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
{
|
||||
return std::make_unique<MenuListLoader>(memory, searchPath);
|
||||
}
|
||||
} // namespace IW4
|
||||
} // namespace IW4::menu
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace IW4
|
||||
namespace IW4::menu
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetMenuList>> CreateMenuListLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace IW4
|
||||
} // namespace IW4::menu
|
||||
|
@@ -14,7 +14,7 @@ namespace IW4
|
||||
IMenuConverter() = default;
|
||||
virtual ~IMenuConverter() = default;
|
||||
|
||||
virtual void ConvertMenu(const menu::CommonMenuDef& commonMenu, menuDef_t& menu, AssetRegistration<AssetMenu>& registration) = 0;
|
||||
virtual void ConvertMenu(const ::menu::CommonMenuDef& commonMenu, menuDef_t& menu, AssetRegistration<AssetMenu>& registration) = 0;
|
||||
|
||||
static std::unique_ptr<IMenuConverter> Create(bool disableOptimizations, ISearchPath& searchPath, MemoryManager& memory, AssetCreationContext& context);
|
||||
};
|
||||
|
@@ -119,19 +119,19 @@ namespace
|
||||
{
|
||||
auto& memory = zone.Memory();
|
||||
|
||||
collection.AddAssetCreator(std::make_unique<RawLoaderPhysPreset>(memory, searchPath, zone));
|
||||
collection.AddAssetCreator(std::make_unique<GdtLoaderPhysPreset>(memory, gdt, zone));
|
||||
collection.AddAssetCreator(phys_preset::CreateRawLoader(memory, searchPath, zone));
|
||||
collection.AddAssetCreator(phys_preset::CreateGdtLoader(memory, gdt, zone));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderPhysCollMap>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderXAnim>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderXModelSurfs>(memory));
|
||||
collection.AddAssetCreator(xmodel::CreateXModelLoader(memory, searchPath, zone));
|
||||
collection.AddAssetCreator(CreateMaterialLoader(memory, searchPath));
|
||||
collection.AddAssetCreator(CreatePixelShaderLoader(memory, searchPath));
|
||||
collection.AddAssetCreator(CreateVertexShaderLoader(memory, searchPath));
|
||||
collection.AddAssetCreator(material::CreateLoader(memory, searchPath));
|
||||
collection.AddAssetCreator(shader::CreatePixelShaderLoader(memory, searchPath));
|
||||
collection.AddAssetCreator(shader::CreateVertexShaderLoader(memory, searchPath));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderTechset>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderImage>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderSound>(memory));
|
||||
collection.AddAssetCreator(CreateSoundCurveLoader(memory, searchPath));
|
||||
collection.AddAssetCreator(sound_curve::CreateLoader(memory, searchPath));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderLoadedSound>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderClipMap>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderComWorld>(memory));
|
||||
@@ -140,19 +140,19 @@ namespace
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderMapEnts>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderFxWorld>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderGfxWorld>(memory));
|
||||
collection.AddAssetCreator(CreateLightDefLoader(memory, searchPath));
|
||||
collection.AddAssetCreator(light_def::CreateLoader(memory, searchPath));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderFont>(memory));
|
||||
collection.AddAssetCreator(CreateMenuListLoader(memory, searchPath));
|
||||
collection.AddAssetCreator(menu::CreateMenuListLoader(memory, searchPath));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderMenu>(memory));
|
||||
collection.AddAssetCreator(CreateLocalizeLoader(memory, searchPath, zone));
|
||||
collection.AddAssetCreator(CreateRawWeaponLoader(memory, searchPath, zone));
|
||||
collection.AddAssetCreator(CreateGdtWeaponLoader(memory, searchPath, gdt, 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(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(CreateStructuredDataDefLoader(memory, searchPath));
|
||||
collection.AddAssetCreator(raw_file::CreateLoader(memory, searchPath));
|
||||
collection.AddAssetCreator(string_table::CreateLoader(memory, searchPath));
|
||||
collection.AddAssetCreator(leaderboard::CreateLoader(memory, searchPath));
|
||||
collection.AddAssetCreator(structured_data_def::CreateLoader(memory, searchPath));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderTracer>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderVehicle>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderAddonMapEnts>(memory));
|
||||
|
@@ -10,26 +10,43 @@
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
GdtLoaderPhysPreset::GdtLoaderPhysPreset(MemoryManager& memory, IGdtQueryable& gdt, Zone& zone)
|
||||
: m_memory(memory),
|
||||
m_gdt(gdt),
|
||||
m_zone(zone)
|
||||
namespace
|
||||
{
|
||||
}
|
||||
|
||||
AssetCreationResult GdtLoaderPhysPreset::CreateAsset(const std::string& assetName, AssetCreationContext& context)
|
||||
{
|
||||
auto* gdtEntry = m_gdt.GetGdtEntryByGdfAndName(ObjConstants::GDF_FILENAME_PHYS_PRESET, assetName);
|
||||
if (gdtEntry == nullptr)
|
||||
return AssetCreationResult::NoAction();
|
||||
|
||||
InfoString infoString;
|
||||
if (!infoString.FromGdtProperties(*gdtEntry))
|
||||
class GdtLoaderPhysPreset final : public AssetCreator<AssetPhysPreset>
|
||||
{
|
||||
std::cerr << std::format("Failed to read phys preset gdt entry: \"{}\"\n", assetName);
|
||||
return AssetCreationResult::Failure();
|
||||
}
|
||||
public:
|
||||
GdtLoaderPhysPreset(MemoryManager& memory, IGdtQueryable& gdt, Zone& zone)
|
||||
: m_gdt(gdt),
|
||||
m_info_string_loader(memory, zone)
|
||||
{
|
||||
}
|
||||
|
||||
InfoStringLoaderPhysPreset infoStringLoader(m_memory, m_zone);
|
||||
return infoStringLoader.CreateAsset(assetName, infoString, context);
|
||||
}
|
||||
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
|
||||
{
|
||||
const auto* gdtEntry = m_gdt.GetGdtEntryByGdfAndName(ObjConstants::GDF_FILENAME_PHYS_PRESET, assetName);
|
||||
if (gdtEntry == nullptr)
|
||||
return AssetCreationResult::NoAction();
|
||||
|
||||
InfoString infoString;
|
||||
if (!infoString.FromGdtProperties(*gdtEntry))
|
||||
{
|
||||
std::cerr << std::format("Failed to read phys preset gdt entry: \"{}\"\n", assetName);
|
||||
return AssetCreationResult::Failure();
|
||||
}
|
||||
|
||||
return m_info_string_loader.CreateAsset(assetName, infoString, context);
|
||||
}
|
||||
|
||||
private:
|
||||
IGdtQueryable& m_gdt;
|
||||
IW4::phys_preset::InfoStringLoader m_info_string_loader;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace IW4::phys_preset
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetPhysPreset>> CreateGdtLoader(MemoryManager& memory, IGdtQueryable& gdt, Zone& zone)
|
||||
{
|
||||
return std::make_unique<GdtLoaderPhysPreset>(memory, gdt, zone);
|
||||
}
|
||||
} // namespace IW4::phys_preset
|
||||
|
@@ -3,20 +3,12 @@
|
||||
#include "Asset/IAssetCreator.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "Gdt/IGdtQueryable.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
#include "Utils/MemoryManager.h"
|
||||
|
||||
namespace IW4
|
||||
#include <memory>
|
||||
|
||||
namespace IW4::phys_preset
|
||||
{
|
||||
class GdtLoaderPhysPreset final : public AssetCreator<AssetPhysPreset>
|
||||
{
|
||||
public:
|
||||
GdtLoaderPhysPreset(MemoryManager& memory, IGdtQueryable& gdt, Zone& zone);
|
||||
|
||||
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override;
|
||||
|
||||
private:
|
||||
MemoryManager& m_memory;
|
||||
IGdtQueryable& m_gdt;
|
||||
Zone& m_zone;
|
||||
};
|
||||
} // namespace IW4
|
||||
std::unique_ptr<AssetCreator<AssetPhysPreset>> CreateGdtLoader(MemoryManager& memory, IGdtQueryable& gdt, Zone& zone);
|
||||
} // namespace IW4::phys_preset
|
||||
|
@@ -58,30 +58,33 @@ namespace
|
||||
}
|
||||
} // namespace
|
||||
|
||||
InfoStringLoaderPhysPreset::InfoStringLoaderPhysPreset(MemoryManager& memory, Zone& zone)
|
||||
: m_memory(memory),
|
||||
m_zone(zone)
|
||||
namespace IW4::phys_preset
|
||||
{
|
||||
}
|
||||
|
||||
AssetCreationResult InfoStringLoaderPhysPreset::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context)
|
||||
{
|
||||
PhysPresetInfo presetInfo;
|
||||
std::memset(&presetInfo, 0, sizeof(presetInfo));
|
||||
|
||||
auto* physPreset = m_memory.Alloc<PhysPreset>();
|
||||
AssetRegistration<AssetPhysPreset> registration(assetName, physPreset);
|
||||
|
||||
InfoStringToPhysPresetConverter converter(
|
||||
infoString, &presetInfo, 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(presetInfo, *physPreset);
|
||||
physPreset->name = m_memory.Dup(assetName.c_str());
|
||||
AssetCreationResult InfoStringLoader::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context)
|
||||
{
|
||||
PhysPresetInfo presetInfo;
|
||||
std::memset(&presetInfo, 0, sizeof(presetInfo));
|
||||
|
||||
return AssetCreationResult::Success(context.AddAsset(std::move(registration)));
|
||||
}
|
||||
auto* physPreset = m_memory.Alloc<PhysPreset>();
|
||||
AssetRegistration<AssetPhysPreset> registration(assetName, physPreset);
|
||||
|
||||
InfoStringToPhysPresetConverter converter(
|
||||
infoString, &presetInfo, 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(presetInfo, *physPreset);
|
||||
physPreset->name = m_memory.Dup(assetName.c_str());
|
||||
|
||||
return AssetCreationResult::Success(context.AddAsset(std::move(registration)));
|
||||
}
|
||||
} // namespace IW4::phys_preset
|
||||
|
@@ -4,12 +4,12 @@
|
||||
#include "Asset/AssetCreationResult.h"
|
||||
#include "InfoString/InfoString.h"
|
||||
|
||||
namespace IW4
|
||||
namespace IW4::phys_preset
|
||||
{
|
||||
class InfoStringLoaderPhysPreset
|
||||
class InfoStringLoader
|
||||
{
|
||||
public:
|
||||
InfoStringLoaderPhysPreset(MemoryManager& memory, Zone& zone);
|
||||
InfoStringLoader(MemoryManager& memory, Zone& zone);
|
||||
|
||||
AssetCreationResult CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context);
|
||||
|
||||
@@ -17,4 +17,4 @@ namespace IW4
|
||||
MemoryManager& m_memory;
|
||||
Zone& m_zone;
|
||||
};
|
||||
} // namespace IW4
|
||||
} // namespace IW4::phys_preset
|
||||
|
@@ -10,28 +10,46 @@
|
||||
#include <iostream>
|
||||
|
||||
using namespace IW4;
|
||||
using namespace ::phys_preset;
|
||||
|
||||
RawLoaderPhysPreset::RawLoaderPhysPreset(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
|
||||
: m_memory(memory),
|
||||
m_search_path(searchPath),
|
||||
m_zone(zone)
|
||||
namespace
|
||||
{
|
||||
}
|
||||
|
||||
AssetCreationResult RawLoaderPhysPreset::CreateAsset(const std::string& assetName, AssetCreationContext& context)
|
||||
{
|
||||
const auto fileName = phys_preset::GetFileNameForAssetName(assetName);
|
||||
const auto file = m_search_path.Open(fileName);
|
||||
if (!file.IsOpen())
|
||||
return AssetCreationResult::NoAction();
|
||||
|
||||
InfoString infoString;
|
||||
if (!infoString.FromStream(ObjConstants::INFO_STRING_PREFIX_PHYS_PRESET, *file.m_stream))
|
||||
class RawLoaderPhysPreset final : public AssetCreator<AssetPhysPreset>
|
||||
{
|
||||
std::cerr << std::format("Could not parse as info string file: \"{}\"\n", fileName);
|
||||
return AssetCreationResult::Failure();
|
||||
}
|
||||
public:
|
||||
RawLoaderPhysPreset(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
|
||||
: m_search_path(searchPath),
|
||||
m_info_string_loader(memory, zone)
|
||||
{
|
||||
}
|
||||
|
||||
InfoStringLoaderPhysPreset infoStringLoader(m_memory, m_zone);
|
||||
return infoStringLoader.CreateAsset(assetName, infoString, context);
|
||||
}
|
||||
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
|
||||
{
|
||||
const auto fileName = GetFileNameForAssetName(assetName);
|
||||
const auto file = m_search_path.Open(fileName);
|
||||
if (!file.IsOpen())
|
||||
return AssetCreationResult::NoAction();
|
||||
|
||||
InfoString infoString;
|
||||
if (!infoString.FromStream(ObjConstants::INFO_STRING_PREFIX_PHYS_PRESET, *file.m_stream))
|
||||
{
|
||||
std::cerr << std::format("Could not parse as info string file: \"{}\"\n", fileName);
|
||||
return AssetCreationResult::Failure();
|
||||
}
|
||||
|
||||
return m_info_string_loader.CreateAsset(assetName, infoString, context);
|
||||
}
|
||||
|
||||
private:
|
||||
ISearchPath& m_search_path;
|
||||
IW4::phys_preset::InfoStringLoader m_info_string_loader;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace IW4::phys_preset
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetPhysPreset>> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
|
||||
{
|
||||
return std::make_unique<RawLoaderPhysPreset>(memory, searchPath, zone);
|
||||
}
|
||||
} // namespace IW4::phys_preset
|
||||
|
@@ -5,18 +5,9 @@
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
#include "Utils/MemoryManager.h"
|
||||
|
||||
namespace IW4
|
||||
#include <memory>
|
||||
|
||||
namespace IW4::phys_preset
|
||||
{
|
||||
class RawLoaderPhysPreset final : public AssetCreator<AssetPhysPreset>
|
||||
{
|
||||
public:
|
||||
RawLoaderPhysPreset(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
|
||||
|
||||
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override;
|
||||
|
||||
private:
|
||||
MemoryManager& m_memory;
|
||||
ISearchPath& m_search_path;
|
||||
Zone& m_zone;
|
||||
};
|
||||
} // namespace IW4
|
||||
std::unique_ptr<AssetCreator<AssetPhysPreset>> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
|
||||
} // namespace IW4::phys_preset
|
||||
|
@@ -82,10 +82,10 @@ namespace
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace IW4
|
||||
namespace IW4::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 IW4
|
||||
} // namespace IW4::raw_file
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace IW4
|
||||
namespace IW4::raw_file
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetRawFile>> CreateRawFileLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace IW4
|
||||
std::unique_ptr<AssetCreator<AssetRawFile>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace IW4::raw_file
|
||||
|
@@ -1,12 +1,14 @@
|
||||
#include "LoaderPixelShaderIW4.h"
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "Shader/ShaderCommon.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
|
||||
using namespace IW4;
|
||||
using namespace ::shader;
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -21,7 +23,7 @@ namespace
|
||||
|
||||
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
|
||||
{
|
||||
const auto fileName = GetPixelShaderFileName(assetName);
|
||||
const auto fileName = GetFileNameForPixelShaderAssetName(assetName);
|
||||
const auto file = m_search_path.Open(fileName);
|
||||
if (!file.IsOpen())
|
||||
return AssetCreationResult::NoAction();
|
||||
@@ -53,15 +55,10 @@ namespace
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace IW4
|
||||
namespace IW4::shader
|
||||
{
|
||||
std::string GetPixelShaderFileName(const std::string& pixelShaderAssetName)
|
||||
{
|
||||
return std::format("shader_bin/ps_{}.cso", pixelShaderAssetName);
|
||||
}
|
||||
|
||||
std::unique_ptr<AssetCreator<AssetPixelShader>> CreatePixelShaderLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
{
|
||||
return std::make_unique<PixelShaderLoader>(memory, searchPath);
|
||||
}
|
||||
} // namespace IW4
|
||||
} // namespace IW4::shader
|
||||
|
@@ -7,9 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace IW4
|
||||
namespace IW4::shader
|
||||
{
|
||||
[[nodiscard]] std::string GetPixelShaderFileName(const std::string& pixelShaderAssetName);
|
||||
|
||||
std::unique_ptr<AssetCreator<AssetPixelShader>> CreatePixelShaderLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace IW4
|
||||
} // namespace IW4::shader
|
||||
|
@@ -1,12 +1,14 @@
|
||||
#include "LoaderVertexShaderIW4.h"
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "Shader/ShaderCommon.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
|
||||
using namespace IW4;
|
||||
using namespace ::shader;
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -21,7 +23,7 @@ namespace
|
||||
|
||||
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
|
||||
{
|
||||
const auto fileName = GetVertexShaderFileName(assetName);
|
||||
const auto fileName = GetFileNameForVertexShaderAssetName(assetName);
|
||||
const auto file = m_search_path.Open(fileName);
|
||||
if (!file.IsOpen())
|
||||
return AssetCreationResult::NoAction();
|
||||
@@ -53,15 +55,10 @@ namespace
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace IW4
|
||||
namespace IW4::shader
|
||||
{
|
||||
std::string GetVertexShaderFileName(const std::string& vertexShaderAssetName)
|
||||
{
|
||||
return std::format("shader_bin/vs_{}.cso", vertexShaderAssetName);
|
||||
}
|
||||
|
||||
std::unique_ptr<AssetCreator<AssetVertexShader>> CreateVertexShaderLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
{
|
||||
return std::make_unique<VertexShaderLoader>(memory, searchPath);
|
||||
}
|
||||
} // namespace IW4
|
||||
} // namespace IW4::shader
|
||||
|
@@ -7,9 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace IW4
|
||||
namespace IW4::shader
|
||||
{
|
||||
[[nodiscard]] std::string GetVertexShaderFileName(const std::string& vertexShaderAssetName);
|
||||
|
||||
std::unique_ptr<AssetCreator<AssetVertexShader>> CreateVertexShaderLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace IW4
|
||||
} // namespace IW4::shader
|
||||
|
@@ -4,6 +4,7 @@
|
||||
#include "ObjLoading.h"
|
||||
#include "Parsing/Graph2D/Graph2DReader.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
#include "Sound/SoundCurveCommon.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <format>
|
||||
@@ -11,6 +12,7 @@
|
||||
#include <sstream>
|
||||
|
||||
using namespace IW4;
|
||||
using namespace ::sound_curve;
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -25,7 +27,7 @@ namespace
|
||||
|
||||
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
|
||||
{
|
||||
const auto fileName = std::format("soundaliases/{}.vfcurve", assetName);
|
||||
const auto fileName = GetFileNameForAssetName(assetName);
|
||||
const auto file = m_search_path.Open(fileName);
|
||||
if (!file.IsOpen())
|
||||
return AssetCreationResult::NoAction();
|
||||
@@ -69,10 +71,10 @@ namespace
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace IW4
|
||||
namespace IW4::sound_curve
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetSoundCurve>> CreateSoundCurveLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
std::unique_ptr<AssetCreator<AssetSoundCurve>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
{
|
||||
return std::make_unique<LoaderSoundCurve>(memory, searchPath);
|
||||
}
|
||||
} // namespace IW4
|
||||
} // namespace IW4::sound_curve
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace IW4
|
||||
namespace IW4::sound_curve
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetSoundCurve>> CreateSoundCurveLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace IW4
|
||||
std::unique_ptr<AssetCreator<AssetSoundCurve>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace IW4::sound_curve
|
||||
|
@@ -6,6 +6,7 @@
|
||||
#include "StringTable/StringTableLoader.h"
|
||||
|
||||
using namespace IW4;
|
||||
using namespace ::string_table;
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -24,7 +25,7 @@ namespace
|
||||
if (!file.IsOpen())
|
||||
return AssetCreationResult::NoAction();
|
||||
|
||||
string_table::StringTableLoaderV2<StringTable, Common::StringTable_HashString> loader;
|
||||
StringTableLoaderV2<StringTable, Common::StringTable_HashString> loader;
|
||||
auto* stringTable = loader.LoadFromStream(assetName, m_memory, *file.m_stream);
|
||||
if (!stringTable)
|
||||
return AssetCreationResult::Failure();
|
||||
@@ -38,10 +39,10 @@ namespace
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace IW4
|
||||
namespace IW4::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<LoaderStringTable>(memory, searchPath);
|
||||
}
|
||||
} // namespace IW4
|
||||
} // namespace IW4::string_table
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace IW4
|
||||
namespace IW4::string_table
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetStringTable>> CreateStringTableLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace IW4
|
||||
std::unique_ptr<AssetCreator<AssetStringTable>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace IW4::string_table
|
||||
|
@@ -207,10 +207,10 @@ namespace
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace IW4
|
||||
namespace IW4::structured_data_def
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetStructuredDataDef>> CreateStructuredDataDefLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
std::unique_ptr<AssetCreator<AssetStructuredDataDef>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
{
|
||||
return std::make_unique<StructuredDataDefLoader>(memory, searchPath);
|
||||
}
|
||||
} // namespace IW4
|
||||
} // namespace IW4::structured_data_def
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace IW4
|
||||
namespace IW4::structured_data_def
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetStructuredDataDef>> CreateStructuredDataDefLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace IW4
|
||||
std::unique_ptr<AssetCreator<AssetStructuredDataDef>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace IW4::structured_data_def
|
||||
|
@@ -40,14 +40,14 @@ namespace
|
||||
|
||||
private:
|
||||
IGdtQueryable& m_gdt;
|
||||
InfoStringLoaderWeapon m_info_string_loader;
|
||||
IW4::weapon::InfoStringLoader m_info_string_loader;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace IW4
|
||||
namespace IW4::weapon
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetWeapon>> CreateGdtWeaponLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone)
|
||||
std::unique_ptr<AssetCreator<AssetWeapon>> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone)
|
||||
{
|
||||
return std::make_unique<GdtLoaderWeapon>(memory, searchPath, gdt, zone);
|
||||
}
|
||||
} // namespace IW4
|
||||
} // namespace IW4::weapon
|
||||
|
@@ -8,7 +8,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace IW4
|
||||
namespace IW4::weapon
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetWeapon>> CreateGdtWeaponLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone);
|
||||
} // namespace IW4
|
||||
std::unique_ptr<AssetCreator<AssetWeapon>> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone);
|
||||
} // namespace IW4::weapon
|
||||
|
@@ -426,33 +426,36 @@ namespace
|
||||
}
|
||||
} // namespace
|
||||
|
||||
InfoStringLoaderWeapon::InfoStringLoaderWeapon(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
|
||||
: m_memory(memory),
|
||||
m_search_path(searchPath),
|
||||
m_zone(zone)
|
||||
namespace IW4::weapon
|
||||
{
|
||||
}
|
||||
|
||||
AssetCreationResult InfoStringLoaderWeapon::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context)
|
||||
{
|
||||
auto* weaponFullDef = m_memory.Alloc<WeaponFullDef>();
|
||||
|
||||
InitWeaponFullDef(*weaponFullDef);
|
||||
weaponFullDef->weapCompleteDef.szInternalName = m_memory.Dup(assetName.c_str());
|
||||
|
||||
AssetRegistration<AssetWeapon> registration(assetName, &weaponFullDef->weapCompleteDef);
|
||||
|
||||
InfoStringToWeaponConverter converter(
|
||||
infoString, *weaponFullDef, m_zone.m_script_strings, m_memory, context, registration, weapon_fields, std::extent_v<decltype(weapon_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 weapon: \"{}\"\n", assetName);
|
||||
return AssetCreationResult::Failure();
|
||||
}
|
||||
|
||||
CalculateWeaponFields(*weaponFullDef, m_memory);
|
||||
AssetCreationResult InfoStringLoader::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context)
|
||||
{
|
||||
auto* weaponFullDef = m_memory.Alloc<WeaponFullDef>();
|
||||
|
||||
LoadAccuracyGraphs(*weaponFullDef, m_memory, m_search_path, context);
|
||||
InitWeaponFullDef(*weaponFullDef);
|
||||
weaponFullDef->weapCompleteDef.szInternalName = m_memory.Dup(assetName.c_str());
|
||||
|
||||
return AssetCreationResult::Success(context.AddAsset(std::move(registration)));
|
||||
}
|
||||
AssetRegistration<AssetWeapon> registration(assetName, &weaponFullDef->weapCompleteDef);
|
||||
|
||||
InfoStringToWeaponConverter converter(
|
||||
infoString, *weaponFullDef, m_zone.m_script_strings, m_memory, context, registration, weapon_fields, std::extent_v<decltype(weapon_fields)>);
|
||||
if (!converter.Convert())
|
||||
{
|
||||
std::cerr << std::format("Failed to parse weapon: \"{}\"\n", assetName);
|
||||
return AssetCreationResult::Failure();
|
||||
}
|
||||
|
||||
CalculateWeaponFields(*weaponFullDef, m_memory);
|
||||
|
||||
LoadAccuracyGraphs(*weaponFullDef, m_memory, m_search_path, context);
|
||||
|
||||
return AssetCreationResult::Success(context.AddAsset(std::move(registration)));
|
||||
}
|
||||
} // namespace IW4::weapon
|
||||
|
@@ -4,12 +4,12 @@
|
||||
#include "Asset/AssetCreationResult.h"
|
||||
#include "InfoString/InfoString.h"
|
||||
|
||||
namespace IW4
|
||||
namespace IW4::weapon
|
||||
{
|
||||
class InfoStringLoaderWeapon
|
||||
class InfoStringLoader
|
||||
{
|
||||
public:
|
||||
InfoStringLoaderWeapon(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 IW4
|
||||
ISearchPath& m_search_path;
|
||||
Zone& m_zone;
|
||||
};
|
||||
} // namespace IW4
|
||||
} // namespace IW4::weapon
|
||||
|
@@ -4,12 +4,14 @@
|
||||
#include "Game/IW4/ObjConstantsIW4.h"
|
||||
#include "InfoString/InfoString.h"
|
||||
#include "InfoStringLoaderWeaponIW4.h"
|
||||
#include "Weapon/WeaponCommon.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
|
||||
using namespace IW4;
|
||||
using namespace ::weapon;
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -24,7 +26,7 @@ namespace
|
||||
|
||||
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
|
||||
{
|
||||
const auto fileName = std::format("weapons/{}", assetName);
|
||||
const auto fileName = GetFileNameForAssetName(assetName);
|
||||
const auto file = m_search_path.Open(fileName);
|
||||
if (!file.IsOpen())
|
||||
return AssetCreationResult::NoAction();
|
||||
@@ -41,14 +43,14 @@ namespace
|
||||
|
||||
private:
|
||||
ISearchPath& m_search_path;
|
||||
InfoStringLoaderWeapon m_info_string_loader;
|
||||
IW4::weapon::InfoStringLoader m_info_string_loader;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace IW4
|
||||
namespace IW4::weapon
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetWeapon>> CreateRawWeaponLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
|
||||
std::unique_ptr<AssetCreator<AssetWeapon>> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
|
||||
{
|
||||
return std::make_unique<RawLoaderWeapon>(memory, searchPath, zone);
|
||||
}
|
||||
} // namespace IW4
|
||||
} // namespace IW4::weapon
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace IW4
|
||||
namespace IW4::weapon
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetWeapon>> CreateRawWeaponLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
|
||||
} // namespace IW4
|
||||
std::unique_ptr<AssetCreator<AssetWeapon>> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
|
||||
} // namespace IW4::weapon
|
||||
|
@@ -52,7 +52,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const
|
||||
DUMP_ASSET_POOL(techset::Dumper, m_technique_set, ASSET_TYPE_TECHNIQUE_SET)
|
||||
DUMP_ASSET_POOL(image::Dumper, m_image, ASSET_TYPE_IMAGE)
|
||||
// DUMP_ASSET_POOL(AssetDumpersnd_alias_list_t, m_sound, ASSET_TYPE_SOUND)
|
||||
DUMP_ASSET_POOL(sound::SndCurveDumper, m_sound_curve, ASSET_TYPE_SOUND_CURVE)
|
||||
DUMP_ASSET_POOL(sound_curve::Dumper, m_sound_curve, ASSET_TYPE_SOUND_CURVE)
|
||||
DUMP_ASSET_POOL(sound::LoadedSoundDumper, m_loaded_sound, ASSET_TYPE_LOADED_SOUND)
|
||||
// DUMP_ASSET_POOL(AssetDumperClipMap, m_clip_map, ASSET_TYPE_CLIPMAP_MP)
|
||||
// DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world, ASSET_TYPE_COMWORLD)
|
||||
|
@@ -1,40 +1,30 @@
|
||||
#include "SndCurveDumperIW4.h"
|
||||
|
||||
#include "Dumping/SndCurve/SndCurveDumper.h"
|
||||
#include "Sound/SndCurveDumper.h"
|
||||
#include "Sound/SoundCurveCommon.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
using namespace IW4;
|
||||
using namespace ::sound_curve;
|
||||
|
||||
namespace
|
||||
namespace IW4::sound_curve
|
||||
{
|
||||
std::string GetAssetFilename(const std::string& assetName)
|
||||
{
|
||||
std::ostringstream ss;
|
||||
|
||||
ss << "soundaliases/" << assetName << ".vfcurve";
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace IW4::sound
|
||||
{
|
||||
bool SndCurveDumper::ShouldDump(XAssetInfo<SndCurve>* asset)
|
||||
bool Dumper::ShouldDump(XAssetInfo<SndCurve>* asset)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void SndCurveDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo<SndCurve>* asset)
|
||||
void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo<SndCurve>* asset)
|
||||
{
|
||||
const auto* sndCurve = asset->Asset();
|
||||
|
||||
const auto assetFile = context.OpenAssetFile(GetAssetFilename(sndCurve->filename));
|
||||
const auto assetFile = context.OpenAssetFile(GetFileNameForAssetName(sndCurve->filename));
|
||||
|
||||
if (!assetFile)
|
||||
return;
|
||||
|
||||
::SndCurveDumper dumper(*assetFile);
|
||||
SndCurveDumper dumper(*assetFile);
|
||||
|
||||
const auto knotCount = std::min(static_cast<size_t>(sndCurve->knotCount), std::extent_v<decltype(SndCurve::knots)>);
|
||||
dumper.Init(knotCount);
|
||||
@@ -42,4 +32,4 @@ namespace IW4::sound
|
||||
for (auto i = 0u; i < knotCount; i++)
|
||||
dumper.WriteKnot(sndCurve->knots[i][0], sndCurve->knots[i][1]);
|
||||
}
|
||||
} // namespace IW4::sound
|
||||
} // namespace IW4::sound_curve
|
||||
|
@@ -3,12 +3,12 @@
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
|
||||
namespace IW4::sound
|
||||
namespace IW4::sound_curve
|
||||
{
|
||||
class SndCurveDumper final : public AbstractAssetDumper<SndCurve>
|
||||
class Dumper final : public AbstractAssetDumper<SndCurve>
|
||||
{
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<SndCurve>* asset) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<SndCurve>* asset) override;
|
||||
};
|
||||
} // namespace IW4::sound
|
||||
} // namespace IW4::sound_curve
|
||||
|
@@ -27,7 +27,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());
|
||||
|
||||
|
@@ -289,7 +289,7 @@ namespace
|
||||
GivenImage("ch_rubble01_col", context, memory);
|
||||
GivenTechset("mc_l_sm_r0c0n0s0", context, memory);
|
||||
|
||||
auto loader = CreateMaterialLoader(memory, searchPath);
|
||||
auto loader = material::CreateLoader(memory, searchPath);
|
||||
auto result = loader->CreateAsset("mc/ch_rubble01", context);
|
||||
REQUIRE(result.HasBeenSuccessful());
|
||||
|
||||
|
@@ -11,7 +11,7 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
using namespace menu;
|
||||
using namespace ::menu;
|
||||
using namespace IW4;
|
||||
using namespace std::literals;
|
||||
using namespace Catch::Matchers;
|
||||
@@ -36,7 +36,7 @@ namespace test::game::iw4::menu::parsing::it
|
||||
m_ignored_asset_lookup(),
|
||||
m_context(m_zone, &m_creator_collection, &m_ignored_asset_lookup)
|
||||
{
|
||||
m_asset_creator = CreateMenuListLoader(m_zone.Memory(), m_search_path);
|
||||
m_asset_creator = IW4::menu::CreateMenuListLoader(m_zone.Memory(), m_search_path);
|
||||
}
|
||||
|
||||
void AddFile(std::string fileName, std::string data)
|
||||
|
Reference in New Issue
Block a user