mirror of
				https://github.com/Laupetin/OpenAssetTools.git
				synced 2025-10-30 10:06:57 +00:00 
			
		
		
		
	chore: refactor IW4 asset loaders
This commit is contained in:
		| @@ -1,35 +1,29 @@ | ||||
| #include "AbstractMenuConverter.h" | ||||
|  | ||||
| #include <format> | ||||
| #include <iostream> | ||||
|  | ||||
| using namespace menu; | ||||
|  | ||||
| AbstractMenuConverter::AbstractMenuConverter(const bool disableOptimizations, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager) | ||||
| AbstractMenuConverter::AbstractMenuConverter(const bool disableOptimizations, ISearchPath& searchPath, MemoryManager& memory, AssetCreationContext& context) | ||||
|     : m_disable_optimizations(disableOptimizations), | ||||
|       m_search_path(searchPath), | ||||
|       m_memory(memory), | ||||
|       m_manager(manager) | ||||
|       m_context(context) | ||||
| { | ||||
| } | ||||
|  | ||||
| void AbstractMenuConverter::PrintConversionExceptionDetails(const MenuConversionException& e) | ||||
| { | ||||
|     std::cout << "ERROR while converting menu:\n"; | ||||
|     std::cout << "  Menu: " << e.m_menu->m_name << "\n"; | ||||
|     std::cerr << "ERROR while converting menu:\n"; | ||||
|     std::cerr << std::format("  Menu: {}\n", e.m_menu->m_name); | ||||
|  | ||||
|     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::cerr << std::format("Item: {}\n", e.m_item->m_name); | ||||
|     } | ||||
|  | ||||
|     std::cout << "  Message: " << e.m_message << "\n"; | ||||
|     std::cerr << std::format("  Message: {}\n", e.m_message); | ||||
| } | ||||
|  | ||||
| const char* AbstractMenuConverter::ConvertString(const std::string& str) const | ||||
| @@ -37,5 +31,5 @@ const char* AbstractMenuConverter::ConvertString(const std::string& str) const | ||||
|     if (str.empty()) | ||||
|         return nullptr; | ||||
|  | ||||
|     return m_memory->Dup(str.c_str()); | ||||
|     return m_memory.Dup(str.c_str()); | ||||
| } | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include "AssetLoading/IAssetLoadingManager.h" | ||||
| #include "Asset/AssetCreationContext.h" | ||||
| #include "MenuConversionException.h" | ||||
| #include "SearchPath/ISearchPath.h" | ||||
| #include "Utils/ClassUtils.h" | ||||
| @@ -11,16 +11,14 @@ namespace menu | ||||
|     class AbstractMenuConverter | ||||
|     { | ||||
|     protected: | ||||
|         bool m_disable_optimizations; | ||||
|         ISearchPath* m_search_path; | ||||
|         MemoryManager* m_memory; | ||||
|         IAssetLoadingManager* m_manager; | ||||
|  | ||||
|         AbstractMenuConverter(bool disableOptimizations, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager); | ||||
|         AbstractMenuConverter(bool disableOptimizations, ISearchPath& searchPath, MemoryManager& memory, AssetCreationContext& context); | ||||
|  | ||||
|         _NODISCARD const char* ConvertString(const std::string& str) const; | ||||
|  | ||||
|     public: | ||||
|         static void PrintConversionExceptionDetails(const MenuConversionException& e); | ||||
|  | ||||
|         bool m_disable_optimizations; | ||||
|         ISearchPath& m_search_path; | ||||
|         MemoryManager& m_memory; | ||||
|         AssetCreationContext& m_context; | ||||
|     }; | ||||
| } // namespace menu | ||||
|   | ||||
		Reference in New Issue
	
	Block a user