refactor: image and obj data loading

This commit is contained in:
Jan
2024-09-24 12:01:42 +01:00
parent 5fee875495
commit 5cc52c42cd
97 changed files with 1784 additions and 1878 deletions

View File

@ -1,27 +1,73 @@
#include "ImageConverter.h"
#include "Image/Texture.h"
#include "ImageConverterArgs.h"
#include "Utils/StringUtils.h"
class ImageConverterImpl final : public ImageConverter
#include <filesystem>
namespace fs = std::filesystem;
namespace image_converter
{
public:
bool Start(const int argc, const char** argv) override
constexpr auto EXTENSION_IWI = ".iwi";
class ImageLoader
{
auto shouldContinue = true;
if (!m_args.ParseArgs(argc, argv, shouldContinue))
return false;
public:
ImageLoader() = default;
virtual ~ImageLoader() = default;
ImageLoader(const ImageLoader& other) = default;
ImageLoader(ImageLoader&& other) noexcept = default;
ImageLoader& operator=(const ImageLoader& other) = default;
ImageLoader& operator=(ImageLoader&& other) noexcept = default;
// virtual Texture*
};
class ImageConverterImpl final : public ImageConverter
{
public:
ImageConverterImpl()
: m_game_to_convert_to(image_converter::Game::UNKNOWN)
{
}
bool Start(const int argc, const char** argv) override
{
auto shouldContinue = true;
if (!m_args.ParseArgs(argc, argv, shouldContinue))
return false;
if (!shouldContinue)
return true;
m_game_to_convert_to = m_args.m_game_to_convert_to;
for (const auto& file : m_args.m_files_to_convert)
Convert(file);
if (!shouldContinue)
return true;
}
return true;
}
private:
void Convert(const std::string& file)
{
fs::path filePath(file);
auto extension = filePath.extension().string();
utils::MakeStringLowerCase(extension);
private:
ImageConverterArgs m_args;
};
if (extension == EXTENSION_IWI)
{
}
}
ImageConverterArgs m_args;
image_converter::Game m_game_to_convert_to;
};
} // namespace image_converter
std::unique_ptr<ImageConverter> ImageConverter::Create()
{
return std::make_unique<ImageConverterImpl>();
return std::make_unique<image_converter::ImageConverterImpl>();
}

View File

@ -29,16 +29,59 @@ const CommandLineOption* const OPTION_VERBOSE =
.WithLongName("verbose")
.WithDescription("Outputs a lot more and more detailed messages.")
.Build();
constexpr auto CATEGORY_GAME = "Game";
const CommandLineOption* const OPTION_GAME_IW3 =
CommandLineOption::Builder::Create()
.WithLongName("iw3")
.WithCategory(CATEGORY_GAME)
.WithDescription("Converts images for IW3.")
.Build();
const CommandLineOption* const OPTION_GAME_IW4 =
CommandLineOption::Builder::Create()
.WithLongName("iw4")
.WithCategory(CATEGORY_GAME)
.WithDescription("Converts images for IW4.")
.Build();
const CommandLineOption* const OPTION_GAME_IW5 =
CommandLineOption::Builder::Create()
.WithLongName("iw5")
.WithCategory(CATEGORY_GAME)
.WithDescription("Converts images for IW5.")
.Build();
const CommandLineOption* const OPTION_GAME_T5 =
CommandLineOption::Builder::Create()
.WithLongName("t5")
.WithCategory(CATEGORY_GAME)
.WithDescription("Converts images for T5.")
.Build();
const CommandLineOption* const OPTION_GAME_T6 =
CommandLineOption::Builder::Create()
.WithLongName("t6")
.WithCategory(CATEGORY_GAME)
.WithDescription("Converts images for T6.")
.Build();
// clang-format on
const CommandLineOption* const COMMAND_LINE_OPTIONS[]{
OPTION_HELP,
OPTION_VERSION,
OPTION_VERBOSE,
OPTION_GAME_IW3,
OPTION_GAME_IW4,
OPTION_GAME_IW5,
OPTION_GAME_T5,
OPTION_GAME_T6,
};
ImageConverterArgs::ImageConverterArgs()
: m_verbose(false),
m_game_to_convert_to(image_converter::Game::UNKNOWN),
m_argument_parser(COMMAND_LINE_OPTIONS, std::extent_v<decltype(COMMAND_LINE_OPTIONS)>)
{
}

View File

@ -1,11 +1,24 @@
#pragma once
#include "Utils/Arguments/ArgumentParser.h"
#include "Utils/ClassUtils.h"
#include <cstdint>
#include <string>
#include <vector>
namespace image_converter
{
enum class Game : std::uint8_t
{
UNKNOWN,
IW3,
IW4,
IW5,
T5,
T6
};
} // namespace image_converter
class ImageConverterArgs
{
public:
@ -14,6 +27,7 @@ public:
bool m_verbose;
std::vector<std::string> m_files_to_convert;
image_converter::Game m_game_to_convert_to;
private:
/**