mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-19 15:52:53 +00:00
ZoneLoading: Extract all obj dumping relevant parts to ObjWriting component
This commit is contained in:
parent
e8de3a3f39
commit
00b3322cb2
@ -100,6 +100,9 @@ include "src/ZoneCodeGenerator.lua"
|
|||||||
include "src/ZoneCommon.lua"
|
include "src/ZoneCommon.lua"
|
||||||
include "src/ZoneLoading.lua"
|
include "src/ZoneLoading.lua"
|
||||||
include "src/ZoneWriting.lua"
|
include "src/ZoneWriting.lua"
|
||||||
|
include "src/ZoneCommon.lua"
|
||||||
|
include "src/ObjLoading.lua"
|
||||||
|
include "src/ObjWriting.lua"
|
||||||
|
|
||||||
-- Components group: All projects assist or are part of a tool
|
-- Components group: All projects assist or are part of a tool
|
||||||
group "Components"
|
group "Components"
|
||||||
@ -110,6 +113,8 @@ group "Components"
|
|||||||
ZoneCommon:project()
|
ZoneCommon:project()
|
||||||
ZoneLoading:project()
|
ZoneLoading:project()
|
||||||
ZoneWriting:project()
|
ZoneWriting:project()
|
||||||
|
ObjLoading:project()
|
||||||
|
ObjWriting:project()
|
||||||
group ""
|
group ""
|
||||||
|
|
||||||
-- Tools group: All projects that compile into the final tools
|
-- Tools group: All projects that compile into the final tools
|
||||||
|
44
src/ObjLoading.lua
Normal file
44
src/ObjLoading.lua
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
ObjLoading = {}
|
||||||
|
|
||||||
|
function ObjLoading:include()
|
||||||
|
ZoneCommon:include()
|
||||||
|
includedirs {
|
||||||
|
path.join(ProjectFolder(), "ObjLoading")
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
function ObjLoading:link()
|
||||||
|
Utils:link()
|
||||||
|
ZoneCommon:link()
|
||||||
|
links {
|
||||||
|
"ObjLoading"
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
function ObjLoading:use()
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function ObjLoading:project()
|
||||||
|
local folder = ProjectFolder();
|
||||||
|
|
||||||
|
project "ObjLoading"
|
||||||
|
targetdir(TargetDirectoryLib)
|
||||||
|
location "%{wks.location}/src/%{prj.name}"
|
||||||
|
kind "StaticLib"
|
||||||
|
language "C++"
|
||||||
|
|
||||||
|
files {
|
||||||
|
path.join(folder, "ObjLoading/**.h"),
|
||||||
|
path.join(folder, "ObjLoading/**.cpp")
|
||||||
|
}
|
||||||
|
|
||||||
|
vpaths {
|
||||||
|
["*"] = {
|
||||||
|
path.join(folder, "ObjLoading")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
self:include()
|
||||||
|
Utils:include()
|
||||||
|
end
|
44
src/ObjWriting.lua
Normal file
44
src/ObjWriting.lua
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
ObjWriting = {}
|
||||||
|
|
||||||
|
function ObjWriting:include()
|
||||||
|
ZoneCommon:include()
|
||||||
|
includedirs {
|
||||||
|
path.join(ProjectFolder(), "ObjWriting")
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
function ObjWriting:link()
|
||||||
|
Utils:link()
|
||||||
|
ZoneCommon:link()
|
||||||
|
links {
|
||||||
|
"ObjWriting"
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
function ObjWriting:use()
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function ObjWriting:project()
|
||||||
|
local folder = ProjectFolder();
|
||||||
|
|
||||||
|
project "ObjWriting"
|
||||||
|
targetdir(TargetDirectoryLib)
|
||||||
|
location "%{wks.location}/src/%{prj.name}"
|
||||||
|
kind "StaticLib"
|
||||||
|
language "C++"
|
||||||
|
|
||||||
|
files {
|
||||||
|
path.join(folder, "ObjWriting/**.h"),
|
||||||
|
path.join(folder, "ObjWriting/**.cpp")
|
||||||
|
}
|
||||||
|
|
||||||
|
vpaths {
|
||||||
|
["*"] = {
|
||||||
|
path.join(folder, "ObjWriting")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
self:include()
|
||||||
|
Utils:include()
|
||||||
|
end
|
32
src/ObjWriting/ObjWriting.cpp
Normal file
32
src/ObjWriting/ObjWriting.cpp
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#include "ObjWriting.h"
|
||||||
|
#include "Dumping/IZoneDumper.h"
|
||||||
|
#include "Game/T6/ZoneDumperT6.h"
|
||||||
|
|
||||||
|
IZoneDumper* zoneDumper[]
|
||||||
|
{
|
||||||
|
new ZoneDumperT6()
|
||||||
|
};
|
||||||
|
|
||||||
|
bool ObjWriting::DumpZone(Zone* zone, const std::string& basePath)
|
||||||
|
{
|
||||||
|
for (auto dumper : zoneDumper)
|
||||||
|
{
|
||||||
|
if (dumper->CanHandleZone(zone))
|
||||||
|
{
|
||||||
|
if (dumper->DumpZone(zone, basePath))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Dumper for zone '%s' failed!\n", zone->m_name.c_str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ObjWriting::WriteZoneDefinition(Zone* zone, FileAPI::File* file, bool minimalistic)
|
||||||
|
{
|
||||||
|
return file->Printf("// %s", "Insert zone definition here") > 0;
|
||||||
|
}
|
12
src/ObjWriting/ObjWriting.h
Normal file
12
src/ObjWriting/ObjWriting.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Zone/Zone.h"
|
||||||
|
#include "Utils/FileAPI.h"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
class ObjWriting
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static bool DumpZone(Zone* zone, const std::string& basePath);
|
||||||
|
static bool WriteZoneDefinition(Zone* zone, FileAPI::File* file, bool minimalistic);
|
||||||
|
};
|
@ -31,7 +31,9 @@ function Unlinker:project()
|
|||||||
self:include()
|
self:include()
|
||||||
Utils:include()
|
Utils:include()
|
||||||
ZoneLoading:include()
|
ZoneLoading:include()
|
||||||
|
ObjWriting:include()
|
||||||
|
|
||||||
Utils:link()
|
Utils:link()
|
||||||
ZoneLoading:link()
|
ZoneLoading:link()
|
||||||
|
ObjWriting:link()
|
||||||
end
|
end
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
#include "Utils/Arguments/ArgumentParser.h"
|
#include "Utils/Arguments/ArgumentParser.h"
|
||||||
#include "Utils/Arguments/UsageInformation.h"
|
#include "Utils/Arguments/UsageInformation.h"
|
||||||
#include "ZoneLoading.h"
|
#include "ZoneLoading.h"
|
||||||
|
#include "ObjWriting.h"
|
||||||
#include "ContentPrinter.h"
|
#include "ContentPrinter.h"
|
||||||
#include "Utils/PathUtils.h"
|
#include "Utils/PathUtils.h"
|
||||||
|
#include "Utils/FileAPI.h"
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
@ -96,8 +98,8 @@ bool HandleZone(Zone* zone, ArgumentParser* argumentParser)
|
|||||||
|
|
||||||
if (zoneDefinitionFile.IsOpen())
|
if (zoneDefinitionFile.IsOpen())
|
||||||
{
|
{
|
||||||
ZoneLoading::WriteZoneDefinition(zone, &zoneDefinitionFile, minimalisticZoneDefinition);
|
ObjWriting::WriteZoneDefinition(zone, &zoneDefinitionFile, minimalisticZoneDefinition);
|
||||||
ZoneLoading::DumpZone(zone, outputFolderPath);
|
ObjWriting::DumpZone(zone, outputFolderPath);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1,20 +1,12 @@
|
|||||||
#include "ZoneLoading.h"
|
#include "ZoneLoading.h"
|
||||||
#include "Utils/PathUtils.h"
|
#include "Utils/PathUtils.h"
|
||||||
#include "Dumping/IZoneDumper.h"
|
|
||||||
|
|
||||||
#include "Game/T6/ZoneLoaderFactoryT6.h"
|
#include "Game/T6/ZoneLoaderFactoryT6.h"
|
||||||
#include "Game/T6/ZoneDumperT6.h"
|
|
||||||
|
|
||||||
IZoneLoaderFactory* zoneLoaderFactories[]
|
IZoneLoaderFactory* zoneLoaderFactories[]
|
||||||
{
|
{
|
||||||
new ZoneLoaderFactoryT6()
|
new ZoneLoaderFactoryT6()
|
||||||
};
|
};
|
||||||
|
|
||||||
IZoneDumper* zoneDumper[]
|
|
||||||
{
|
|
||||||
new ZoneDumperT6()
|
|
||||||
};
|
|
||||||
|
|
||||||
Zone* ZoneLoading::LoadZone(const std::string& path)
|
Zone* ZoneLoading::LoadZone(const std::string& path)
|
||||||
{
|
{
|
||||||
std::string zoneName = utils::Path::GetFilenameWithoutExtension(path);
|
std::string zoneName = utils::Path::GetFilenameWithoutExtension(path);
|
||||||
@ -49,27 +41,3 @@ Zone* ZoneLoading::LoadZone(const std::string& path)
|
|||||||
file.Close();
|
file.Close();
|
||||||
return loadedZone;
|
return loadedZone;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ZoneLoading::DumpZone(Zone* zone, const std::string& basePath)
|
|
||||||
{
|
|
||||||
for(auto dumper : zoneDumper)
|
|
||||||
{
|
|
||||||
if(dumper->CanHandleZone(zone))
|
|
||||||
{
|
|
||||||
if(dumper->DumpZone(zone, basePath))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Dumper for zone '%s' failed!\n", zone->m_name.c_str());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ZoneLoading::WriteZoneDefinition(Zone* zone, FileAPI::File* file, bool minimalistic)
|
|
||||||
{
|
|
||||||
return file->Printf("// %s", "Insert zone definition here") > 0;
|
|
||||||
}
|
|
@ -1,12 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "Zone/Zone.h"
|
#include "Zone/Zone.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "Utils/FileAPI.h"
|
|
||||||
|
|
||||||
class ZoneLoading
|
class ZoneLoading
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Zone* LoadZone(const std::string& path);
|
static Zone* LoadZone(const std::string& path);
|
||||||
static bool DumpZone(Zone* zone, const std::string& basePath);
|
|
||||||
static bool WriteZoneDefinition(Zone* zone, FileAPI::File* file, bool minimalistic);
|
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user