Reformat code with clang format

This commit is contained in:
Clang Format
2023-11-19 15:28:38 +01:00
committed by Jan
parent 22e17272fd
commit 6b4f5d94a8
1099 changed files with 16763 additions and 18076 deletions

View File

@ -1,9 +1,9 @@
#pragma once
#include <string>
#include "Parsing/Simple/Expression/ISimpleExpression.h"
#include <string>
namespace menu
{
class CommonFunctionDef
@ -12,4 +12,4 @@ namespace menu
std::string m_name;
std::unique_ptr<ISimpleExpression> m_value;
};
}
} // namespace menu

View File

@ -1,12 +1,12 @@
#pragma once
#include <vector>
#include <string>
#include "CommonMenuTypes.h"
#include "EventHandler/CommonEventHandlerSet.h"
#include "Parsing/Simple/Expression/ISimpleExpression.h"
#include <string>
#include <vector>
namespace menu
{
enum class CommonItemFeatureType
@ -163,4 +163,4 @@ namespace menu
std::string m_enum_dvar_name;
std::unique_ptr<CommonItemFeaturesNewsTicker> m_news_ticker_features;
};
}
} // namespace menu

View File

@ -1,15 +1,15 @@
#pragma once
#include <string>
#include <vector>
#include <map>
#include <memory>
#include "CommonItemDef.h"
#include "CommonMenuTypes.h"
#include "EventHandler/CommonEventHandlerSet.h"
#include "Parsing/Simple/Expression/ISimpleExpression.h"
#include <map>
#include <memory>
#include <string>
#include <vector>
namespace menu
{
class CommonMenuDef
@ -63,4 +63,4 @@ namespace menu
std::vector<std::unique_ptr<CommonItemDef>> m_items;
};
}
} // namespace menu

View File

@ -1,7 +1,7 @@
#include "CommonMenuTypes.h"
#include <limits>
#include <cmath>
#include <limits>
using namespace menu;
@ -25,10 +25,8 @@ CommonColor::CommonColor(const double r, const double g, const double b, const d
bool CommonColor::Equals(const CommonColor& other) const
{
return std::fabs(this->r - other.r) < std::numeric_limits<double>::epsilon()
&& std::fabs(this->g - other.g) < std::numeric_limits<double>::epsilon()
&& std::fabs(this->b - other.b) < std::numeric_limits<double>::epsilon()
&& std::fabs(this->a - other.a) < std::numeric_limits<double>::epsilon();
return std::fabs(this->r - other.r) < std::numeric_limits<double>::epsilon() && std::fabs(this->g - other.g) < std::numeric_limits<double>::epsilon()
&& std::fabs(this->b - other.b) < std::numeric_limits<double>::epsilon() && std::fabs(this->a - other.a) < std::numeric_limits<double>::epsilon();
}
CommonRect::CommonRect()

View File

@ -11,6 +11,7 @@ namespace menu
double b;
double a;
};
double array[4];
CommonColor();
@ -32,4 +33,4 @@ namespace menu
CommonRect(double x, double y, double w, double h);
CommonRect(double x, double y, double w, double h, int horizontalAlign, int verticalAlign);
};
}
} // namespace menu

View File

@ -2,10 +2,10 @@
using namespace menu;
CommonEventHandlerCondition::CommonEventHandlerCondition()
= default;
CommonEventHandlerCondition::CommonEventHandlerCondition() = default;
CommonEventHandlerCondition::CommonEventHandlerCondition(std::unique_ptr<ISimpleExpression> condition, std::unique_ptr<CommonEventHandlerSet> conditionElements,
CommonEventHandlerCondition::CommonEventHandlerCondition(std::unique_ptr<ISimpleExpression> condition,
std::unique_ptr<CommonEventHandlerSet> conditionElements,
std::unique_ptr<CommonEventHandlerSet> elseElements)
: m_condition(std::move(condition)),
m_condition_elements(std::move(conditionElements)),

View File

@ -1,11 +1,11 @@
#pragma once
#include <memory>
#include "CommonEventHandlerSet.h"
#include "ICommonEventHandlerElement.h"
#include "Parsing/Simple/Expression/ISimpleExpression.h"
#include <memory>
namespace menu
{
class CommonEventHandlerCondition final : public ICommonEventHandlerElement
@ -16,9 +16,10 @@ namespace menu
std::unique_ptr<CommonEventHandlerSet> m_else_elements;
CommonEventHandlerCondition();
CommonEventHandlerCondition(std::unique_ptr<ISimpleExpression> condition, std::unique_ptr<CommonEventHandlerSet> conditionElements,
CommonEventHandlerCondition(std::unique_ptr<ISimpleExpression> condition,
std::unique_ptr<CommonEventHandlerSet> conditionElements,
std::unique_ptr<CommonEventHandlerSet> elseElements);
_NODISCARD CommonEventHandlerElementType GetType() const override;
};
}
} // namespace menu

View File

@ -2,8 +2,7 @@
using namespace menu;
CommonEventHandlerScript::CommonEventHandlerScript()
= default;
CommonEventHandlerScript::CommonEventHandlerScript() = default;
CommonEventHandlerScript::CommonEventHandlerScript(std::string script)
: m_script(std::move(script))

View File

@ -1,9 +1,9 @@
#pragma once
#include <string>
#include "ICommonEventHandlerElement.h"
#include <string>
namespace menu
{
class CommonEventHandlerScript final : public ICommonEventHandlerElement
@ -16,4 +16,4 @@ namespace menu
_NODISCARD CommonEventHandlerElementType GetType() const override;
};
}
} // namespace menu

View File

@ -2,8 +2,7 @@
using namespace menu;
CommonEventHandlerSet::CommonEventHandlerSet()
= default;
CommonEventHandlerSet::CommonEventHandlerSet() = default;
CommonEventHandlerSet::CommonEventHandlerSet(std::vector<std::unique_ptr<ICommonEventHandlerElement>> elements)
: m_elements(std::move(elements))

View File

@ -1,10 +1,10 @@
#pragma once
#include "ICommonEventHandlerElement.h"
#include <memory>
#include <vector>
#include "ICommonEventHandlerElement.h"
namespace menu
{
class CommonEventHandlerSet
@ -15,4 +15,4 @@ namespace menu
CommonEventHandlerSet();
explicit CommonEventHandlerSet(std::vector<std::unique_ptr<ICommonEventHandlerElement>> elements);
};
}
} // namespace menu

View File

@ -1,10 +1,10 @@
#pragma once
#include <memory>
#include <string>
#include "ICommonEventHandlerElement.h"
#include "Parsing/Simple/Expression/ISimpleExpression.h"
#include <memory>
#include <string>
namespace menu
{
enum class SetLocalVarType
@ -28,4 +28,4 @@ namespace menu
_NODISCARD CommonEventHandlerElementType GetType() const override;
};
}
} // namespace menu

View File

@ -25,4 +25,4 @@ namespace menu
_NODISCARD virtual CommonEventHandlerElementType GetType() const = 0;
};
}
} // namespace menu

View File

@ -12,9 +12,7 @@ bool CommonExpressionBaseFunctionCall::Equals(const ISimpleExpression* other) co
{
const auto otherFunctionCall = dynamic_cast<const CommonExpressionBaseFunctionCall*>(other);
if (!otherFunctionCall
|| m_function_name != otherFunctionCall->m_function_name
|| m_function_index != otherFunctionCall->m_function_index
if (!otherFunctionCall || m_function_name != otherFunctionCall->m_function_name || m_function_index != otherFunctionCall->m_function_index
|| m_args.size() != otherFunctionCall->m_args.size())
{
return false;

View File

@ -1,8 +1,8 @@
#pragma once
#include <vector>
#include "Parsing/Simple/Expression/ISimpleExpression.h"
#include <vector>
namespace menu
{
class CommonExpressionBaseFunctionCall final : public ISimpleExpression
@ -19,4 +19,4 @@ namespace menu
_NODISCARD SimpleExpressionValue EvaluateStatic() const override;
_NODISCARD SimpleExpressionValue EvaluateNonStatic(const ISimpleExpressionScopeValues* scopeValues) const override;
};
}
} // namespace menu

View File

@ -16,4 +16,4 @@ namespace menu
_NODISCARD SimpleExpressionValue EvaluateStatic() const override;
_NODISCARD SimpleExpressionValue EvaluateNonStatic(const ISimpleExpressionScopeValues* scopeValues) const override;
};
}
} // namespace menu

View File

@ -7,4 +7,4 @@ namespace menu
IW4,
IW5
};
}
} // namespace menu

View File

@ -1,11 +1,11 @@
#pragma once
#include <memory>
#include <vector>
#include "CommonFunctionDef.h"
#include "CommonMenuDef.h"
#include <memory>
#include <vector>
namespace menu
{
class ParsingResult
@ -15,4 +15,4 @@ namespace menu
std::vector<std::unique_ptr<CommonFunctionDef>> m_functions;
std::vector<std::string> m_menus_to_load;
};
}
} // namespace menu

View File

