Skip to content

Commit 9d0c978

Browse files
committed
[R] IsUtage移动到MA2Generator上
1 parent e3643bb commit 9d0c978

8 files changed

Lines changed: 19 additions & 12 deletions

File tree

Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,9 @@ private static void ConvertPlainSimai(string text, string outputDir, HashSet<int
312312

313313
private static string SimaiToMa2(string inote, int clockCount=4, bool bigTouch=false, bool isUtage=false)
314314
{
315-
var (chart, parseAlerts) = new SimaiParser(bigTouch, isUtage, clockCount).Parse(inote);
315+
var (chart, parseAlerts) = new SimaiParser(bigTouch, clockCount).Parse(inote);
316316
PrintAlerts(parseAlerts);
317-
var (ma2, genAlerts) = new MA2Generator().Generate(chart);
317+
var (ma2, genAlerts) = new MA2Generator(isUtage).Generate(chart);
318318
PrintAlerts(genAlerts);
319319
return ma2;
320320
}

chart/Chart.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ public class Chart
99
public List<Note> Notes = [];
1010

1111
public string DefaultTouchSize = "M1";
12-
public bool IsUtage = false;
1312
public int ClockCount = 4;
1413

1514
public Rational ToSecond(Rational barTime) => BpmList.ToSecond(barTime);

chart/Note.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public abstract class Note
1515

1616
public int FalseEachIdx = 0; // 如果>0,表示这是一个伪双押,数字越大、延后的时刻越多
1717

18+
public Rational TimeInSeconds => throw new NotImplementedException();
19+
1820
public virtual Duration Duration
1921
{
2022
get => new(this);

generator/MA2Generator.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,19 @@ record MA2Line(string Name, int Bar, int Tick, int Key, string Extra = "");
1010

1111
public class MA2Generator : IGenerator
1212
{
13-
private List<MA2Line> lines = [];
14-
private readonly List<Alert> alerts = [];
13+
public MA2Generator(bool isUtage = false)
14+
{
15+
IsUtage = isUtage;
16+
}
1517

1618
// 除非你知道你在做什么,不然以下两个变量请勿修改!
19+
public bool IsUtage;
1720
public int MA2Version = 105;
1821
public int RSL = 384;
1922

23+
private List<MA2Line> lines = [];
24+
private readonly List<Alert> alerts = [];
25+
2026
private string headTemplate = @"VERSION 0.00.00 {0}
2127
FES_MODE {1}
2228
BPM_DEF {2:F3} {3:F3} {4:F3} {5:F3}
@@ -82,7 +88,7 @@ private void AddTap(Tap tap, int bar, int tick)
8288
// 文件头
8389
var bpmStatistics = bpmStats(chart);
8490
string head = string.Format(headTemplate,
85-
$"{MA2Version / 100}.{MA2Version % 100:D2}.00", chart.IsUtage?1:0,
91+
$"{MA2Version / 100}.{MA2Version % 100:D2}.00", IsUtage?1:0,
8692
bpmStatistics.Item1, bpmStatistics.Item2, bpmStatistics.Item3, bpmStatistics.Item4,
8793
RSL, RSL/4 * chart.ClockCount, Utils.AppVersion);
8894
result.Append(head);

parser/simai/SimaiParser.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ public partial class SimaiParser : SimaiBaseVisitor<object>, IParser
2424
private readonly List<string> extraModifiers = [];
2525
private bool absoluteTimeStepWarned; // 用于确保Warning只打印一次
2626

27-
public SimaiParser(bool bigTouch = false, bool isUtage = false, int clockCount = 4)
27+
public SimaiParser(bool bigTouch = false, int clockCount = 4)
2828
{
29-
chart = new Chart { DefaultTouchSize = bigTouch ? "L1" : "M1", IsUtage = isUtage, ClockCount = clockCount};
29+
chart = new Chart { DefaultTouchSize = bigTouch ? "L1" : "M1", ClockCount = clockCount};
3030
}
3131

3232
private void AddAlert(Alert.LEVEL level, string content, ParserRuleContext? context = null)

tests/ChartShift测试.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ private static Chart LoadChart(out List<Alert> alerts)
2525
Assert.True(maidata.Levels.ContainsKey(6), "Expected lv6 (inote_6) in maidata.");
2626
var chartInfo = maidata.Levels[6];
2727

28-
var (chart, parseAlerts) = new SimaiParser(bigTouch: false, isUtage: false, clockCount: maidata.ClockCount)
28+
var (chart, parseAlerts) = new SimaiParser(clockCount: maidata.ClockCount)
2929
.Parse(chartInfo.Inote);
3030
alerts = parseAlerts;
3131
chart.Sort();

tests/Simai转MA2测试.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ private void TestChart(TestInput input)
4444
var chartInfo = maidata.Levels[input.LevelId];
4545
var expectedMa2 = File.ReadAllText(input.MA2, Encoding.UTF8);
4646

47-
var (chart, _) = new SimaiParser(bigTouch: false, isUtage: false, clockCount: maidata.ClockCount).Parse(chartInfo.Inote);
48-
var (ma2, _) = new MA2Generator().Generate(chart);
47+
var (chart, _) = new SimaiParser(bigTouch: false, clockCount: maidata.ClockCount).Parse(chartInfo.Inote);
48+
var (ma2, _) = new MA2Generator(isUtage: false).Generate(chart);
4949

5050
ma2 = keepNotesOnly(ma2);
5151
expectedMa2 = keepNotesOnly(expectedMa2);

tests/Simai预处理纠错测试.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class Simai预处理纠错测试
1919
/// <summary>规范 simai → 完整 MA2 文本(含头与 BPM)。</summary>
2020
private string SimaiToMa2(string inote, bool DontTryFix = false)
2121
{
22-
var parser = new SimaiParser(bigTouch: false, isUtage: false, clockCount: 4) { DontTryFix = DontTryFix };
22+
var parser = new SimaiParser() { DontTryFix = DontTryFix };
2323
var (chart, alerts) = parser.Parse(inote);
2424
var (ma2, alerts2) = new MA2Generator().Generate(chart);
2525
_output.WriteLine(string.Join('\n', alerts));

0 commit comments

Comments
 (0)