2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-11-29 15:57:48 +00:00

refactor: do not nest asset namespaces in game namespaces

* Duplicated namespace names are kind of annoying
This commit is contained in:
Jan Laupetin
2025-08-06 00:50:35 +02:00
parent 33c09dfe61
commit 46fb919a52
336 changed files with 1430 additions and 1480 deletions

View File

@@ -10,7 +10,6 @@
#include <sstream>
using namespace IW5;
using namespace ::image;
namespace
{
@@ -27,7 +26,7 @@ namespace
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
{
const auto fileName = GetFileNameForAsset(assetName, ".iwi");
const auto fileName = image::GetFileNameForAsset(assetName, ".iwi");
const auto file = m_search_path.Open(fileName);
if (!file.IsOpen())
return AssetCreationResult::NoAction();
@@ -62,10 +61,10 @@ namespace
};
} // namespace
namespace IW5::image
namespace image
{
std::unique_ptr<AssetCreator<AssetImage>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath)
std::unique_ptr<AssetCreator<AssetImage>> CreateLoaderIW5(MemoryManager& memory, ISearchPath& searchPath)
{
return std::make_unique<ImageLoader>(memory, searchPath);
}
} // namespace IW5::image
} // namespace image

View File

@@ -7,7 +7,7 @@
#include <memory>
namespace IW5::image
namespace image
{
std::unique_ptr<AssetCreator<AssetImage>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath);
} // namespace IW5::image
std::unique_ptr<AssetCreator<IW5::AssetImage>> CreateLoaderIW5(MemoryManager& memory, ISearchPath& searchPath);
} // namespace image

View File

@@ -11,7 +11,6 @@
using namespace nlohmann;
using namespace IW5;
using namespace ::leaderboard;
namespace
{
@@ -133,7 +132,7 @@ namespace
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
{
const auto file = m_search_path.Open(GetJsonFileNameForAsset(assetName));
const auto file = m_search_path.Open(leaderboard::GetJsonFileNameForAsset(assetName));
if (!file.IsOpen())
return AssetCreationResult::NoAction();
@@ -156,10 +155,10 @@ namespace
};
} // namespace
namespace IW5::leaderboard
namespace leaderboard
{
std::unique_ptr<AssetCreator<AssetLeaderboard>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath)
std::unique_ptr<AssetCreator<AssetLeaderboard>> CreateLoaderIW5(MemoryManager& memory, ISearchPath& searchPath)
{
return std::make_unique<LeaderboardLoader>(memory, searchPath);
}
} // namespace IW5::leaderboard
} // namespace leaderboard

View File

@@ -7,7 +7,7 @@
#include <memory>
namespace IW5::leaderboard
namespace leaderboard
{
std::unique_ptr<AssetCreator<AssetLeaderboard>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath);
} // namespace IW5::leaderboard
std::unique_ptr<AssetCreator<IW5::AssetLeaderboard>> CreateLoaderIW5(MemoryManager& memory, ISearchPath& searchPath);
} // namespace leaderboard

View File

@@ -35,10 +35,10 @@ namespace
};
} // namespace
namespace IW5::localize
namespace localize
{
std::unique_ptr<AssetCreator<AssetLocalize>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
std::unique_ptr<AssetCreator<AssetLocalize>> CreateLoaderIW5(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
{
return std::make_unique<LocalizeLoader>(memory, searchPath, zone);
}
} // namespace IW5::localize
} // namespace localize

View File

@@ -8,7 +8,7 @@
#include <memory>
namespace IW5::localize
namespace localize
{
std::unique_ptr<AssetCreator<AssetLocalize>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
} // namespace IW5::localize
std::unique_ptr<AssetCreator<IW5::AssetLocalize>> CreateLoaderIW5(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
} // namespace localize

View File