@ -1,10 +1,10 @@
#include "MenuExpressionMatchers.h"
#include "MenuMatcherFactory.h"
#include "Game/IW4/IW4.h"
#include "Game/IW5/IW5.h"
#include "Game/IW4/MenuConstantsIW4.h"
#include "Game/IW5/IW5.h"
#include "Game/IW5/MenuConstantsIW5.h"
#include "MenuMatcherFactory.h"
#include "Parsing/Menu/Domain/Expression/CommonExpressionBaseFunctionCall.h"
#include "Parsing/Menu/Domain/Expression/CommonExpressionCustomFunctionCall.h"
@ -30,45 +30,40 @@ std::unique_ptr<SimpleExpressionMatchers::matcher_t> MenuExpressionMatchers::Par
{
const MenuMatcherFactory create(labelSupplier);
return create.Or({
create.And({
create.Identifier().Capture(CAPTURE_FUNCTION_NAME),
create.Char('('),
create.Optional(create.And({
create.Label(LABEL_EXPRESSION),
create.OptionalLoop(create.And({
create.Char(','),
create.Label(LABEL_EXPRESSION)
})),
})),
create.Char(')').Tag(TAG_EXPRESSION_FUNCTION_CALL_END)
}).Tag(TAG_EXPRESSION_FUNCTION_CALL)
});
return create.Or({create
.And({create.Identifier().Capture(CAPTURE_FUNCTION_NAME),
create.Char('('),
create.Optional(create.And({
create.Label(LABEL_EXPRESSION),
create.OptionalLoop(create.And({create.Char(','), create.Label(LABEL_EXPRESSION)})),
})),
create.Char(')').Tag(TAG_EXPRESSION_FUNCTION_CALL_END)})
.Tag(TAG_EXPRESSION_FUNCTION_CALL)});
}
const std::map<std::string, size_t>& MenuExpressionMatchers::GetBaseFunctionMapForFeatureLevel(const FeatureLevel featureLevel)
{
if(featureLevel == FeatureLevel::IW4)
if (featureLevel == FeatureLevel::IW4)
{
static std::map<std::string, size_t> iw4FunctionMap;
static bool iw4FunctionMapInitialized = false;
if(!iw4FunctionMapInitialized)
if (!iw4FunctionMapInitialized)
{
for(size_t i = IW4::expressionFunction_e::EXP_FUNC_DYN_START; i < std::extent_v<decltype(IW4::g_expFunctionNames)>; i++)
for (size_t i = IW4::expressionFunction_e::EXP_FUNC_DYN_START; i < std::extent_v<decltype(IW4::g_expFunctionNames)>; i++)
iw4FunctionMap.emplace(std::make_pair(IW4::g_expFunctionNames[i], i));
}
return iw4FunctionMap;
}
if(featureLevel == FeatureLevel::IW5)
if (featureLevel == FeatureLevel::IW5)
{
static std::map<std::string, size_t> iw5FunctionMap;
static bool iw5FunctionMapInitialized = false;
if(!iw5FunctionMapInitialized)
if (!iw5FunctionMapInitialized)
{
for(size_t i = IW5::expressionFunction_e::EXP_FUNC_DYN_START; i < std::extent_v<decltype(IW5::g_expFunctionNames)>; i++)
for (size_t i = IW5::expressionFunction_e::EXP_FUNC_DYN_START; i < std::extent_v<decltype(IW5::g_expFunctionNames)>; i++)
iw5FunctionMap.emplace(std::make_pair(IW5::g_expFunctionNames[i], i));
}
@ -82,7 +77,7 @@ const std::map<std::string, size_t>& MenuExpressionMatchers::GetBaseFunctionMapF
std::unique_ptr<ISimpleExpression> MenuExpressionMatchers::ProcessOperandExtension(SequenceResult<SimpleParserValue>& result) const
{
assert(m_state);
if(m_state == nullptr)
if (m_state == nullptr)
throw ParsingException(TokenPos(), "No state when processing menu operand extension!!");
if (result.PeekAndRemoveIfTag(TAG_EXPRESSION_FUNCTION_CALL) != TAG_EXPRESSION_FUNCTION_CALL)
@ -93,7 +88,7 @@ std::unique_ptr<ISimpleExpression> MenuExpressionMatchers::ProcessOperandExtensi
const auto& baseFunctionMap = GetBaseFunctionMapForFeatureLevel(m_state->m_feature_level);
const auto foundBaseFunction = baseFunctionMap.find(functionCallName);
if(foundBaseFunction != baseFunctionMap.end())
if (foundBaseFunction != baseFunctionMap.end())
{
auto functionCall = std::make_unique<CommonExpressionBaseFunctionCall>(std::move(functionCallName), foundBaseFunction->second);
while (result.PeekAndRemoveIfTag(TAG_EXPRESSION_FUNCTION_CALL_END) != TAG_EXPRESSION_FUNCTION_CALL_END)
@ -104,11 +99,11 @@ std::unique_ptr<ISimpleExpression> MenuExpressionMatchers::ProcessOperandExtensi
}
const auto foundCustomFunction = m_state->m_functions_by_name.find(functionCallName);
if(foundCustomFunction != m_state->m_functions_by_name.end())
if (foundCustomFunction != m_state->m_functions_by_name.end())
{
auto functionCall = std::make_unique<CommonExpressionCustomFunctionCall>(std::move(functionCallName));
if(result.PeekAndRemoveIfTag(TAG_EXPRESSION_FUNCTION_CALL_END) != TAG_EXPRESSION_FUNCTION_CALL_END)
if (result.PeekAndRemoveIfTag(TAG_EXPRESSION_FUNCTION_CALL_END) != TAG_EXPRESSION_FUNCTION_CALL_END)
throw ParsingException(functionCallToken.GetPos(), "Custom functions cannot be called with arguments");
return std::move(functionCall);

View File

@ -1,10 +1,10 @@
#pragma once
#include <memory>
#include "Parsing/Menu/MenuFileParserState.h"
#include "Parsing/Simple/Expression/SimpleExpressionMatchers.h"
#include <memory>
namespace menu
{
class MenuExpressionMatchers final : public SimpleExpressionMatchers
@ -21,4 +21,4 @@ namespace menu
std::unique_ptr<matcher_t> ParseOperandExtension(const supplier_t* labelSupplier) const override;
std::unique_ptr<ISimpleExpression> ProcessOperandExtension(SequenceResult<SimpleParserValue>& result) const override;
};
}
} // namespace menu

View File

@ -1,9 +1,9 @@
#include "MenuMatcherFactory.h"
#include <sstream>
#include "MenuExpressionMatchers.h"
#include <sstream>
using namespace menu;
MenuMatcherFactory::MenuMatcherFactory(const IMatcherForLabelSupplier<SimpleParserValue>* labelSupplier)
@ -13,23 +13,20 @@ MenuMatcherFactory::MenuMatcherFactory(const IMatcherForLabelSupplier<SimplePars
MatcherFactoryWrapper<SimpleParserValue> MenuMatcherFactory::StringChain() const
{
return Or({
And({
String(),
Loop(String())
}).Transform([](const token_list_t& tokens) -> SimpleParserValue
{
std::ostringstream ss;
return Or({And({String(), Loop(String())})
.Transform(
[](const token_list_t& tokens) -> SimpleParserValue
{
std::ostringstream ss;
for (const auto& token : tokens)
{
ss << token.get().StringValue();
}
for (const auto& token : tokens)
{
ss << token.get().StringValue();
}
return SimpleParserValue::String(tokens[0].get().GetPos(), new std::string(ss.str()));
}),
String()
});
return SimpleParserValue::String(tokens[0].get().GetPos(), new std::string(ss.str()));
}),
String()});
}
MatcherFactoryWrapper<SimpleParserValue> MenuMatcherFactory::Text() const
@ -49,26 +46,24 @@ MatcherFactoryWrapper<SimpleParserValue> MenuMatcherFactory::Numeric() const
MatcherFactoryWrapper<SimpleParserValue> MenuMatcherFactory::IntExpression() const
{
return MatcherFactoryWrapper(Or({
Integer().Tag(TAG_INT).Capture(CAPTURE_INT),
And({
Char('(').Capture(CAPTURE_FIRST_TOKEN),
Label(MenuExpressionMatchers::LABEL_EXPRESSION),
Char(')'),
}).Tag(TAG_EXPRESSION)
}));
return MatcherFactoryWrapper(Or({Integer().Tag(TAG_INT).Capture(CAPTURE_INT),
And({
Char('(').Capture(CAPTURE_FIRST_TOKEN),
Label(MenuExpressionMatchers::LABEL_EXPRESSION),
Char(')'),
})
.Tag(TAG_EXPRESSION)}));
}
MatcherFactoryWrapper<SimpleParserValue> MenuMatcherFactory::NumericExpression() const
{
return MatcherFactoryWrapper(Or({
Numeric().Tag(TAG_NUMERIC).Capture(CAPTURE_NUMERIC),
And({
Char('(').Capture(CAPTURE_FIRST_TOKEN),
Label(MenuExpressionMatchers::LABEL_EXPRESSION),
Char(')'),
}).Tag(TAG_EXPRESSION)
}));
return MatcherFactoryWrapper(Or({Numeric().Tag(TAG_NUMERIC).Capture(CAPTURE_NUMERIC),
And({
Char('(').Capture(CAPTURE_FIRST_TOKEN),
Label(MenuExpressionMatchers::LABEL_EXPRESSION),
Char(')'),
})
.Tag(TAG_EXPRESSION)}));
}
int MenuMatcherFactory::TokenNumericIntValue(const SimpleParserValue& value)

View File

@ -1,8 +1,8 @@
#pragma once
#include "Parsing/Menu/MenuFileParserState.h"
#include "Parsing/Sequence/SequenceResult.h"
#include "Parsing/Simple/Matcher/SimpleMatcherFactory.h"
#include "Parsing/Menu/MenuFileParserState.h"
namespace menu
{
@ -34,4 +34,4 @@ namespace menu
_NODISCARD static int TokenIntExpressionValue(MenuFileParserState* state, SequenceResult<SimpleParserValue>& result);
_NODISCARD static double TokenNumericExpressionValue(MenuFileParserState* state, SequenceResult<SimpleParserValue>& result);
};
}
} // namespace menu

View File

@ -1,7 +1,6 @@
#include "MenuMatcherScriptInt.h"
MenuMatcherScriptInt::MenuMatcherScriptInt()
= default;
MenuMatcherScriptInt::MenuMatcherScriptInt() = default;
MatcherResult<SimpleParserValue> MenuMatcherScriptInt::CanMatch(ILexer<SimpleParserValue>* lexer, const unsigned tokenOffset)
{

View File

@ -1,7 +1,7 @@
#pragma once
#include "Parsing/Simple/SimpleParserValue.h"
#include "Parsing/Matcher/AbstractMatcher.h"
#include "Parsing/Simple/SimpleParserValue.h"
class MenuMatcherScriptInt final : public AbstractMatcher<SimpleParserValue>
{

View File

@ -1,7 +1,6 @@
#include "MenuMatcherScriptNumeric.h"
MenuMatcherScriptNumeric::MenuMatcherScriptNumeric()
= default;
MenuMatcherScriptNumeric::MenuMatcherScriptNumeric() = default;
MatcherResult<SimpleParserValue> MenuMatcherScriptNumeric::CanMatch(ILexer<SimpleParserValue>* lexer, const unsigned tokenOffset)
{
@ -34,7 +33,7 @@ MatcherResult<SimpleParserValue> MenuMatcherScriptNumeric::CanMatch(ILexer<Simpl
// The return result does not matter here
const auto _ = strtod(stringValue.data(), &endPtr);
if(endPtr != &stringValue[stringValue.size()])
if (endPtr != &stringValue[stringValue.size()])
return MatcherResult<SimpleParserValue>::NoMatch();
return MatcherResult<SimpleParserValue>::Match(1);

View File

@ -1,7 +1,7 @@
#pragma once
#include "Parsing/Simple/SimpleParserValue.h"
#include "Parsing/Matcher/AbstractMatcher.h"
#include "Parsing/Simple/SimpleParserValue.h"
class MenuMatcherScriptNumeric final : public AbstractMatcher<SimpleParserValue>
{

View File

@ -1,11 +1,11 @@
#pragma once
#include <string>
#include "AssetLoading/IZoneAssetLoaderState.h"
#include "Domain/CommonFunctionDef.h"
#include "Domain/CommonMenuDef.h"
#include <string>
namespace menu
{
class MenuAssetZoneState final : public IZoneAssetLoaderState
@ -19,9 +19,9 @@ namespace menu
std::map<std::string, std::vector<std::string>> m_menus_to_load_by_menu;
MenuAssetZoneState() = default;
void AddFunction(std::unique_ptr<CommonFunctionDef> function);
void AddMenu(std::unique_ptr<CommonMenuDef> menu);
void AddMenusToLoad(std::string menuName, std::vector<std::string> menusToLoad);
};
}
} // namespace menu

View File

@ -24,4 +24,4 @@ void MenuFileCommonOperations::EnsureIsStringExpression(const MenuFileParserStat
if (staticValue.m_type != SimpleExpressionValue::Type::STRING)
throw ParsingException(pos, "Expression is expected to be string. Use permissive mode to compile anyway.");
}
}
}

View File

@ -1,7 +1,7 @@
#pragma once
#include "MenuFileParserState.h"
#include "Parsing/TokenPos.h"
#include "Parsing/Simple/Expression/ISimpleExpression.h"
#include "Parsing/TokenPos.h"
namespace menu
{
@ -11,4 +11,4 @@ namespace menu
static void EnsureIsNumericExpression(const MenuFileParserState* state, const TokenPos& pos, const ISimpleExpression& expression);
static void EnsureIsStringExpression(const MenuFileParserState* state, const TokenPos& pos, const ISimpleExpression& expression);
};
}
} // namespace menu

