1
0
mirror of synced 2024-11-30 14:14:29 +01:00

added more exception guards

This commit is contained in:
NotImplementedLife 2023-07-17 13:24:28 +03:00
parent 6b1008bfae
commit c2e0f761d7
3 changed files with 49 additions and 15 deletions

View File

@ -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;

View File

@ -82,11 +82,38 @@ 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);
}
}*/
}
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;
@ -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
View File

@ -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;