@@ -8,7 +8,6 @@
#include <iostream>
using namespace IW5;
using namespace ::material;
namespace
{
@@ -23,7 +22,7 @@ namespace
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
{
const auto file = m_search_path.Open(GetFileNameForAssetName(assetName));
const auto file = m_search_path.Open(material::GetFileNameForAssetName(assetName));
if (!file.IsOpen())
return AssetCreationResult::NoAction();
@@ -46,10 +45,10 @@ namespace
};
} // namespace
namespace IW5::material
namespace material
{
std::unique_ptr<AssetCreator<AssetMaterial>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath)
std::unique_ptr<AssetCreator<AssetMaterial>> CreateLoaderIW5(MemoryManager& memory, ISearchPath& searchPath)
{
return std::make_unique<MaterialLoader>(memory, searchPath);
}
} // namespace IW5::material
} // namespace material

View File

@@ -7,7 +7,7 @@
#include <memory>
namespace IW5::material
namespace material
{
std::unique_ptr<AssetCreator<AssetMaterial>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath);
} // namespace IW5::material
std::unique_ptr<AssetCreator<IW5::AssetMaterial>> CreateLoaderIW5(MemoryManager& memory, ISearchPath& searchPath);
} // namespace material

View File

@@ -11,7 +11,6 @@
#include <iostream>
using namespace IW5;
using namespace ::menu;
namespace
{
@@ -29,7 +28,7 @@ namespace
std::vector<menuDef_t*> menus;
AssetRegistration<AssetMenuList> registration(assetName);
auto& zoneState = context.GetZoneAssetCreationState<MenuAssetZoneState>();
auto& zoneState = context.GetZoneAssetCreationState<menu::MenuAssetZoneState>();
auto& conversionState = context.GetZoneAssetCreationState<MenuConversionZoneState>();
std::deque<std::string> menuLoadQueue;
@@ -81,7 +80,7 @@ namespace
private:
bool LoadMenuFileFromQueue(const std::string& menuFilePath,
AssetCreationContext& context,
MenuAssetZoneState& zoneState,
menu::MenuAssetZoneState& zoneState,
MenuConversionZoneState& conversionState,
std::vector<menuDef_t*>& menus,
AssetRegistration<AssetMenuList>& registration) const
@@ -122,8 +121,8 @@ namespace
bool ProcessParsedResults(const std::string& fileName,
AssetCreationContext& context,
ParsingResult& parsingResult,
MenuAssetZoneState& zoneState,
menu::ParsingResult& parsingResult,
menu::MenuAssetZoneState& zoneState,
MenuConversionZoneState& conversionState,
std::vector<menuDef_t*>& menus,
AssetRegistration<AssetMenuList>& registration) const
@@ -197,9 +196,10 @@ namespace
menuList.menus = nullptr;
}
std::unique_ptr<ParsingResult> ParseMenuFile(std::istream& stream, const std::string& menuFileName, const MenuAssetZoneState& zoneState) const
std::unique_ptr<menu::ParsingResult>
ParseMenuFile(std::istream& stream, const std::string& menuFileName, const menu::MenuAssetZoneState& zoneState) const
{
MenuFileReader reader(stream, menuFileName, FeatureLevel::IW5, m_search_path);
menu::MenuFileReader reader(stream, menuFileName, menu::FeatureLevel::IW5, m_search_path);
reader.IncludeZoneState(zoneState);
reader.SetPermissiveMode(ObjLoading::Configuration.MenuPermissiveParsing);
@@ -212,10 +212,10 @@ namespace
};
} // namespace
namespace IW5::menu
namespace menu
{
std::unique_ptr<AssetCreator<AssetMenuList>> CreateMenuListLoader(MemoryManager& memory, ISearchPath& searchPath)
std::unique_ptr<AssetCreator<AssetMenuList>> CreateMenuListLoaderIW5(MemoryManager& memory, ISearchPath& searchPath)
{
return std::make_unique<MenuListLoader>(memory, searchPath);
}
} // namespace IW5::menu
} // namespace menu

View File

