Skip to content

Commit dbbc18d

Browse files
committed
[+] Air和Air-Crush 颜色的正确处理
1 parent bdab8d8 commit dbbc18d

3 files changed

Lines changed: 49 additions & 14 deletions

File tree

generator/chu/UgcGenerator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ private static bool IsSlideContinueSegments(ChuNote n) // Air Slide的前驱只
187187

188188
private string AirColor(ChuNote n)
189189
{
190-
if (C2U_AirColor.TryGetValue(n.Tag, out var color)) return color;
190+
if (Try_C2U_AirColor(n, out var color)) return color;
191191
else
192192
{
193193
if (n.Tag != "") alerts.Add(new Alert(Alert.LEVEL.Warning, string.Format(Locale.C2SUnsupportedAirColor, "UGC Generator", n.Type, n.Tag), n.Time));
@@ -216,7 +216,7 @@ private string UCode(ChuNote n)
216216
return n.Type switch
217217
{
218218
"TAP" => $"t{c}{w}",
219-
"CHR" => $"x{c}{w}{C2U_ChrExtras.GetValueOrDefault(n.Tag, n.Tag)}",
219+
"CHR" => $"x{c}{w}{C2U_ChrExtras.GetValueOrDefault(n.Tag, "C")}",
220220
"HLD" or "HXD" => $"h{c}{w}",
221221
"SLD" or "SXD" => $"s{c}{w}",
222222
"SLC" or "SXC" => $"s{c}{w}",

parser/chu/UgcParser.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,8 @@ private void ParseHeightAndColor(ChuNote n, string str, List<Alert> alerts, int
371371
if (str.Length > 0)
372372
{ // 解析颜色
373373
var rawColorStr = str.Last().ToString();
374-
n.Tag = (noteType == "C" ? U2C_AirCrushColor : U2C_AirColor).GetValueOrDefault(rawColorStr, rawColorStr);
374+
if (noteType == "C") n.Tag = U2C_AirCrushColor.GetValueOrDefault(rawColorStr, rawColorStr); // Air Crush
375+
else n.Tag = Try_U2C_AirColor(n, rawColorStr, out var color) ? color : rawColorStr;
375376
}
376377
if (str.Length > 1)
377378
{ // 解析高度

utils/ChuUtils.cs

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,56 @@ public class ChuUtils
2020
["U"] = "UP",
2121
["D"] = "DW",
2222
["C"] = "CE",
23+
["L"] = "LS",
24+
["R"] = "RS",
25+
["A"] = "RC",
26+
["W"] = "LC",
27+
["I"] = "BS",
2328
};
2429
public static readonly Dictionary<string, string> C2U_ChrExtras = Utils.ReverseDict(U2C_ChrExtras);
2530

26-
public static readonly Dictionary<string, string> U2C_AirColor = new()
31+
public static bool Try_U2C_AirColor(ChuNote n, string rawColorStr, out string color)
2732
{
28-
["N"] = "DEF",
29-
// ["I"] = "I", // TODO 搞清楚UGC里的'I'颜色,在C2S里,对应的字符串是什么
30-
};
31-
public static readonly Dictionary<string, string> C2U_AirColor = Utils.ReverseDict(U2C_AirColor);
32-
public static readonly HashSet<string> C2sAllowedColors = C2U_AirColor.Keys.ToHashSet();
33+
color = rawColorStr switch
34+
{
35+
"N" => "DEF",
36+
"I" => IsAirDown(n) ? "GRN" : "PPL",
37+
_ => "",
38+
};
39+
return color != "";
40+
}
41+
public static bool Try_C2U_AirColor(ChuNote n, out string color)
42+
{
43+
color = n.Tag switch
44+
{
45+
"DEF" => "N",
46+
"" => "N",
47+
"GRN" => IsAirDown(n) ? "I" : "N",
48+
"PPL" => IsAirDown(n) ? "N" : "I",
49+
_ => "",
50+
};
51+
return color != "";
52+
}
53+
public static readonly HashSet<string> C2sAllowedColors = ["DEF", "GRN", "PPL"];
3354

3455
public static readonly Dictionary<string, string> U2C_AirCrushColor = new()
3556
{
36-
["0"] = "DEF",
37-
["Z"] = "NON",
38-
["6"] = "CYN",
39-
["A"] = "VLT",
40-
// TODO 补充更多对应关系
57+
["0"] = "DEF", // Normal / 通常
58+
["Z"] = "NON", // Transparent / 透明
59+
["1"] = "RED", // Red / 赤
60+
["2"] = "ORN", // Orange / 橙
61+
["3"] = "YEL", // Yellow / 黄
62+
["4"] = "LIM", // Grass / 黄緑
63+
["5"] = "GRN", // Green / 緑
64+
["6"] = "AQA", // Sky / 水
65+
["7"] = "CYN", // Sky blue / 空
66+
["8"] = "DGR", // (存疑,不确定) Cobalt blue / 天(DGR ≈ Dark GRay?)
67+
["9"] = "BLU", // Blue / 青
68+
["A"] = "VLT", // Violet / 青紫
69+
["Y"] = "PPL", // Purple / 赤紫
70+
["B"] = "PNK", // Pink / 桃
71+
["C"] = "GRY", // (有点存疑,略微不确定) White / 白
72+
["D"] = "BLK", // Black / 黒
4173
};
4274
public static readonly Dictionary<string, string> C2U_AirCrushColor = Utils.ReverseDict(U2C_AirCrushColor);
4375
public static readonly HashSet<string> C2sAllowedCrushColors = C2U_AirCrushColor.Keys.ToHashSet();
@@ -49,6 +81,7 @@ public class ChuUtils
4981
public static bool IsSlide(string t) => t is "SLD" or "SLC" or "SXD" or "SXC";
5082
public static bool IsAirSlide(string t) => t is "ASD" or "ASC";
5183
public static bool IsAir(string t) => t is "AIR" or "AUR" or "AUL" or "ADW" or "ADR" or "ADL";
84+
public static bool IsAirDown(string t) => t is "ADW" or "ADR" or "ADL";
5285
public static bool IsAirHold(string t) => t is "AHD" or "AHX";
5386
public static bool IsAirCrush(string t) => t is "ALD";
5487
// 是否是广义的air音符(Air/Air Hold/Air Slide/Air Crush)
@@ -58,6 +91,7 @@ public class ChuUtils
5891
public static bool IsSlide(ChuNote? n) => IsSlide(n?.Type!);
5992
public static bool IsAirSlide(ChuNote? n) => IsAirSlide(n?.Type!);
6093
public static bool IsAir(ChuNote? n) => IsAir(n?.Type!);
94+
public static bool IsAirDown(ChuNote? n) => IsAirDown(n?.Type!);
6195
public static bool IsAirHold(ChuNote? n) => IsAirHold(n?.Type!);
6296
public static bool IsAirCrush(ChuNote? n) => IsAirCrush(n?.Type!);
6397
// 是否是广义的air音符(Air/Air Hold/Air Slide/Air Crush)

0 commit comments

Comments
 (0)