add chartinfo implementation

This commit is contained in:
Alex
2025-08-19 19:30:37 -07:00
parent 66c834e8be
commit 2e5fc7191f
7 changed files with 82 additions and 2 deletions
+1 -1
View File
@@ -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));
+8
View File
@@ -58,4 +58,12 @@ public static class Consts
{Difficulty.Inferno, "ClearNormaRateInferno"},
};
public static readonly IReadOnlyDictionary<Difficulty, string> DIFF_CLEAR_KEY = _DIFF_CLEAR_KEY;
public static readonly IReadOnlyDictionary<Difficulty, string> DIFF_DESIGNER_KEY = new Dictionary<Difficulty, string>()
{
{Difficulty.Normal, "NotesDesignerNormal"},
{Difficulty.Hard, "NotesDesignerHard"},
{Difficulty.Expert, "NotesDesignerExpert"},
{Difficulty.Inferno, "NotesDesignerInferno"},
};
}
+1 -1
View File
@@ -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:
+19
View File
@@ -0,0 +1,19 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MercuryConverter.UI.Views"
x:Class="MercuryConverter.UI.Views.ChartInfo">
<StackPanel Margin="0 0 0 12">
<Canvas Width="150" Height="32">
<Rectangle Name="ShapeBase" Width="118" Height="32" Canvas.Left="16"/>
<Ellipse Name="ShapeLeftRound" Width="32" Height="32" Canvas.Left="0" Canvas.Top="0"/>
<Ellipse Name="ShapeRightRound" Width="32" Height="32" Canvas.Right="0" Canvas.Top="0"/>
<Polygon Name="ShapeDiagonal" Points="0,32 16,0 45,0 50,32" Canvas.Top="0" Canvas.Right="16"/>
<TextBlock Name="LevelNoTxt" Text="14+" Canvas.Right="8" Canvas.Top="4" Foreground="White" FontSize="20" FontWeight="Bold"/>
<TextBlock Name="LevelNameTxt" Text="INFERNO" Canvas.Left="12" Canvas.Top="6" Foreground="White" FontSize="16" FontWeight="Bold"/>
</Canvas>
<TextBlock Name="DesignerTxt" Text="muskit" HorizontalAlignment="Center"/>
</StackPanel>
</UserControl>
+36
View File
@@ -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<Difficulty, (Color, Color)> COLORS = new Dictionary<Difficulty, (Color, Color)>(){
{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;
}
}
+2
View File
@@ -23,6 +23,8 @@
<TextBlock Name="InfoNameText" Text="Name" FontWeight="Bold" HorizontalAlignment="Center" Margin="0 10 0 0"/>
<TextBlock Name="InfoArtistText" Text="Artist" HorizontalAlignment="Center"/>
<TextBlock Name="InfoSourceText" Text="Source" HorizontalAlignment="Center"/>
<StackPanel Name="ChartInfoGroup" Margin="0 36 0 0">
</StackPanel>
</StackPanel>
</TabItem>
<TabItem Header="Filters" FontSize="16">
+15
View File
@@ -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);
}
});
}
}