mirror of
https://github.com/muskit/MercuryConverter.git
synced 2026-06-02 20:24:26 -07:00
add data reading & selection table population
This commit is contained in:
+79
-74
@@ -1,102 +1,107 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
using Avalonia.Threading;
|
||||||
|
using MercuryConverter.UI.Views;
|
||||||
|
using SaturnData.Notation.Core;
|
||||||
|
using SaturnData.Notation.Serialization;
|
||||||
|
using SaturnData.Notation.Serialization.Mer;
|
||||||
|
using UAssetAPI;
|
||||||
|
using UAssetAPI.ExportTypes;
|
||||||
|
using UAssetAPI.PropertyTypes.Objects;
|
||||||
|
using UAssetAPI.PropertyTypes.Structs;
|
||||||
|
using UAssetAPI.UnrealTypes;
|
||||||
|
|
||||||
namespace MercuryConverter.Data;
|
namespace MercuryConverter.Data;
|
||||||
|
|
||||||
public static class Database
|
public static class Database
|
||||||
{
|
{
|
||||||
public static void Setup(string dataDirPath)
|
public static ObservableCollection<Song> Songs = new();
|
||||||
|
|
||||||
|
public static void SetupNew(string dataPath)
|
||||||
{
|
{
|
||||||
// Check that path exists
|
Dispatcher.UIThread.Invoke(() => Songs.Clear());
|
||||||
if (!Directory.Exists(dataDirPath))
|
|
||||||
|
var metadataTablePath = Path.Combine(dataPath, "MusicParameterTable.uasset");
|
||||||
|
var metadataAsset = new UAsset(metadataTablePath, EngineVersion.VER_UE4_19);
|
||||||
|
var metadataTable = metadataAsset.Exports[0] as DataTableExport;
|
||||||
|
|
||||||
|
foreach (var data in metadataTable!.Table.Data)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Folder {dataDirPath} doesn't exist!");
|
if (data["AssetDirectory"].ToString()!.Contains("S99"))
|
||||||
return;
|
{
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get metadata.json
|
var previewBegin = ((FloatPropertyData)data["PreviewBeginTime"]).Value;
|
||||||
var jPath = Path.Combine(dataDirPath, "metadata.json");
|
var previewLen = ((FloatPropertyData)data["PreviewSeconds"]).Value;
|
||||||
string jStr;
|
|
||||||
JsonElement mdObj;
|
string? cTxt = data["CopyrightMessage"].ToString();
|
||||||
|
|
||||||
|
var jacketPath = $"{Path.Combine(dataPath, "jackets", data["JacketAssetName"].ToString()!)}.png";
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
jStr = File.ReadAllText(jPath);
|
var song = new Song
|
||||||
|
{
|
||||||
|
Id = data["AssetDirectory"].ToString()!,
|
||||||
|
Rubi = data["Rubi"].ToString()!,
|
||||||
|
Name = data["MusicMessage"].ToString()!,
|
||||||
|
Artist = data["ArtistMessage"].ToString()!,
|
||||||
|
Genre = ((IntPropertyData)data["ScoreGenre"]).Value,
|
||||||
|
Source = ((UInt32PropertyData)data["VersionNo"]).Value,
|
||||||
|
PreviewTime = previewBegin,
|
||||||
|
PreviewLen = previewLen,
|
||||||
|
Jacket = File.Exists(jacketPath) ? jacketPath : null,
|
||||||
|
Copyright = (cTxt == "-" || cTxt == "") ? null : cTxt,
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (Difficulty diff in Enum.GetValues(typeof(Difficulty)))
|
||||||
|
{
|
||||||
|
// skip non-canon difficulties
|
||||||
|
if (diff == Difficulty.None || diff == Difficulty.WorldsEnd) continue;
|
||||||
|
|
||||||
|
if (GetDiffPair(dataPath, data, diff) is var pair && pair != null)
|
||||||
|
{
|
||||||
|
song.charts.Add((diff, pair.Value.Item1, pair.Value.Item2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Dispatcher.UIThread.Invoke(() => Songs.Add(song));
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Couldn't read {jPath}: {e}");
|
Console.WriteLine($"Couldn't construct a song!\n{e}");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
try
|
|
||||||
{
|
|
||||||
mdObj = JsonDocument.Parse(jStr).RootElement.GetProperty("Exports")[0].GetProperty("Table").GetProperty("Data");
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
Console.WriteLine("finished music table");
|
||||||
{
|
|
||||||
Console.WriteLine($"Couldn't parse JSON object: {e}");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Clear existing structures
|
private static (Entry, Chart)? GetDiffPair(string dataPath, StructPropertyData song, Difficulty diff)
|
||||||
|
|
||||||
// Parse metadata.json
|
|
||||||
foreach (var mdSong in mdObj.EnumerateArray())
|
|
||||||
{
|
{
|
||||||
var id = "";
|
|
||||||
var title = "";
|
|
||||||
var rubi = "";
|
|
||||||
var artist = "";
|
|
||||||
var genre = -1;
|
|
||||||
var copyright = "";
|
|
||||||
var bpm = "";
|
|
||||||
var version = -1;
|
|
||||||
var previewTime = -1;
|
|
||||||
var previewLength = -1;
|
|
||||||
var jacketPath = "";
|
|
||||||
|
|
||||||
var level = new string?[] { null, null, null, null };
|
var level = ((FloatPropertyData)song[Consts.DIFF_LVL_KEY[diff]]).Value;
|
||||||
var levelBGA = new string?[] { null, null, null, null};
|
if (level == 0)
|
||||||
var levelAudio = new string?[] { null, null, null, null };
|
return null;
|
||||||
var levelDesigner = new string?[] { null, null, null, null };
|
|
||||||
var levelClearRequirements = new string?[] { null, null, null, null };
|
|
||||||
|
|
||||||
foreach (var prop in mdSong.GetProperty("Value").EnumerateArray())
|
var id = song["AssetDirectory"].ToString()!;
|
||||||
{
|
var chartFilePath = Path.Combine(dataPath, "MusicData", id, $"{id}_{Consts.DIFF_FILENAME_PREPEND[diff]}.mer");
|
||||||
var value = prop.GetProperty("Value");
|
var clearThreshold = ((FloatPropertyData)song[Consts.DIFF_CLEAR_KEY[diff]]).Value;
|
||||||
// Console.WriteLine($"{prop.GetProperty("Name")}={prop.GetProperty("Value")}");
|
|
||||||
switch (prop.GetProperty("Name").GetString()!)
|
|
||||||
{
|
|
||||||
case "AssetDirectory":
|
|
||||||
id = value.GetString()!;
|
|
||||||
break;
|
|
||||||
case "ScoreGenre":
|
|
||||||
genre = value.GetInt16();
|
|
||||||
break;
|
|
||||||
case "MusicMessage":
|
|
||||||
title = value.GetString();
|
|
||||||
break;
|
|
||||||
case "ArtistMessage":
|
|
||||||
artist = value.GetString();
|
|
||||||
break;
|
|
||||||
case "Rubi":
|
|
||||||
rubi = value.GetString();
|
|
||||||
break;
|
|
||||||
case "Bpm":
|
|
||||||
bpm = value.GetString();
|
|
||||||
break;
|
|
||||||
case "CopyrightMessage":
|
|
||||||
var c = value.GetString();
|
|
||||||
if (!new string?[] { "", "-", null }.Contains(c))
|
|
||||||
{
|
|
||||||
copyright = c;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Console.WriteLine($"[{id}] {artist} - {title}");
|
var e = NotationSerializer.ToEntry(chartFilePath, new NotationReadArgs
|
||||||
}
|
{
|
||||||
|
InferClearThresholdFromDifficulty = false
|
||||||
|
});
|
||||||
|
e.ClearThreshold = clearThreshold;
|
||||||
|
var c = NotationSerializer.ToChart(chartFilePath, new NotationReadArgs
|
||||||
|
{
|
||||||
|
InferClearThresholdFromDifficulty = false
|
||||||
|
});
|
||||||
|
|
||||||
|
return (e, c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace MercuryConverter.Data;
|
|
||||||
|
|
||||||
|
|
||||||
public class Chart
|
|
||||||
{
|
|
||||||
public required string audioId;
|
|
||||||
public required string audioOffset;
|
|
||||||
public required string audioPreviewTime;
|
|
||||||
public required string audioPreviewDuration;
|
|
||||||
public required string video;
|
|
||||||
public required string designer;
|
|
||||||
public required string clearRequirement;
|
|
||||||
public required string diffLevel;
|
|
||||||
public string diffString
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
var d = Convert.ToDouble(diffLevel);
|
|
||||||
var i = (int)d;
|
|
||||||
return $"{(int)d}{(d > i ? "+" : "")}";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+31
-3
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using SaturnData.Notation.Core;
|
||||||
|
|
||||||
namespace MercuryConverter.Data;
|
namespace MercuryConverter.Data;
|
||||||
|
|
||||||
@@ -20,7 +21,7 @@ public static class Consts
|
|||||||
};
|
};
|
||||||
public static readonly IReadOnlyDictionary<int, string> CATEGORY_INDEX = _CATEGORY_INDEX;
|
public static readonly IReadOnlyDictionary<int, string> CATEGORY_INDEX = _CATEGORY_INDEX;
|
||||||
|
|
||||||
private static Dictionary<int, string> _NUM_SOURCE = new()
|
private static Dictionary<uint, string> _NUM_SOURCE = new()
|
||||||
{
|
{
|
||||||
{ 1, string.Concat(new int[] {87, 65, 67, 67, 65}.Select(i => Convert.ToChar(i))) },
|
{ 1, string.Concat(new int[] {87, 65, 67, 67, 65}.Select(i => Convert.ToChar(i))) },
|
||||||
{ 2, string.Concat(new int[] {87, 65, 67, 67, 65, 32, 83}.Select(i => Convert.ToChar(i))) },
|
{ 2, string.Concat(new int[] {87, 65, 67, 67, 65, 32, 83}.Select(i => Convert.ToChar(i))) },
|
||||||
@@ -28,11 +29,38 @@ public static class Consts
|
|||||||
{ 4, string.Concat(new int[] {87, 65, 67, 67, 65, 32, 76, 73, 76, 89, 32, 82}.Select(i => Convert.ToChar(i))) },
|
{ 4, string.Concat(new int[] {87, 65, 67, 67, 65, 32, 76, 73, 76, 89, 32, 82}.Select(i => Convert.ToChar(i))) },
|
||||||
{ 5, string.Concat(new int[] {87, 65, 67, 67, 65, 32, 82, 101, 118, 101, 114, 115, 101}.Select(i => Convert.ToChar(i))) }
|
{ 5, string.Concat(new int[] {87, 65, 67, 67, 65, 32, 82, 101, 118, 101, 114, 115, 101}.Select(i => Convert.ToChar(i))) }
|
||||||
};
|
};
|
||||||
public static readonly IReadOnlyDictionary<int, string> NUM_SOURCE = _NUM_SOURCE;
|
public static readonly IReadOnlyDictionary<uint, string> NUM_SOURCE = _NUM_SOURCE;
|
||||||
public static readonly IReadOnlyDictionary<string, int> SOURCE_NUM = _NUM_SOURCE.ToDictionary(p => p.Value, p=>p.Key);
|
public static readonly IReadOnlyDictionary<string, uint> SOURCE_NUM = _NUM_SOURCE.ToDictionary(p => p.Value, p => p.Key);
|
||||||
|
|
||||||
private static string[] _DIFFICULTIES = {
|
private static string[] _DIFFICULTIES = {
|
||||||
"Normal", "Hard", "Expert", "Inferno"
|
"Normal", "Hard", "Expert", "Inferno"
|
||||||
};
|
};
|
||||||
public static readonly IReadOnlyList<string> DIFFICULTIES = _DIFFICULTIES;
|
public static readonly IReadOnlyList<string> DIFFICULTIES = _DIFFICULTIES;
|
||||||
|
|
||||||
|
private static readonly Dictionary<Difficulty, string> _DIFF_LVL_KEY = new()
|
||||||
|
{
|
||||||
|
{Difficulty.Normal, "DifficultyNormalLv"},
|
||||||
|
{Difficulty.Hard, "DifficultyHardLv"},
|
||||||
|
{Difficulty.Expert, "DifficultyExtremeLv"},
|
||||||
|
{Difficulty.Inferno, "DifficultyInfernoLv"},
|
||||||
|
};
|
||||||
|
public static readonly IReadOnlyDictionary<Difficulty, string> DIFF_LVL_KEY = _DIFF_LVL_KEY;
|
||||||
|
|
||||||
|
private static readonly Dictionary<Difficulty, string> _DIFF_FILENAME_PREPEND = new()
|
||||||
|
{
|
||||||
|
{Difficulty.Normal, "00"},
|
||||||
|
{Difficulty.Hard, "01"},
|
||||||
|
{Difficulty.Expert, "02"},
|
||||||
|
{Difficulty.Inferno, "03"},
|
||||||
|
};
|
||||||
|
public static readonly IReadOnlyDictionary<Difficulty, string> DIFF_FILENAME_PREPEND = _DIFF_FILENAME_PREPEND;
|
||||||
|
|
||||||
|
private static readonly Dictionary<Difficulty, string> _DIFF_CLEAR_KEY = new()
|
||||||
|
{
|
||||||
|
{Difficulty.Normal, "ClearNormaRateNormal"},
|
||||||
|
{Difficulty.Hard, "ClearNormaRateHard"},
|
||||||
|
{Difficulty.Expert, "ClearNormaRateExtreme"},
|
||||||
|
{Difficulty.Inferno, "ClearNormaRateInferno"},
|
||||||
|
};
|
||||||
|
public static readonly IReadOnlyDictionary<Difficulty, string> DIFF_CLEAR_KEY = _DIFF_CLEAR_KEY;
|
||||||
}
|
}
|
||||||
+18
-11
@@ -1,22 +1,29 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Avalonia.Media;
|
using Avalonia.Media;
|
||||||
|
using SaturnData.Notation.Core;
|
||||||
|
|
||||||
namespace MercuryConverter.Data;
|
namespace MercuryConverter.Data;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Combining SaturnData's Entry & Chart.
|
||||||
|
/// </summary>
|
||||||
public class Song
|
public class Song
|
||||||
{
|
{
|
||||||
/// <summary>
|
public required string Id { get; set; } // Snn-nnn
|
||||||
/// Format: `Snn-nnn` where `n` is a digit.
|
|
||||||
/// </summary>
|
|
||||||
public required string Id { get; set;}
|
|
||||||
public required string Name { get; set; }
|
public required string Name { get; set; }
|
||||||
public required string Artist { get; set; }
|
public required string Artist { get; set; }
|
||||||
public required string Source { get; set; }
|
public required uint Source { get; set; }
|
||||||
public string rubi;
|
public required string Rubi { get; set; }
|
||||||
public string copyright;
|
public string? Copyright { get; set; } // May have never been used?
|
||||||
public string tempo;
|
public required int Genre { get; set; }
|
||||||
public int genreId;
|
public required string? Jacket { get; set; }
|
||||||
public string jacket;
|
public required float PreviewTime { get; set; }
|
||||||
public Chart?[] charts = { null, null, null, null };
|
public required float PreviewLen { get; set; }
|
||||||
|
public string SourceName => Consts.NUM_SOURCE[Source];
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: For SaturnData.Entry instances, use this Guid format:
|
||||||
|
// MERCURY_[SONGID]_[DIFF] (each var is int)
|
||||||
|
public List<(Difficulty, Entry, Chart)> charts = new();
|
||||||
}
|
}
|
||||||
@@ -6,8 +6,9 @@
|
|||||||
xmlns:progRing="clr-namespace:AvaloniaProgressRing;assembly=AvaloniaProgressRing"
|
xmlns:progRing="clr-namespace:AvaloniaProgressRing;assembly=AvaloniaProgressRing"
|
||||||
x:Class="MercuryConverter.UI.Dialogs.DataOpen"
|
x:Class="MercuryConverter.UI.Dialogs.DataOpen"
|
||||||
>
|
>
|
||||||
<StackPanel Margin="12">
|
<Panel Margin="12">
|
||||||
<TextBlock Text="Select your data folder..."/>
|
<StackPanel Name="SelectView" IsVisible="false">
|
||||||
|
<TextBlock FontSize="24" FontWeight="Light" Text="select your data folder..."/>
|
||||||
<progRing:ProgressRing Foreground="{DynamicResource SystemBaseMediumColor}"
|
<progRing:ProgressRing Foreground="{DynamicResource SystemBaseMediumColor}"
|
||||||
Width="36"
|
Width="36"
|
||||||
Height="36"
|
Height="36"
|
||||||
@@ -15,5 +16,26 @@
|
|||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
Margin="0,15,0,0"/>
|
Margin="0,15,0,0"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
<StackPanel Name="ScanView" IsVisible="true">
|
||||||
|
<TextBlock Name="ScanStatus" FontSize="24" FontWeight="Light" Text="scanning..."/>
|
||||||
|
<TextBlock Name="ScanPath" Text="/there/is/a/path/here or whatever it is askljdhflksahdfliuahleifhu"/>
|
||||||
|
<StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch">
|
||||||
|
<progRing:ProgressRing Foreground="{DynamicResource SystemBaseMediumColor}"
|
||||||
|
Width="36"
|
||||||
|
Height="36"
|
||||||
|
IsActive="True"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
Margin="0,15,0,0"/>
|
||||||
|
<StackPanel Margin="0 12 0 0" Orientation="Horizontal" HorizontalAlignment="Right">
|
||||||
|
<Button Margin="6 0 0 0" Content="Cancel" />
|
||||||
|
<Button Margin="6 0 0 0" Content="Open Data Folder" />
|
||||||
|
</StackPanel>
|
||||||
|
</StackPanel>
|
||||||
|
</StackPanel>
|
||||||
|
<!-- <StackPanel Name="SelectErrorView" IsVisible="true">
|
||||||
|
<TextBlock FontSize="24" FontWeight="Light" Text="couldn't fully open data folder"/>
|
||||||
|
<TextBlock Text="Unable to open PATH: ERROR"/>
|
||||||
|
<Button HorizontalAlignment="Right" Margin="0 12 0 0" Content="Open Data Folder" />
|
||||||
|
</StackPanel> -->
|
||||||
|
</Panel>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
@@ -1,40 +1,95 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Platform.Storage;
|
using Avalonia.Platform.Storage;
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
|
using MercuryConverter.Data;
|
||||||
|
using UAssetAPI;
|
||||||
|
using UAssetAPI.UnrealTypes;
|
||||||
|
|
||||||
namespace MercuryConverter.UI.Dialogs;
|
namespace MercuryConverter.UI.Dialogs;
|
||||||
|
|
||||||
public partial class DataOpen : Window
|
public partial class DataOpen : UserControl
|
||||||
{
|
{
|
||||||
|
public static DataOpen? Instance { get; private set; }
|
||||||
public DataOpen()
|
public DataOpen()
|
||||||
{
|
{
|
||||||
|
Instance = this;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
BeginDirSelection();
|
|
||||||
|
if (!Design.IsDesignMode)
|
||||||
|
Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BeginDirSelection()
|
public void Run()
|
||||||
{
|
{
|
||||||
Dispatcher.UIThread.Invoke(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
|
var path = ""; // TODO: set to current data path
|
||||||
|
|
||||||
|
// Content selection
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
var selectedPath = await BeginDirSelection();
|
||||||
|
Console.WriteLine($"selectedPath={selectedPath}");
|
||||||
|
if (selectedPath != "" && Directory.Exists(selectedPath))
|
||||||
|
{
|
||||||
|
path = selectedPath;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// Display error message
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
BeginDataScan(path);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<string> BeginDirSelection()
|
||||||
|
{
|
||||||
|
IReadOnlyList<IStorageFolder>? dirSelection = null;
|
||||||
|
|
||||||
|
await Dispatcher.UIThread.Invoke(async () =>
|
||||||
|
{
|
||||||
|
// Update UI
|
||||||
|
ScanView.IsVisible = false;
|
||||||
|
SelectView.IsVisible = true;
|
||||||
|
|
||||||
await Task.Delay(200);
|
await Task.Delay(200);
|
||||||
var dirSelection = await GetTopLevel(this)!.StorageProvider.OpenFolderPickerAsync
|
|
||||||
|
dirSelection = await TopLevel.GetTopLevel(MainWindow.Instance)!.StorageProvider.OpenFolderPickerAsync
|
||||||
(
|
(
|
||||||
new FolderPickerOpenOptions
|
new FolderPickerOpenOptions
|
||||||
{
|
{
|
||||||
Title = "Open Data Folder",
|
Title = "Locate Data Folder",
|
||||||
AllowMultiple = false,
|
AllowMultiple = false,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
});
|
||||||
|
|
||||||
if (dirSelection.Count <= 0)
|
if (dirSelection!.Count <= 0)
|
||||||
{
|
{
|
||||||
return;
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
var d = dirSelection!.First().TryGetLocalPath()!;
|
return dirSelection!.First().TryGetLocalPath()!;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void BeginDataScan(string dataPath)
|
||||||
|
{
|
||||||
|
Console.WriteLine(dataPath);
|
||||||
|
// Update UI
|
||||||
|
Dispatcher.UIThread.Invoke(() =>
|
||||||
|
{
|
||||||
|
SelectView.IsVisible = false;
|
||||||
|
ScanStatus.Text = "scanning...";
|
||||||
|
ScanPath.Text = dataPath;
|
||||||
|
ScanView.IsVisible = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Database.SetupNew(dataPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,16 +6,15 @@
|
|||||||
x:Class="MercuryConverter.UI.Dialogs.Welcome"
|
x:Class="MercuryConverter.UI.Dialogs.Welcome"
|
||||||
>
|
>
|
||||||
<StackPanel Margin="12">
|
<StackPanel Margin="12">
|
||||||
<TextBlock FontSize="36" HorizontalAlignment="Center">
|
<TextBlock FontSize="24" FontWeight="Light">
|
||||||
Welcome to <Bold>MercuryConverter</Bold>!
|
welcome to <Run FontWeight="SemiBold" Text="mercury"/>converter!
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
<TextBlock HorizontalAlignment="Center">
|
<TextBlock HorizontalAlignment="Left" Padding="0 6 0 0">
|
||||||
<InlineUIContainer BaselineAlignment="Bottom">
|
<InlineUIContainer>
|
||||||
<!-- TODO: move HOWTO to this repo -->
|
<HyperlinkButton Content="Setup your data folder" Padding="0" NavigateUri="https://github.com/muskit/MercuryConverter/blob/main/HOWTO.md" />
|
||||||
<HyperlinkButton Content="Setup your data folder" Padding="0" NavigateUri="https://github.com/muskit/WacK-Repackager/blob/main/HOWTO.md" />
|
|
||||||
</InlineUIContainer>
|
</InlineUIContainer>
|
||||||
before proceeding.
|
before proceeding.
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
<Button Content="Open Data Folder" Click="ClickHandler" HorizontalAlignment="Center" Margin="0 8 0 0" />
|
<Button Content="Open Data Folder" Click="ClickHandler" HorizontalAlignment="Right" Margin="0 24 0 0" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
@@ -4,6 +4,8 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:local="clr-namespace:MercuryConverter.UI.Views"
|
xmlns:local="clr-namespace:MercuryConverter.UI.Views"
|
||||||
x:Class="MercuryConverter.UI.Views.Selection"
|
x:Class="MercuryConverter.UI.Views.Selection"
|
||||||
|
|
||||||
|
xmlns:data="clr-namespace:MercuryConverter.Data"
|
||||||
>
|
>
|
||||||
<DockPanel>
|
<DockPanel>
|
||||||
<!-- Sidebar -->
|
<!-- Sidebar -->
|
||||||
@@ -41,12 +43,12 @@
|
|||||||
<TextBox Watermark="Search for title, artist, designer..."/>
|
<TextBox Watermark="Search for title, artist, designer..."/>
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
<UserControl Background="{DynamicResource DataGridContentBackground}">
|
<UserControl Background="{DynamicResource DataGridContentBackground}">
|
||||||
<DataGrid Name="ListingTable" IsReadOnly="True" SelectionMode="Extended" ItemsSource="{Binding SongCollection}">
|
<DataGrid Name="ListingTable" IsReadOnly="True" SelectionMode="Extended" ItemsSource="{x:Static data:Database.Songs}">
|
||||||
<DataGrid.Columns>
|
<DataGrid.Columns>
|
||||||
<DataGridTextColumn Header="ID" Width="90" Binding="{Binding Id}"/>
|
<DataGridTextColumn Header="ID" Width="90" Binding="{Binding Id}"/>
|
||||||
<DataGridTextColumn Header="Title" Width="*" Binding="{Binding Name}"/>
|
<DataGridTextColumn Header="Title" Width="*" Binding="{Binding Name}"/>
|
||||||
<DataGridTextColumn Header="Artist" Width="*" Binding="{Binding Artist}"/>
|
<DataGridTextColumn Header="Artist" Width="*" Binding="{Binding Artist}"/>
|
||||||
<DataGridTextColumn Header="Source" Width="150" Binding="{Binding Source}"/>
|
<DataGridTextColumn Header="Source" Width="150" Binding="{Binding SourceName}"/>
|
||||||
</DataGrid.Columns>
|
</DataGrid.Columns>
|
||||||
</DataGrid>
|
</DataGrid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ namespace MercuryConverter.UI.Views;
|
|||||||
|
|
||||||
public partial class Selection : Panel
|
public partial class Selection : Panel
|
||||||
{
|
{
|
||||||
public static ObservableCollection<Song> SongCollection { get; } = new();
|
|
||||||
public Selection()
|
public Selection()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@@ -41,40 +40,6 @@ public partial class Selection : Panel
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SongCollection.CollectionChanged += OnSongsChg;
|
// DataContext = this;
|
||||||
DataContext = this;
|
|
||||||
|
|
||||||
// placeholder data
|
|
||||||
if (SongCollection.Count == 0)
|
|
||||||
{
|
|
||||||
SongCollection.Add(
|
|
||||||
new Song { Id = "S00-000", Name = "A Name", Artist = "An Artist", Source = Consts.NUM_SOURCE[2] }
|
|
||||||
);
|
|
||||||
SongCollection.Add(
|
|
||||||
new Song { Id = "S00-001", Name = "A Name", Artist = "An Artist", Source = Consts.NUM_SOURCE[3] }
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnSongsChg(object? sender, NotifyCollectionChangedEventArgs e)
|
|
||||||
{
|
|
||||||
Console.WriteLine("Songs collection changed!");
|
|
||||||
|
|
||||||
if (e.NewItems != null)
|
|
||||||
{
|
|
||||||
Console.WriteLine("Added...");
|
|
||||||
foreach (Song added in e.NewItems)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"[{added.Id}] {added.Artist} - {added.Name}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (e.OldItems != null)
|
|
||||||
{
|
|
||||||
Console.WriteLine("Removed...");
|
|
||||||
foreach (Song rem in e.OldItems)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"[{rem.Id}] {rem.Artist} - {rem.Name}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
Submodule _External/SaturnData updated: 8ed9bb1654...803117e1ac
Reference in New Issue
Block a user