2023-07-28 18:02:47 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using TaikoSoundEditor.Data;
|
|
|
|
|
using TaikoSoundEditor.Utils;
|
|
|
|
|
|
|
|
|
|
namespace TaikoSoundEditor
|
|
|
|
|
{
|
|
|
|
|
partial class MainForm
|
|
|
|
|
{
|
|
|
|
|
#region Requesting Files
|
|
|
|
|
|
|
|
|
|
private void WordListPathSelector_PathChanged(object sender, EventArgs args)
|
|
|
|
|
{
|
|
|
|
|
Logger.Info($"WordListPathSelector_PathChanged : {WordListPathSelector.Path}");
|
|
|
|
|
WordListPath = WordListPathSelector.Path;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void MusicInfoPathSelector_PathChanged(object sender, EventArgs args)
|
|
|
|
|
{
|
|
|
|
|
Logger.Info($"MusicInfoPathSelector_PathChanged : {MusicInfoPathSelector.Path}");
|
|
|
|
|
MusicInfoPath = MusicInfoPathSelector.Path;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void MusicOrderPathSelector_PathChanged(object sender, EventArgs args)
|
|
|
|
|
{
|
|
|
|
|
Logger.Info($"MusicOrderPathSelector_PathChanged : {MusicOrderPathSelector.Path}");
|
|
|
|
|
MusicOrderPath = MusicOrderPathSelector.Path;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void MusicAttributePathSelector_PathChanged(object sender, EventArgs args)
|
|
|
|
|
{
|
|
|
|
|
Logger.Info($"MusicAttributePathSelector_PathChanged : {MusicAttributePathSelector.Path}");
|
|
|
|
|
MusicAttributePath = MusicAttributePathSelector.Path;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DirSelector_PathChanged(object sender, EventArgs args) => ExceptionGuard.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
Logger.Info($"MusicAttributePathSelector_PathChanged : {DirSelector.Path}");
|
|
|
|
|
var dir = DirSelector.Path;
|
|
|
|
|
var files = new string[] { "music_attribute.bin", "music_order.bin", "musicinfo.bin", "wordlist.bin" };
|
|
|
|
|
var sels = new PathSelector[] { MusicAttributePathSelector, MusicOrderPathSelector, MusicInfoPathSelector, WordListPathSelector };
|
|
|
|
|
|
|
|
|
|
List<string> NotFoundFiles = new List<string>();
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < files.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
var path = Path.Combine(dir, files[i]);
|
|
|
|
|
if (!File.Exists(path))
|
|
|
|
|
{
|
|
|
|
|
NotFoundFiles.Add(files[i]);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
sels[i].Path = path;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (NotFoundFiles.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
Logger.Warning("The following files could not be found:\n\n" + String.Join("\n", NotFoundFiles));
|
|
|
|
|
MessageBox.Show("The following files could not be found:\n\n" + String.Join("\n", NotFoundFiles));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
private void OkButton_Click(object sender, EventArgs e) => ExceptionGuard.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
Logger.Info($"Clicked 'Looks good' ");
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
MusicAttributes = Json.Deserialize<MusicAttributes>(GZ.DecompressString(MusicAttributePath));
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception($"Failed to parse\n{MusicAttributePath}\nReason:\n{ex.InnerException}");
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
MusicOrders = Json.Deserialize<MusicOrders>(GZ.DecompressString(MusicOrderPath));
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception($"Failed to parse\n{MusicOrderPath}\nReason:\n{ex.InnerException}");
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
MusicInfos = Json.Deserialize<MusicInfos>(GZ.DecompressString(MusicInfoPath));
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception($"Failed to parse\n{MusicInfoPath}\nReason:\n{ex.InnerException}");
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
WordList = Json.Deserialize<WordList>(GZ.DecompressString(WordListPath));
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception($"Failed to parse\n{WordListPath}\nReason:\n{ex.InnerException}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Logger.Info($"Setting LoadedMusicBox DataSource");
|
|
|
|
|
|
|
|
|
|
LoadedMusicBinding = new BindingSource();
|
2023-07-29 07:58:11 +02:00
|
|
|
|
var cleanList = MusicInfos.Items.Where(mi => mi.UniqueId != 0).OrderBy(_ => _.UniqueId).ToList();
|
2023-07-28 21:28:05 +02:00
|
|
|
|
|
|
|
|
|
LoadedMusicBinding.DataSource = cleanList;
|
2023-07-28 18:02:47 +02:00
|
|
|
|
LoadedMusicBox.DataSource = LoadedMusicBinding;
|
|
|
|
|
TabControl.SelectedIndex = 1;
|
2023-07-28 21:28:05 +02:00
|
|
|
|
|
2023-07-29 08:15:24 +02:00
|
|
|
|
WordList.Items.RemoveAll(w =>
|
|
|
|
|
{
|
|
|
|
|
var key = w.Key;
|
|
|
|
|
|
|
|
|
|
var prefixes = new string[] { "song_sub_", "song_detail_", "song_" };
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 3; i++)
|
|
|
|
|
if (key.StartsWith(prefixes[i]))
|
|
|
|
|
{
|
|
|
|
|
key = key.Substring(prefixes[i].Length);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return !MusicInfos.Items.Any(mi => mi.Id == key);
|
|
|
|
|
});
|
|
|
|
|
|
2023-07-28 21:28:05 +02:00
|
|
|
|
|
|
|
|
|
MusicOrderViewer.WordList = WordList;
|
2023-07-29 07:58:11 +02:00
|
|
|
|
foreach (var musicOrder in MusicOrders.Items.Where(_ => MusicInfos.Items.Any(mi => mi.UniqueId == _.UniqueId)))
|
2023-07-28 21:28:05 +02:00
|
|
|
|
{
|
|
|
|
|
MusicOrderViewer.AddSong(musicOrder);
|
|
|
|
|
}
|
2023-07-29 07:58:11 +02:00
|
|
|
|
});
|
2023-07-28 18:02:47 +02:00
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|