View File

@ -1,11 +1,11 @@
#pragma once
#include "MenuAssetZoneState.h"
#include "Utils/ClassUtils.h"
#include "MenuFileParserState.h"
#include "Parsing/Impl/AbstractParser.h"
#include "Parsing/Simple/SimpleLexer.h"
#include "Parsing/Simple/SimpleParserValue.h"
#include "Parsing/Impl/AbstractParser.h"
#include "Utils/ClassUtils.h"
namespace menu
{
@ -30,4 +30,4 @@ namespace menu
MenuFileParser(SimpleLexer* lexer, FeatureLevel featureLevel, bool permissiveMode, const MenuAssetZoneState* zoneState);
_NODISCARD MenuFileParserState* GetState() const;
};
}
} // namespace menu

View File

@ -1,17 +1,17 @@
#pragma once
#include "Domain/CommonFunctionDef.h"
#include "Domain/CommonMenuDef.h"
#include "Domain/EventHandler/CommonEventHandlerCondition.h"
#include "Domain/EventHandler/CommonEventHandlerSet.h"
#include "Domain/MenuFeatureLevel.h"
#include "MenuAssetZoneState.h"
#include <map>
#include <memory>
#include <vector>
#include <sstream>
#include <stack>
#include "MenuAssetZoneState.h"
#include "Domain/CommonFunctionDef.h"
#include "Domain/CommonMenuDef.h"
#include "Domain/MenuFeatureLevel.h"
#include "Domain/EventHandler/CommonEventHandlerSet.h"
#include "Domain/EventHandler/CommonEventHandlerCondition.h"
#include <vector>
namespace menu
{
@ -44,7 +44,7 @@ namespace menu
CommonMenuDef* m_current_menu;
CommonItemDef* m_current_item;
CommonEventHandlerSet* m_current_event_handler_set;
std::ostringstream m_current_script;
bool m_current_script_statement_terminated;
std::stack<EventHandlerConditionState> m_condition_stack;
@ -53,4 +53,4 @@ namespace menu
explicit MenuFileParserState(FeatureLevel featureLevel, bool permissiveMode);
MenuFileParserState(FeatureLevel featureLevel, bool permissiveMode, const MenuAssetZoneState* zoneState);
};
}
} // namespace menu

View File

@ -1,7 +1,7 @@
#include "MenuFileReader.h"
#include "MenuFileParser.h"
#include "Matcher/MenuExpressionMatchers.h"
#include "MenuFileParser.h"
#include "Parsing/Impl/CommentRemovingStreamProxy.h"
#include "Parsing/Impl/DefinesStreamProxy.h"
#include "Parsing/Impl/IncludingStreamProxy.h"
@ -142,7 +142,7 @@ std::unique_ptr<ParsingResult> MenuFileReader::ReadMenuFile()
std::cerr << "Parsing menu file failed!" << std::endl;
const auto* parserEndState = parser->GetState();
if(parserEndState->m_current_event_handler_set && !parserEndState->m_permissive_mode)
if (parserEndState->m_current_event_handler_set && !parserEndState->m_permissive_mode)
std::cerr << "You can use the --menu-permissive option to try to compile the event handler script anyway." << std::endl;
return nullptr;
}

View File

@ -1,15 +1,15 @@
#pragma once
#include "Domain/MenuFeatureLevel.h"
#include "Domain/MenuParsingResult.h"
#include "MenuAssetZoneState.h"
#include "MenuFileParserState.h"
#include "Parsing/IParserLineStream.h"
#include <memory>
#include <string>
#include <vector>
#include "MenuFileParserState.h"
#include "Domain/MenuFeatureLevel.h"
#include "Domain/MenuParsingResult.h"
#include "Parsing/IParserLineStream.h"
#include "MenuAssetZoneState.h"
namespace menu
{
class MenuFileReader
@ -43,4 +43,4 @@ namespace menu
std::unique_ptr<ParsingResult> ReadMenuFile();
};
}
} // namespace menu

View File

@ -8,8 +8,9 @@ namespace menu
class EventHandlerSetScopeSequences final : AbstractScopeSequenceHolder<MenuFileParser>
{
public:
EventHandlerSetScopeSequences(std::vector<std::unique_ptr<MenuFileParser::sequence_t>>& allSequences, std::vector<MenuFileParser::sequence_t*>& scopeSequences);
EventHandlerSetScopeSequences(std::vector<std::unique_ptr<MenuFileParser::sequence_t>>& allSequences,
std::vector<MenuFileParser::sequence_t*>& scopeSequences);
void AddSequences(FeatureLevel featureLevel, bool permissive) const;
};
}
} // namespace menu

View File

