From ed329e64534ffafbd5bc6bbeacc4633f9aa4c8fb Mon Sep 17 00:00:00 2001 From: Jan Date: Sun, 14 Nov 2021 20:05:06 +0100 Subject: [PATCH] Add item scope sequences for expressions and menueventhandlerset --- .../Parsing/Menu/Domain/CommonItemDef.h | 32 +++++ .../Menu/Sequence/ItemScopeSequences.cpp | 134 ++++++++++++++++++ 2 files changed, 166 insertions(+) diff --git a/src/ObjLoading/Parsing/Menu/Domain/CommonItemDef.h b/src/ObjLoading/Parsing/Menu/Domain/CommonItemDef.h index 57723ae9..d62e7b36 100644 --- a/src/ObjLoading/Parsing/Menu/Domain/CommonItemDef.h +++ b/src/ObjLoading/Parsing/Menu/Domain/CommonItemDef.h @@ -4,12 +4,24 @@ #include #include "CommonMenuTypes.h" +#include "EventHandler/CommonEventHandlerSet.h" +#include "Expression/ICommonExpression.h" namespace menu { class CommonItemDef { public: + class ColorExpressions + { + public: + std::unique_ptr m_r_exp; + std::unique_ptr m_g_exp; + std::unique_ptr m_b_exp; + std::unique_ptr m_a_exp; + std::unique_ptr m_rgb_exp; + }; + std::string m_name; std::string m_text; bool m_text_save_game; @@ -51,5 +63,25 @@ namespace menu int m_fx_letter_time; int m_fx_decay_start_time; int m_fx_decay_duration; + + std::unique_ptr m_visible_expression; + std::unique_ptr m_disabled_expression; + std::unique_ptr m_text_expression; + std::unique_ptr m_material_expression; + std::unique_ptr m_rect_x_exp; + std::unique_ptr m_rect_y_exp; + std::unique_ptr m_rect_w_exp; + std::unique_ptr m_rect_h_exp; + ColorExpressions m_forecolor_expressions; + ColorExpressions m_glowcolor_expressions; + ColorExpressions m_backcolor_expressions; + std::unique_ptr m_on_focus; + std::unique_ptr m_on_leave_focus; + std::unique_ptr m_on_mouse_enter; + std::unique_ptr m_on_mouse_exit; + std::unique_ptr m_on_mouse_enter_text; + std::unique_ptr m_on_mouse_exit_text; + std::unique_ptr m_on_action; + std::unique_ptr m_on_accept; }; } diff --git a/src/ObjLoading/Parsing/Menu/Sequence/ItemScopeSequences.cpp b/src/ObjLoading/Parsing/Menu/Sequence/ItemScopeSequences.cpp index 89fbb05e..8cfca861 100644 --- a/src/ObjLoading/Parsing/Menu/Sequence/ItemScopeSequences.cpp +++ b/src/ObjLoading/Parsing/Menu/Sequence/ItemScopeSequences.cpp @@ -4,9 +4,11 @@ #include #include "Generic/GenericColorPropertySequence.h" +#include "Generic/GenericExpressionPropertySequence.h" #include "Generic/GenericFloatingPointPropertySequence.h" #include "Generic/GenericIntPropertySequence.h" #include "Generic/GenericKeywordPropertySequence.h" +#include "Generic/GenericMenuEventHandlerSetPropertySequence.h" #include "Generic/GenericStringPropertySequence.h" #include "Parsing/Menu/Matcher/MenuMatcherFactory.h" @@ -321,4 +323,136 @@ void ItemScopeSequences::AddSequences(FeatureLevel featureLevel) state->m_current_item->m_game_message_window_mode = value; })); AddSequence(std::make_unique()); + AddSequence(GenericExpressionPropertySequence::WithKeywordAndBool("visible", [](const MenuFileParserState* state, std::unique_ptr value) + { + state->m_current_item->m_visible_expression = std::move(value); + })); + AddSequence(GenericExpressionPropertySequence::WithKeywordAndBool("disabled", [](const MenuFileParserState* state, std::unique_ptr value) + { + state->m_current_item->m_disabled_expression = std::move(value); + })); + AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "disabled"}, [](const MenuFileParserState* state, std::unique_ptr value) + { + state->m_current_item->m_disabled_expression = std::move(value); + })); + AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "text"}, [](const MenuFileParserState* state, std::unique_ptr value) + { + state->m_current_item->m_text_expression = std::move(value); + })); + AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "material"}, [](const MenuFileParserState* state, std::unique_ptr value) + { + state->m_current_item->m_material_expression = std::move(value); + })); + AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "material"}, [](const MenuFileParserState* state, std::unique_ptr value) + { + state->m_current_item->m_material_expression = std::move(value); + })); + AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "rect", "X"}, [](const MenuFileParserState* state, std::unique_ptr value) + { + state->m_current_item->m_rect_x_exp = std::move(value); + })); + AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "rect", "Y"}, [](const MenuFileParserState* state, std::unique_ptr value) + { + state->m_current_item->m_rect_y_exp = std::move(value); + })); + AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "rect", "W"}, [](const MenuFileParserState* state, std::unique_ptr value) + { + state->m_current_item->m_rect_w_exp = std::move(value); + })); + AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "rect", "H"}, [](const MenuFileParserState* state, std::unique_ptr value) + { + state->m_current_item->m_rect_h_exp = std::move(value); + })); + AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "forecolor", "R"}, [](const MenuFileParserState* state, std::unique_ptr value) + { + state->m_current_item->m_forecolor_expressions.m_r_exp = std::move(value); + })); + AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "forecolor", "G"}, [](const MenuFileParserState* state, std::unique_ptr value) + { + state->m_current_item->m_forecolor_expressions.m_g_exp = std::move(value); + })); + AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "forecolor", "B"}, [](const MenuFileParserState* state, std::unique_ptr value) + { + state->m_current_item->m_forecolor_expressions.m_b_exp = std::move(value); + })); + AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "forecolor", "A"}, [](const MenuFileParserState* state, std::unique_ptr value) + { + state->m_current_item->m_forecolor_expressions.m_a_exp = std::move(value); + })); + AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "forecolor", "RGB"}, [](const MenuFileParserState* state, std::unique_ptr value) + { + state->m_current_item->m_forecolor_expressions.m_rgb_exp = std::move(value); + })); + AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "glowcolor", "R"}, [](const MenuFileParserState* state, std::unique_ptr value) + { + state->m_current_item->m_glowcolor_expressions.m_r_exp = std::move(value); + })); + AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "glowcolor", "G"}, [](const MenuFileParserState* state, std::unique_ptr value) + { + state->m_current_item->m_glowcolor_expressions.m_g_exp = std::move(value); + })); + AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "glowcolor", "B"}, [](const MenuFileParserState* state, std::unique_ptr value) + { + state->m_current_item->m_glowcolor_expressions.m_b_exp = std::move(value); + })); + AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "glowcolor", "A"}, [](const MenuFileParserState* state, std::unique_ptr value) + { + state->m_current_item->m_glowcolor_expressions.m_a_exp = std::move(value); + })); + AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "glowcolor", "RGB"}, [](const MenuFileParserState* state, std::unique_ptr value) + { + state->m_current_item->m_glowcolor_expressions.m_rgb_exp = std::move(value); + })); + AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "backcolor", "R"}, [](const MenuFileParserState* state, std::unique_ptr value) + { + state->m_current_item->m_backcolor_expressions.m_r_exp = std::move(value); + })); + AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "backcolor", "G"}, [](const MenuFileParserState* state, std::unique_ptr value) + { + state->m_current_item->m_backcolor_expressions.m_g_exp = std::move(value); + })); + AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "backcolor", "B"}, [](const MenuFileParserState* state, std::unique_ptr value) + { + state->m_current_item->m_backcolor_expressions.m_b_exp = std::move(value); + })); + AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "backcolor", "A"}, [](const MenuFileParserState* state, std::unique_ptr value) + { + state->m_current_item->m_backcolor_expressions.m_a_exp = std::move(value); + })); + AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "backcolor", "RGB"}, [](const MenuFileParserState* state, std::unique_ptr value) + { + state->m_current_item->m_backcolor_expressions.m_rgb_exp = std::move(value); + })); + AddSequence(std::make_unique("onFocus", [](const MenuFileParserState* state, std::unique_ptr value) + { + state->m_current_item->m_on_focus = std::move(value); + })); + AddSequence(std::make_unique("leaveFocus", [](const MenuFileParserState* state, std::unique_ptr value) + { + state->m_current_item->m_on_leave_focus = std::move(value); + })); + AddSequence(std::make_unique("mouseEnter", [](const MenuFileParserState* state, std::unique_ptr value) + { + state->m_current_item->m_on_mouse_enter = std::move(value); + })); + AddSequence(std::make_unique("mouseExit", [](const MenuFileParserState* state, std::unique_ptr value) + { + state->m_current_item->m_on_mouse_exit = std::move(value); + })); + AddSequence(std::make_unique("mouseEnterText", [](const MenuFileParserState* state, std::unique_ptr value) + { + state->m_current_item->m_on_mouse_enter_text = std::move(value); + })); + AddSequence(std::make_unique("mouseExitText", [](const MenuFileParserState* state, std::unique_ptr value) + { + state->m_current_item->m_on_mouse_exit_text = std::move(value); + })); + AddSequence(std::make_unique("action", [](const MenuFileParserState* state, std::unique_ptr value) + { + state->m_current_item->m_on_action = std::move(value); + })); + AddSequence(std::make_unique("accept", [](const MenuFileParserState* state, std::unique_ptr value) + { + state->m_current_item->m_on_accept = std::move(value); + })); }