@@ -7,7 +7,7 @@
#include <memory>
namespace IW5::menu
namespace menu
{
std::unique_ptr<AssetCreator<AssetMenuList>> CreateMenuListLoader(MemoryManager& memory, ISearchPath& searchPath);
} // namespace IW5::menu
std::unique_ptr<AssetCreator<IW5::AssetMenuList>> CreateMenuListLoaderIW5(MemoryManager& memory, ISearchPath& searchPath);
} // namespace menu

View File

@@ -125,13 +125,13 @@ namespace
// 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(material::CreateLoader(memory, searchPath));
collection.AddAssetCreator(xmodel::CreateLoaderIW5(memory, searchPath, zone));
collection.AddAssetCreator(material::CreateLoaderIW5(memory, searchPath));
// collection.AddAssetCreator(std::make_unique<AssetLoaderPixelShader>(memory));
// collection.AddAssetCreator(std::make_unique<AssetLoaderVertexShader>(memory));
// collection.AddAssetCreator(std::make_unique<AssetLoaderVertexDecl>(memory));
// collection.AddAssetCreator(std::make_unique<AssetLoaderTechniqueSet>(memory));
collection.AddAssetCreator(image::CreateLoader(memory, searchPath));
collection.AddAssetCreator(image::CreateLoaderIW5(memory, searchPath));
// collection.AddAssetCreator(std::make_unique<AssetLoaderSound>(memory));
// collection.AddAssetCreator(std::make_unique<AssetLoaderSoundCurve>(memory));
// collection.AddAssetCreator(std::make_unique<AssetLoaderLoadedSound>(memory));
@@ -145,19 +145,19 @@ namespace
// collection.AddAssetCreator(std::make_unique<AssetLoaderGfxWorld>(memory));
// collection.AddAssetCreator(std::make_unique<AssetLoaderLightDef>(memory));
// collection.AddAssetCreator(std::make_unique<AssetLoaderFont>(memory));
collection.AddAssetCreator(menu::CreateMenuListLoader(memory, searchPath));
collection.AddAssetCreator(menu::CreateMenuListLoaderIW5(memory, searchPath));
// collection.AddAssetCreator(std::make_unique<AssetLoaderMenu>(memory));
collection.AddAssetCreator(localize::CreateLoader(memory, searchPath, zone));
collection.AddAssetCreator(attachment::CreateLoader(memory, searchPath));
collection.AddAssetCreator(weapon::CreateRawLoader(memory, searchPath, zone));
collection.AddAssetCreator(weapon::CreateGdtLoader(memory, searchPath, gdt, zone));
collection.AddAssetCreator(localize::CreateLoaderIW5(memory, searchPath, zone));
collection.AddAssetCreator(attachment::CreateLoaderIW5(memory, searchPath));
collection.AddAssetCreator(weapon::CreateRawLoaderIW5(memory, searchPath, zone));
collection.AddAssetCreator(weapon::CreateGdtLoaderIW5(memory, searchPath, gdt, zone));
// collection.AddAssetCreator(std::make_unique<AssetLoaderFx>(memory));
// collection.AddAssetCreator(std::make_unique<AssetLoaderImpactFx>(memory));
// collection.AddAssetCreator(std::make_unique<AssetLoaderSurfaceFx>(memory));
collection.AddAssetCreator(raw_file::CreateLoader(memory, searchPath));
collection.AddAssetCreator(script::CreateLoader(memory, searchPath));
collection.AddAssetCreator(string_table::CreateLoader(memory, searchPath));
collection.AddAssetCreator(leaderboard::CreateLoader(memory, searchPath));
collection.AddAssetCreator(raw_file::CreateLoaderIW5(memory, searchPath));
collection.AddAssetCreator(script::CreateLoaderIW5(memory, searchPath));
collection.AddAssetCreator(string_table::CreateLoaderIW5(memory, searchPath));
collection.AddAssetCreator(leaderboard::CreateLoaderIW5(memory, searchPath));
// collection.AddAssetCreator(std::make_unique<AssetLoaderStructuredDataDef>(memory));
// collection.AddAssetCreator(std::make_unique<AssetLoaderTracer>(memory));
// collection.AddAssetCreator(std::make_unique<AssetLoaderVehicle>(memory));

