From 2e5fc7191f1cbf84c7d385353665166bbc78684d Mon Sep 17 00:00:00 2001 From: Alex <15199219+muskit@users.noreply.github.com> Date: Tue, 19 Aug 2025 19:30:37 -0700 Subject: [PATCH] add chartinfo implementation --- src/Data/Database.cs | 2 +- src/Data/Song/Consts.cs | 8 +++++ src/Data/Song/Song.cs | 2 +- src/UI/Views/Selection/ChartInfo.axaml | 19 ++++++++++++ src/UI/Views/Selection/ChartInfo.axaml.cs | 36 +++++++++++++++++++++++ src/UI/Views/Selection/Selection.axaml | 2 ++ src/UI/Views/Selection/Selection.axaml.cs | 15 ++++++++++ 7 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 src/UI/Views/Selection/ChartInfo.axaml create mode 100644 src/UI/Views/Selection/ChartInfo.axaml.cs diff --git a/src/Data/Database.cs b/src/Data/Database.cs index 59dbca7..f7f572e 100644 --- a/src/Data/Database.cs +++ b/src/Data/Database.cs @@ -80,7 +80,7 @@ public static class Database // TODO: check audio existence; add warning but don't skip - song.Levels[(int)diff] = lvl; + song.Levels[(int)diff] = (lvl, data[Consts.DIFF_DESIGNER_KEY[diff]].ToString()!); } Dispatcher.UIThread.Post(() => Songs.Add(song)); diff --git a/src/Data/Song/Consts.cs b/src/Data/Song/Consts.cs index 6b5cb51..db95f30 100644 --- a/src/Data/Song/Consts.cs +++ b/src/Data/Song/Consts.cs @@ -58,4 +58,12 @@ public static class Consts {Difficulty.Inferno, "ClearNormaRateInferno"}, }; public static readonly IReadOnlyDictionary DIFF_CLEAR_KEY = _DIFF_CLEAR_KEY; + + public static readonly IReadOnlyDictionary DIFF_DESIGNER_KEY = new Dictionary() + { + {Difficulty.Normal, "NotesDesignerNormal"}, + {Difficulty.Hard, "NotesDesignerHard"}, + {Difficulty.Expert, "NotesDesignerExpert"}, + {Difficulty.Inferno, "NotesDesignerInferno"}, + }; } \ No newline at end of file diff --git a/src/Data/Song/Song.cs b/src/Data/Song/Song.cs index dae241d..4686f36 100644 --- a/src/Data/Song/Song.cs +++ b/src/Data/Song/Song.cs @@ -22,7 +22,7 @@ public class Song public required float PreviewTime { get; set; } public required float PreviewLen { get; set; } public string SourceName => Consts.NUM_SOURCE[Source]; - public float?[] Levels { get; set; } = { null, null, null, null }; + public (float, string)?[] Levels { get; set; } = { null, null, null, null }; // TODO: For SaturnData.Entry instances, use this Guid format: diff --git a/src/UI/Views/Selection/ChartInfo.axaml b/src/UI/Views/Selection/ChartInfo.axaml new file mode 100644 index 0000000..5a1d67c --- /dev/null +++ b/src/UI/Views/Selection/ChartInfo.axaml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/UI/Views/Selection/ChartInfo.axaml.cs b/src/UI/Views/Selection/ChartInfo.axaml.cs new file mode 100644 index 0000000..401a293 --- /dev/null +++ b/src/UI/Views/Selection/ChartInfo.axaml.cs @@ -0,0 +1,36 @@ +using System.Collections.Generic; +using Avalonia.Controls; +using Avalonia.Media; +using MercuryConverter.Data; +using SaturnData.Notation.Core; + +namespace MercuryConverter.UI.Views; + +public partial class ChartInfo : UserControl +{ + private static readonly IReadOnlyDictionary COLORS = new Dictionary(){ + {Difficulty.Normal, (new Color(0xff, 0x1b, 0x7c, 0xff), new Color(0xff, 0x3f, 0x66, 0xfa))}, + {Difficulty.Hard, (new Color(0xff, 0xFF, 0xC3, 0x00), new Color(0xff, 0xFF, 0xA0, 0x00))}, + {Difficulty.Expert, (new Color(0xff, 0xFF, 0x00, 0x84), new Color(0xff, 0xCF, 0x00, 0x5B))}, + {Difficulty.Inferno, (new Color(0xff, 0x40, 0x00, 0x43), new Color(0xff, 0x1F, 0x00, 0x20))} + }; + + public ChartInfo(Song song, Difficulty diff = Difficulty.Inferno) + { + InitializeComponent(); + + var colLight = COLORS[diff].Item1; + var colDark = COLORS[diff].Item2; + ShapeBase.Fill = new SolidColorBrush(colLight); + ShapeLeftRound.Fill = new SolidColorBrush(colLight); + ShapeRightRound.Fill = new SolidColorBrush(colDark); + ShapeDiagonal.Fill = new SolidColorBrush(colDark); + + var l = song.Levels[(int)diff]!; + var level = l.Value.Item1; + var designer = l.Value.Item2; + LevelNoTxt.Text = $"{(int)level}{(level - (int)level >= 0.7f ? "+" : "")}"; + LevelNameTxt.Text = diff.ToString().ToUpper(); + DesignerTxt.Text = designer; + } +} \ No newline at end of file diff --git a/src/UI/Views/Selection/Selection.axaml b/src/UI/Views/Selection/Selection.axaml index 4ade52e..c32b72e 100644 --- a/src/UI/Views/Selection/Selection.axaml +++ b/src/UI/Views/Selection/Selection.axaml @@ -23,6 +23,8 @@ + + diff --git a/src/UI/Views/Selection/Selection.axaml.cs b/src/UI/Views/Selection/Selection.axaml.cs index 22a698f..9087c8d 100644 --- a/src/UI/Views/Selection/Selection.axaml.cs +++ b/src/UI/Views/Selection/Selection.axaml.cs @@ -10,6 +10,7 @@ using Avalonia.Threading; using Avalonia.Media; using System.IO; using Avalonia.Media.Imaging; +using SaturnData.Notation.Core; namespace MercuryConverter.UI.Views; @@ -63,6 +64,20 @@ public partial class Selection : Panel InfoNameText.Text = song.Name; InfoArtistText.Text = song.Artist; InfoSourceText.Text = song.SourceName; + + ChartInfoGroup.Children.Clear(); + foreach (Difficulty diff in Enum.GetValues(typeof(Difficulty))) + { + // skip non-canon difficulties + if (diff == Difficulty.None || diff == Difficulty.WorldsEnd) continue; + + var idx = (int)diff; + var level = song.Levels[idx]; + if (level == null) continue; + + var ci = new ChartInfo(song, diff); + ChartInfoGroup.Children.Add(ci); + } }); } }