Unlinker: Make zone files creators game dependent and in the unlinker project instead of the ObjWriting component

This commit is contained in:
Jan
2020-02-18 17:15:51 +01:00
parent 992e9cea30
commit 9572391082
18 changed files with 217 additions and 40 deletions

View File

@ -0,0 +1,21 @@
#include "ContentPrinter.h"
ContentPrinter::ContentPrinter(Zone* zone)
{
m_zone = zone;
}
void ContentPrinter::PrintContent() const
{
const ZoneContent content = m_zone->GetPools()->GetContent();
printf("Zone '%s' (%s)\n", m_zone->m_name.c_str(), content.m_game_name.c_str());
puts("Content:");
for(const auto& asset : content.m_assets)
{
printf("%s, %s\n", asset.m_asset_type_name.c_str(), asset.m_asset_name.c_str());
}
puts("");
}

View File

@ -0,0 +1,13 @@
#pragma once
#include "Zone/Zone.h"
class ContentPrinter
{
Zone* m_zone;
public:
explicit ContentPrinter(Zone* zone);
void PrintContent() const;
};

View File

@ -0,0 +1,39 @@
#include "ZoneDefWriter.h"
const std::string AbstractZoneDefWriter::META_DATA_KEY_GAME = "game";
AbstractZoneDefWriter::AbstractZoneDefWriter(Zone* zone, FileAPI::IFile* file)
{
m_zone = zone;
m_file = file;
}
void AbstractZoneDefWriter::EmptyLine() const
{
m_file->Printf("\n");
}
void AbstractZoneDefWriter::WriteComment(const std::string& comment) const
{
m_file->Printf("// %s\n", comment.c_str());
}
void AbstractZoneDefWriter::WriteMetaData(const std::string& metaDataKey, const std::string& metaDataValue) const
{
m_file->Printf(">%s,%s\n", metaDataKey.c_str(), metaDataValue.c_str());
}
void AbstractZoneDefWriter::WriteEntry(const std::string& entryKey, const std::string& entryValue) const
{
m_file->Printf("%s,%s\n", entryKey.c_str(), entryValue.c_str());
}
void AbstractZoneDefWriter::WriteContent() const
{
auto zoneContent = m_zone->GetPools()->GetContent();
for(const auto& asset : zoneContent.m_assets)
{
WriteEntry(asset.m_asset_type_name, asset.m_asset_name);
}
}

View File

@ -0,0 +1,30 @@
#pragma once
#include "Utils/FileAPI.h"
#include "Zone/Zone.h"
class AbstractZoneDefWriter
{
protected:
Zone* m_zone;
FileAPI::IFile* m_file;
static const std::string META_DATA_KEY_GAME;
void EmptyLine() const;
void WriteComment(const std::string& comment) const;
void WriteMetaData(const std::string& metaDataKey, const std::string& metaDataValue) const;
void WriteEntry(const std::string& entryKey, const std::string& entryValue) const;
void WriteContent() const;
AbstractZoneDefWriter(Zone* zone, FileAPI::IFile* file);
public:
virtual void WriteZoneDef() = 0;
};
class IZoneDefWriter
{
public:
virtual bool CanHandleZone(Zone* zone) const = 0;
virtual void WriteZoneDef(Zone* zone, FileAPI::IFile* file) const = 0;
};