mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-08-30 21:53:15 +00:00
refactor: merge leaderboard dumpers for iw4,iw5
This commit is contained in:
@@ -1,24 +0,0 @@
|
||||
#include "AssetDumperLeaderboardDef.h"
|
||||
|
||||
#include "Game/IW4/Leaderboard/JsonLeaderboardDefWriter.h"
|
||||
|
||||
#include <format>
|
||||
#include <ranges>
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
bool AssetDumperLeaderboardDef::ShouldDump(XAssetInfo<LeaderboardDef>* asset)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void AssetDumperLeaderboardDef::DumpAsset(AssetDumpingContext& context, XAssetInfo<LeaderboardDef>* asset)
|
||||
{
|
||||
const auto assetName = asset->m_name;
|
||||
const auto assetFile = context.OpenAssetFile(std::format("leaderboards/{}.json", assetName));
|
||||
|
||||
if (!assetFile)
|
||||
return;
|
||||
|
||||
DumpLeaderboardDefAsJson(*assetFile, asset->Asset());
|
||||
}
|
@@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
|
||||
namespace IW4
|
||||
{
|
||||
class AssetDumperLeaderboardDef final : public AbstractAssetDumper<LeaderboardDef>
|
||||
{
|
||||
protected:
|
||||
_NODISCARD bool ShouldDump(XAssetInfo<LeaderboardDef>* asset) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<LeaderboardDef>* asset) override;
|
||||
};
|
||||
} // namespace IW4
|
@@ -1,11 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AssetDumpingContext.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
|
||||
#include <ostream>
|
||||
|
||||
namespace IW4
|
||||
{
|
||||
void DumpLeaderboardDefAsJson(std::ostream& stream, const LeaderboardDef* leaderboardDef);
|
||||
} // namespace IW4
|
@@ -1,28 +1,30 @@
|
||||
#include "JsonLeaderboardDefWriter.h"
|
||||
#include "LeaderboardJsonDumperIW4.h"
|
||||
|
||||
#include "Game/IW4/CommonIW4.h"
|
||||
#include "Game/IW4/Leaderboard/JsonLeaderboardDef.h"
|
||||
#include "Leaderboard/LeaderboardCommon.h"
|
||||
|
||||
#include <iomanip>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
using namespace IW4;
|
||||
using namespace ::leaderboard;
|
||||
|
||||
namespace
|
||||
{
|
||||
class JsonDumper
|
||||
class Dumper
|
||||
{
|
||||
public:
|
||||
explicit JsonDumper(std::ostream& stream)
|
||||
explicit Dumper(std::ostream& stream)
|
||||
: m_stream(stream)
|
||||
{
|
||||
}
|
||||
|
||||
void Dump(const LeaderboardDef* leaderboardDef) const
|
||||
void Dump(const LeaderboardDef& leaderboardDef) const
|
||||
{
|
||||
JsonLeaderboardDef jsonLeaderboardDef;
|
||||
CreateJsonLeaderboardDef(jsonLeaderboardDef, *leaderboardDef);
|
||||
CreateJsonLeaderboardDef(jsonLeaderboardDef, leaderboardDef);
|
||||
|
||||
json jRoot = jsonLeaderboardDef;
|
||||
|
||||
@@ -74,11 +76,21 @@ namespace
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace IW4
|
||||
namespace IW4::leaderboard
|
||||
{
|
||||
void DumpLeaderboardDefAsJson(std::ostream& stream, const LeaderboardDef* leaderboardDef)
|
||||
bool JsonDumper::ShouldDump(XAssetInfo<LeaderboardDef>* asset)
|
||||
{
|
||||
JsonDumper dumper(stream);
|
||||
dumper.Dump(leaderboardDef);
|
||||
return true;
|
||||
}
|
||||
} // namespace IW4
|
||||
|
||||
void JsonDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo<LeaderboardDef>* asset)
|
||||
{
|
||||
const auto assetFile = context.OpenAssetFile(GetJsonFileNameForAsset(asset->m_name));
|
||||
|
||||
if (!assetFile)
|
||||
return;
|
||||
|
||||
Dumper dumper(*assetFile);
|
||||
dumper.Dump(*asset->Asset());
|
||||
}
|
||||
} // namespace IW4::leaderboard
|
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
|
||||
namespace IW4::leaderboard
|
||||
{
|
||||
class JsonDumper final : public AbstractAssetDumper<LeaderboardDef>
|
||||
{
|
||||
protected:
|
||||
[[nodiscard]] bool ShouldDump(XAssetInfo<LeaderboardDef>* asset) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<LeaderboardDef>* asset) override;
|
||||
};
|
||||
} // namespace IW4::leaderboard
|
@@ -3,7 +3,7 @@
|
||||
#include "Game/IW4/GameAssetPoolIW4.h"
|
||||
#include "Game/IW4/XModel/XModelDumperIW4.h"
|
||||
#include "Image/AssetDumperGfxImage.h"
|
||||
#include "Leaderboard/AssetDumperLeaderboardDef.h"
|
||||
#include "Leaderboard/LeaderboardJsonDumperIW4.h"
|
||||
#include "LightDef/AssetDumperGfxLightDef.h"
|
||||
#include "Localize/AssetDumperLocalizeEntry.h"
|
||||
#include "Maps/AssetDumperAddonMapEnts.h"
|
||||
@@ -68,7 +68,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const
|
||||
// DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table, ASSET_TYPE_IMPACT_FX)
|
||||
DUMP_ASSET_POOL(AssetDumperRawFile, m_raw_file, ASSET_TYPE_RAWFILE)
|
||||
DUMP_ASSET_POOL(AssetDumperStringTable, m_string_table, ASSET_TYPE_STRINGTABLE)
|
||||
DUMP_ASSET_POOL(AssetDumperLeaderboardDef, m_leaderboard, ASSET_TYPE_LEADERBOARD)
|
||||
DUMP_ASSET_POOL(leaderboard::JsonDumper, m_leaderboard, ASSET_TYPE_LEADERBOARD)
|
||||
DUMP_ASSET_POOL(AssetDumperStructuredDataDefSet, m_structed_data_def_set, ASSET_TYPE_STRUCTURED_DATA_DEF)
|
||||
DUMP_ASSET_POOL(AssetDumperTracer, m_tracer, ASSET_TYPE_TRACER)
|
||||
DUMP_ASSET_POOL(AssetDumperVehicle, m_vehicle, ASSET_TYPE_VEHICLE)
|
||||
|
@@ -1,24 +0,0 @@
|
||||
#include "AssetDumperLeaderboardDef.h"
|
||||
|
||||
#include "Game/IW5/Leaderboard/JsonLeaderboardDefWriter.h"
|
||||
|
||||
#include <format>
|
||||
#include <ranges>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
bool AssetDumperLeaderboardDef::ShouldDump(XAssetInfo<LeaderboardDef>* asset)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void AssetDumperLeaderboardDef::DumpAsset(AssetDumpingContext& context, XAssetInfo<LeaderboardDef>* asset)
|
||||
{
|
||||
const auto assetName = asset->m_name;
|
||||
const auto assetFile = context.OpenAssetFile(std::format("leaderboards/{}.json", assetName));
|
||||
|
||||
if (!assetFile)
|
||||
return;
|
||||
|
||||
DumpLeaderboardDefAsJson(*assetFile, asset->Asset());
|
||||
}
|
@@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetDumperLeaderboardDef final : public AbstractAssetDumper<LeaderboardDef>
|
||||
{
|
||||
protected:
|
||||
_NODISCARD bool ShouldDump(XAssetInfo<LeaderboardDef>* asset) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<LeaderboardDef>* asset) override;
|
||||
};
|
||||
} // namespace IW5
|
@@ -1,11 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AssetDumpingContext.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
|
||||
#include <ostream>
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
void DumpLeaderboardDefAsJson(std::ostream& stream, const LeaderboardDef* leaderboardDef);
|
||||
} // namespace IW5
|
@@ -1,28 +1,31 @@
|
||||
#include "JsonLeaderboardDefWriter.h"
|
||||
#include "LeaderboardJsonDumperIW5.h"
|
||||
|
||||
#include "Game/IW5/CommonIW5.h"
|
||||
#include "Game/IW5/Leaderboard/JsonLeaderboardDef.h"
|
||||
#include "Leaderboard/LeaderboardCommon.h"
|
||||
|
||||
#include <iomanip>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <ranges>
|
||||
|
||||
using namespace nlohmann;
|
||||
using namespace IW5;
|
||||
using namespace ::leaderboard;
|
||||
|
||||
namespace
|
||||
{
|
||||
class JsonDumper
|
||||
class Dumper
|
||||
{
|
||||
public:
|
||||
explicit JsonDumper(std::ostream& stream)
|
||||
explicit Dumper(std::ostream& stream)
|
||||
: m_stream(stream)
|
||||
{
|
||||
}
|
||||
|
||||
void Dump(const LeaderboardDef* leaderboardDef) const
|
||||
void Dump(const LeaderboardDef& leaderboardDef) const
|
||||
{
|
||||
JsonLeaderboardDef jsonLeaderboardDef;
|
||||
CreateJsonLeaderboardDef(jsonLeaderboardDef, *leaderboardDef);
|
||||
CreateJsonLeaderboardDef(jsonLeaderboardDef, leaderboardDef);
|
||||
|
||||
json jRoot = jsonLeaderboardDef;
|
||||
|
||||
@@ -90,11 +93,21 @@ namespace
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace IW5
|
||||
namespace IW5::leaderboard
|
||||
{
|
||||
void DumpLeaderboardDefAsJson(std::ostream& stream, const LeaderboardDef* leaderboardDef)
|
||||
bool JsonDumper::ShouldDump(XAssetInfo<LeaderboardDef>* asset)
|
||||
{
|
||||
JsonDumper dumper(stream);
|
||||
dumper.Dump(leaderboardDef);
|
||||
return true;
|
||||
}
|
||||
} // namespace IW5
|
||||
|
||||
void JsonDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo<LeaderboardDef>* asset)
|
||||
{
|
||||
const auto assetFile = context.OpenAssetFile(GetJsonFileNameForAsset(asset->m_name));
|
||||
|
||||
if (!assetFile)
|
||||
return;
|
||||
|
||||
Dumper dumper(*assetFile);
|
||||
dumper.Dump(*asset->Asset());
|
||||
}
|
||||
} // namespace IW5::leaderboard
|
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
|
||||
namespace IW5::leaderboard
|
||||
{
|
||||
class JsonDumper final : public AbstractAssetDumper<LeaderboardDef>
|
||||
{
|
||||
protected:
|
||||
[[nodiscard]] bool ShouldDump(XAssetInfo<LeaderboardDef>* asset) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<LeaderboardDef>* asset) override;
|
||||
};
|
||||
} // namespace IW5::leaderboard
|
@@ -3,7 +3,7 @@
|
||||
#include "Game/IW5/GameAssetPoolIW5.h"
|
||||
#include "Game/IW5/XModel/XModelDumperIW5.h"
|
||||
#include "Image/AssetDumperGfxImage.h"
|
||||
#include "Leaderboard/AssetDumperLeaderboardDef.h"
|
||||
#include "Leaderboard/LeaderboardJsonDumperIW5.h"
|
||||
#include "Localize/AssetDumperLocalizeEntry.h"
|
||||
#include "Maps/AssetDumperAddonMapEnts.h"
|
||||
#include "Material/DumperMaterialIW5.h"
|
||||
@@ -64,7 +64,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const
|
||||
DUMP_ASSET_POOL(AssetDumperRawFile, m_raw_file, ASSET_TYPE_RAWFILE)
|
||||
DUMP_ASSET_POOL(AssetDumperScriptFile, m_script_file, ASSET_TYPE_SCRIPTFILE)
|
||||
DUMP_ASSET_POOL(AssetDumperStringTable, m_string_table, ASSET_TYPE_STRINGTABLE)
|
||||
DUMP_ASSET_POOL(AssetDumperLeaderboardDef, m_leaderboard, ASSET_TYPE_LEADERBOARD)
|
||||
DUMP_ASSET_POOL(leaderboard::JsonDumper, m_leaderboard, ASSET_TYPE_LEADERBOARD)
|
||||
// DUMP_ASSET_POOL(AssetDumperStructuredDataDefSet, m_structed_data_def_set, ASSET_TYPE_STRUCTURED_DATA_DEF)
|
||||
// DUMP_ASSET_POOL(AssetDumperTracerDef, m_tracer, ASSET_TYPE_TRACER)
|
||||
// DUMP_ASSET_POOL(AssetDumperVehicleDef, m_vehicle, ASSET_TYPE_VEHICLE)
|
||||
|
@@ -4,7 +4,6 @@
|
||||
#include "Game/T6/Leaderboard/JsonLeaderboardDef.h"
|
||||
#include "Leaderboard/LeaderboardCommon.h"
|
||||
|
||||
#include <format>
|
||||
#include <iomanip>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <ranges>
|
||||
|
Reference in New Issue
Block a user