mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 00:02:55 +00:00
Add base for StructuredDataDefDumper
This commit is contained in:
parent
b48d55671e
commit
5c2f7de87d
@ -0,0 +1,43 @@
|
||||
#include "StructuredDataDefDumper.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
StructuredDataDefDumper::StructuredDataDefDumper(std::ostream& stream)
|
||||
: AbstractTextDumper(stream),
|
||||
m_flags{}
|
||||
{
|
||||
}
|
||||
|
||||
void StructuredDataDefDumper::BeginVersion(const int version)
|
||||
{
|
||||
assert(!m_flags.m_in_version);
|
||||
if (m_flags.m_in_version)
|
||||
return;
|
||||
|
||||
if (m_flags.m_empty_line_before_version)
|
||||
m_stream << "\n";
|
||||
else
|
||||
m_flags.m_empty_line_before_version = true;
|
||||
|
||||
Indent();
|
||||
m_stream << "version " << version << "\n";
|
||||
|
||||
Indent();
|
||||
m_stream << "{\n";
|
||||
|
||||
IncIndent();
|
||||
|
||||
m_flags.m_in_version = true;
|
||||
}
|
||||
|
||||
void StructuredDataDefDumper::EndVersion()
|
||||
{
|
||||
assert(m_flags.m_in_version);
|
||||
if (!m_flags.m_in_version)
|
||||
return;
|
||||
|
||||
DecIndent();
|
||||
Indent();
|
||||
m_stream << "}\n";
|
||||
m_flags.m_in_version = false;
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractTextDumper.h"
|
||||
|
||||
class StructuredDataDefDumper : AbstractTextDumper
|
||||
{
|
||||
struct
|
||||
{
|
||||
bool m_in_version : 1;
|
||||
bool m_empty_line_before_version : 1;
|
||||
} m_flags;
|
||||
|
||||
public:
|
||||
explicit StructuredDataDefDumper(std::ostream& stream);
|
||||
|
||||
void BeginVersion(int version);
|
||||
void EndVersion();
|
||||
};
|
@ -0,0 +1,32 @@
|
||||
#include "AssetDumperStructuredDataDefSet.h"
|
||||
|
||||
#include "Dumping/StructuredDataDef/StructuredDataDefDumper.h"
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
bool AssetDumperStructuredDataDefSet::ShouldDump(XAssetInfo<StructuredDataDefSet>* asset)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void AssetDumperStructuredDataDefSet::DumpAsset(AssetDumpingContext& context, XAssetInfo<StructuredDataDefSet>* asset)
|
||||
{
|
||||
const auto* set = asset->Asset();
|
||||
const auto assetFile = context.OpenAssetFile(asset->m_name);
|
||||
|
||||
if (!assetFile || set->defs == nullptr)
|
||||
return;
|
||||
|
||||
StructuredDataDefDumper dumper(*assetFile);
|
||||
|
||||
for(auto defIndex = 0u; defIndex < set->defCount; defIndex++)
|
||||
{
|
||||
const auto& def = set->defs[defIndex];
|
||||
|
||||
dumper.BeginVersion(def.version);
|
||||
|
||||
// TODO
|
||||
|
||||
dumper.EndVersion();
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
|
||||
namespace IW4
|
||||
{
|
||||
class AssetDumperStructuredDataDefSet final : public AbstractAssetDumper<StructuredDataDefSet>
|
||||
{
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<StructuredDataDefSet>* asset) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<StructuredDataDefSet>* asset) override;
|
||||
};
|
||||
}
|
@ -16,6 +16,7 @@
|
||||
#include "AssetDumpers/AssetDumperRawFile.h"
|
||||
#include "AssetDumpers/AssetDumperSndCurve.h"
|
||||
#include "AssetDumpers/AssetDumperStringTable.h"
|
||||
#include "AssetDumpers/AssetDumperStructuredDataDefSet.h"
|
||||
#include "AssetDumpers/AssetDumperTracer.h"
|
||||
#include "AssetDumpers/AssetDumperVehicle.h"
|
||||
#include "AssetDumpers/AssetDumperWeapon.h"
|
||||
@ -71,7 +72,7 @@ bool ZoneDumper::DumpZone(AssetDumpingContext& context) const
|
||||
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(AssetDumperStructuredDataDefSet, m_structed_data_def_set, ASSET_TYPE_STRUCTURED_DATA_DEF)
|
||||
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)
|
||||
DUMP_ASSET_POOL(AssetDumperAddonMapEnts, m_addon_map_ents, ASSET_TYPE_ADDON_MAP_ENTS)
|
||||
|
Loading…
x
Reference in New Issue
Block a user