fix(zzz); voicepack language detection

This commit is contained in:
2024-12-18 17:39:48 +07:00
parent a33bdaa473
commit 441a06fb5b
2 changed files with 22 additions and 2 deletions

View File

@ -30,3 +30,23 @@ class VoicePackLanguage(Enum):
return VoicePackLanguage.English
else:
raise ValueError(f"Invalid language string: {s}")
@staticmethod
def from_zzz_name(s: str) -> "VoicePackLanguage":
"""
Converts a language string from ZZZ file name to a VoicePackLanguage enum.
Only English is tested for now.
"""
if s == "Jp":
return VoicePackLanguage.Japanese
elif s == "Cn":
return VoicePackLanguage.Chinese
elif s == "Tw":
return VoicePackLanguage.Taiwanese
elif s == "Kr":
return VoicePackLanguage.Korean
elif s == "En":
return VoicePackLanguage.English
else:
raise ValueError(f"Invalid language string: {s}")

View File

@ -277,12 +277,12 @@ class Game(GameABC):
voicepacks = []
for child in (
self.data_folder()
.joinpath("StreamingAssets/AudioAssets/AudioPackage/")
.joinpath("StreamingAssets/Audio/Windows/Full/")
.iterdir()
):
if child.resolve().is_dir():
try:
voicepacks.append(VoicePackLanguage[child.name])
voicepacks.append(VoicePackLanguage.from_zzz_name(child.name))
except ValueError:
pass
return voicepacks