mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 00:02:55 +00:00
Accept expressions as part of the column sequence
This commit is contained in:
parent
f6b5dcae39
commit
7fff36dab2
@ -11,6 +11,7 @@
|
|||||||
#include "Parsing/Menu/Matcher/MenuMatcherFactory.h"
|
#include "Parsing/Menu/Matcher/MenuMatcherFactory.h"
|
||||||
#include "Parsing/Menu/MenuFileCommonOperations.h"
|
#include "Parsing/Menu/MenuFileCommonOperations.h"
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -449,19 +450,16 @@ namespace menu::item_scope_sequences
|
|||||||
|
|
||||||
class SequenceColumns final : public MenuFileParser::sequence_t
|
class SequenceColumns final : public MenuFileParser::sequence_t
|
||||||
{
|
{
|
||||||
|
static constexpr auto TAG_COLUMN = 1;
|
||||||
|
|
||||||
static constexpr auto CAPTURE_FIRST_TOKEN = 1;
|
static constexpr auto CAPTURE_FIRST_TOKEN = 1;
|
||||||
static constexpr auto CAPTURE_COLUMN_COUNT = 2;
|
static constexpr auto CAPTURE_COLUMN_COUNT = 2;
|
||||||
static constexpr auto CAPTURE_X_POS = 3;
|
|
||||||
static constexpr auto CAPTURE_Y_POS = 4;
|
|
||||||
static constexpr auto CAPTURE_WIDTH = 5;
|
|
||||||
static constexpr auto CAPTURE_HEIGHT = 6;
|
|
||||||
static constexpr auto CAPTURE_MAX_CHARS = 7;
|
|
||||||
static constexpr auto CAPTURE_ALIGNMENT = 8;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SequenceColumns(const FeatureLevel featureLevel)
|
explicit SequenceColumns(const FeatureLevel featureLevel)
|
||||||
{
|
{
|
||||||
const MenuMatcherFactory create(this);
|
const MenuMatcherFactory create(this);
|
||||||
|
AddLabeledMatchers(MenuExpressionMatchers().Expression(this), MenuExpressionMatchers::LABEL_EXPRESSION);
|
||||||
|
|
||||||
if (featureLevel == FeatureLevel::IW5)
|
if (featureLevel == FeatureLevel::IW5)
|
||||||
{
|
{
|
||||||
@ -469,12 +467,13 @@ namespace menu::item_scope_sequences
|
|||||||
create.KeywordIgnoreCase("columns").Capture(CAPTURE_FIRST_TOKEN),
|
create.KeywordIgnoreCase("columns").Capture(CAPTURE_FIRST_TOKEN),
|
||||||
create.Integer().Capture(CAPTURE_COLUMN_COUNT),
|
create.Integer().Capture(CAPTURE_COLUMN_COUNT),
|
||||||
create.Loop(create.And({
|
create.Loop(create.And({
|
||||||
create.Integer().Capture(CAPTURE_X_POS),
|
create.True().Tag(TAG_COLUMN),
|
||||||
create.Integer().Capture(CAPTURE_Y_POS),
|
create.IntExpression(), // xpos
|
||||||
create.Integer().Capture(CAPTURE_WIDTH),
|
create.IntExpression(), // ypos
|
||||||
create.Integer().Capture(CAPTURE_HEIGHT),
|
create.IntExpression(), // width
|
||||||
create.Integer().Capture(CAPTURE_MAX_CHARS),
|
create.IntExpression(), // height
|
||||||
create.Integer().Capture(CAPTURE_ALIGNMENT),
|
create.IntExpression(), // maxChars
|
||||||
|
create.IntExpression(), // alignment
|
||||||
})),
|
})),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -484,10 +483,11 @@ namespace menu::item_scope_sequences
|
|||||||
create.KeywordIgnoreCase("columns").Capture(CAPTURE_FIRST_TOKEN),
|
create.KeywordIgnoreCase("columns").Capture(CAPTURE_FIRST_TOKEN),
|
||||||
create.Integer().Capture(CAPTURE_COLUMN_COUNT),
|
create.Integer().Capture(CAPTURE_COLUMN_COUNT),
|
||||||
create.Loop(create.And({
|
create.Loop(create.And({
|
||||||
create.Integer().Capture(CAPTURE_X_POS),
|
create.True().Tag(TAG_COLUMN),
|
||||||
create.Integer().Capture(CAPTURE_WIDTH),
|
create.IntExpression(), // xpos
|
||||||
create.Integer().Capture(CAPTURE_MAX_CHARS),
|
create.IntExpression(), // width
|
||||||
create.Integer().Capture(CAPTURE_ALIGNMENT),
|
create.IntExpression(), // maxChars
|
||||||
|
create.IntExpression(), // alignment
|
||||||
})),
|
})),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -500,16 +500,42 @@ namespace menu::item_scope_sequences
|
|||||||
|
|
||||||
ItemScopeOperations::EnsureHasListboxFeatures(*state->m_current_item, result.NextCapture(CAPTURE_FIRST_TOKEN).GetPos());
|
ItemScopeOperations::EnsureHasListboxFeatures(*state->m_current_item, result.NextCapture(CAPTURE_FIRST_TOKEN).GetPos());
|
||||||
|
|
||||||
|
assert(state->m_feature_level == FeatureLevel::IW4 || state->m_feature_level == FeatureLevel::IW5);
|
||||||
|
|
||||||
const auto& listBoxFeatures = state->m_current_item->m_list_box_features;
|
const auto& listBoxFeatures = state->m_current_item->m_list_box_features;
|
||||||
while (result.HasNextCapture(CAPTURE_X_POS))
|
while (result.PeekAndRemoveIfTag(TAG_COLUMN) == TAG_COLUMN)
|
||||||
{
|
{
|
||||||
|
int xPos = 0;
|
||||||
|
int yPos = 0;
|
||||||
|
int width = 0;
|
||||||
|
int height = 0;
|
||||||
|
int maxChars = 0;
|
||||||
|
int alignment = 0;
|
||||||
|
|
||||||
|
if (state->m_feature_level == FeatureLevel::IW4)
|
||||||
|
{
|
||||||
|
xPos = MenuMatcherFactory::TokenIntExpressionValue(state, result);
|
||||||
|
width = MenuMatcherFactory::TokenIntExpressionValue(state, result);
|
||||||
|
maxChars = MenuMatcherFactory::TokenIntExpressionValue(state, result);
|
||||||
|
alignment = MenuMatcherFactory::TokenIntExpressionValue(state, result);
|
||||||
|
}
|
||||||
|
else if (state->m_feature_level == FeatureLevel::IW5)
|
||||||
|
{
|
||||||
|
xPos = MenuMatcherFactory::TokenIntExpressionValue(state, result);
|
||||||
|
yPos = MenuMatcherFactory::TokenIntExpressionValue(state, result);
|
||||||
|
width = MenuMatcherFactory::TokenIntExpressionValue(state, result);
|
||||||
|
height = MenuMatcherFactory::TokenIntExpressionValue(state, result);
|
||||||
|
maxChars = MenuMatcherFactory::TokenIntExpressionValue(state, result);
|
||||||
|
alignment = MenuMatcherFactory::TokenIntExpressionValue(state, result);
|
||||||
|
}
|
||||||
|
|
||||||
CommonItemFeaturesListBox::Column column{
|
CommonItemFeaturesListBox::Column column{
|
||||||
result.NextCapture(CAPTURE_X_POS).IntegerValue(),
|
xPos,
|
||||||
state->m_feature_level == FeatureLevel::IW5 ? result.NextCapture(CAPTURE_Y_POS).IntegerValue() : 0,
|
yPos,
|
||||||
result.NextCapture(CAPTURE_WIDTH).IntegerValue(),
|
width,
|
||||||
state->m_feature_level == FeatureLevel::IW5 ? result.NextCapture(CAPTURE_HEIGHT).IntegerValue() : 0,
|
height,
|
||||||
result.NextCapture(CAPTURE_MAX_CHARS).IntegerValue(),
|
maxChars,
|
||||||
result.NextCapture(CAPTURE_ALIGNMENT).IntegerValue(),
|
alignment,
|
||||||
};
|
};
|
||||||
listBoxFeatures->m_columns.emplace_back(column);
|
listBoxFeatures->m_columns.emplace_back(column);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user