mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-21 00:25:44 +00:00
Add static dvars to menu conversion
This commit is contained in:
parent
5e31be9bac
commit
847e4d568c
@ -1152,7 +1152,20 @@ namespace IW4
|
|||||||
EXP_FUNC_STATIC_DVAR_FLOAT,
|
EXP_FUNC_STATIC_DVAR_FLOAT,
|
||||||
EXP_FUNC_STATIC_DVAR_STRING,
|
EXP_FUNC_STATIC_DVAR_STRING,
|
||||||
|
|
||||||
EXP_FUNC_DYN_START
|
EXP_FUNC_DYN_START,
|
||||||
|
|
||||||
|
EXP_FUNC_INT = EXP_FUNC_DYN_START,
|
||||||
|
EXP_FUNC_STRING,
|
||||||
|
EXP_FUNC_FLOAT,
|
||||||
|
EXP_FUNC_SIN,
|
||||||
|
EXP_FUNC_COS,
|
||||||
|
EXP_FUNC_MIN,
|
||||||
|
EXP_FUNC_MAX,
|
||||||
|
EXP_FUNC_MILLISECONDS,
|
||||||
|
EXP_FUNC_DVAR_INT,
|
||||||
|
EXP_FUNC_DVAR_BOOL,
|
||||||
|
EXP_FUNC_DVAR_FLOAT,
|
||||||
|
EXP_FUNC_DVAR_STRING
|
||||||
};
|
};
|
||||||
|
|
||||||
union entryInternalData
|
union entryInternalData
|
||||||
|
@ -95,8 +95,64 @@ namespace IW4
|
|||||||
return static_cast<Material*>(materialDependency->m_ptr);
|
return static_cast<Material*>(materialDependency->m_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool HandleStaticDvarFunctionCall(Statement_s* gameStatement, std::vector<expressionEntry>& entries, const CommonExpressionBaseFunctionCall* functionCall, const int targetFunctionIndex) const
|
||||||
|
{
|
||||||
|
if (functionCall->m_args.size() != 1)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const auto* dvarNameExpression = functionCall->m_args[0].get();
|
||||||
|
if (!dvarNameExpression->IsStatic())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const auto staticDvarNameExpressionValue = dvarNameExpression->Evaluate();
|
||||||
|
if (staticDvarNameExpressionValue.m_type != SimpleExpressionValue::Type::STRING)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
expressionEntry functionEntry{};
|
||||||
|
functionEntry.type = EET_OPERATOR;
|
||||||
|
functionEntry.data.op = targetFunctionIndex;
|
||||||
|
entries.emplace_back(functionEntry);
|
||||||
|
|
||||||
|
expressionEntry staticDvarIndexEntry{};
|
||||||
|
staticDvarIndexEntry.type = EET_OPERAND;
|
||||||
|
staticDvarIndexEntry.data.operand.dataType = VAL_INT;
|
||||||
|
staticDvarIndexEntry.data.operand.internals.intVal = static_cast<int>(m_conversion_zone_state->AddStaticDvar(*staticDvarNameExpressionValue.m_string_value));
|
||||||
|
entries.emplace_back(staticDvarIndexEntry);
|
||||||
|
|
||||||
|
expressionEntry parenRight{};
|
||||||
|
parenRight.type = EET_OPERATOR;
|
||||||
|
parenRight.data.op = OP_RIGHTPAREN;
|
||||||
|
entries.emplace_back(parenRight);
|
||||||
|
|
||||||
|
gameStatement->supportingData = m_conversion_zone_state->m_supporting_data;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HandleSpecialBaseFunctionCall(Statement_s* gameStatement, std::vector<expressionEntry>& entries, const CommonExpressionBaseFunctionCall* functionCall, const CommonMenuDef* menu,
|
||||||
|
const CommonItemDef* item) const
|
||||||
|
{
|
||||||
|
switch(functionCall->m_function_index)
|
||||||
|
{
|
||||||
|
case EXP_FUNC_DVAR_INT:
|
||||||
|
return HandleStaticDvarFunctionCall(gameStatement, entries, functionCall, EXP_FUNC_STATIC_DVAR_INT);
|
||||||
|
case EXP_FUNC_DVAR_BOOL:
|
||||||
|
return HandleStaticDvarFunctionCall(gameStatement, entries, functionCall, EXP_FUNC_STATIC_DVAR_BOOL);
|
||||||
|
case EXP_FUNC_DVAR_FLOAT:
|
||||||
|
return HandleStaticDvarFunctionCall(gameStatement, entries, functionCall, EXP_FUNC_STATIC_DVAR_FLOAT);
|
||||||
|
case EXP_FUNC_DVAR_STRING:
|
||||||
|
return HandleStaticDvarFunctionCall(gameStatement, entries, functionCall, EXP_FUNC_STATIC_DVAR_STRING);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void ConvertExpressionEntryBaseFunctionCall(Statement_s* gameStatement, std::vector<expressionEntry>& entries, const CommonExpressionBaseFunctionCall* functionCall, const CommonMenuDef* menu,
|
void ConvertExpressionEntryBaseFunctionCall(Statement_s* gameStatement, std::vector<expressionEntry>& entries, const CommonExpressionBaseFunctionCall* functionCall, const CommonMenuDef* menu,
|
||||||
const CommonItemDef* item) const
|
const CommonItemDef* item) const
|
||||||
|
{
|
||||||
|
if (!HandleSpecialBaseFunctionCall(gameStatement, entries, functionCall, menu, item))
|
||||||
{
|
{
|
||||||
expressionEntry functionEntry{};
|
expressionEntry functionEntry{};
|
||||||
functionEntry.type = EET_OPERATOR;
|
functionEntry.type = EET_OPERATOR;
|
||||||
@ -124,8 +180,10 @@ namespace IW4
|
|||||||
parenRight.data.op = OP_RIGHTPAREN;
|
parenRight.data.op = OP_RIGHTPAREN;
|
||||||
entries.emplace_back(parenRight);
|
entries.emplace_back(parenRight);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ConvertExpressionEntryCustomFunctionCall(Statement_s* gameStatement, std::vector<expressionEntry>& entries, const CommonExpressionCustomFunctionCall* functionCall, const CommonMenuDef* menu,
|
void ConvertExpressionEntryCustomFunctionCall(Statement_s* gameStatement, std::vector<expressionEntry>& entries, const CommonExpressionCustomFunctionCall* functionCall,
|
||||||
|
const CommonMenuDef* menu,
|
||||||
const CommonItemDef* item) const
|
const CommonItemDef* item) const
|
||||||
{
|
{
|
||||||
Statement_s* functionStatement = m_conversion_zone_state->FindFunction(functionCall->m_function_name);
|
Statement_s* functionStatement = m_conversion_zone_state->FindFunction(functionCall->m_function_name);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user