View File

@@ -81,10 +81,10 @@ namespace
};
} // namespace
namespace IW5::raw_file
namespace raw_file
{
std::unique_ptr<AssetCreator<AssetRawFile>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath)
std::unique_ptr<AssetCreator<AssetRawFile>> CreateLoaderIW5(MemoryManager& memory, ISearchPath& searchPath)
{
return std::make_unique<RawFileLoader>(memory, searchPath);
}
} // namespace IW5::raw_file
} // namespace raw_file

View File

@@ -7,7 +7,7 @@
#include <memory>
namespace IW5::raw_file
namespace raw_file
{
std::unique_ptr<AssetCreator<AssetRawFile>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath);
} // namespace IW5::raw_file
std::unique_ptr<AssetCreator<IW5::AssetRawFile>> CreateLoaderIW5(MemoryManager& memory, ISearchPath& searchPath);
} // namespace raw_file

View File

@@ -79,10 +79,10 @@ namespace
};
} // namespace
namespace IW5::script
namespace script
{
std::unique_ptr<AssetCreator<AssetScript>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath)
std::unique_ptr<AssetCreator<AssetScript>> CreateLoaderIW5(MemoryManager& memory, ISearchPath& searchPath)
{
return std::make_unique<ScriptLoader>(memory, searchPath);
}
} // namespace IW5::script
} // namespace script

View File

@@ -7,7 +7,7 @@
#include <memory>
namespace IW5::script
namespace script
{
std::unique_ptr<AssetCreator<AssetScript>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath);
} // namespace IW5::script
std::unique_ptr<AssetCreator<IW5::AssetScript>> CreateLoaderIW5(MemoryManager& memory, ISearchPath& searchPath);
} // namespace script

View File

@@ -10,7 +10,6 @@
#include <cstring>
using namespace IW5;
using namespace ::string_table;
namespace
{
@@ -29,7 +28,7 @@ namespace
if (!file.IsOpen())
return AssetCreationResult::NoAction();
StringTableLoaderV2<StringTable, Common::StringTable_HashString> loader;
string_table::StringTableLoaderV2<StringTable, Common::StringTable_HashString> loader;
auto* stringTable = loader.LoadFromStream(assetName, m_memory, *file.m_stream);
return AssetCreationResult::Success(context.AddAsset<AssetStringTable>(assetName, stringTable));
@@ -41,10 +40,10 @@ namespace
};
} // namespace
namespace IW5::string_table
namespace string_table
{
std::unique_ptr<AssetCreator<AssetStringTable>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath)
std::unique_ptr<AssetCreator<AssetStringTable>> CreateLoaderIW5(MemoryManager& memory, ISearchPath& searchPath)
{
return std::make_unique<StringTableLoader>(memory, searchPath);
}
} // namespace IW5::string_table
} // namespace string_table

View File

@@ -7,7 +7,7 @@
#include <memory>
namespace IW5::string_table
namespace string_table
{
std::unique_ptr<AssetCreator<AssetStringTable>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath);
} // namespace IW5::string_table
std::unique_ptr<AssetCreator<IW5::AssetStringTable>> CreateLoaderIW5(MemoryManager& memory, ISearchPath& searchPath);
} // namespace string_table

View File

@@ -40,14 +40,14 @@ namespace
private:
IGdtQueryable& m_gdt;
IW5::weapon::InfoStringLoader m_info_string_loader;
weapon::InfoStringLoaderIW5 m_info_string_loader;
};
} // namespace
namespace IW5::weapon
namespace weapon
{
std::unique_ptr<AssetCreator<AssetWeapon>> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone)
std::unique_ptr<AssetCreator<AssetWeapon>> CreateGdtLoaderIW5(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone)
{
return std::make_unique<GdtLoaderWeapon>(memory, searchPath, gdt, zone);
}
} // namespace IW5::weapon
} // namespace weapon

