Skip to content

Commit

Permalink
Support #SCROLL
Browse files Browse the repository at this point in the history
  • Loading branch information
VioletXF committed Mar 29, 2024
1 parent b792138 commit 14908ba
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 4 deletions.
43 changes: 40 additions & 3 deletions src/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ namespace bms_parser
P1LongKeyBase = 5 * 36 + 1,
P2LongKeyBase = 6 * 36 + 1,
P1MineKeyBase = 13 * 36 + 1,
P2MineKeyBase = 14 * 36 + 1
P2MineKeyBase = 14 * 36 + 1,

Scroll = 1020
};

namespace KeyAssign
Expand All @@ -86,9 +88,8 @@ namespace bms_parser
};

constexpr int TempKey = 16;
constexpr int Scroll = 1020;

Parser::Parser() : BpmTable{}, StopLengthTable{}
Parser::Parser() : BpmTable{}, StopLengthTable{}, ScrollTable{}
{
std::random_device seeder;
Seed = seeder();
Expand Down Expand Up @@ -383,6 +384,16 @@ namespace bms_parser
ParseHeader(new_chart, L"BPM", xx, value);
}
}
else if (MatchHeader(line, L"#SCROLL"))
{
if (line.length() < 10)
{
continue;
}
auto xx = line.substr(7, 2);
auto value = line.substr(10);
ParseHeader(new_chart, L"SCROLL", xx, value);
}
else
{
std::wsmatch matcher;
Expand Down Expand Up @@ -632,6 +643,25 @@ namespace bms_parser
timeline->BpmChange = true;
break;
}
case Scroll:
{
auto id = ParseInt(val_view);
if (!CheckResourceIdRange(id))
{
// UE_LOG(LogTemp, Warning, TEXT("Invalid Scroll id: %s"), *val);
break;
}
if (ScrollTable.find(id) != ScrollTable.end())
{
timeline->Scroll = ScrollTable[id];
}
else
{
timeline->Scroll = 1;
}
// Debug.Log($"SCROLL: {timeline.Scroll}, on measure {i}");
break;
}
case Stop:
{
auto id = ParseInt(val_view);
Expand Down Expand Up @@ -1071,6 +1101,13 @@ namespace bms_parser
{
Chart->Meta.LnMode = static_cast<int>(std::wcstol(Value.c_str(), nullptr, 10));
}
else if (MatchHeader(cmd, L"SCROLL"))
{
auto xx = ParseInt(Xx);
auto value = std::wcstod(Value.c_str(), nullptr);
ScrollTable[xx] = value;
std::wcout << "SCROLL: " << xx << " = " << value << std::endl;
}
else
{
std::wcout << "Unknown command: " << cmd << std::endl;
Expand Down
3 changes: 2 additions & 1 deletion test/testcases/aleph0_another.output
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ total_long_notes: 0
total_scratch_notes: 67
total_backspin_notes: 0
playlevel: 12
playlength: 138717008
playlength: 138717008
difficulty: 4

0 comments on commit 14908ba

Please sign in to comment.