diff --git a/src/ObjLoading/Parsing/Menu/Matcher/MenuMatcherScriptInt.cpp b/src/ObjLoading/Parsing/Menu/Matcher/MenuMatcherScriptInt.cpp index 1f45f84b..1b4a234f 100644 --- a/src/ObjLoading/Parsing/Menu/Matcher/MenuMatcherScriptInt.cpp +++ b/src/ObjLoading/Parsing/Menu/Matcher/MenuMatcherScriptInt.cpp @@ -3,10 +3,22 @@ MenuMatcherScriptInt::MenuMatcherScriptInt() = default; -MatcherResult MenuMatcherScriptInt::CanMatch(ILexer*lexer, const unsigned tokenOffset) +MatcherResult MenuMatcherScriptInt::CanMatch(ILexer* lexer, const unsigned tokenOffset) { const auto& token = lexer->GetToken(tokenOffset); + if (token.m_type == SimpleParserValueType::CHARACTER) + { + if (token.CharacterValue() != '-') + return MatcherResult::NoMatch(); + + const auto& nextToken = lexer->GetToken(tokenOffset + 1); + if (nextToken.m_type != SimpleParserValueType::INTEGER) + return MatcherResult::NoMatch(); + + return MatcherResult::Match(2); + } + if (token.m_type == SimpleParserValueType::INTEGER) return MatcherResult::Match(1); @@ -20,7 +32,7 @@ MatcherResult MenuMatcherScriptInt::CanMatch(ILexer::NoMatch(); diff --git a/src/ObjLoading/Parsing/Menu/Matcher/MenuMatcherScriptNumeric.cpp b/src/ObjLoading/Parsing/Menu/Matcher/MenuMatcherScriptNumeric.cpp index 5ca14e43..969349d2 100644 --- a/src/ObjLoading/Parsing/Menu/Matcher/MenuMatcherScriptNumeric.cpp +++ b/src/ObjLoading/Parsing/Menu/Matcher/MenuMatcherScriptNumeric.cpp @@ -7,6 +7,18 @@ MatcherResult MenuMatcherScriptNumeric::CanMatch(ILexerGetToken(tokenOffset); + if (token.m_type == SimpleParserValueType::CHARACTER) + { + if (token.CharacterValue() != '-') + return MatcherResult::NoMatch(); + + const auto& nextToken = lexer->GetToken(tokenOffset + 1); + if (nextToken.m_type != SimpleParserValueType::FLOATING_POINT && nextToken.m_type != SimpleParserValueType::INTEGER) + return MatcherResult::NoMatch(); + + return MatcherResult::Match(2); + } + if (token.m_type == SimpleParserValueType::FLOATING_POINT || token.m_type == SimpleParserValueType::INTEGER) return MatcherResult::Match(1); @@ -20,7 +32,7 @@ MatcherResult MenuMatcherScriptNumeric::CanMatch(ILexer::NoMatch(); diff --git a/src/ObjLoading/Parsing/Menu/Sequence/EventHandlerSetScopeSequences.cpp b/src/ObjLoading/Parsing/Menu/Sequence/EventHandlerSetScopeSequences.cpp index 1bf5eb2f..89c6b96d 100644 --- a/src/ObjLoading/Parsing/Menu/Sequence/EventHandlerSetScopeSequences.cpp +++ b/src/ObjLoading/Parsing/Menu/Sequence/EventHandlerSetScopeSequences.cpp @@ -38,6 +38,17 @@ namespace menu { const auto& firstToken = tokens[0].get(); + if (firstToken.m_type == SimpleParserValueType::CHARACTER) + { + const auto& secondToken = tokens[1].get(); + if (secondToken.m_type == SimpleParserValueType::INTEGER) + return SimpleParserValue::String(firstToken.GetPos(), new std::string(std::to_string(-secondToken.IntegerValue()))); + + std::ostringstream ss; + ss << std::noshowpoint << -firstToken.FloatingPointValue(); + return SimpleParserValue::String(firstToken.GetPos(), new std::string(ss.str())); + } + if (firstToken.m_type == SimpleParserValueType::INTEGER) return SimpleParserValue::String(firstToken.GetPos(), new std::string(std::to_string(firstToken.IntegerValue()))); if (firstToken.m_type == SimpleParserValueType::FLOATING_POINT) @@ -73,6 +84,9 @@ namespace menu { const auto& firstToken = tokens[0].get(); + if (firstToken.m_type == SimpleParserValueType::CHARACTER) + return SimpleParserValue::String(firstToken.GetPos(), new std::string(std::to_string(-tokens[1].get().IntegerValue()))); + if (firstToken.m_type == SimpleParserValueType::INTEGER) return SimpleParserValue::String(firstToken.GetPos(), new std::string(std::to_string(firstToken.IntegerValue()))); return SimpleParserValue::String(firstToken.GetPos(), new std::string(firstToken.StringValue()));