@ -1,86 +1,89 @@
#include "FunctionScopeSequences.h"
#include <sstream>
#include "Generic/GenericExpressionPropertySequence.h"
#include "Generic/GenericStringPropertySequence.h"
#include "Parsing/Menu/Matcher/MenuMatcherFactory.h"
#include <sstream>
using namespace menu;
namespace menu::function_scope_sequences
{
class SequenceCloseBlock final : public MenuFileParser::sequence_t
{
static constexpr auto CAPTURE_TOKEN = 1;
class SequenceCloseBlock final : public MenuFileParser::sequence_t
{
static constexpr auto CAPTURE_TOKEN = 1;
public:
SequenceCloseBlock()
{
const MenuMatcherFactory create(this);
public:
SequenceCloseBlock()
{
const MenuMatcherFactory create(this);
AddMatchers({
create.Char('}').Capture(CAPTURE_TOKEN)
});
}
AddMatchers({create.Char('}').Capture(CAPTURE_TOKEN)});
}
protected:
void ProcessMatch(MenuFileParserState* state, SequenceResult<SimpleParserValue>& result) const override
{
if (!state->m_current_function->m_value)
{
std::ostringstream ss;
ss << "Cannot define function name \"" << state->m_current_function->m_name << "\" without a value";
throw ParsingException(result.NextCapture(CAPTURE_TOKEN).GetPos(), ss.str());
}
protected:
void ProcessMatch(MenuFileParserState* state, SequenceResult<SimpleParserValue>& result) const override
{
if (!state->m_current_function->m_value)
{
std::ostringstream ss;
ss << "Cannot define function name \"" << state->m_current_function->m_name << "\" without a value";
throw ParsingException(result.NextCapture(CAPTURE_TOKEN).GetPos(), ss.str());
}
const auto existingFunction = state->m_functions_by_name.find(state->m_current_function->m_name);
if (existingFunction == state->m_functions_by_name.end())
{
state->m_functions_by_name.emplace(std::make_pair(state->m_current_function->m_name, state->m_current_function));
state->m_current_function = nullptr;
}
else if (!state->m_current_function->m_value->Equals(existingFunction->second->m_value.get()))
{
std::ostringstream ss;
ss << "Function with name \"" << state->m_current_function->m_name << "\" already exists";
throw ParsingException(result.NextCapture(CAPTURE_TOKEN).GetPos(), ss.str());
}
else
{
// Remove definition of function to not re-add it
const auto foundFunction = std::find_if(state->m_functions.rbegin(), state->m_functions.rend(), [state](const auto& element)
{
return element.get() == state->m_current_function;
});
assert(foundFunction != state->m_functions.rend());
assert((foundFunction + 1).base()->get() == state->m_current_function);
if (foundFunction != state->m_functions.rend())
state->m_functions.erase((foundFunction + 1).base());
const auto existingFunction = state->m_functions_by_name.find(state->m_current_function->m_name);
if (existingFunction == state->m_functions_by_name.end())
{
state->m_functions_by_name.emplace(std::make_pair(state->m_current_function->m_name, state->m_current_function));
state->m_current_function = nullptr;
}
else if (!state->m_current_function->m_value->Equals(existingFunction->second->m_value.get()))
{
std::ostringstream ss;
ss << "Function with name \"" << state->m_current_function->m_name << "\" already exists";
throw ParsingException(result.NextCapture(CAPTURE_TOKEN).GetPos(), ss.str());
}
else
{
// Remove definition of function to not re-add it
const auto foundFunction = std::find_if(state->m_functions.rbegin(),
state->m_functions.rend(),
[state](const auto& element)
{
return element.get() == state->m_current_function;
});
state->m_current_function = nullptr;
}
}
};
}
assert(foundFunction != state->m_functions.rend());
assert((foundFunction + 1).base()->get() == state->m_current_function);
if (foundFunction != state->m_functions.rend())
state->m_functions.erase((foundFunction + 1).base());
state->m_current_function = nullptr;
}
}
};
} // namespace menu::function_scope_sequences
using namespace function_scope_sequences;
FunctionScopeSequences::FunctionScopeSequences(std::vector<std::unique_ptr<MenuFileParser::sequence_t>>& allSequences, std::vector<MenuFileParser::sequence_t*>& scopeSequences)
: AbstractScopeSequenceHolder(allSequences, scopeSequences)
FunctionScopeSequences::FunctionScopeSequences(std::vector<std::unique_ptr<MenuFileParser::sequence_t>>& allSequences,
std::vector<MenuFileParser::sequence_t*>& scopeSequences)
: AbstractScopeSequenceHolder(allSequences, scopeSequences)
{
}
void FunctionScopeSequences::AddSequences(FeatureLevel featureLevel, bool permissive) const
{
AddSequence(std::make_unique<SequenceCloseBlock>());
AddSequence(std::make_unique<GenericStringPropertySequence>("name", [](const MenuFileParserState* state, const TokenPos&, const std::string& value)
{
state->m_current_function->m_name = value;
}));
AddSequence(GenericExpressionPropertySequence::WithKeyword("value", [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ISimpleExpression> value)
{
state->m_current_function->m_value = std::move(value);
}));
AddSequence(std::make_unique<SequenceCloseBlock>());
AddSequence(std::make_unique<GenericStringPropertySequence>("name",
[](const MenuFileParserState* state, const TokenPos&, const std::string& value)
{
state->m_current_function->m_name = value;
}));
AddSequence(GenericExpressionPropertySequence::WithKeyword("value",
[](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ISimpleExpression> value)
{
state->m_current_function->m_value = std::move(value);
}));
}

View File

@ -8,8 +8,9 @@ namespace menu
class FunctionScopeSequences final : AbstractScopeSequenceHolder<MenuFileParser>
{
public:
FunctionScopeSequences(std::vector<std::unique_ptr<MenuFileParser::sequence_t>>& allSequences, std::vector<MenuFileParser::sequence_t*>& scopeSequences);
FunctionScopeSequences(std::vector<std::unique_ptr<MenuFileParser::sequence_t>>& allSequences,
std::vector<MenuFileParser::sequence_t*>& scopeSequences);
void AddSequences(FeatureLevel featureLevel, bool permissive) const;
};
}
} // namespace menu

View File

@ -1,9 +1,9 @@
#include "GenericBoolPropertySequence.h"
#include <utility>
#include "Parsing/Menu/Matcher/MenuMatcherFactory.h"
#include <utility>
using namespace menu;
GenericBoolPropertySequence::GenericBoolPropertySequence(std::string keywordName, callback_t setCallback)
@ -11,10 +11,7 @@ GenericBoolPropertySequence::GenericBoolPropertySequence(std::string keywordName
{
const MenuMatcherFactory create(this);
AddMatchers({
create.KeywordIgnoreCase(std::move(keywordName)).Capture(CAPTURE_FIRST_TOKEN),
create.Integer().Capture(CAPTURE_VALUE)
});
AddMatchers({create.KeywordIgnoreCase(std::move(keywordName)).Capture(CAPTURE_FIRST_TOKEN), create.Integer().Capture(CAPTURE_VALUE)});
}
void GenericBoolPropertySequence::ProcessMatch(MenuFileParserState* state, SequenceResult<SimpleParserValue>& result) const

View File

@ -1,10 +1,10 @@
#pragma once
#include <string>
#include <functional>
#include "Parsing/Menu/MenuFileParser.h"
#include <functional>
#include <string>
namespace menu
{
class GenericBoolPropertySequence final : public MenuFileParser::sequence_t
@ -24,4 +24,4 @@ namespace menu
public:
GenericBoolPropertySequence(std::string keywordName, callback_t setCallback);
};
}
} // namespace menu

View File

@ -1,10 +1,10 @@
#include "GenericColorPropertySequence.h"
#include <utility>
#include "Parsing/Menu/Matcher/MenuExpressionMatchers.h"
#include "Parsing/Menu/Matcher/MenuMatcherFactory.h"
#include <utility>
using namespace menu;
GenericColorPropertySequence::GenericColorPropertySequence(std::string keywordName, callback_t setCallback)
@ -15,10 +15,10 @@ GenericColorPropertySequence::GenericColorPropertySequence(std::string keywordNa
AddLabeledMatchers(MenuExpressionMatchers().Expression(this), MenuExpressionMatchers::LABEL_EXPRESSION);
AddMatchers({
create.KeywordIgnoreCase(std::move(keywordName)).Capture(CAPTURE_FIRST_TOKEN),
create.NumericExpression().Tag(TAG_COLOR), // r
create.NumericExpression().Tag(TAG_COLOR), // r
create.Optional(create.NumericExpression().Tag(TAG_COLOR)), // g
create.Optional(create.NumericExpression().Tag(TAG_COLOR)), // b
create.Optional(create.NumericExpression().Tag(TAG_COLOR)) // a
create.Optional(create.NumericExpression().Tag(TAG_COLOR)) // a
});
}

View File

@ -1,10 +1,10 @@
#pragma once
#include <string>
#include <functional>
#include "Parsing/Menu/MenuFileParser.h"
#include "Parsing/Menu/Domain/CommonMenuTypes.h"
#include "Parsing/Menu/MenuFileParser.h"
#include <functional>
#include <string>
namespace menu
{
@ -28,4 +28,4 @@ namespace menu
public:
GenericColorPropertySequence(std::string keywordName, callback_t setCallback);
};
}
} // namespace menu

View File

@ -1,10 +1,10 @@
#include "GenericExpressionPropertySequence.h"
#include <utility>
#include "Parsing/Menu/Matcher/MenuExpressionMatchers.h"
#include "Parsing/Menu/Matcher/MenuMatcherFactory.h"
#include <utility>
using namespace menu;
GenericExpressionPropertySequence::GenericExpressionPropertySequence(callback_t setCallback)
@ -19,16 +19,15 @@ std::unique_ptr<GenericExpressionPropertySequence> GenericExpressionPropertySequ
auto result = std::unique_ptr<GenericExpressionPropertySequence>(new GenericExpressionPropertySequence(std::move(setCallback)));
const MenuMatcherFactory create(result.get());
result->AddMatchers({
create.KeywordIgnoreCase(std::move(keyword)).Capture(CAPTURE_FIRST_TOKEN),
create.Label(MenuExpressionMatchers::LABEL_EXPRESSION),
create.Optional(create.Char(';'))
});
result->AddMatchers({create.KeywordIgnoreCase(std::move(keyword)).Capture(CAPTURE_FIRST_TOKEN),
create.Label(MenuExpressionMatchers::LABEL_EXPRESSION),
create.Optional(create.Char(';'))});
return std::move(result);
}
std::unique_ptr<GenericExpressionPropertySequence> GenericExpressionPropertySequence::WithKeywords(const std::initializer_list<std::string> keywords, callback_t setCallback)
std::unique_ptr<GenericExpressionPropertySequence> GenericExpressionPropertySequence::WithKeywords(const std::initializer_list<std::string> keywords,
callback_t setCallback)
{
auto result = std::unique_ptr<GenericExpressionPropertySequence>(new GenericExpressionPropertySequence(std::move(setCallback)));
@ -37,11 +36,9 @@ std::unique_ptr<GenericExpressionPropertySequence> GenericExpressionPropertySequ
for (auto keyword : keywords)
keywordMatchers.emplace_back(create.KeywordIgnoreCase(std::move(keyword)));
result->AddMatchers({
create.And(std::move(keywordMatchers)).Capture(CAPTURE_FIRST_TOKEN),
create.Label(MenuExpressionMatchers::LABEL_EXPRESSION),
create.Optional(create.Char(';'))
});
result->AddMatchers({create.And(std::move(keywordMatchers)).Capture(CAPTURE_FIRST_TOKEN),
create.Label(MenuExpressionMatchers::LABEL_EXPRESSION),
create.Optional(create.Char(';'))});
return std::move(result);
}
@ -51,12 +48,10 @@ std::unique_ptr<GenericExpressionPropertySequence> GenericExpressionPropertySequ
auto result = std::unique_ptr<GenericExpressionPropertySequence>(new GenericExpressionPropertySequence(std::move(setCallback)));
const MenuMatcherFactory create(result.get());
result->AddMatchers({
create.KeywordIgnoreCase(std::move(keyword)).Capture(CAPTURE_FIRST_TOKEN),
create.Optional(create.KeywordIgnoreCase("when")),
create.Label(MenuExpressionMatchers::LABEL_EXPRESSION),
create.Optional(create.Char(';'))
});
result->AddMatchers({create.KeywordIgnoreCase(std::move(keyword)).Capture(CAPTURE_FIRST_TOKEN),
create.Optional(create.KeywordIgnoreCase("when")),
create.Label(MenuExpressionMatchers::LABEL_EXPRESSION),
create.Optional(create.Char(';'))});
return std::move(result);
}

