2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-09-09 10:07:28 +00:00

Make sure you can specify event handlers more than once to be able to append script data

This commit is contained in:
Jan
2022-01-01 20:00:09 +01:00
parent d900b9cccd
commit 8a3bbf948b
5 changed files with 113 additions and 32 deletions

View File

@@ -21,9 +21,11 @@ void GenericMenuEventHandlerSetPropertySequence::ProcessMatch(MenuFileParserStat
{
if (m_set_callback)
{
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, result.NextCapture(CAPTURE_FIRST_TOKEN).GetPos(), std::move(newEventHandlerSet));
auto& eventHandlerPtr = m_set_callback(state, result.NextCapture(CAPTURE_FIRST_TOKEN).GetPos());
if(!eventHandlerPtr)
eventHandlerPtr = std::make_unique<CommonEventHandlerSet>();
state->m_current_event_handler_set = eventHandlerPtr.get();
state->m_current_nested_event_handler_set = eventHandlerPtr.get();
}
}

View File

@@ -11,7 +11,7 @@ namespace menu
class GenericMenuEventHandlerSetPropertySequence final : public MenuFileParser::sequence_t
{
public:
using callback_t = std::function<void(MenuFileParserState* state, const TokenPos& pos, std::unique_ptr<CommonEventHandlerSet> value)>;
using callback_t = std::function<std::unique_ptr<CommonEventHandlerSet>& (MenuFileParserState* state, const TokenPos& pos)>;
private:
static constexpr auto CAPTURE_FIRST_TOKEN = 1;