Skip to content

Commit

Permalink
refactor: extract image code into single component
Browse files Browse the repository at this point in the history
  • Loading branch information
Laupetin committed Sep 27, 2024
1 parent a2d70c1 commit 2dccd42
Show file tree
Hide file tree
Showing 46 changed files with 66 additions and 13 deletions.
2 changes: 2 additions & 0 deletions premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ include "src/ZoneLoading.lua"
include "src/ZoneWriting.lua"
include "src/ZoneCommon.lua"
include "src/ObjCommon.lua"
include "src/ObjImage.lua"
include "src/ObjLoading.lua"
include "src/ObjWriting.lua"
include "tools/scripts/raw.lua"
Expand All @@ -142,6 +143,7 @@ group "Components"
ZoneLoading:project()
ZoneWriting:project()
ObjCommon:project()
ObjImage:project()
ObjLoading:project()
ObjWriting:project()
group ""
Expand Down
1 change: 0 additions & 1 deletion src/Common/Game/IW3/IW3.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

// #include <d3d9.h>
#include "Game/IAsset.h"
#include "Image/Texture.h"

#include "IW3_Assets.h"

Expand Down
2 changes: 2 additions & 0 deletions src/Common/Game/IW4/CommonIW4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include "Utils/Pack.h"

#include <cctype>

using namespace IW4;

int Common::StringTable_HashString(const char* str)
Expand Down
1 change: 0 additions & 1 deletion src/Common/Game/IW4/IW4.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

// #include <d3d9.h>
#include "Game/IAsset.h"
#include "Image/Texture.h"

#include "IW4_Assets.h"

Expand Down
2 changes: 2 additions & 0 deletions src/Common/Game/IW5/CommonIW5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include "Utils/Pack.h"

#include <cctype>

using namespace IW5;

int Common::StringTable_HashString(const char* str)
Expand Down
1 change: 0 additions & 1 deletion src/Common/Game/IW5/IW5.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

// #include <d3d9.h>
#include "Game/IAsset.h"
#include "Image/Texture.h"

#include "IW5_Assets.h"

Expand Down
1 change: 0 additions & 1 deletion src/Common/Game/T5/T5.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

// #include <d3d9.h>
#include "Game/IAsset.h"
#include "Image/Texture.h"

#include "T5_Assets.h"

Expand Down
1 change: 0 additions & 1 deletion src/Common/Game/T6/T6.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

// #include <d3d11.h>
#include "Game/IAsset.h"
#include "Image/Texture.h"

#include "T6_Assets.h"

Expand Down
6 changes: 2 additions & 4 deletions src/ImageConverter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,11 @@ function ImageConverter:project()

self:include(includes)
Utils:include(includes)
ObjLoading:include(includes)
ObjWriting:include(includes)
ObjImage:include(includes)

Raw:use()

links:linkto(Utils)
links:linkto(ObjLoading)
links:linkto(ObjWriting)
links:linkto(ObjImage)
links:linkall()
end
4 changes: 0 additions & 4 deletions src/ImageConverter/ImageConverterArgs.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#include "ImageConverterArgs.h"

#include "GitVersion.h"
#include "ObjLoading.h"
#include "ObjWriting.h"
#include "Utils/Arguments/UsageInformation.h"

#include <format>
Expand Down Expand Up @@ -109,8 +107,6 @@ void ImageConverterArgs::PrintVersion()
void ImageConverterArgs::SetVerbose(const bool isVerbose)
{
m_verbose = isVerbose;
ObjLoading::Configuration.Verbose = isVerbose;
ObjWriting::Configuration.Verbose = isVerbose;
}

bool ImageConverterArgs::ParseArgs(const int argc, const char** argv, bool& shouldContinue)
Expand Down
47 changes: 47 additions & 0 deletions src/ObjImage.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
ObjImage = {}

function ObjImage:include(includes)
if includes:handle(self:name()) then
includedirs {
path.join(ProjectFolder(), "ObjImage")
}
end
end

function ObjImage:link(links)
links:add(self:name())
links:linkto(Utils)
end

function ObjImage:use()

end

function ObjImage:name()
return "ObjImage"
end

function ObjImage:project()
local folder = ProjectFolder()
local includes = Includes:create()

project(self:name())
targetdir(TargetDirectoryLib)
location "%{wks.location}/src/%{prj.name}"
kind "StaticLib"
language "C++"

files {
path.join(folder, "ObjImage/**.h"),
path.join(folder, "ObjImage/**.cpp")
}

vpaths {
["*"] = {
path.join(folder, "ObjImage")
}
}

self:include(includes)
Utils:include(includes)
end
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions src/ObjLoading.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ ObjLoading = {}
function ObjLoading:include(includes)
if includes:handle(self:name()) then
ObjCommon:include(includes)
ObjImage:include(includes)
ZoneCommon:include(includes)
includedirs {
path.join(ProjectFolder(), "ObjLoading")
Expand All @@ -14,6 +15,7 @@ function ObjLoading:link(links)
links:add(self:name())
links:linkto(Utils)
links:linkto(ObjCommon)
links:linkto(ObjImage)
links:linkto(ZoneCommon)
links:linkto(minilzo)
links:linkto(minizip)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "Game/IW4/IW4.h"
#include "Utils/MemoryManager.h"

#include <istream>

namespace IW4
{
bool LoadLeaderboardAsJson(std::istream& stream, LeaderboardDef& leaderboard, MemoryManager* memory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "Game/IW5/IW5.h"
#include "Utils/MemoryManager.h"

#include <istream>

namespace IW5
{
bool LoadLeaderboardAsJson(std::istream& stream, LeaderboardDef& leaderboard, MemoryManager* memory);
Expand Down
2 changes: 2 additions & 0 deletions src/ObjWriting.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ ObjWriting = {}
function ObjWriting:include(includes)
if includes:handle(self:name()) then
ObjCommon:include(includes)
ObjImage:include(includes)
ObjLoading:include(includes)
ZoneCommon:include(includes)
includedirs {
Expand All @@ -15,6 +16,7 @@ function ObjWriting:link(links)
links:add(self:name())
links:linkto(Utils)
links:linkto(ObjCommon)
links:linkto(ObjImage)
links:linkto(ObjLoading)
links:linkto(ZoneCommon)
links:linkto(minilzo)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <algorithm>
#include <cassert>
#include <set>
#include <sstream>
#include <type_traits>

Expand Down
2 changes: 2 additions & 0 deletions test/ObjCommonTests.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ function ObjCommonTests:project()

self:include(includes)
ObjCommon:include(includes)
ObjImage:include(includes)
catch2:include(includes)

links:linkto(ObjCommon)
links:linkto(ObjImage)
links:linkto(catch2)
links:linkall()
end

0 comments on commit 2dccd42

Please sign in to comment.