1
0
mirror of synced 2024-11-23 23:21:06 +01:00

0.6.0.17 - HitSounds.json if it was epic

- Make HitSounds.json per-folder instead of one central file
- Initialize new JSON file if one does not exist in that folder, using folder name as Hitsound name
- Add localization support for Hitsounds
This commit is contained in:
DragonRatTiger / リュウコ 2024-11-12 07:30:04 -06:00 committed by GitHub
parent ea5838e7e8
commit 0dd2ede162
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 98 additions and 69 deletions

View File

@ -0,0 +1,8 @@
{
"name" : {
"strings": {
"default": "'08 Dual",
"ja": "'08デュアル"
}
}
}

View File

@ -0,0 +1,8 @@
{
"name" : {
"strings": {
"default": "Break",
"ja": "ブレーク"
}
}
}

View File

@ -0,0 +1,8 @@
{
"name" : {
"strings": {
"default": "Electro",
"ja": "エレクトロ"
}
}
}

View File

@ -0,0 +1,8 @@
{
"name" : {
"strings": {
"default": "Gorgeous Taiko",
"ja": "ゴージャス太鼓"
}
}
}

View File

@ -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",
},
]

View File

@ -0,0 +1,8 @@
{
"name" : {
"strings": {
"default": "Konga",
"ja": "コンガ"
}
}
}

View File

@ -0,0 +1,8 @@
{
"name" : {
"strings": {
"default": "Old Taiko",
"ja": "旧式太鼓"
}
}
}

View File

@ -0,0 +1,8 @@
{
"name" : {
"strings": {
"default": "Taiko",
"ja": "太鼓"
}
}
}

View File

@ -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<CLocalizationData>))]
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<List<HitSoundsData>>(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<HitSoundsData>(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); }
}
}

View File

@ -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() {

View File

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

View File

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

View File

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

View File

@ -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],

View File

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