mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-21 00:25:44 +00:00
Read multi token properties for items
This commit is contained in:
parent
4d868d9b6d
commit
84a9c5e701
@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "CommonMenuTypes.h"
|
#include "CommonMenuTypes.h"
|
||||||
@ -40,6 +41,11 @@ namespace menu
|
|||||||
std::string m_background;
|
std::string m_background;
|
||||||
std::string m_focus_sound;
|
std::string m_focus_sound;
|
||||||
std::string m_dvar_test;
|
std::string m_dvar_test;
|
||||||
|
std::vector<std::string> m_enable_dvar;
|
||||||
|
std::vector<std::string> m_disable_dvar;
|
||||||
|
std::vector<std::string> m_show_dvar;
|
||||||
|
std::vector<std::string> m_hide_dvar;
|
||||||
|
std::vector<std::string> m_focus_dvar;
|
||||||
int m_game_message_window_index;
|
int m_game_message_window_index;
|
||||||
int m_game_message_window_mode;
|
int m_game_message_window_mode;
|
||||||
int m_fx_letter_time;
|
int m_fx_letter_time;
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
#include "ItemPropertySequences.h"
|
#include "ItemPropertySequences.h"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "GenericColorPropertySequence.h"
|
#include "GenericColorPropertySequence.h"
|
||||||
#include "GenericFloatingPointPropertySequence.h"
|
#include "GenericFloatingPointPropertySequence.h"
|
||||||
#include "GenericIntPropertySequence.h"
|
#include "GenericIntPropertySequence.h"
|
||||||
@ -91,6 +94,52 @@ namespace menu::item_properties
|
|||||||
state->m_current_item->m_fx_decay_duration = result.NextCapture(CAPTURE_DECAY_DURATION).IntegerValue();
|
state->m_current_item->m_fx_decay_duration = result.NextCapture(CAPTURE_DECAY_DURATION).IntegerValue();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class SequenceMultiTokenBlock final : public MenuFileParser::sequence_t
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using callback_t = std::function<void(MenuFileParserState* state, std::vector<std::string> value)>;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static constexpr auto CAPTURE_VALUE = 1;
|
||||||
|
|
||||||
|
callback_t m_set_callback;
|
||||||
|
|
||||||
|
public:
|
||||||
|
SequenceMultiTokenBlock(std::string keyName, callback_t setCallback)
|
||||||
|
: m_set_callback(std::move(setCallback))
|
||||||
|
{
|
||||||
|
const MenuMatcherFactory create(this);
|
||||||
|
|
||||||
|
AddMatchers({
|
||||||
|
create.KeywordIgnoreCase(std::move(keyName)),
|
||||||
|
create.Char('{'),
|
||||||
|
create.Optional(create.And({
|
||||||
|
create.Text().Capture(CAPTURE_VALUE),
|
||||||
|
create.OptionalLoop(create.And({
|
||||||
|
create.Char(';'),
|
||||||
|
create.Text().Capture(CAPTURE_VALUE)
|
||||||
|
}))
|
||||||
|
})),
|
||||||
|
create.Char('}'),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void ProcessMatch(MenuFileParserState* state, SequenceResult<SimpleParserValue>& result) const override
|
||||||
|
{
|
||||||
|
if (!m_set_callback)
|
||||||
|
return;
|
||||||
|
|
||||||
|
std::vector<std::string> values;
|
||||||
|
while (result.HasNextCapture(CAPTURE_VALUE))
|
||||||
|
{
|
||||||
|
values.emplace_back(MenuMatcherFactory::TokenTextValue(result.NextCapture(CAPTURE_VALUE)));
|
||||||
|
}
|
||||||
|
|
||||||
|
m_set_callback(state, std::move(values));
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
using namespace item_properties;
|
using namespace item_properties;
|
||||||
@ -223,6 +272,26 @@ void ItemPropertySequences::AddSequences(FeatureLevel featureLevel)
|
|||||||
{
|
{
|
||||||
state->m_current_item->m_dvar_test = value;
|
state->m_current_item->m_dvar_test = value;
|
||||||
}));
|
}));
|
||||||
|
AddSequence(std::make_unique<SequenceMultiTokenBlock>("enableDvar", [](const MenuFileParserState* state, std::vector<std::string> value)
|
||||||
|
{
|
||||||
|
state->m_current_item->m_enable_dvar = std::move(value);
|
||||||
|
}));
|
||||||
|
AddSequence(std::make_unique<SequenceMultiTokenBlock>("disableDvar", [](const MenuFileParserState* state, std::vector<std::string> value)
|
||||||
|
{
|
||||||
|
state->m_current_item->m_disable_dvar = std::move(value);
|
||||||
|
}));
|
||||||
|
AddSequence(std::make_unique<SequenceMultiTokenBlock>("showDvar", [](const MenuFileParserState* state, std::vector<std::string> value)
|
||||||
|
{
|
||||||
|
state->m_current_item->m_show_dvar = std::move(value);
|
||||||
|
}));
|
||||||
|
AddSequence(std::make_unique<SequenceMultiTokenBlock>("hideDvar", [](const MenuFileParserState* state, std::vector<std::string> value)
|
||||||
|
{
|
||||||
|
state->m_current_item->m_hide_dvar = std::move(value);
|
||||||
|
}));
|
||||||
|
AddSequence(std::make_unique<SequenceMultiTokenBlock>("focusDvar", [](const MenuFileParserState* state, std::vector<std::string> value)
|
||||||
|
{
|
||||||
|
state->m_current_item->m_focus_dvar = std::move(value);
|
||||||
|
}));
|
||||||
AddSequence(std::make_unique<GenericIntPropertySequence>("gamemsgwindowindex", [](const MenuFileParserState* state, const int value)
|
AddSequence(std::make_unique<GenericIntPropertySequence>("gamemsgwindowindex", [](const MenuFileParserState* state, const int value)
|
||||||
{
|
{
|
||||||
state->m_current_item->m_game_message_window_index = value;
|
state->m_current_item->m_game_message_window_index = value;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user