2
0
mirror of https://github.com/HMCL-dev/HMCL.git synced 2024-12-27 07:10:41 +08:00

Fix 修复游戏语言自动切换功能与不同版本的兼容性问题 ()

* Fix 

* fix
This commit is contained in:
Burning_TNT 2023-07-06 23:28:41 +08:00 committed by GitHub
parent c9465d89f5
commit a5ee6b05e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -61,17 +61,42 @@ public final class HMCLGameLauncher extends DefaultLauncher {
File optionsFile = new File(repository.getRunDirectory(version.getId()), "options.txt");
File configFolder = new File(repository.getRunDirectory(version.getId()), "config");
if (optionsFile.exists())
if (optionsFile.exists()) {
return;
if (configFolder.isDirectory())
if (findFiles(configFolder, "options.txt"))
}
if (configFolder.isDirectory()) {
if (findFiles(configFolder, "options.txt")) {
return;
try {
// TODO: Dirty implementation here
if (I18n.getCurrentLocale().getLocale() == Locale.CHINA)
FileUtils.writeText(optionsFile, "lang:zh_CN\nforceUnicodeFont:true\n");
} catch (IOException e) {
Logging.LOG.log(Level.WARNING, "Unable to generate options.txt", e);
}
}
if (I18n.getCurrentLocale().getLocale() != Locale.CHINA) {
return;
}
String lang;
/*
1.0- 没有语言选项遇到这些版本时不设置
1.1 ~ 5 zh_CN 时正常zh_cn 时崩溃最后两位字母必须大写否则将会 NPE 崩溃
1.6 ~ 10 zh_CN 时正常zh_cn 时自动切换为英文
1.11 ~ 12zh_cn 时正常zh_CN 时虽然显示了中文但语言设置会错误地显示选择英文
1.13+ zh_cn 时正常zh_CN 时自动切换为英文
*/
if (this.version.compareTo(new Version("1.1")) < 0) {
lang = null;
} else if (this.version.compareTo(new Version("1.10")) <= 0) {
lang = "zh_CN";
} else {
lang = "zh_cn";
}
if (lang != null) {
try {
FileUtils.writeText(optionsFile, String.format("lang:%s\nforceUnicodeFont:true\n", lang));
} catch (IOException e) {
Logging.LOG.log(Level.WARNING, "Unable to generate options.txt", e);
}
}
}