View File

@ -1,11 +1,11 @@
#pragma once
#include <string>
#include <functional>
#include "Parsing/Menu/MenuFileParser.h"
#include "Parsing/Simple/Expression/ISimpleExpression.h"
#include <functional>
#include <string>
namespace menu
{
class GenericExpressionPropertySequence final : public MenuFileParser::sequence_t
@ -29,4 +29,4 @@ namespace menu
static std::unique_ptr<GenericExpressionPropertySequence> WithKeywords(std::initializer_list<std::string> keywords, callback_t setCallback);
static std::unique_ptr<GenericExpressionPropertySequence> WithKeywordAndBool(std::string keyword, callback_t setCallback);
};
}
} // namespace menu

View File

@ -1,10 +1,10 @@
#include "GenericFloatingPointPropertySequence.h"
#include <utility>
#include "Parsing/Menu/Matcher/MenuExpressionMatchers.h"
#include "Parsing/Menu/Matcher/MenuMatcherFactory.h"
#include <utility>
using namespace menu;
GenericFloatingPointPropertySequence::GenericFloatingPointPropertySequence(std::string keywordName, callback_t setCallback)
@ -13,10 +13,7 @@ GenericFloatingPointPropertySequence::GenericFloatingPointPropertySequence(std::
const MenuMatcherFactory create(this);
AddLabeledMatchers(MenuExpressionMatchers().Expression(this), MenuExpressionMatchers::LABEL_EXPRESSION);
AddMatchers({
create.KeywordIgnoreCase(std::move(keywordName)).Capture(CAPTURE_FIRST_TOKEN),
create.NumericExpression()
});
AddMatchers({create.KeywordIgnoreCase(std::move(keywordName)).Capture(CAPTURE_FIRST_TOKEN), create.NumericExpression()});
}
void GenericFloatingPointPropertySequence::ProcessMatch(MenuFileParserState* state, SequenceResult<SimpleParserValue>& result) const

View File

@ -1,10 +1,10 @@
#pragma once
#include <string>
#include <functional>
#include "Parsing/Menu/MenuFileParser.h"
#include <functional>
#include <string>
namespace menu
{
class GenericFloatingPointPropertySequence final : public MenuFileParser::sequence_t
@ -23,4 +23,4 @@ namespace menu
public:
GenericFloatingPointPropertySequence(std::string keywordName, callback_t setCallback);
};
}
} // namespace menu

View File

@ -1,10 +1,10 @@
#include "GenericIntPropertySequence.h"
#include <utility>
#include "Parsing/Menu/Matcher/MenuExpressionMatchers.h"
#include "Parsing/Menu/Matcher/MenuMatcherFactory.h"
#include <utility>
using namespace menu;
GenericIntPropertySequence::GenericIntPropertySequence(std::string keywordName, callback_t setCallback)

View File

@ -1,10 +1,10 @@
#pragma once
#include <string>
#include <functional>
#include "Parsing/Menu/MenuFileParser.h"
#include <functional>
#include <string>
namespace menu
{
class GenericIntPropertySequence final : public MenuFileParser::sequence_t
@ -23,4 +23,4 @@ namespace menu
public:
GenericIntPropertySequence(std::string keywordName, callback_t setCallback);
};
}
} // namespace menu

View File

@ -1,9 +1,9 @@
#include "GenericKeywordPropertySequence.h"
#include <utility>
#include "Parsing/Menu/Matcher/MenuMatcherFactory.h"
#include <utility>
using namespace menu;
GenericKeywordPropertySequence::GenericKeywordPropertySequence(std::string keywordName, callback_t setCallback)

View File

@ -1,10 +1,10 @@
#pragma once
#include <string>
#include <functional>
#include "Parsing/Menu/MenuFileParser.h"
#include <functional>
#include <string>
namespace menu
{
class GenericKeywordPropertySequence final : public MenuFileParser::sequence_t
@ -23,4 +23,4 @@ namespace menu
public:
GenericKeywordPropertySequence(std::string keywordName, callback_t setCallback);
};
}
} // namespace menu

View File

@ -1,9 +1,9 @@
#include "GenericMenuEventHandlerSetPropertySequence.h"
#include <utility>
#include "Parsing/Menu/Matcher/MenuMatcherFactory.h"
#include <utility>
using namespace menu;
GenericMenuEventHandlerSetPropertySequence::GenericMenuEventHandlerSetPropertySequence(std::string keywordName, callback_t setCallback)
@ -11,10 +11,7 @@ GenericMenuEventHandlerSetPropertySequence::GenericMenuEventHandlerSetPropertySe
{
const MenuMatcherFactory create(this);
AddMatchers({
create.KeywordIgnoreCase(std::move(keywordName)).Capture(CAPTURE_FIRST_TOKEN),
create.Char('{')
});
AddMatchers({create.KeywordIgnoreCase(std::move(keywordName)).Capture(CAPTURE_FIRST_TOKEN), create.Char('{')});
}
void GenericMenuEventHandlerSetPropertySequence::ProcessMatch(MenuFileParserState* state, SequenceResult<SimpleParserValue>& result) const
@ -22,7 +19,7 @@ void GenericMenuEventHandlerSetPropertySequence::ProcessMatch(MenuFileParserStat
if (m_set_callback)
{
auto& eventHandlerPtr = m_set_callback(state, result.NextCapture(CAPTURE_FIRST_TOKEN).GetPos());
if(!eventHandlerPtr)
if (!eventHandlerPtr)
eventHandlerPtr = std::make_unique<CommonEventHandlerSet>();
state->m_current_event_handler_set = eventHandlerPtr.get();

View File

@ -1,17 +1,17 @@
#pragma once
#include <string>
#include <functional>
#include "Parsing/Menu/MenuFileParser.h"
#include "Parsing/Menu/Domain/EventHandler/CommonEventHandlerSet.h"
#include "Parsing/Menu/MenuFileParser.h"
#include <functional>
#include <string>
namespace menu
{
class GenericMenuEventHandlerSetPropertySequence final : public MenuFileParser::sequence_t
{
public:
using callback_t = std::function<std::unique_ptr<CommonEventHandlerSet>& (MenuFileParserState* state, const TokenPos& pos)>;
using callback_t = std::function<std::unique_ptr<CommonEventHandlerSet>&(MenuFileParserState* state, const TokenPos& pos)>;
private:
static constexpr auto CAPTURE_FIRST_TOKEN = 1;
@ -24,4 +24,4 @@ namespace menu
public:
GenericMenuEventHandlerSetPropertySequence(std::string keywordName, callback_t setCallback);
};
}
} // namespace menu

View File

@ -1,9 +1,9 @@
#include "GenericStringPropertySequence.h"
#include <utility>
#include "Parsing/Menu/Matcher/MenuMatcherFactory.h"
#include <utility>
using namespace menu;
GenericStringPropertySequence::GenericStringPropertySequence(std::string keywordName, callback_t setCallback)
@ -11,10 +11,7 @@ GenericStringPropertySequence::GenericStringPropertySequence(std::string keyword
{
const MenuMatcherFactory create(this);
AddMatchers({
create.KeywordIgnoreCase(std::move(keywordName)).Capture(CAPTURE_FIRST_TOKEN),
create.Text().Capture(CAPTURE_VALUE)
});
AddMatchers({create.KeywordIgnoreCase(std::move(keywordName)).Capture(CAPTURE_FIRST_TOKEN), create.Text().Capture(CAPTURE_VALUE)});
}
void GenericStringPropertySequence::ProcessMatch(MenuFileParserState* state, SequenceResult<SimpleParserValue>& result) const

View File

@ -1,10 +1,10 @@
#pragma once
#include <string>
#include <functional>
#include "Parsing/Menu/MenuFileParser.h"
#include <functional>
#include <string>
namespace menu
{
class GenericStringPropertySequence final : public MenuFileParser::sequence_t
@ -24,4 +24,4 @@ namespace menu
public:
GenericStringPropertySequence(std::string keywordName, callback_t setCallback);
};
}
} // namespace menu

View File

