mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 00:02:55 +00:00
Add command line argument for disable menu optimizations on loading
This commit is contained in:
parent
6d622e6ae1
commit
d24e847204
@ -76,6 +76,12 @@ const CommandLineOption* const OPTION_MENU_PERMISSIVE =
|
|||||||
.WithDescription("Allows the usage of unknown script commands that can be compiled.")
|
.WithDescription("Allows the usage of unknown script commands that can be compiled.")
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
|
const CommandLineOption* const OPTION_MENU_NO_OPTIMIZATION =
|
||||||
|
CommandLineOption::Builder::Create()
|
||||||
|
.WithLongName("menu-no-optimization")
|
||||||
|
.WithDescription("Refrain from applying optimizations to parsed menus. (Optimizations increase menu performance and size. May result in less source information when dumped though.)")
|
||||||
|
.Build();
|
||||||
|
|
||||||
const CommandLineOption* const COMMAND_LINE_OPTIONS[]
|
const CommandLineOption* const COMMAND_LINE_OPTIONS[]
|
||||||
{
|
{
|
||||||
OPTION_HELP,
|
OPTION_HELP,
|
||||||
@ -266,7 +272,11 @@ bool LinkerArgs::ParseArgs(const int argc, const char** argv)
|
|||||||
|
|
||||||
// --menu-permissive
|
// --menu-permissive
|
||||||
if (m_argument_parser.IsOptionSpecified(OPTION_MENU_PERMISSIVE))
|
if (m_argument_parser.IsOptionSpecified(OPTION_MENU_PERMISSIVE))
|
||||||
ObjLoading::Configuration.PermissiveMenuParsing = true;
|
ObjLoading::Configuration.MenuPermissiveParsing = true;
|
||||||
|
|
||||||
|
// --menu-no-optimization
|
||||||
|
if (m_argument_parser.IsOptionSpecified(OPTION_MENU_NO_OPTIMIZATION))
|
||||||
|
ObjLoading::Configuration.MenuNoOptimization = true;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -75,8 +75,7 @@ bool AssetLoaderMenuList::ProcessParsedResults(const std::string& assetName, ISe
|
|||||||
|
|
||||||
for (const auto& menu : parsingResult->m_menus)
|
for (const auto& menu : parsingResult->m_menus)
|
||||||
{
|
{
|
||||||
// TODO: Use command line arguments to activate legacy mode
|
MenuConverter converter(ObjLoading::Configuration.MenuNoOptimization, searchPath, memory, manager);
|
||||||
MenuConverter converter(false, searchPath, memory, manager);
|
|
||||||
auto* menuAsset = converter.ConvertMenu(*menu);
|
auto* menuAsset = converter.ConvertMenu(*menu);
|
||||||
if(menuAsset == nullptr)
|
if(menuAsset == nullptr)
|
||||||
{
|
{
|
||||||
@ -143,7 +142,7 @@ bool AssetLoaderMenuList::LoadFromRaw(const std::string& assetName, ISearchPath*
|
|||||||
});
|
});
|
||||||
|
|
||||||
reader.IncludeZoneState(zoneState);
|
reader.IncludeZoneState(zoneState);
|
||||||
reader.SetPermissiveMode(ObjLoading::Configuration.PermissiveMenuParsing);
|
reader.SetPermissiveMode(ObjLoading::Configuration.MenuPermissiveParsing);
|
||||||
|
|
||||||
const auto menuFileResult = reader.ReadMenuFile();
|
const auto menuFileResult = reader.ReadMenuFile();
|
||||||
if (menuFileResult)
|
if (menuFileResult)
|
||||||
|
@ -268,7 +268,7 @@ namespace IW4
|
|||||||
|
|
||||||
void ConvertExpressionEntry(std::vector<expressionEntry>& entries, const ISimpleExpression* expression, const CommonMenuDef* menu, const CommonItemDef* item) const
|
void ConvertExpressionEntry(std::vector<expressionEntry>& entries, const ISimpleExpression* expression, const CommonMenuDef* menu, const CommonItemDef* item) const
|
||||||
{
|
{
|
||||||
if (!m_legacy_mode && expression->IsStatic())
|
if (!m_disable_optimizations && expression->IsStatic())
|
||||||
{
|
{
|
||||||
const auto expressionStaticValue = expression->Evaluate();
|
const auto expressionStaticValue = expression->Evaluate();
|
||||||
ConvertExpressionEntryExpressionValue(entries, &expressionStaticValue);
|
ConvertExpressionEntryExpressionValue(entries, &expressionStaticValue);
|
||||||
@ -327,7 +327,7 @@ namespace IW4
|
|||||||
|
|
||||||
_NODISCARD Statement_s* ConvertOrApplyStatement(float& staticValue, const ISimpleExpression* expression, const CommonMenuDef* menu, const CommonItemDef* item = nullptr) const
|
_NODISCARD Statement_s* ConvertOrApplyStatement(float& staticValue, const ISimpleExpression* expression, const CommonMenuDef* menu, const CommonItemDef* item = nullptr) const
|
||||||
{
|
{
|
||||||
if (m_legacy_mode)
|
if (m_disable_optimizations)
|
||||||
return ConvertExpression(expression, menu, item);
|
return ConvertExpression(expression, menu, item);
|
||||||
|
|
||||||
if (!expression)
|
if (!expression)
|
||||||
@ -355,7 +355,7 @@ namespace IW4
|
|||||||
|
|
||||||
_NODISCARD Statement_s* ConvertOrApplyStatement(const char*& staticValue, const ISimpleExpression* expression, const CommonMenuDef* menu, const CommonItemDef* item = nullptr) const
|
_NODISCARD Statement_s* ConvertOrApplyStatement(const char*& staticValue, const ISimpleExpression* expression, const CommonMenuDef* menu, const CommonItemDef* item = nullptr) const
|
||||||
{
|
{
|
||||||
if (m_legacy_mode)
|
if (m_disable_optimizations)
|
||||||
return ConvertExpression(expression, menu, item);
|
return ConvertExpression(expression, menu, item);
|
||||||
|
|
||||||
if (!expression)
|
if (!expression)
|
||||||
@ -382,7 +382,7 @@ namespace IW4
|
|||||||
|
|
||||||
_NODISCARD Statement_s* ConvertOrApplyStatement(Material*& staticValue, const ISimpleExpression* expression, const CommonMenuDef* menu, const CommonItemDef* item = nullptr) const
|
_NODISCARD Statement_s* ConvertOrApplyStatement(Material*& staticValue, const ISimpleExpression* expression, const CommonMenuDef* menu, const CommonItemDef* item = nullptr) const
|
||||||
{
|
{
|
||||||
if (m_legacy_mode)
|
if (m_disable_optimizations)
|
||||||
return ConvertExpression(expression, menu, item);
|
return ConvertExpression(expression, menu, item);
|
||||||
|
|
||||||
if (!expression)
|
if (!expression)
|
||||||
@ -645,8 +645,8 @@ namespace IW4
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MenuConverterImpl(const bool legacyMode, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager)
|
MenuConverterImpl(const bool disableOptimizations, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager)
|
||||||
: AbstractMenuConverter(legacyMode, searchPath, memory, manager)
|
: AbstractMenuConverter(disableOptimizations, searchPath, memory, manager)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -705,8 +705,8 @@ namespace IW4
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuConverter::MenuConverter(const bool legacyMode, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager)
|
MenuConverter::MenuConverter(const bool disableOptimizations, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager)
|
||||||
: m_legacy_mode(legacyMode),
|
: m_disable_optimizations(disableOptimizations),
|
||||||
m_search_path(searchPath),
|
m_search_path(searchPath),
|
||||||
m_memory(memory),
|
m_memory(memory),
|
||||||
m_manager(manager)
|
m_manager(manager)
|
||||||
@ -720,7 +720,7 @@ std::vector<XAssetInfoGeneric*>& MenuConverter::GetDependencies()
|
|||||||
|
|
||||||
menuDef_t* MenuConverter::ConvertMenu(const CommonMenuDef& commonMenu)
|
menuDef_t* MenuConverter::ConvertMenu(const CommonMenuDef& commonMenu)
|
||||||
{
|
{
|
||||||
MenuConverterImpl impl(m_legacy_mode, m_search_path, m_memory, m_manager);
|
MenuConverterImpl impl(m_disable_optimizations, m_search_path, m_memory, m_manager);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -11,14 +11,14 @@ namespace IW4
|
|||||||
{
|
{
|
||||||
class MenuConverter
|
class MenuConverter
|
||||||
{
|
{
|
||||||
bool m_legacy_mode;
|
bool m_disable_optimizations;
|
||||||
ISearchPath* m_search_path;
|
ISearchPath* m_search_path;
|
||||||
MemoryManager* m_memory;
|
MemoryManager* m_memory;
|
||||||
IAssetLoadingManager* m_manager;
|
IAssetLoadingManager* m_manager;
|
||||||
std::vector<XAssetInfoGeneric*> m_dependencies;
|
std::vector<XAssetInfoGeneric*> m_dependencies;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MenuConverter(bool legacyMode, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager);
|
MenuConverter(bool disableOptimizations, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager);
|
||||||
|
|
||||||
std::vector<XAssetInfoGeneric*>& GetDependencies();
|
std::vector<XAssetInfoGeneric*>& GetDependencies();
|
||||||
_NODISCARD menuDef_t* ConvertMenu(const menu::CommonMenuDef& commonMenu);
|
_NODISCARD menuDef_t* ConvertMenu(const menu::CommonMenuDef& commonMenu);
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
using namespace menu;
|
using namespace menu;
|
||||||
|
|
||||||
AbstractMenuConverter::AbstractMenuConverter(const bool legacyMode, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager)
|
AbstractMenuConverter::AbstractMenuConverter(const bool disableOptimizations, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager)
|
||||||
: m_legacy_mode(legacyMode),
|
: m_disable_optimizations(disableOptimizations),
|
||||||
m_search_path(searchPath),
|
m_search_path(searchPath),
|
||||||
m_memory(memory),
|
m_memory(memory),
|
||||||
m_manager(manager)
|
m_manager(manager)
|
||||||
|
@ -11,12 +11,12 @@ namespace menu
|
|||||||
class AbstractMenuConverter
|
class AbstractMenuConverter
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
bool m_legacy_mode;
|
bool m_disable_optimizations;
|
||||||
ISearchPath* m_search_path;
|
ISearchPath* m_search_path;
|
||||||
MemoryManager* m_memory;
|
MemoryManager* m_memory;
|
||||||
IAssetLoadingManager* m_manager;
|
IAssetLoadingManager* m_manager;
|
||||||
|
|
||||||
AbstractMenuConverter(bool legacyMode, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager);
|
AbstractMenuConverter(bool disableOptimizations, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager);
|
||||||
|
|
||||||
_NODISCARD const char* ConvertString(const std::string& str) const;
|
_NODISCARD const char* ConvertString(const std::string& str) const;
|
||||||
|
|
||||||
|
@ -12,7 +12,8 @@ public:
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool Verbose = false;
|
bool Verbose = false;
|
||||||
bool PermissiveMenuParsing = false;
|
bool MenuPermissiveParsing = false;
|
||||||
|
bool MenuNoOptimization = false;
|
||||||
} Configuration;
|
} Configuration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user