diff --git a/OpenTaiko/Global/HitSounds/'08 Dual/HitSounds.json b/OpenTaiko/Global/HitSounds/'08 Dual/HitSounds.json new file mode 100644 index 00000000..220b03ab --- /dev/null +++ b/OpenTaiko/Global/HitSounds/'08 Dual/HitSounds.json @@ -0,0 +1,8 @@ +{ + "name" : { + "strings": { + "default": "'08 Dual", + "ja": "'08デュアル" + } + } +} diff --git a/OpenTaiko/Global/HitSounds/Break/HitSounds.json b/OpenTaiko/Global/HitSounds/Break/HitSounds.json new file mode 100644 index 00000000..878573dd --- /dev/null +++ b/OpenTaiko/Global/HitSounds/Break/HitSounds.json @@ -0,0 +1,8 @@ +{ + "name" : { + "strings": { + "default": "Break", + "ja": "ブレーク" + } + } +} diff --git a/OpenTaiko/Global/HitSounds/Electro/HitSounds.json b/OpenTaiko/Global/HitSounds/Electro/HitSounds.json new file mode 100644 index 00000000..b48c435b --- /dev/null +++ b/OpenTaiko/Global/HitSounds/Electro/HitSounds.json @@ -0,0 +1,8 @@ +{ + "name" : { + "strings": { + "default": "Electro", + "ja": "エレクトロ" + } + } +} diff --git a/OpenTaiko/Global/HitSounds/Gorgeous Taiko/HitSounds.json b/OpenTaiko/Global/HitSounds/Gorgeous Taiko/HitSounds.json new file mode 100644 index 00000000..1b932d23 --- /dev/null +++ b/OpenTaiko/Global/HitSounds/Gorgeous Taiko/HitSounds.json @@ -0,0 +1,8 @@ +{ + "name" : { + "strings": { + "default": "Gorgeous Taiko", + "ja": "ゴージャス太鼓" + } + } +} diff --git a/OpenTaiko/Global/HitSounds/HitSounds.json b/OpenTaiko/Global/HitSounds/HitSounds.json deleted file mode 100644 index bb69a4d9..00000000 --- a/OpenTaiko/Global/HitSounds/HitSounds.json +++ /dev/null @@ -1,43 +0,0 @@ -[ - { - "name": "Taiko", - "path": "Taiko\\", - "format": "WAV", - }, - { - "name": "Old Taiko", - "path": "Old Taiko\\", - "format": "OGG", - }, - { - "name": "Electro", - "path": "Electro\\", - "format": "WAV", - }, - { - "name": "Konga", - "path": "Konga\\", - "format": "WAV", - }, - { - "name": "'08 Dual", - "path": "'08 Dual\\", - "format": "WAV", - }, - { - "name": "Break", - "path": "Break\\", - "format": "WAV", - }, - { - "name": "Gorgeous Taiko", - "path": "Gorgeous Taiko\\", - "format": "WAV", - }, - { - "name": "None", - "path": "None", - "format": "WAV", - }, - -] \ No newline at end of file diff --git a/OpenTaiko/Global/HitSounds/Konga/HitSounds.json b/OpenTaiko/Global/HitSounds/Konga/HitSounds.json new file mode 100644 index 00000000..546b6ddd --- /dev/null +++ b/OpenTaiko/Global/HitSounds/Konga/HitSounds.json @@ -0,0 +1,8 @@ +{ + "name" : { + "strings": { + "default": "Konga", + "ja": "コンガ" + } + } +} diff --git a/OpenTaiko/Global/HitSounds/Old Taiko/HitSounds.json b/OpenTaiko/Global/HitSounds/Old Taiko/HitSounds.json new file mode 100644 index 00000000..f8c81439 --- /dev/null +++ b/OpenTaiko/Global/HitSounds/Old Taiko/HitSounds.json @@ -0,0 +1,8 @@ +{ + "name" : { + "strings": { + "default": "Old Taiko", + "ja": "旧式太鼓" + } + } +} diff --git a/OpenTaiko/Global/HitSounds/Taiko/HitSounds.json b/OpenTaiko/Global/HitSounds/Taiko/HitSounds.json new file mode 100644 index 00000000..191c6383 --- /dev/null +++ b/OpenTaiko/Global/HitSounds/Taiko/HitSounds.json @@ -0,0 +1,8 @@ +{ + "name" : { + "strings": { + "default": "Taiko", + "ja": "太鼓" + } + } +} diff --git a/OpenTaiko/src/Common/CHitSounds.cs b/OpenTaiko/src/Common/CHitSounds.cs index f75e6535..f981fe8d 100644 --- a/OpenTaiko/src/Common/CHitSounds.cs +++ b/OpenTaiko/src/Common/CHitSounds.cs @@ -1,4 +1,6 @@ -namespace OpenTaiko; +using Newtonsoft.Json; + +namespace OpenTaiko; class CHitSounds { public CHitSounds(string path) { @@ -12,21 +14,20 @@ class CHitSounds { if (id >= names.Length || id >= data.Length) return false; - string ext = this.data[id].format switch { - "WAV" => ".wav", - "OGG" => ".ogg", - _ => "" - }; + string fileExtension(string file) { + string path = Path.Combine(data[id].path, file); + return File.Exists(path + ".ogg") ? path + ".ogg" : path + ".wav"; + } - don[player] = data[id].path + "dong" + ext; - ka[player] = data[id].path + "ka" + ext; - adlib[player] = data[id].path + "Adlib" + ext; - clap[player] = data[id].path + "clap" + ext; + don[player] = fileExtension("dong"); + ka[player] = fileExtension("ka"); + adlib[player] = fileExtension("Adlib"); + clap[player] = fileExtension("clap"); return true; } - public string[] names; + public CLocalizationData[] names; public string[] don = new string[5]; public string[] ka = new string[5]; @@ -36,18 +37,34 @@ class CHitSounds { #region [private] private class HitSoundsData { - public string name; - public string path; - public string format; + [JsonProperty("name")] + [JsonConverter(typeof(LocalizedStringConverter))] + public CLocalizationData name = new(); + + [JsonIgnore] + public string path = $"Global{Path.DirectorySeparatorChar}HitSounds{Path.DirectorySeparatorChar}_fallback{Path.DirectorySeparatorChar}"; + + public HitSoundsData() { name.SetString("default", "Unknown Hitsound"); } + public HitSoundsData(string path) : this() { + name.SetString("default", Path.GetRelativePath($"Global{Path.DirectorySeparatorChar}HitSounds{Path.DirectorySeparatorChar}", path)); + this.path = path; + } } private HitSoundsData[] data; private void tLoadFile(string path) { - data = ConfigManager.GetConfig>(path).ToArray(); - names = new string[data.Length]; + string[] directories = Directory.GetDirectories(path); + data = new HitSoundsData[directories.Length]; + names = new CLocalizationData[data.Length]; + for (int i = 0; i < data.Length; i++) { + string dir_path = Path.Combine(directories[i], "HitSounds.json"); + data[i] = File.Exists(dir_path) ? ConfigManager.GetConfig(dir_path) : new(directories[i]); + data[i].path = directories[i]; names[i] = data[i].name; + + if (!File.Exists(dir_path)) { ConfigManager.SaveConfig(data[i], dir_path); } } } diff --git a/OpenTaiko/src/Common/CSkin.cs b/OpenTaiko/src/Common/CSkin.cs index 76e55e7b..d746464e 100644 --- a/OpenTaiko/src/Common/CSkin.cs +++ b/OpenTaiko/src/Common/CSkin.cs @@ -729,7 +729,7 @@ internal class CSkin : IDisposable { tReadSkinConfig(); //hsHitSoundsInformations = new CHitSounds(Path(@$"Sounds{System.IO.Path.DirectorySeparatorChar}HitSounds{System.IO.Path.DirectorySeparatorChar}HitSounds.json")); - hsHitSoundsInformations = new CHitSounds(@$"Global{System.IO.Path.DirectorySeparatorChar}HitSounds{System.IO.Path.DirectorySeparatorChar}HitSounds.json"); + hsHitSoundsInformations = new CHitSounds(@$"Global{System.IO.Path.DirectorySeparatorChar}HitSounds"); } public void ReloadSkin() { diff --git a/OpenTaiko/src/Common/ImGuiDebugWindow.cs b/OpenTaiko/src/Common/ImGuiDebugWindow.cs index a68b9379..851e5a64 100644 --- a/OpenTaiko/src/Common/ImGuiDebugWindow.cs +++ b/OpenTaiko/src/Common/ImGuiDebugWindow.cs @@ -274,7 +274,7 @@ public static class ImGuiDebugWindow { ImGui.TextColored(OpenTaiko.ConfigIni.bAutoPlay[i] ? diff : normal, "Auto: " + OpenTaiko.ConfigIni.bAutoPlay[i]); - ImGui.Text("Hitsound: " + OpenTaiko.Skin.hsHitSoundsInformations.names[OpenTaiko.ConfigIni.nHitSounds[i]]); + ImGui.Text("Hitsound: " + OpenTaiko.Skin.hsHitSoundsInformations.names[OpenTaiko.ConfigIni.nHitSounds[i]].GetString("???")); ImGui.TextColored(OpenTaiko.ConfigIni.nFunMods[i] == EFunMods.None ? normal : diff, "Fun Mods: " + OpenTaiko.ConfigIni.nFunMods[i].ToString()); diff --git a/OpenTaiko/src/I18N/ILang.cs b/OpenTaiko/src/I18N/ILang.cs index c159d4cb..e5a22425 100644 --- a/OpenTaiko/src/I18N/ILang.cs +++ b/OpenTaiko/src/I18N/ILang.cs @@ -7,8 +7,7 @@ internal interface ILang { static internal class CLangManager { // Cheap factory-like design pattern - public static (string, int) DefaultLanguage = ("ja", 0); - public static CLang LangInstance { get; private set; } = new CLang(Langcodes.FirstOrDefault("ja")); + public static CLang LangInstance { get; private set; } = new CLang("en"); public static void langAttach(string lang) { LangInstance = CLang.GetCLang(lang); CLuaScript.tReloadLanguage(lang); diff --git a/OpenTaiko/src/Stages/05.SongSelect/CActPlayOption.cs b/OpenTaiko/src/Stages/05.SongSelect/CActPlayOption.cs index 393d0b5b..3af9af43 100644 --- a/OpenTaiko/src/Stages/05.SongSelect/CActPlayOption.cs +++ b/OpenTaiko/src/Stages/05.SongSelect/CActPlayOption.cs @@ -83,7 +83,7 @@ internal class CActPlayOption : CActivity { if (txOtoiro.Length > 0) { for (int i = 0; i < txOtoiro.Length; i++) { - txOtoiro[i] = OptionTypeTx(hsInfo.names[i], Color.White, Color.Black); + txOtoiro[i] = OptionTypeTx(hsInfo.names[i].GetString("???"), Color.White, Color.Black); } } else { txOtoiro = new CTexture[1]; diff --git a/OpenTaiko/src/Stages/05.SongSelect/CActSelectPopupMenu.cs b/OpenTaiko/src/Stages/05.SongSelect/CActSelectPopupMenu.cs index 3bbfb715..2a971e94 100644 --- a/OpenTaiko/src/Stages/05.SongSelect/CActSelectPopupMenu.cs +++ b/OpenTaiko/src/Stages/05.SongSelect/CActSelectPopupMenu.cs @@ -338,7 +338,7 @@ internal class CActSelectPopupMenu : CActivity { // } //font.t文字列描画( (int)(340 * Scale.X), (int)(80 + i * 32), s, bValueBold, 1.0f * Scale.Y); using (var bmpStr = bValueBold ? - prvFont.DrawText(s, Color.White, Color.Black, null, Color.Yellow, Color.OrangeRed, 30) : + prvFont.DrawText(s, Color.White, Color.OrangeRed, null, Color.Yellow, Color.OrangeRed, 30) : prvFont.DrawText(s, Color.White, Color.Black, null, 30)) { using (var ctStr = OpenTaiko.tテクスチャの生成(bmpStr, false)) { ctStr.t2D描画(OpenTaiko.Skin.PopupMenu_MenuItem_Value[0] + i * OpenTaiko.Skin.PopupMenu_Move[0], diff --git a/OpenTaiko/src/Stages/07.Game/Taiko/CStage演奏ドラム画面.cs b/OpenTaiko/src/Stages/07.Game/Taiko/CStage演奏ドラム画面.cs index e7c36239..4d483df3 100644 --- a/OpenTaiko/src/Stages/07.Game/Taiko/CStage演奏ドラム画面.cs +++ b/OpenTaiko/src/Stages/07.Game/Taiko/CStage演奏ドラム画面.cs @@ -294,10 +294,10 @@ internal class CStage演奏ドラム画面 : CStage演奏画面共通 { var hs = OpenTaiko.Skin.hsHitSoundsInformations; - this.soundRed[i] = OpenTaiko.SoundManager.tCreateSound((@$"Global{Path.DirectorySeparatorChar}HitSounds{Path.DirectorySeparatorChar}" + hs.don[actual]), ESoundGroup.SoundEffect); - this.soundBlue[i] = OpenTaiko.SoundManager.tCreateSound((@$"Global{Path.DirectorySeparatorChar}HitSounds{Path.DirectorySeparatorChar}" + hs.ka[actual]), ESoundGroup.SoundEffect); - this.soundAdlib[i] = OpenTaiko.SoundManager.tCreateSound((@$"Global{Path.DirectorySeparatorChar}HitSounds{Path.DirectorySeparatorChar}" + hs.adlib[actual]), ESoundGroup.SoundEffect); - this.soundClap[i] = OpenTaiko.SoundManager.tCreateSound((@$"Global{Path.DirectorySeparatorChar}HitSounds{Path.DirectorySeparatorChar}" + hs.clap[actual]), ESoundGroup.SoundEffect); + this.soundRed[i] = OpenTaiko.SoundManager.tCreateSound(hs.don[actual], ESoundGroup.SoundEffect); + this.soundBlue[i] = OpenTaiko.SoundManager.tCreateSound(hs.ka[actual], ESoundGroup.SoundEffect); + this.soundAdlib[i] = OpenTaiko.SoundManager.tCreateSound(hs.adlib[actual], ESoundGroup.SoundEffect); + this.soundClap[i] = OpenTaiko.SoundManager.tCreateSound(hs.clap[actual], ESoundGroup.SoundEffect); int _panning = OpenTaiko.ConfigIni.nPanning[OpenTaiko.ConfigIni.nPlayerCount - 1][i]; if (this.soundRed[i] != null) this.soundRed[i].SoundPosition = _panning;