@ -14,9 +14,7 @@ namespace menu::global_scope_sequences
{
const MenuMatcherFactory create(this);
AddMatchers({
create.Char('}')
});
AddMatchers({create.Char('}')});
}
protected:
@ -98,11 +96,12 @@ namespace menu::global_scope_sequences
state->m_menus_to_load.emplace_back(menuNameToken.StringValue());
}
};
}
} // namespace menu::global_scope_sequences
using namespace global_scope_sequences;
GlobalScopeSequences::GlobalScopeSequences(std::vector<std::unique_ptr<MenuFileParser::sequence_t>>& allSequences, std::vector<MenuFileParser::sequence_t*>& scopeSequences)
GlobalScopeSequences::GlobalScopeSequences(std::vector<std::unique_ptr<MenuFileParser::sequence_t>>& allSequences,
std::vector<MenuFileParser::sequence_t*>& scopeSequences)
: AbstractScopeSequenceHolder(allSequences, scopeSequences)
{
}

View File

@ -12,4 +12,4 @@ namespace menu
void AddSequences(FeatureLevel featureLevel, bool permissive) const;
};
}
} // namespace menu

File diff suppressed because it is too large Load Diff

View File

@ -12,4 +12,4 @@ namespace menu
void AddSequences(FeatureLevel featureLevel, bool permissive) const;
};
}
} // namespace menu

View File

