mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-18 10:47:57 -05:00
Move common expression classes to simple parsing setup
This commit is contained in:
@ -360,40 +360,40 @@ namespace menu::event_handler_set_scope_sequences
|
||||
}
|
||||
}
|
||||
|
||||
static void EmitStaticValue(MenuFileParserState* state, const CommonExpressionValue& value)
|
||||
static void EmitStaticValue(MenuFileParserState* state, const SimpleExpressionValue& value)
|
||||
{
|
||||
switch (value.m_type)
|
||||
{
|
||||
case CommonExpressionValue::Type::DOUBLE:
|
||||
case SimpleExpressionValue::Type::DOUBLE:
|
||||
state->m_current_script << value.m_double_value;
|
||||
break;
|
||||
|
||||
case CommonExpressionValue::Type::INT:
|
||||
case SimpleExpressionValue::Type::INT:
|
||||
state->m_current_script << value.m_int_value;
|
||||
break;
|
||||
|
||||
case CommonExpressionValue::Type::STRING:
|
||||
case SimpleExpressionValue::Type::STRING:
|
||||
state->m_current_script << *value.m_string_value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void CheckStaticValueType(const TokenPos& pos, const SetLocalVarType type, const CommonExpressionValue& staticValue)
|
||||
static void CheckStaticValueType(const TokenPos& pos, const SetLocalVarType type, const SimpleExpressionValue& staticValue)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case SetLocalVarType::BOOL:
|
||||
if (staticValue.m_type != CommonExpressionValue::Type::INT)
|
||||
if (staticValue.m_type != SimpleExpressionValue::Type::INT)
|
||||
throw ParsingException(pos, "Static value must be BOOL");
|
||||
break;
|
||||
|
||||
case SetLocalVarType::INT:
|
||||
if (staticValue.m_type != CommonExpressionValue::Type::INT)
|
||||
if (staticValue.m_type != SimpleExpressionValue::Type::INT)
|
||||
throw ParsingException(pos, "Static value must be INT");
|
||||
break;
|
||||
|
||||
case SetLocalVarType::FLOAT:
|
||||
if (staticValue.m_type != CommonExpressionValue::Type::DOUBLE && staticValue.m_type != CommonExpressionValue::Type::INT)
|
||||
if (staticValue.m_type != SimpleExpressionValue::Type::DOUBLE && staticValue.m_type != SimpleExpressionValue::Type::INT)
|
||||
throw ParsingException(pos, "Static value must be FLOAT");
|
||||
break;
|
||||
|
||||
@ -403,7 +403,7 @@ namespace menu::event_handler_set_scope_sequences
|
||||
}
|
||||
}
|
||||
|
||||
static void EmitStaticSetLocalVar(MenuFileParserState* state, const TokenPos& pos, const SetLocalVarType type, const std::string& varName, std::unique_ptr<ICommonExpression> expression)
|
||||
static void EmitStaticSetLocalVar(MenuFileParserState* state, const TokenPos& pos, const SetLocalVarType type, const std::string& varName, std::unique_ptr<ISimpleExpression> expression)
|
||||
{
|
||||
state->m_current_script << "\"" << ScriptKeywordForType(type) << "\" \"" << varName << "\" \"";
|
||||
const auto staticValue = expression->Evaluate();
|
||||
@ -412,7 +412,7 @@ namespace menu::event_handler_set_scope_sequences
|
||||
state->m_current_script << "\" ; ";
|
||||
}
|
||||
|
||||
static void EmitDynamicSetLocalVar(const MenuFileParserState* state, const SetLocalVarType type, const std::string& varName, std::unique_ptr<ICommonExpression> expression)
|
||||
static void EmitDynamicSetLocalVar(const MenuFileParserState* state, const SetLocalVarType type, const std::string& varName, std::unique_ptr<ISimpleExpression> expression)
|
||||
{
|
||||
state->m_current_nested_event_handler_set->m_elements.emplace_back(std::make_unique<CommonEventHandlerSetLocalVar>(type, varName, std::move(expression)));
|
||||
}
|
||||
|
@ -4,14 +4,14 @@
|
||||
#include <functional>
|
||||
|
||||
#include "Parsing/Menu/MenuFileParser.h"
|
||||
#include "Parsing/Menu/Domain/Expression/ICommonExpression.h"
|
||||
#include "Parsing/Simple/Expression/ISimpleExpression.h"
|
||||
|
||||
namespace menu
|
||||
{
|
||||
class GenericExpressionPropertySequence final : public MenuFileParser::sequence_t
|
||||
{
|
||||
public:
|
||||
using callback_t = std::function<void(MenuFileParserState* state, const TokenPos& pos, std::unique_ptr<ICommonExpression> value)>;
|
||||
using callback_t = std::function<void(MenuFileParserState* state, const TokenPos& pos, std::unique_ptr<ISimpleExpression> value)>;
|
||||
|
||||
private:
|
||||
static constexpr auto CAPTURE_FIRST_TOKEN = 1;
|
||||
|
@ -664,103 +664,103 @@ void ItemScopeSequences::AddSequences(FeatureLevel featureLevel)
|
||||
state->m_current_item->m_game_message_window_mode = value;
|
||||
}));
|
||||
AddSequence(std::make_unique<SequenceDecodeEffect>());
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywordAndBool("visible", [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ICommonExpression> value)
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywordAndBool("visible", [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ISimpleExpression> value)
|
||||
{
|
||||
state->m_current_item->m_visible_expression = std::move(value);
|
||||
}));
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywordAndBool("disabled", [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ICommonExpression> value)
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywordAndBool("disabled", [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ISimpleExpression> value)
|
||||
{
|
||||
state->m_current_item->m_disabled_expression = std::move(value);
|
||||
}));
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "disabled"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ICommonExpression> value)
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "disabled"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ISimpleExpression> value)
|
||||
{
|
||||
state->m_current_item->m_disabled_expression = std::move(value);
|
||||
}));
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "text"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ICommonExpression> value)
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "text"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ISimpleExpression> value)
|
||||
{
|
||||
state->m_current_item->m_text_expression = std::move(value);
|
||||
}));
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "material"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ICommonExpression> value)
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "material"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ISimpleExpression> value)
|
||||
{
|
||||
state->m_current_item->m_material_expression = std::move(value);
|
||||
}));
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "material"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ICommonExpression> value)
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "material"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ISimpleExpression> value)
|
||||
{
|
||||
state->m_current_item->m_material_expression = std::move(value);
|
||||
}));
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "rect", "X"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ICommonExpression> value)
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "rect", "X"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ISimpleExpression> value)
|
||||
{
|
||||
state->m_current_item->m_rect_x_exp = std::move(value);
|
||||
}));
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "rect", "Y"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ICommonExpression> value)
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "rect", "Y"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ISimpleExpression> value)
|
||||
{
|
||||
state->m_current_item->m_rect_y_exp = std::move(value);
|
||||
}));
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "rect", "W"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ICommonExpression> value)
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "rect", "W"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ISimpleExpression> value)
|
||||
{
|
||||
state->m_current_item->m_rect_w_exp = std::move(value);
|
||||
}));
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "rect", "H"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ICommonExpression> value)
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "rect", "H"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ISimpleExpression> value)
|
||||
{
|
||||
state->m_current_item->m_rect_h_exp = std::move(value);
|
||||
}));
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "forecolor", "R"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ICommonExpression> value)
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "forecolor", "R"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ISimpleExpression> value)
|
||||
{
|
||||
state->m_current_item->m_forecolor_expressions.m_r_exp = std::move(value);
|
||||
}));
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "forecolor", "G"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ICommonExpression> value)
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "forecolor", "G"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ISimpleExpression> value)
|
||||
{
|
||||
state->m_current_item->m_forecolor_expressions.m_g_exp = std::move(value);
|
||||
}));
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "forecolor", "B"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ICommonExpression> value)
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "forecolor", "B"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ISimpleExpression> value)
|
||||
{
|
||||
state->m_current_item->m_forecolor_expressions.m_b_exp = std::move(value);
|
||||
}));
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "forecolor", "A"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ICommonExpression> value)
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "forecolor", "A"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ISimpleExpression> value)
|
||||
{
|
||||
state->m_current_item->m_forecolor_expressions.m_a_exp = std::move(value);
|
||||
}));
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "forecolor", "RGB"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ICommonExpression> value)
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "forecolor", "RGB"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ISimpleExpression> value)
|
||||
{
|
||||
state->m_current_item->m_forecolor_expressions.m_rgb_exp = std::move(value);
|
||||
}));
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "glowcolor", "R"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ICommonExpression> value)
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "glowcolor", "R"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ISimpleExpression> value)
|
||||
{
|
||||
state->m_current_item->m_glowcolor_expressions.m_r_exp = std::move(value);
|
||||
}));
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "glowcolor", "G"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ICommonExpression> value)
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "glowcolor", "G"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ISimpleExpression> value)
|
||||
{
|
||||
state->m_current_item->m_glowcolor_expressions.m_g_exp = std::move(value);
|
||||
}));
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "glowcolor", "B"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ICommonExpression> value)
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "glowcolor", "B"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ISimpleExpression> value)
|
||||
{
|
||||
state->m_current_item->m_glowcolor_expressions.m_b_exp = std::move(value);
|
||||
}));
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "glowcolor", "A"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ICommonExpression> value)
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "glowcolor", "A"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ISimpleExpression> value)
|
||||
{
|
||||
state->m_current_item->m_glowcolor_expressions.m_a_exp = std::move(value);
|
||||
}));
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "glowcolor", "RGB"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ICommonExpression> value)
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "glowcolor", "RGB"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ISimpleExpression> value)
|
||||
{
|
||||
state->m_current_item->m_glowcolor_expressions.m_rgb_exp = std::move(value);
|
||||
}));
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "backcolor", "R"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ICommonExpression> value)
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "backcolor", "R"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ISimpleExpression> value)
|
||||
{
|
||||
state->m_current_item->m_backcolor_expressions.m_r_exp = std::move(value);
|
||||
}));
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "backcolor", "G"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ICommonExpression> value)
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "backcolor", "G"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ISimpleExpression> value)
|
||||
{
|
||||
state->m_current_item->m_backcolor_expressions.m_g_exp = std::move(value);
|
||||
}));
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "backcolor", "B"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ICommonExpression> value)
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "backcolor", "B"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ISimpleExpression> value)
|
||||
{
|
||||
state->m_current_item->m_backcolor_expressions.m_b_exp = std::move(value);
|
||||
}));
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "backcolor", "A"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ICommonExpression> value)
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "backcolor", "A"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ISimpleExpression> value)
|
||||
{
|
||||
state->m_current_item->m_backcolor_expressions.m_a_exp = std::move(value);
|
||||
}));
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "backcolor", "RGB"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ICommonExpression> value)
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "backcolor", "RGB"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ISimpleExpression> value)
|
||||
{
|
||||
state->m_current_item->m_backcolor_expressions.m_rgb_exp = std::move(value);
|
||||
}));
|
||||
|
@ -323,23 +323,23 @@ void MenuScopeSequences::AddSequences(FeatureLevel featureLevel)
|
||||
{
|
||||
state->m_current_menu->m_text_only_focus = true;
|
||||
}));
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywordAndBool("visible", [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ICommonExpression> value)
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywordAndBool("visible", [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ISimpleExpression> value)
|
||||
{
|
||||
state->m_current_menu->m_visible_expression = std::move(value);
|
||||
}));
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "rect", "X"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ICommonExpression> value)
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "rect", "X"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ISimpleExpression> value)
|
||||
{
|
||||
state->m_current_menu->m_rect_x_exp = std::move(value);
|
||||
}));
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "rect", "Y"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ICommonExpression> value)
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "rect", "Y"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ISimpleExpression> value)
|
||||
{
|
||||
state->m_current_menu->m_rect_y_exp = std::move(value);
|
||||
}));
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "rect", "W"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ICommonExpression> value)
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "rect", "W"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ISimpleExpression> value)
|
||||
{
|
||||
state->m_current_menu->m_rect_w_exp = std::move(value);
|
||||
}));
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "rect", "H"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ICommonExpression> value)
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "rect", "H"}, [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ISimpleExpression> value)
|
||||
{
|
||||
state->m_current_menu->m_rect_h_exp = std::move(value);
|
||||
}));
|
||||
|
Reference in New Issue
Block a user