mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-07-26 18:00:38 +00:00
feat: T4 add StringTable loader (#934)
* feat: T4 add string table loader * chore: rename stringtable loaders to match style between games * fix: make sure all games correctly interpret failed stringtable loading --------- Co-authored-by: Jan Laupetin <[email protected]>
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
#include "PhysPreset/RawLoaderPhysPresetIW3.h"
|
||||
#include "RawFile/AssetLoaderRawFileIW3.h"
|
||||
#include "Sound/LoaderSoundCurveIW3.h"
|
||||
#include "StringTable/AssetLoaderStringTableIW3.h"
|
||||
#include "StringTable/LoaderStringTableIW3.h"
|
||||
#include "Weapon/WeaponGdtLoaderIW3.h"
|
||||
#include "Weapon/WeaponRawLoaderIW3.h"
|
||||
|
||||
|
||||
+1
-3
@@ -1,10 +1,8 @@
|
||||
#include "AssetLoaderStringTableIW3.h"
|
||||
#include "LoaderStringTableIW3.h"
|
||||
|
||||
#include "Game/IW3/IW3.h"
|
||||
#include "StringTable/StringTableLoader.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW3;
|
||||
|
||||
namespace
|
||||
@@ -3,12 +3,8 @@
|
||||
#include "Csv/CsvStream.h"
|
||||
#include "Game/IW5/CommonIW5.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
#include "StringTable/StringTableLoader.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
namespace
|
||||
@@ -30,6 +26,8 @@ namespace
|
||||
|
||||
string_table::StringTableLoaderV2<StringTable, Common::StringTable_HashString> loader;
|
||||
auto* stringTable = loader.LoadFromStream(assetName, m_memory, *file.m_stream);
|
||||
if (!stringTable)
|
||||
return AssetCreationResult::Failure();
|
||||
|
||||
return AssetCreationResult::Success(context.AddAsset<AssetStringTable>(assetName, stringTable));
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "PhysPreset/GdtLoaderPhysPresetT4.h"
|
||||
#include "PhysPreset/RawLoaderPhysPresetT4.h"
|
||||
#include "RawFile/AssetLoaderRawFileT4.h"
|
||||
#include "StringTable/LoaderStringTableT4.h"
|
||||
#include "Weapon/FlameTableLoaderT4.h"
|
||||
#include "Weapon/WeaponGdtLoaderT4.h"
|
||||
#include "Weapon/WeaponRawLoaderT4.h"
|
||||
@@ -108,6 +109,7 @@ namespace
|
||||
collection.AddAssetCreator(phys_preset::CreateRawLoaderT4(memory, searchPath, zone));
|
||||
collection.AddAssetCreator(phys_preset::CreateGdtLoaderT4(memory, gdt, zone));
|
||||
collection.AddAssetCreator(raw_file::CreateLoaderT4(memory, searchPath));
|
||||
collection.AddAssetCreator(string_table::CreateLoaderT4(memory, searchPath));
|
||||
collection.AddAssetCreator(weapon::CreateRawLoaderT4(memory, searchPath, zone));
|
||||
collection.AddAssetCreator(weapon::CreateGdtLoaderT4(memory, searchPath, gdt, zone));
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
#include "LoaderStringTableT4.h"
|
||||
|
||||
#include "Game/T4/T4.h"
|
||||
#include "StringTable/StringTableLoader.h"
|
||||
|
||||
using namespace T4;
|
||||
|
||||
namespace
|
||||
{
|
||||
class StringTableLoader final : public AssetCreator<AssetStringTable>
|
||||
{
|
||||
public:
|
||||
StringTableLoader(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(assetName);
|
||||
if (!file.IsOpen())
|
||||
return AssetCreationResult::NoAction();
|
||||
|
||||
string_table::StringTableLoaderV1<StringTable> loader;
|
||||
auto* stringTable = loader.LoadFromStream(assetName, m_memory, *file.m_stream);
|
||||
if (!stringTable)
|
||||
return AssetCreationResult::Failure();
|
||||
|
||||
return AssetCreationResult::Success(context.AddAsset<AssetStringTable>(assetName, stringTable));
|
||||
}
|
||||
|
||||
private:
|
||||
MemoryManager& m_memory;
|
||||
ISearchPath& m_search_path;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace string_table
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetStringTable>> CreateLoaderT4(MemoryManager& memory, ISearchPath& searchPath)
|
||||
{
|
||||
return std::make_unique<StringTableLoader>(memory, searchPath);
|
||||
}
|
||||
} // namespace string_table
|
||||
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "Asset/IAssetCreator.h"
|
||||
#include "Game/T4/T4.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
#include "Utils/MemoryManager.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace string_table
|
||||
{
|
||||
std::unique_ptr<AssetCreator<T4::AssetStringTable>> CreateLoaderT4(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace string_table
|
||||
@@ -4,8 +4,6 @@
|
||||
#include "Game/T5/T5.h"
|
||||
#include "StringTable/StringTableLoader.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace T5;
|
||||
|
||||
namespace
|
||||
@@ -27,6 +25,8 @@ namespace
|
||||
|
||||
string_table::StringTableLoaderV3<StringTable, Common::Com_HashString> loader;
|
||||
auto* stringTable = loader.LoadFromStream(assetName, m_memory, *file.m_stream);
|
||||
if (!stringTable)
|
||||
return AssetCreationResult::Failure();
|
||||
|
||||
return AssetCreationResult::Success(context.AddAsset<AssetStringTable>(assetName, stringTable));
|
||||
}
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
#include "Game/T6/T6.h"
|
||||
#include "StringTable/StringTableLoader.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace T6;
|
||||
|
||||
namespace
|
||||
@@ -28,6 +26,8 @@ namespace
|
||||
|
||||
string_table::StringTableLoaderV3<StringTable, Common::Com_HashString> loader;
|
||||
auto* stringTable = loader.LoadFromStream(assetName, m_memory, *file.m_stream);
|
||||
if (!stringTable)
|
||||
return AssetCreationResult::Failure();
|
||||
|
||||
return AssetCreationResult::Success(context.AddAsset<AssetStringTable>(assetName, stringTable));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user