mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-11 23:38:09 -05:00
Menu conversion base
This commit is contained in:
41
src/ObjLoading/Menu/AbstractMenuConverter.cpp
Normal file
41
src/ObjLoading/Menu/AbstractMenuConverter.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
#include "AbstractMenuConverter.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace menu;
|
||||
|
||||
AbstractMenuConverter::AbstractMenuConverter(const bool legacyMode, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager)
|
||||
: m_legacy_mode(legacyMode),
|
||||
m_search_path(searchPath),
|
||||
m_memory(memory),
|
||||
m_manager(manager)
|
||||
{
|
||||
}
|
||||
|
||||
void AbstractMenuConverter::PrintConversionExceptionDetails(const MenuConversionException& e)
|
||||
{
|
||||
std::cout << "ERROR while converting menu:\n";
|
||||
std::cout << " Menu: " << e.m_menu->m_name << "\n";
|
||||
|
||||
if (e.m_item)
|
||||
{
|
||||
std::cout << "Item: ";
|
||||
|
||||
if (!e.m_item->m_name.empty())
|
||||
{
|
||||
std::cout << e.m_item->m_name << "\n";
|
||||
}
|
||||
|
||||
std::cout << "\n";
|
||||
}
|
||||
|
||||
std::cout << " Message: " << e.m_message << "\n";
|
||||
}
|
||||
|
||||
const char* AbstractMenuConverter::ConvertString(const std::string& str) const
|
||||
{
|
||||
if (str.empty())
|
||||
return nullptr;
|
||||
|
||||
return m_memory->Dup(str.c_str());
|
||||
}
|
26
src/ObjLoading/Menu/AbstractMenuConverter.h
Normal file
26
src/ObjLoading/Menu/AbstractMenuConverter.h
Normal file
@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include "MenuConversionException.h"
|
||||
#include "AssetLoading/IAssetLoadingManager.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
#include "Utils/MemoryManager.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
||||
namespace menu
|
||||
{
|
||||
class AbstractMenuConverter
|
||||
{
|
||||
protected:
|
||||
bool m_legacy_mode;
|
||||
ISearchPath* m_search_path;
|
||||
MemoryManager* m_memory;
|
||||
IAssetLoadingManager* m_manager;
|
||||
|
||||
AbstractMenuConverter(bool legacyMode, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager);
|
||||
|
||||
_NODISCARD const char* ConvertString(const std::string& str) const;
|
||||
|
||||
public:
|
||||
static void PrintConversionExceptionDetails(const MenuConversionException& e);
|
||||
};
|
||||
}
|
17
src/ObjLoading/Menu/MenuConversionException.cpp
Normal file
17
src/ObjLoading/Menu/MenuConversionException.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
#include "MenuConversionException.h"
|
||||
|
||||
using namespace menu;
|
||||
|
||||
MenuConversionException::MenuConversionException(std::string message, const CommonMenuDef* menu)
|
||||
: m_menu(menu),
|
||||
m_item(nullptr),
|
||||
m_message(std::move(message))
|
||||
{
|
||||
}
|
||||
|
||||
MenuConversionException::MenuConversionException(std::string message, const CommonMenuDef* menu, const CommonItemDef* item)
|
||||
: m_menu(menu),
|
||||
m_item(item),
|
||||
m_message(std::move(message))
|
||||
{
|
||||
}
|
16
src/ObjLoading/Menu/MenuConversionException.h
Normal file
16
src/ObjLoading/Menu/MenuConversionException.h
Normal file
@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
#include "Parsing/Menu/Domain/CommonMenuDef.h"
|
||||
|
||||
namespace menu
|
||||
{
|
||||
class MenuConversionException final : public std::exception
|
||||
{
|
||||
public:
|
||||
const CommonMenuDef* m_menu;
|
||||
const CommonItemDef* m_item;
|
||||
std::string m_message;
|
||||
|
||||
explicit MenuConversionException(std::string message, const CommonMenuDef* menu);
|
||||
MenuConversionException(std::string message, const CommonMenuDef* menu, const CommonItemDef* item);
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user