mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 16:15:43 +00:00
Handle condition stack on event handler closing parenthesis
This commit is contained in:
parent
54d7f75af6
commit
81203e523e
@ -2,9 +2,9 @@
|
||||
|
||||
using namespace menu;
|
||||
|
||||
MenuFileParserState::EventHandlerConditionState::EventHandlerConditionState(std::unique_ptr<CommonEventHandlerCondition> condition)
|
||||
MenuFileParserState::EventHandlerConditionState::EventHandlerConditionState(CommonEventHandlerCondition* condition)
|
||||
: m_in_condition_elements(true),
|
||||
m_condition(std::move(condition))
|
||||
m_condition(condition)
|
||||
{
|
||||
}
|
||||
|
||||
@ -14,6 +14,7 @@ MenuFileParserState::MenuFileParserState(const FeatureLevel featureLevel)
|
||||
m_current_function(nullptr),
|
||||
m_current_menu(nullptr),
|
||||
m_current_item(nullptr),
|
||||
m_current_event_handler_set(nullptr)
|
||||
m_current_event_handler_set(nullptr),
|
||||
m_current_nested_event_handler_set(nullptr)
|
||||
{
|
||||
}
|
||||
|
@ -20,9 +20,9 @@ namespace menu
|
||||
{
|
||||
public:
|
||||
bool m_in_condition_elements;
|
||||
std::unique_ptr<CommonEventHandlerCondition> m_condition;
|
||||
CommonEventHandlerCondition* m_condition;
|
||||
|
||||
explicit EventHandlerConditionState(std::unique_ptr<CommonEventHandlerCondition> condition);
|
||||
explicit EventHandlerConditionState(CommonEventHandlerCondition* condition);
|
||||
};
|
||||
|
||||
const FeatureLevel m_feature_level;
|
||||
@ -41,7 +41,8 @@ namespace menu
|
||||
CommonEventHandlerSet* m_current_event_handler_set;
|
||||
|
||||
std::ostringstream m_current_script;
|
||||
std::stack<EventHandlerConditionState> m_current_condition;
|
||||
std::stack<EventHandlerConditionState> m_condition_stack;
|
||||
CommonEventHandlerSet* m_current_nested_event_handler_set;
|
||||
|
||||
explicit MenuFileParserState(FeatureLevel featureLevel);
|
||||
};
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <sstream>
|
||||
|
||||
#include "Generic/GenericStringPropertySequence.h"
|
||||
#include "Parsing/Menu/Domain/EventHandler/CommonEventHandlerScript.h"
|
||||
#include "Parsing/Menu/Matcher/MenuMatcherFactory.h"
|
||||
|
||||
using namespace menu;
|
||||
@ -26,7 +27,31 @@ namespace menu::event_handler_set_scope_sequences
|
||||
protected:
|
||||
void ProcessMatch(MenuFileParserState* state, SequenceResult<SimpleParserValue>& result) const override
|
||||
{
|
||||
state->m_current_event_handler_set = nullptr;
|
||||
auto remainingScript = state->m_current_script.str();
|
||||
if (!remainingScript.empty())
|
||||
state->m_current_nested_event_handler_set->m_elements.emplace_back(std::make_unique<CommonEventHandlerScript>(std::move(remainingScript)));
|
||||
state->m_current_script.clear();
|
||||
|
||||
if (!state->m_condition_stack.empty())
|
||||
{
|
||||
state->m_condition_stack.pop();
|
||||
|
||||
if(!state->m_condition_stack.empty())
|
||||
{
|
||||
const auto& newConditionState = state->m_condition_stack.top();
|
||||
if (newConditionState.m_in_condition_elements)
|
||||
state->m_current_nested_event_handler_set = newConditionState.m_condition->m_condition_elements.get();
|
||||
else
|
||||
state->m_current_nested_event_handler_set = newConditionState.m_condition->m_else_elements.get();
|
||||
}
|
||||
else
|
||||
state->m_current_nested_event_handler_set = state->m_current_event_handler_set;
|
||||
}
|
||||
else
|
||||
{
|
||||
state->m_current_event_handler_set = nullptr;
|
||||
state->m_current_nested_event_handler_set = nullptr;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ void GenericMenuEventHandlerSetPropertySequence::ProcessMatch(MenuFileParserStat
|
||||
{
|
||||
auto newEventHandlerSet = std::make_unique<CommonEventHandlerSet>();
|
||||
state->m_current_event_handler_set = newEventHandlerSet.get();
|
||||
state->m_current_nested_event_handler_set = newEventHandlerSet.get();
|
||||
m_set_callback(state, std::move(newEventHandlerSet));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user