@ -1,7 +1,5 @@
#include "MenuScopeSequences.h"
#include <sstream>
#include "Generic/GenericBoolPropertySequence.h"
#include "Generic/GenericColorPropertySequence.h"
#include "Generic/GenericExpressionPropertySequence.h"
@ -10,10 +8,12 @@
#include "Generic/GenericKeywordPropertySequence.h"
#include "Generic/GenericMenuEventHandlerSetPropertySequence.h"
#include "Generic/GenericStringPropertySequence.h"
#include "Parsing/Menu/MenuFileCommonOperations.h"
#include "Parsing/Menu/Matcher/MenuMatcherFactory.h"
#include "Parsing/Menu/Domain/CommonMenuTypes.h"
#include "Parsing/Menu/Matcher/MenuExpressionMatchers.h"
#include "Parsing/Menu/Matcher/MenuMatcherFactory.h"
#include "Parsing/Menu/MenuFileCommonOperations.h"
#include <sstream>
using namespace menu;
@ -28,9 +28,7 @@ namespace menu::menu_scope_sequences
{
const MenuMatcherFactory create(this);
AddMatchers({
create.Char('}').Capture(CAPTURE_TOKEN)
});
AddMatchers({create.Char('}').Capture(CAPTURE_TOKEN)});
}
protected:
@ -61,15 +59,11 @@ namespace menu::menu_scope_sequences
{
const MenuMatcherFactory create(this);
AddMatchers({
create.Char(';')
});
AddMatchers({create.Char(';')});
}
protected:
void ProcessMatch(MenuFileParserState* state, SequenceResult<SimpleParserValue>& result) const override
{
}
void ProcessMatch(MenuFileParserState* state, SequenceResult<SimpleParserValue>& result) const override {}
};
class SequenceItemDef final : public MenuFileParser::sequence_t
@ -81,10 +75,7 @@ namespace menu::menu_scope_sequences
{
const MenuMatcherFactory create(this);
AddMatchers({
create.Keyword("itemDef"),
create.Char('{')
});
AddMatchers({create.Keyword("itemDef"), create.Char('{')});
}
protected:
@ -107,17 +98,12 @@ namespace menu::menu_scope_sequences
const MenuMatcherFactory create(this);
AddLabeledMatchers(MenuExpressionMatchers().Expression(this), MenuExpressionMatchers::LABEL_EXPRESSION);
AddMatchers({
create.KeywordIgnoreCase("rect"),
create.NumericExpression(), // x
create.NumericExpression(), // y
create.NumericExpression(), // w
create.NumericExpression(), // h
create.Optional(create.And({
create.Integer().Capture(CAPTURE_ALIGN_HORIZONTAL),
create.Integer().Capture(CAPTURE_ALIGN_VERTICAL)
}))
});
AddMatchers({create.KeywordIgnoreCase("rect"),
create.NumericExpression(), // x
create.NumericExpression(), // y
create.NumericExpression(), // w
create.NumericExpression(), // h
create.Optional(create.And({create.Integer().Capture(CAPTURE_ALIGN_HORIZONTAL), create.Integer().Capture(CAPTURE_ALIGN_VERTICAL)}))});
}
protected:
@ -129,14 +115,7 @@ namespace menu::menu_scope_sequences
const auto y = MenuMatcherFactory::TokenNumericExpressionValue(state, result);
const auto w = MenuMatcherFactory::TokenNumericExpressionValue(state, result);
const auto h = MenuMatcherFactory::TokenNumericExpressionValue(state, result);
CommonRect rect
{
x,
y,
w,
h,
0, 0
};
CommonRect rect{x, y, w, h, 0, 0};
if (result.HasNextCapture(CAPTURE_ALIGN_HORIZONTAL) && result.HasNextCapture(CAPTURE_ALIGN_VERTICAL))
{
@ -157,11 +136,7 @@ namespace menu::menu_scope_sequences
{
const MenuMatcherFactory create(this);
AddMatchers({
create.KeywordIgnoreCase("execKey"),
create.StringChain().Capture(CAPTURE_KEY),
create.Char('{')
});
AddMatchers({create.KeywordIgnoreCase("execKey"), create.StringChain().Capture(CAPTURE_KEY), create.Char('{')});
}
protected:
@ -193,11 +168,7 @@ namespace menu::menu_scope_sequences
{
const MenuMatcherFactory create(this);
AddMatchers({
create.KeywordIgnoreCase("execKeyInt"),
create.Integer().Capture(CAPTURE_KEY),
create.Char('{')
});
AddMatchers({create.KeywordIgnoreCase("execKeyInt"), create.Integer().Capture(CAPTURE_KEY), create.Char('{')});
}
protected:
@ -217,11 +188,12 @@ namespace menu::menu_scope_sequences
state->m_current_menu->m_key_handlers.emplace(std::make_pair(keyValue, std::move(newEventHandlerSet)));
}
};
}
} // namespace menu::menu_scope_sequences
using namespace menu_scope_sequences;
MenuScopeSequences::MenuScopeSequences(std::vector<std::unique_ptr<MenuFileParser::sequence_t>>& allSequences, std::vector<MenuFileParser::sequence_t*>& scopeSequences)
MenuScopeSequences::MenuScopeSequences(std::vector<std::unique_ptr<MenuFileParser::sequence_t>>& allSequences,
std::vector<MenuFileParser::sequence_t*>& scopeSequences)
: AbstractScopeSequenceHolder(allSequences, scopeSequences)
{
}
@ -230,190 +202,248 @@ void MenuScopeSequences::AddSequences(FeatureLevel featureLevel, bool permissive
{
AddSequence(std::make_unique<SequenceCloseBlock>());
AddSequence(std::make_unique<SequenceItemDef>());
AddSequence(std::make_unique<GenericStringPropertySequence>("name", [](const MenuFileParserState* state, const TokenPos&, const std::string& value)
{
state->m_current_menu->m_name = value;
}));
AddSequence(std::make_unique<GenericBoolPropertySequence>("fullScreen", [](const MenuFileParserState* state, const TokenPos&, const bool value)
{
state->m_current_menu->m_full_screen = value;
}));
AddSequence(std::make_unique<GenericKeywordPropertySequence>("screenSpace", [](const MenuFileParserState* state, const TokenPos&)
{
state->m_current_menu->m_screen_space = true;
}));
AddSequence(std::make_unique<GenericKeywordPropertySequence>("decoration", [](const MenuFileParserState* state, const TokenPos&)
{
state->m_current_menu->m_decoration = true;
}));
AddSequence(std::make_unique<GenericStringPropertySequence>("name",
[](const MenuFileParserState* state, const TokenPos&, const std::string& value)
{
state->m_current_menu->m_name = value;
}));
AddSequence(std::make_unique<GenericBoolPropertySequence>("fullScreen",
[](const MenuFileParserState* state, const TokenPos&, const bool value)
{
state->m_current_menu->m_full_screen = value;
}));
AddSequence(std::make_unique<GenericKeywordPropertySequence>("screenSpace",
[](const MenuFileParserState* state, const TokenPos&)
{
state->m_current_menu->m_screen_space = true;
}));
AddSequence(std::make_unique<GenericKeywordPropertySequence>("decoration",
[](const MenuFileParserState* state, const TokenPos&)
{
state->m_current_menu->m_decoration = true;
}));
AddSequence(std::make_unique<SequenceRect>());
// rect480
// rect720
// pos480
// pos720
AddSequence(std::make_unique<GenericIntPropertySequence>("style", [](const MenuFileParserState* state, const TokenPos&, const int value)
{
state->m_current_menu->m_style = value;
}));
AddSequence(GenericExpressionPropertySequence::WithKeywordAndBool("visible", [](const MenuFileParserState* state, const TokenPos& pos, std::unique_ptr<ISimpleExpression> value)
{
MenuFileCommonOperations::EnsureIsNumericExpression(state, pos, *value);
state->m_current_menu->m_visible_expression = std::move(value);
}));
AddSequence(std::make_unique<GenericMenuEventHandlerSetPropertySequence>("onOpen", [](const MenuFileParserState* state, const TokenPos&) -> std::unique_ptr<CommonEventHandlerSet>& {
return state->m_current_menu->m_on_open;
}));
AddSequence(std::make_unique<GenericMenuEventHandlerSetPropertySequence>("onClose", [](const MenuFileParserState* state, const TokenPos&) -> std::unique_ptr<CommonEventHandlerSet>& {
return state->m_current_menu->m_on_close;
}));
AddSequence(std::make_unique<GenericMenuEventHandlerSetPropertySequence>("onRequestClose", [](const MenuFileParserState* state, const TokenPos&) -> std::unique_ptr<CommonEventHandlerSet>& {
return state->m_current_menu->m_on_request_close;
}));
AddSequence(std::make_unique<GenericMenuEventHandlerSetPropertySequence>("onESC", [](const MenuFileParserState* state, const TokenPos&) -> std::unique_ptr<CommonEventHandlerSet>& {
return state->m_current_menu->m_on_esc;
}));
AddSequence(std::make_unique<GenericIntPropertySequence>("border", [](const MenuFileParserState* state, const TokenPos&, const int value)
{
state->m_current_menu->m_border = value;
}));
AddSequence(std::make_unique<GenericFloatingPointPropertySequence>("borderSize", [](const MenuFileParserState* state, const TokenPos&, const double value)
{
state->m_current_menu->m_border_size = value;
}));
AddSequence(std::make_unique<GenericColorPropertySequence>("backcolor", [](const MenuFileParserState* state, const TokenPos&, const CommonColor value)
{
state->m_current_menu->m_back_color = value;
}));
AddSequence(std::make_unique<GenericColorPropertySequence>("forecolor", [](const MenuFileParserState* state, const TokenPos&, const CommonColor value)
{
state->m_current_menu->m_fore_color = value;
}));
AddSequence(std::make_unique<GenericColorPropertySequence>("bordercolor", [](const MenuFileParserState* state, const TokenPos&, const CommonColor value)
{
state->m_current_menu->m_border_color = value;
}));
AddSequence(std::make_unique<GenericColorPropertySequence>("focuscolor", [](const MenuFileParserState* state, const TokenPos&, const CommonColor value)
{
state->m_current_menu->m_focus_color = value;
}));
AddSequence(std::make_unique<GenericColorPropertySequence>("outlinecolor", [](const MenuFileParserState* state, const TokenPos&, const CommonColor value)
{
state->m_current_menu->m_outline_color = value;
}));
AddSequence(std::make_unique<GenericStringPropertySequence>("background", [](const MenuFileParserState* state, const TokenPos&, const std::string& value)
{
state->m_current_menu->m_background = value;
}));
AddSequence(std::make_unique<GenericIntPropertySequence>("ownerdraw", [](const MenuFileParserState* state, const TokenPos&, const int value)
{
state->m_current_menu->m_owner_draw = value;
}));
AddSequence(std::make_unique<GenericIntPropertySequence>("ownerdrawFlag", [](const MenuFileParserState* state, const TokenPos&, const int value)
{
state->m_current_menu->m_owner_draw_flags |= value;
}));
AddSequence(std::make_unique<GenericKeywordPropertySequence>("outOfBoundsClick", [](const MenuFileParserState* state, const TokenPos&)
{
state->m_current_menu->m_out_of_bounds_click = true;
}));
AddSequence(std::make_unique<GenericStringPropertySequence>("soundLoop", [](const MenuFileParserState* state, const TokenPos&, const std::string& value)
{
state->m_current_menu->m_sound_loop = value;
}));
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "rect", "X"}, [](const MenuFileParserState* state, const TokenPos& pos, std::unique_ptr<ISimpleExpression> value)
{
MenuFileCommonOperations::EnsureIsNumericExpression(state, pos, *value);
state->m_current_menu->m_rect_x_exp = std::move(value);
}));
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "rect", "Y"}, [](const MenuFileParserState* state, const TokenPos& pos, std::unique_ptr<ISimpleExpression> value)
{
MenuFileCommonOperations::EnsureIsNumericExpression(state, pos, *value);
state->m_current_menu->m_rect_y_exp = std::move(value);
}));
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "rect", "W"}, [](const MenuFileParserState* state, const TokenPos& pos, std::unique_ptr<ISimpleExpression> value)
{
MenuFileCommonOperations::EnsureIsNumericExpression(state, pos, *value);
state->m_current_menu->m_rect_w_exp = std::move(value);
}));
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "rect", "H"}, [](const MenuFileParserState* state, const TokenPos& pos, std::unique_ptr<ISimpleExpression> value)
{
MenuFileCommonOperations::EnsureIsNumericExpression(state, pos, *value);
state->m_current_menu->m_rect_h_exp = std::move(value);
}));
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "openSound"}, [](const MenuFileParserState* state, const TokenPos& pos, std::unique_ptr<ISimpleExpression> value)
{
MenuFileCommonOperations::EnsureIsStringExpression(state, pos, *value);
state->m_current_menu->m_open_sound_exp = std::move(value);
}));
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "closeSound"}, [](const MenuFileParserState* state, const TokenPos& pos, std::unique_ptr<ISimpleExpression> value)
{
MenuFileCommonOperations::EnsureIsStringExpression(state, pos, *value);
state->m_current_menu->m_close_sound_exp = std::move(value);
}));
AddSequence(std::make_unique<GenericKeywordPropertySequence>("popup", [](const MenuFileParserState* state, const TokenPos&)
{
state->m_current_menu->m_popup = true;
}));
AddSequence(std::make_unique<GenericFloatingPointPropertySequence>("fadeClamp", [](const MenuFileParserState* state, const TokenPos&, const double value)
{
state->m_current_menu->m_fade_clamp = value;
}));
AddSequence(std::make_unique<GenericIntPropertySequence>("fadeCycle", [](const MenuFileParserState* state, const TokenPos&, const int value)
{
state->m_current_menu->m_fade_cycle = value;
}));
AddSequence(std::make_unique<GenericFloatingPointPropertySequence>("fadeAmount", [](const MenuFileParserState* state, const TokenPos&, const double value)
{
state->m_current_menu->m_fade_amount = value;
}));
AddSequence(std::make_unique<GenericFloatingPointPropertySequence>("fadeInAmount", [](const MenuFileParserState* state, const TokenPos&, const double value)
{
state->m_current_menu->m_fade_in_amount = value;
}));
AddSequence(std::make_unique<GenericIntPropertySequence>("style",
[](const MenuFileParserState* state, const TokenPos&, const int value)
{
state->m_current_menu->m_style = value;
}));
AddSequence(GenericExpressionPropertySequence::WithKeywordAndBool(
"visible",
[](const MenuFileParserState* state, const TokenPos& pos, std::unique_ptr<ISimpleExpression> value)
{
MenuFileCommonOperations::EnsureIsNumericExpression(state, pos, *value);
state->m_current_menu->m_visible_expression = std::move(value);
}));
AddSequence(std::make_unique<GenericMenuEventHandlerSetPropertySequence>(
"onOpen",
[](const MenuFileParserState* state, const TokenPos&) -> std::unique_ptr<CommonEventHandlerSet>&
{
return state->m_current_menu->m_on_open;
}));
AddSequence(std::make_unique<GenericMenuEventHandlerSetPropertySequence>(
"onClose",
[](const MenuFileParserState* state, const TokenPos&) -> std::unique_ptr<CommonEventHandlerSet>&
{
return state->m_current_menu->m_on_close;
}));
AddSequence(std::make_unique<GenericMenuEventHandlerSetPropertySequence>(
"onRequestClose",
[](const MenuFileParserState* state, const TokenPos&) -> std::unique_ptr<CommonEventHandlerSet>&
{
return state->m_current_menu->m_on_request_close;
}));
AddSequence(std::make_unique<GenericMenuEventHandlerSetPropertySequence>(
"onESC",
[](const MenuFileParserState* state, const TokenPos&) -> std::unique_ptr<CommonEventHandlerSet>&
{
return state->m_current_menu->m_on_esc;
}));
AddSequence(std::make_unique<GenericIntPropertySequence>("border",
[](const MenuFileParserState* state, const TokenPos&, const int value)
{
state->m_current_menu->m_border = value;
}));
AddSequence(std::make_unique<GenericFloatingPointPropertySequence>("borderSize",
[](const MenuFileParserState* state, const TokenPos&, const double value)
{
state->m_current_menu->m_border_size = value;
}));
AddSequence(std::make_unique<GenericColorPropertySequence>("backcolor",
[](const MenuFileParserState* state, const TokenPos&, const CommonColor value)
{
state->m_current_menu->m_back_color = value;
}));
AddSequence(std::make_unique<GenericColorPropertySequence>("forecolor",
[](const MenuFileParserState* state, const TokenPos&, const CommonColor value)
{
state->m_current_menu->m_fore_color = value;
}));
AddSequence(std::make_unique<GenericColorPropertySequence>("bordercolor",
[](const MenuFileParserState* state, const TokenPos&, const CommonColor value)
{
state->m_current_menu->m_border_color = value;
}));
AddSequence(std::make_unique<GenericColorPropertySequence>("focuscolor",
[](const MenuFileParserState* state, const TokenPos&, const CommonColor value)
{
state->m_current_menu->m_focus_color = value;
}));
AddSequence(std::make_unique<GenericColorPropertySequence>("outlinecolor",
[](const MenuFileParserState* state, const TokenPos&, const CommonColor value)
{
state->m_current_menu->m_outline_color = value;
}));
AddSequence(std::make_unique<GenericStringPropertySequence>("background",
[](const MenuFileParserState* state, const TokenPos&, const std::string& value)
{
state->m_current_menu->m_background = value;
}));
AddSequence(std::make_unique<GenericIntPropertySequence>("ownerdraw",
[](const MenuFileParserState* state, const TokenPos&, const int value)
{
state->m_current_menu->m_owner_draw = value;
}));
AddSequence(std::make_unique<GenericIntPropertySequence>("ownerdrawFlag",
[](const MenuFileParserState* state, const TokenPos&, const int value)
{
state->m_current_menu->m_owner_draw_flags |= value;
}));
AddSequence(std::make_unique<GenericKeywordPropertySequence>("outOfBoundsClick",
[](const MenuFileParserState* state, const TokenPos&)
{
state->m_current_menu->m_out_of_bounds_click = true;
}));
AddSequence(std::make_unique<GenericStringPropertySequence>("soundLoop",
[](const MenuFileParserState* state, const TokenPos&, const std::string& value)
{
state->m_current_menu->m_sound_loop = value;
}));
AddSequence(
GenericExpressionPropertySequence::WithKeywords({"exp", "rect", "X"},
[](const MenuFileParserState* state, const TokenPos& pos, std::unique_ptr<ISimpleExpression> value)
{
MenuFileCommonOperations::EnsureIsNumericExpression(state, pos, *value);
state->m_current_menu->m_rect_x_exp = std::move(value);
}));
AddSequence(
GenericExpressionPropertySequence::WithKeywords({"exp", "rect", "Y"},
[](const MenuFileParserState* state, const TokenPos& pos, std::unique_ptr<ISimpleExpression> value)
{
MenuFileCommonOperations::EnsureIsNumericExpression(state, pos, *value);
state->m_current_menu->m_rect_y_exp = std::move(value);
}));
AddSequence(
GenericExpressionPropertySequence::WithKeywords({"exp", "rect", "W"},
[](const MenuFileParserState* state, const TokenPos& pos, std::unique_ptr<ISimpleExpression> value)
{
MenuFileCommonOperations::EnsureIsNumericExpression(state, pos, *value);
state->m_current_menu->m_rect_w_exp = std::move(value);
}));
AddSequence(
GenericExpressionPropertySequence::WithKeywords({"exp", "rect", "H"},
[](const MenuFileParserState* state, const TokenPos& pos, std::unique_ptr<ISimpleExpression> value)
{
MenuFileCommonOperations::EnsureIsNumericExpression(state, pos, *value);
state->m_current_menu->m_rect_h_exp = std::move(value);
}));
AddSequence(
GenericExpressionPropertySequence::WithKeywords({"exp", "openSound"},
[](const MenuFileParserState* state, const TokenPos& pos, std::unique_ptr<ISimpleExpression> value)
{
MenuFileCommonOperations::EnsureIsStringExpression(state, pos, *value);
state->m_current_menu->m_open_sound_exp = std::move(value);
}));
AddSequence(
GenericExpressionPropertySequence::WithKeywords({"exp", "closeSound"},
[](const MenuFileParserState* state, const TokenPos& pos, std::unique_ptr<ISimpleExpression> value)
{
MenuFileCommonOperations::EnsureIsStringExpression(state, pos, *value);
state->m_current_menu->m_close_sound_exp = std::move(value);
}));
AddSequence(std::make_unique<GenericKeywordPropertySequence>("popup",
[](const MenuFileParserState* state, const TokenPos&)
{
state->m_current_menu->m_popup = true;
}));
AddSequence(std::make_unique<GenericFloatingPointPropertySequence>("fadeClamp",
[](const MenuFileParserState* state, const TokenPos&, const double value)
{
state->m_current_menu->m_fade_clamp = value;
}));
AddSequence(std::make_unique<GenericIntPropertySequence>("fadeCycle",
[](const MenuFileParserState* state, const TokenPos&, const int value)
{
state->m_current_menu->m_fade_cycle = value;
}));
AddSequence(std::make_unique<GenericFloatingPointPropertySequence>("fadeAmount",
[](const MenuFileParserState* state, const TokenPos&, const double value)
{
state->m_current_menu->m_fade_amount = value;
}));
AddSequence(std::make_unique<GenericFloatingPointPropertySequence>("fadeInAmount",
[](const MenuFileParserState* state, const TokenPos&, const double value)
{
state->m_current_menu->m_fade_in_amount = value;
}));
AddSequence(std::make_unique<SequenceExecKey>());
AddSequence(std::make_unique<SequenceExecKeyInt>());
AddSequence(std::make_unique<GenericFloatingPointPropertySequence>("blurWorld", [](const MenuFileParserState* state, const TokenPos&, const double value)
{
state->m_current_menu->m_blur_radius = value;
}));
AddSequence(std::make_unique<GenericKeywordPropertySequence>("legacySplitScreenScale", [](const MenuFileParserState* state, const TokenPos&)
{
state->m_current_menu->m_legacy_split_screen_scale = true;
}));
AddSequence(std::make_unique<GenericKeywordPropertySequence>("hiddenDuringScope", [](const MenuFileParserState* state, const TokenPos&)
{
state->m_current_menu->m_hidden_during_scope = true;
}));
AddSequence(std::make_unique<GenericKeywordPropertySequence>("hiddenDuringFlashbang", [](const MenuFileParserState* state, const TokenPos&)
{
state->m_current_menu->m_hidden_during_flashbang = true;
}));
AddSequence(std::make_unique<GenericKeywordPropertySequence>("hiddenDuringUI", [](const MenuFileParserState* state, const TokenPos&)
{
state->m_current_menu->m_hidden_during_ui = true;
}));
AddSequence(std::make_unique<GenericStringPropertySequence>("allowedBinding", [](const MenuFileParserState* state, const TokenPos&, const std::string& value)
{
state->m_current_menu->m_allowed_binding = value;
}));
AddSequence(std::make_unique<GenericKeywordPropertySequence>("textOnlyFocus", [](const MenuFileParserState* state, const TokenPos&)
{
state->m_current_menu->m_text_only_focus = true;
}));
AddSequence(std::make_unique<GenericFloatingPointPropertySequence>("blurWorld",
[](const MenuFileParserState* state, const TokenPos&, const double value)
{
state->m_current_menu->m_blur_radius = value;
}));
AddSequence(std::make_unique<GenericKeywordPropertySequence>("legacySplitScreenScale",
[](const MenuFileParserState* state, const TokenPos&)
{
state->m_current_menu->m_legacy_split_screen_scale = true;
}));
AddSequence(std::make_unique<GenericKeywordPropertySequence>("hiddenDuringScope",
[](const MenuFileParserState* state, const TokenPos&)
{
state->m_current_menu->m_hidden_during_scope = true;
}));
AddSequence(std::make_unique<GenericKeywordPropertySequence>("hiddenDuringFlashbang",
[](const MenuFileParserState* state, const TokenPos&)
{
state->m_current_menu->m_hidden_during_flashbang = true;
}));
AddSequence(std::make_unique<GenericKeywordPropertySequence>("hiddenDuringUI",
[](const MenuFileParserState* state, const TokenPos&)
{
state->m_current_menu->m_hidden_during_ui = true;
}));
AddSequence(std::make_unique<GenericStringPropertySequence>("allowedBinding",
[](const MenuFileParserState* state, const TokenPos&, const std::string& value)
{
state->m_current_menu->m_allowed_binding = value;
}));
AddSequence(std::make_unique<GenericKeywordPropertySequence>("textOnlyFocus",
[](const MenuFileParserState* state, const TokenPos&)
{
state->m_current_menu->m_text_only_focus = true;
}));
if (featureLevel == FeatureLevel::IW5)
{
AddSequence(GenericExpressionPropertySequence::WithKeywords({"exp", "soundLoop"}, [](const MenuFileParserState* state, const TokenPos& pos, std::unique_ptr<ISimpleExpression> value)
{
MenuFileCommonOperations::EnsureIsStringExpression(state, pos, *value);
state->m_current_menu->m_sound_loop_exp = std::move(value);
}));
AddSequence(std::make_unique<GenericMenuEventHandlerSetPropertySequence>("onFocusDueToClose", [](const MenuFileParserState* state, const TokenPos&) -> std::unique_ptr<CommonEventHandlerSet>& {
return state->m_current_menu->m_on_focus_due_to_close;
}));
AddSequence(
GenericExpressionPropertySequence::WithKeywords({"exp", "soundLoop"},
[](const MenuFileParserState* state, const TokenPos& pos, std::unique_ptr<ISimpleExpression> value)
{
MenuFileCommonOperations::EnsureIsStringExpression(state, pos, *value);
state->m_current_menu->m_sound_loop_exp = std::move(value);
}));
AddSequence(std::make_unique<GenericMenuEventHandlerSetPropertySequence>(
"onFocusDueToClose",
[](const MenuFileParserState* state, const TokenPos&) -> std::unique_ptr<CommonEventHandlerSet>&
{
return state->m_current_menu->m_on_focus_due_to_close;
}));
}
AddSequence(std::make_unique<SequenceConsumeSemicolons>());
}

View File

@ -12,4 +12,4 @@ namespace menu
void AddSequences(FeatureLevel featureLevel, bool permissive) const;
};
}
} // namespace menu

View File

@ -14,9 +14,7 @@ namespace menu::no_scope_sequences
{
const MenuMatcherFactory create(this);
AddMatchers({
create.Char('{')
});
AddMatchers({create.Char('{')});
}
protected:
@ -25,11 +23,12 @@ namespace menu::no_scope_sequences
state->m_in_global_scope = true;
}
};
}
} // namespace menu::no_scope_sequences
using namespace no_scope_sequences;
NoScopeSequences::NoScopeSequences(std::vector<std::unique_ptr<MenuFileParser::sequence_t>>& allSequences, std::vector<MenuFileParser::sequence_t*>& scopeSequences)
NoScopeSequences::NoScopeSequences(std::vector<std::unique_ptr<MenuFileParser::sequence_t>>& allSequences,
std::vector<MenuFileParser::sequence_t*>& scopeSequences)
: AbstractScopeSequenceHolder(allSequences, scopeSequences)
{
}

View File

@ -12,4 +12,4 @@ namespace menu
void AddSequences(FeatureLevel featureLevel, bool permissive) const;
};
}
} // namespace menu