mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-09-01 14:37:25 +00:00
refactor: use IAssetDumper interface on implementations directly
This commit is contained in:
@@ -1,9 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/T6/T6.h"
|
||||
|
||||
namespace T6
|
||||
{
|
||||
void DumpFontIconAsCsv(const AssetDumpingContext& context, const FontIcon& fontIcon);
|
||||
}
|
@@ -1,9 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/T6/T6.h"
|
||||
|
||||
namespace T6
|
||||
{
|
||||
void DumpFontIconAsJson(const AssetDumpingContext& context, const FontIcon& fontIcon);
|
||||
}
|
@@ -1,22 +0,0 @@
|
||||
#include "DumperFontIconT6.h"
|
||||
|
||||
#include "DumperFontIconCsvT6.h"
|
||||
#include "DumperFontIconJsonT6.h"
|
||||
|
||||
using namespace T6;
|
||||
|
||||
// #define DUMP_FONT_ICON_AS_CSV 1
|
||||
|
||||
bool AssetDumperFontIcon::ShouldDump(XAssetInfo<FontIcon>* asset)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void AssetDumperFontIcon::DumpAsset(AssetDumpingContext& context, XAssetInfo<FontIcon>* asset)
|
||||
{
|
||||
#ifdef DUMP_FONT_ICON_AS_CSV
|
||||
DumpFontIconAsCsv(context, *asset->Asset());
|
||||
#else
|
||||
DumpFontIconAsJson(context, *asset->Asset());
|
||||
#endif
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
#include "DumperFontIconCsvT6.h"
|
||||
#include "FontIconCsvDumperT6.h"
|
||||
|
||||
#include "Csv/CsvStream.h"
|
||||
#include "Game/T6/CommonT6.h"
|
||||
@@ -52,15 +52,15 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
class DumperFontIconCsv
|
||||
class Dumper
|
||||
{
|
||||
public:
|
||||
explicit DumperFontIconCsv(std::ostream& stream)
|
||||
explicit Dumper(std::ostream& stream)
|
||||
: m_csv(stream)
|
||||
{
|
||||
}
|
||||
|
||||
void DumpFontIcon(const FontIcon& fontIcon)
|
||||
void Dump(const FontIcon& fontIcon)
|
||||
{
|
||||
WriteFontIconEntries(fontIcon);
|
||||
m_csv.NextRow();
|
||||
@@ -131,16 +131,21 @@ namespace
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace T6
|
||||
namespace T6::font_icon
|
||||
{
|
||||
void DumpFontIconAsCsv(const AssetDumpingContext& context, const FontIcon& fontIcon)
|
||||
bool CsvDumper::ShouldDump(XAssetInfo<FontIcon>* asset)
|
||||
{
|
||||
const auto assetFile = context.OpenAssetFile(fontIcon.name);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CsvDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo<FontIcon>* asset)
|
||||
{
|
||||
const auto assetFile = context.OpenAssetFile(asset->m_name);
|
||||
|
||||
if (!assetFile)
|
||||
return;
|
||||
|
||||
DumperFontIconCsv dumperFontIconCsv(*assetFile);
|
||||
dumperFontIconCsv.DumpFontIcon(fontIcon);
|
||||
Dumper dumper(*assetFile);
|
||||
dumper.Dump(*asset->Asset());
|
||||
}
|
||||
} // namespace T6
|
||||
} // namespace T6::font_icon
|
@@ -3,12 +3,12 @@
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/T6/T6.h"
|
||||
|
||||
namespace T6
|
||||
namespace T6::font_icon
|
||||
{
|
||||
class AssetDumperFontIcon final : public AbstractAssetDumper<FontIcon>
|
||||
class CsvDumper final : public AbstractAssetDumper<FontIcon>
|
||||
{
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<FontIcon>* asset) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<FontIcon>* asset) override;
|
||||
};
|
||||
} // namespace T6
|
||||
} // namespace T6::font_icon
|
20
src/ObjWriting/Game/T6/FontIcon/FontIconDumperT6.cpp
Normal file
20
src/ObjWriting/Game/T6/FontIcon/FontIconDumperT6.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#include "FontIconDumperT6.h"
|
||||
|
||||
#include "FontIconCsvDumperT6.h"
|
||||
#include "FontIconJsonDumperT6.h"
|
||||
|
||||
using namespace T6;
|
||||
|
||||
// #define DUMP_FONT_ICON_AS_CSV 1
|
||||
|
||||
namespace T6::font_icon
|
||||
{
|
||||
std::unique_ptr<IAssetDumper<FontIcon>> CreateDumper()
|
||||
{
|
||||
#ifdef DUMP_FONT_ICON_AS_CSV
|
||||
return std::make_unique<CsvDumper>();
|
||||
#else
|
||||
return std::make_unique<JsonDumper>();
|
||||
#endif
|
||||
}
|
||||
} // namespace T6::font_icon
|
9
src/ObjWriting/Game/T6/FontIcon/FontIconDumperT6.h
Normal file
9
src/ObjWriting/Game/T6/FontIcon/FontIconDumperT6.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/T6/T6.h"
|
||||
|
||||
namespace T6::font_icon
|
||||
{
|
||||
std::unique_ptr<IAssetDumper<FontIcon>> CreateDumper();
|
||||
} // namespace T6::font_icon
|
@@ -1,4 +1,4 @@
|
||||
#include "DumperFontIconJsonT6.h"
|
||||
#include "FontIconJsonDumperT6.h"
|
||||
|
||||
#include "Game/T6/CommonT6.h"
|
||||
#include "Game/T6/FontIcon/FontIconCommonT6.h"
|
||||
@@ -76,15 +76,20 @@ namespace
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace T6
|
||||
namespace T6::font_icon
|
||||
{
|
||||
void DumpFontIconAsJson(const AssetDumpingContext& context, const FontIcon& fontIcon)
|
||||
bool JsonDumper::ShouldDump(XAssetInfo<FontIcon>* asset)
|
||||
{
|
||||
const auto assetFile = context.OpenAssetFile(font_icon::GetJsonFileNameForAssetName(fontIcon.name));
|
||||
return true;
|
||||
}
|
||||
|
||||
void JsonDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo<FontIcon>* asset)
|
||||
{
|
||||
const auto assetFile = context.OpenAssetFile(font_icon::GetJsonFileNameForAssetName(asset->m_name));
|
||||
|
||||
if (!assetFile)
|
||||
return;
|
||||
|
||||
DumpFontIcon(*assetFile, fontIcon);
|
||||
DumpFontIcon(*assetFile, *asset->Asset());
|
||||
}
|
||||
} // namespace T6
|
||||
} // namespace T6::font_icon
|
14
src/ObjWriting/Game/T6/FontIcon/FontIconJsonDumperT6.h
Normal file
14
src/ObjWriting/Game/T6/FontIcon/FontIconJsonDumperT6.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/T6/T6.h"
|
||||
|
||||
namespace T6::font_icon
|
||||
{
|
||||
class JsonDumper final : public AbstractAssetDumper<FontIcon>
|
||||
{
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<FontIcon>* asset) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<FontIcon>* asset) override;
|
||||
};
|
||||
} // namespace T6::font_icon
|
@@ -1,6 +1,6 @@
|
||||
#include "ObjWriterT6.h"
|
||||
|
||||
#include "FontIcon/DumperFontIconT6.h"
|
||||
#include "FontIcon/FontIconDumperT6.h"
|
||||
#include "Game/T6/GameAssetPoolT6.h"
|
||||
#include "Game/T6/XModel/XModelDumperT6.h"
|
||||
#include "Image/AssetDumperGfxImage.h"
|
||||
@@ -37,6 +37,12 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const
|
||||
dumperType dumper; \
|
||||
dumper.DumpPool(context, assetPools->poolName.get()); \
|
||||
}
|
||||
#define DUMP_ASSET_POOL_WITH_FACTORY(createDumper, poolName, assetType) \
|
||||
if (assetPools->poolName && ObjWriting::ShouldHandleAssetType(assetType)) \
|
||||
{ \
|
||||
const auto dumper = createDumper; \
|
||||
dumper->DumpPool(context, assetPools->poolName.get()); \
|
||||
}
|
||||
|
||||
const auto* assetPools = dynamic_cast<GameAssetPoolT6*>(context.m_zone.m_pools.get());
|
||||
|
||||
@@ -58,7 +64,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const
|
||||
// DUMP_ASSET_POOL(AssetDumperGfxWorld, m_gfx_world, ASSET_TYPE_GFXWORLD)
|
||||
// DUMP_ASSET_POOL(AssetDumperGfxLightDef, m_gfx_light_def, ASSET_TYPE_LIGHT_DEF)
|
||||
// DUMP_ASSET_POOL(AssetDumperFont, m_font, ASSET_TYPE_FONT)
|
||||
DUMP_ASSET_POOL(AssetDumperFontIcon, m_font_icon, ASSET_TYPE_FONTICON)
|
||||
DUMP_ASSET_POOL_WITH_FACTORY(font_icon::CreateDumper(), m_font_icon, ASSET_TYPE_FONTICON)
|
||||
// DUMP_ASSET_POOL(AssetDumperMenuList, m_menu_list, ASSET_TYPE_MENULIST)
|
||||
// DUMP_ASSET_POOL(AssetDumperMenuDef, m_menu_def, ASSET_TYPE_MENU)
|
||||
DUMP_ASSET_POOL(AssetDumperLocalizeEntry, m_localize, ASSET_TYPE_LOCALIZE_ENTRY)
|
||||
|
Reference in New Issue
Block a user