View File

@@ -8,7 +8,7 @@
#include <memory>
namespace IW5::weapon
namespace weapon
{
std::unique_ptr<AssetCreator<AssetWeapon>> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone);
} // namespace IW5::weapon
std::unique_ptr<AssetCreator<IW5::AssetWeapon>> CreateGdtLoaderIW5(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone);
} // namespace weapon

View File

@@ -856,16 +856,16 @@ namespace
}
} // namespace
namespace IW5::weapon
namespace weapon
{
InfoStringLoader::InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
InfoStringLoaderIW5::InfoStringLoaderIW5(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
: m_memory(memory),
m_search_path(searchPath),
m_zone(zone)
{
}
AssetCreationResult InfoStringLoader::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) const
AssetCreationResult InfoStringLoaderIW5::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) const
{
auto* weaponFullDef = m_memory.Alloc<WeaponFullDef>();
@@ -888,4 +888,4 @@ namespace IW5::weapon
return AssetCreationResult::Success(context.AddAsset(std::move(registration)));
}
} // namespace IW5::weapon
} // namespace weapon

View File

@@ -4,12 +4,12 @@
#include "Asset/AssetCreationResult.h"
#include "InfoString/InfoString.h"
namespace IW5::weapon
namespace weapon
{
class InfoStringLoader
class InfoStringLoaderIW5
{
public:
InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
InfoStringLoaderIW5(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
AssetCreationResult CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) const;
@@ -18,4 +18,4 @@ namespace IW5::weapon
ISearchPath& m_search_path;
Zone& m_zone;
};
} // namespace IW5::weapon
} // namespace weapon

View File

@@ -11,7 +11,6 @@
using namespace nlohmann;
using namespace IW5;
using namespace ::attachment;
namespace
{
@@ -643,7 +642,7 @@ namespace
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
{
const auto file = m_search_path.Open(GetJsonFileNameForAssetName(assetName));
const auto file = m_search_path.Open(attachment::GetJsonFileNameForAssetName(assetName));
if (!file.IsOpen())
return AssetCreationResult::NoAction();
@@ -667,10 +666,10 @@ namespace
};
} // namespace
namespace IW5::attachment
namespace attachment
{
std::unique_ptr<AssetCreator<AssetAttachment>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath)
std::unique_ptr<AssetCreator<AssetAttachment>> CreateLoaderIW5(MemoryManager& memory, ISearchPath& searchPath)
{
return std::make_unique<AttachmentLoader>(memory, searchPath);
}
} // namespace IW5::attachment
} // namespace attachment

View File

@@ -7,7 +7,7 @@
#include <memory>
namespace IW5::attachment
namespace attachment
{
std::unique_ptr<AssetCreator<AssetAttachment>> CreateLoader(MemoryManager& memory, ISearchPath& searchPath);
} // namespace IW5::attachment
std::unique_ptr<AssetCreator<IW5::AssetAttachment>> CreateLoaderIW5(MemoryManager& memory, ISearchPath& searchPath);
} // namespace attachment

View File

@@ -43,14 +43,14 @@ namespace
private:
ISearchPath& m_search_path;
IW5::weapon::InfoStringLoader m_info_string_loader;
weapon::InfoStringLoaderIW5 m_info_string_loader;
};
} // namespace
namespace IW5::weapon
namespace weapon
{
std::unique_ptr<AssetCreator<AssetWeapon>> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
std::unique_ptr<AssetCreator<AssetWeapon>> CreateRawLoaderIW5(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
{
return std::make_unique<RawLoaderWeapon>(memory, searchPath, zone);
}
} // namespace IW5::weapon
} // namespace weapon

View File

@@ -7,7 +7,7 @@
#include <memory>
namespace IW5::weapon
namespace weapon
{
std::unique_ptr<AssetCreator<AssetWeapon>> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
} // namespace IW5::weapon
std::unique_ptr<AssetCreator<IW5::AssetWeapon>> CreateRawLoaderIW5(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
} // namespace weapon