mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-10 23:08:05 -05:00
Add AssetDumperContext to bundle context fields for dumping
(cherry picked from commit ed8331280392ef3a2b4657c5dbd0880463d85f2c)
This commit is contained in:
@ -7,15 +7,15 @@
|
||||
#include <iostream>
|
||||
|
||||
template<class T>
|
||||
class AbstractAssetDumper : public IAssetDumper<T>
|
||||
class AbstractFileDumper : public IAssetDumper<T>
|
||||
{
|
||||
protected:
|
||||
virtual bool ShouldDump(XAssetInfo<T>* asset) = 0;
|
||||
virtual std::string GetFileNameForAsset(Zone* zone, XAssetInfo<T>* asset) = 0;
|
||||
virtual void DumpAsset(Zone* zone, XAssetInfo<T>* asset, std::ostream& stream) = 0;
|
||||
virtual void DumpAsset(AssetDumpingContext& context, XAssetInfo<T>* asset, std::ostream& stream) = 0;
|
||||
|
||||
public:
|
||||
void DumpPool(Zone* zone, AssetPool<T>* pool, const std::string& basePath) override
|
||||
void DumpPool(AssetDumpingContext& context, AssetPool<T>* pool) override
|
||||
{
|
||||
for(auto assetInfo : *pool)
|
||||
{
|
||||
@ -25,8 +25,8 @@ public:
|
||||
continue;
|
||||
}
|
||||
|
||||
std::filesystem::path assetFilePath(basePath);
|
||||
assetFilePath.append(GetFileNameForAsset(zone, assetInfo));
|
||||
std::filesystem::path assetFilePath(context.m_base_path);
|
||||
assetFilePath.append(GetFileNameForAsset(context.m_zone, assetInfo));
|
||||
|
||||
auto assetFileFolder(assetFilePath);
|
||||
assetFileFolder.replace_filename("");
|
||||
@ -35,7 +35,7 @@ public:
|
||||
std::ofstream file(assetFilePath, std::fstream::out | std::fstream::binary);
|
||||
if(file.is_open())
|
||||
{
|
||||
DumpAsset(zone, assetInfo, file);
|
||||
DumpAsset(context, assetInfo, file);
|
||||
|
||||
file.close();
|
||||
}
|
0
src/ObjWriting/Dumping/AssetDumpingContext.cpp
Normal file
0
src/ObjWriting/Dumping/AssetDumpingContext.cpp
Normal file
12
src/ObjWriting/Dumping/AssetDumpingContext.h
Normal file
12
src/ObjWriting/Dumping/AssetDumpingContext.h
Normal file
@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "Zone/Zone.h"
|
||||
|
||||
class AssetDumpingContext
|
||||
{
|
||||
public:
|
||||
Zone* m_zone;
|
||||
std::string m_base_path;
|
||||
};
|
@ -1,13 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include "Zone/Zone.h"
|
||||
#include "AssetDumpingContext.h"
|
||||
#include "Pool/AssetPool.h"
|
||||
|
||||
template<class T>
|
||||
class IAssetDumper
|
||||
{
|
||||
public:
|
||||
IAssetDumper() = default;
|
||||
virtual ~IAssetDumper() = default;
|
||||
IAssetDumper(const IAssetDumper& other) = default;
|
||||
IAssetDumper(IAssetDumper&& other) noexcept = default;
|
||||
IAssetDumper& operator=(const IAssetDumper& other) = default;
|
||||
IAssetDumper& operator=(IAssetDumper&& other) noexcept = default;
|
||||
|
||||
virtual void DumpPool(Zone* zone, AssetPool<T>* pool, const std::string& basePath) = 0;
|
||||
virtual void DumpPool(AssetDumpingContext& context, AssetPool<T>* pool) = 0;
|
||||
};
|
@ -1,12 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "Zone/Zone.h"
|
||||
#include "AssetDumpingContext.h"
|
||||
|
||||
class IZoneDumper
|
||||
{
|
||||
public:
|
||||
IZoneDumper() = default;
|
||||
virtual ~IZoneDumper() = default;
|
||||
IZoneDumper(const IZoneDumper& other) = default;
|
||||
IZoneDumper(IZoneDumper&& other) noexcept = default;
|
||||
IZoneDumper& operator=(const IZoneDumper& other) = default;
|
||||
IZoneDumper& operator=(IZoneDumper&& other) noexcept = default;
|
||||
|
||||
virtual bool CanHandleZone(Zone* zone) const = 0;
|
||||
virtual bool DumpZone(Zone* zone, const std::string& basePath) const = 0;
|
||||
virtual bool CanHandleZone(AssetDumpingContext& assetDumpingContext) const = 0;
|
||||
virtual bool DumpZone(AssetDumpingContext& assetDumpingContext) const = 0;
|
||||
};
|
Reference in New Issue
Block a user