flesh out the data scan UI, tweak selection table

This commit is contained in:
Alex
2025-08-19 00:27:53 -07:00
parent f4a091dfa4
commit 09de9cc0a7
11 changed files with 237 additions and 130 deletions
+16 -4
View File
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data.Common;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
@@ -65,13 +66,24 @@ public static class Database
// skip non-canon difficulties
if (diff == Difficulty.None || diff == Difficulty.WorldsEnd) continue;
if (GetDiffPair(dataPath, data, diff) is var pair && pair != null)
var lvl = ((FloatPropertyData)data[Consts.DIFF_LVL_KEY[diff]]).Value;
if (lvl == 0) continue; // skip nonexistent level
// check chart existence
var chartFilePath = Path.Combine(dataPath, "MusicData", song.Id, $"{song.Id}_{Consts.DIFF_FILENAME_PREPEND[diff]}.mer");
if (!File.Exists(chartFilePath))
{
song.charts.Add((diff, pair.Value.Item1, pair.Value.Item2));
// TODO: add warning message to DataScan
Console.WriteLine($"[MISSING CHART] {song.Id} {song.Artist} - {song.Name} / {diff}");
continue;
}
// TODO: check audio existence; add warning but don't skip
song.Levels[(int)diff] = lvl;
}
Dispatcher.UIThread.Invoke(() => Songs.Add(song));
Dispatcher.UIThread.Post(() => Songs.Add(song));
}
catch (Exception e)
{
@@ -83,7 +95,6 @@ public static class Database
private static (Entry, Chart)? GetDiffPair(string dataPath, StructPropertyData song, Difficulty diff)
{
var level = ((FloatPropertyData)song[Consts.DIFF_LVL_KEY[diff]]).Value;
if (level == 0)
return null;
@@ -97,6 +108,7 @@ public static class Database
InferClearThresholdFromDifficulty = false
});
e.ClearThreshold = clearThreshold;
e.Difficulty = diff;
var c = NotationSerializer.ToChart(chartFilePath, new NotationReadArgs
{
InferClearThresholdFromDifficulty = false
-5
View File
@@ -32,11 +32,6 @@ public static class Consts
public static readonly IReadOnlyDictionary<uint, string> NUM_SOURCE = _NUM_SOURCE;
public static readonly IReadOnlyDictionary<string, uint> SOURCE_NUM = _NUM_SOURCE.ToDictionary(p => p.Value, p => p.Key);
private static string[] _DIFFICULTIES = {
"Normal", "Hard", "Expert", "Inferno"
};
public static readonly IReadOnlyList<string> DIFFICULTIES = _DIFFICULTIES;
private static readonly Dictionary<Difficulty, string> _DIFF_LVL_KEY = new()
{
{Difficulty.Normal, "DifficultyNormalLv"},
+2 -1
View File
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using Avalonia.Controls;
using Avalonia.Media;
using SaturnData.Notation.Core;
@@ -21,9 +22,9 @@ 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 };
// TODO: For SaturnData.Entry instances, use this Guid format:
// MERCURY_[SONGID]_[DIFF] (each var is int)
public List<(Difficulty, Entry, Chart)> charts = new();
}