This commit is contained in:
yuhuihuang
2020-08-09 19:44:48 +08:00
parent 66459a124c
commit 1d66ebef58
2 changed files with 31 additions and 1 deletions

View File

@@ -21,8 +21,16 @@ import org.jackhuang.hmcl.Metadata;
import org.jackhuang.hmcl.auth.AuthInfo;
import org.jackhuang.hmcl.launch.DefaultLauncher;
import org.jackhuang.hmcl.launch.ProcessListener;
import org.jackhuang.hmcl.util.Logging;
import org.jackhuang.hmcl.util.i18n.I18n;
import org.jackhuang.hmcl.util.io.FileUtils;
import org.jackhuang.hmcl.util.platform.ManagedProcess;
import java.io.File;
import java.io.IOException;
import java.util.Locale;
import java.util.Map;
import java.util.logging.Level;
/**
* @author huangyuhui
@@ -48,4 +56,26 @@ public final class HMCLGameLauncher extends DefaultLauncher {
res.put("${launcher_version}", Metadata.VERSION);
return res;
}
private void generateOptionsTxt() {
try {
// TODO: Dirty implementation here
if (I18n.getCurrentLocale().getLocale() == Locale.CHINA)
FileUtils.writeText(new File(repository.getRunDirectory(version.getId()), "options.txt"), "lang:zh_cn\nforceUnicodeFont:true\n");
} catch (IOException e) {
Logging.LOG.log(Level.WARNING, "Unable to generate options.txt", e);
}
}
@Override
public ManagedProcess launch() throws IOException, InterruptedException {
generateOptionsTxt();
return super.launch();
}
@Override
public void makeLaunchScript(File scriptFile) throws IOException {
generateOptionsTxt();
super.makeLaunchScript(scriptFile);
}
}

View File

@@ -30,7 +30,7 @@ public final class I18n {
private I18n() {}
private static SupportedLocale getCurrentLocale() {
public static SupportedLocale getCurrentLocale() {
try {
return ConfigHolder.config().getLocalization();
} catch (IllegalStateException e) {