added more exception guards
This commit is contained in:
parent
6b1008bfae
commit
c2e0f761d7
5
Json.cs
5
Json.cs
@ -1,4 +1,5 @@
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Diagnostics;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Text.Json;
|
||||
using System.Text.Unicode;
|
||||
|
||||
@ -7,7 +8,7 @@ namespace TaikoSoundEditor
|
||||
internal static class Json
|
||||
{
|
||||
public static T Deserialize<T>(string json)
|
||||
{
|
||||
{
|
||||
return JsonSerializer.Deserialize<T>(json);
|
||||
}
|
||||
|
||||
|
53
MainForm.cs
53
MainForm.cs
@ -81,12 +81,39 @@ namespace TaikoSoundEditor
|
||||
});
|
||||
|
||||
private void OkButton_Click(object sender, EventArgs e) => RunGuard(() =>
|
||||
{
|
||||
MusicAttributes = Json.Deserialize<MusicAttributes>(GZ.DecompressString(MusicAttributePath));
|
||||
MusicOrders = Json.Deserialize<MusicOrders>(GZ.DecompressString(MusicOrderPath));
|
||||
MusicInfos = Json.Deserialize<MusicInfos>(GZ.DecompressString(MusicInfoPath));
|
||||
WordList = Json.Deserialize<WordList>(GZ.DecompressString(WordListPath));
|
||||
|
||||
{
|
||||
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}");
|
||||
}
|
||||
|
||||
LoadedMusicBox.DataSource = MusicInfos.Items;
|
||||
TabControl.SelectedIndex = 1;
|
||||
@ -98,14 +125,14 @@ namespace TaikoSoundEditor
|
||||
|
||||
public static void RunGuard(Action action)
|
||||
{
|
||||
try
|
||||
//try
|
||||
{
|
||||
action();
|
||||
}
|
||||
catch (Exception ex)
|
||||
/*catch (Exception ex)
|
||||
{
|
||||
Error(ex);
|
||||
}
|
||||
Error(ex);
|
||||
}*/
|
||||
}
|
||||
|
||||
public static void Error(Exception e)
|
||||
@ -228,7 +255,7 @@ namespace TaikoSoundEditor
|
||||
|
||||
ns.Word = new Word { Key = $"song_{songName}", JapaneseText = tja.Headers.Title };
|
||||
ns.WordSub = new Word { Key = $"song_sub_{songName}", JapaneseText = tja.Headers.Subtitle };
|
||||
ns.WordDetail = new Word { Key = $"song_detail_{songName}", JapaneseText = "[song details...]" };
|
||||
ns.WordDetail = new Word { Key = $"song_detail_{songName}", JapaneseText = tja.Headers.TitleJa };
|
||||
|
||||
mi.EasyOnpuNum = tja.Courses[0].Converted.Notes.Length;
|
||||
mi.NormalOnpuNum = tja.Courses[1].Converted.Notes.Length;
|
||||
@ -327,7 +354,7 @@ namespace TaikoSoundEditor
|
||||
|
||||
var ma = new MusicAttributes();
|
||||
ma.Items.AddRange(MusicAttributes.Items);
|
||||
ma.Items.AddRange(AddedMusic.Select(_ => _.MusicAttribute));
|
||||
ma.Items.AddRange(AddedMusic.Select(_ => _.MusicAttribute));
|
||||
|
||||
var mo = new MusicOrders();
|
||||
mo.Items.AddRange(MusicOrders.Items);
|
||||
@ -342,6 +369,8 @@ namespace TaikoSoundEditor
|
||||
var jmo = Json.Serialize(mo);
|
||||
var jwl = Json.Serialize(wl);
|
||||
|
||||
jma = jma.Replace("\"new\": true,", "\"new\":true,");
|
||||
|
||||
File.WriteAllText(Path.Combine(path,"musicinfo"), jmi);
|
||||
File.WriteAllText(Path.Combine(path,"music_attribute"), jma);
|
||||
File.WriteAllText(Path.Combine(path,"music_order"), jmo);
|
||||
|
6
TJA.cs
6
TJA.cs
@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
@ -36,7 +37,7 @@ namespace TaikoSoundEditor
|
||||
|
||||
static readonly string[] HEADER_GLOBAL = new string[]
|
||||
{
|
||||
"TITLE", "SUBTITLE", "BPM", "WAVE", "OFFSET", "DEMOSTART","GENRE",
|
||||
"TITLE", "TITLEJA", "SUBTITLE", "BPM", "WAVE", "OFFSET", "DEMOSTART","GENRE",
|
||||
};
|
||||
|
||||
static readonly string[] HEADER_COURSE = new string[]
|
||||
@ -274,6 +275,8 @@ namespace TaikoSoundEditor
|
||||
{
|
||||
if (parsed.Name == "TITLE")
|
||||
headers.Title = parsed.Value;
|
||||
if (parsed.Name == "TITLEJA")
|
||||
headers.TitleJa = parsed.Value;
|
||||
if (parsed.Name == "SUBTITLE")
|
||||
headers.Subtitle = parsed.Value;
|
||||
if (parsed.Name == "BPM")
|
||||
@ -377,6 +380,7 @@ namespace TaikoSoundEditor
|
||||
{
|
||||
public string Title { get; set; } = "";
|
||||
public string Subtitle { get; set; } = "";
|
||||
public string TitleJa { get; set; } = "";
|
||||
public float Bpm { get; set; } = 120;
|
||||
public string Wave { get; set; } = "";
|
||||
public float Offset { get; set; } = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user