Use static import for ConfigHolder.CONFIG
This commit is contained in:
@@ -17,7 +17,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.jackhuang.hmcl.game;
|
package org.jackhuang.hmcl.game;
|
||||||
|
|
||||||
import org.jackhuang.hmcl.setting.ConfigHolder;
|
|
||||||
import org.jackhuang.hmcl.setting.Profile;
|
import org.jackhuang.hmcl.setting.Profile;
|
||||||
import org.jackhuang.hmcl.task.FileDownloadTask;
|
import org.jackhuang.hmcl.task.FileDownloadTask;
|
||||||
import org.jackhuang.hmcl.task.FileDownloadTask.IntegrityCheck;
|
import org.jackhuang.hmcl.task.FileDownloadTask.IntegrityCheck;
|
||||||
@@ -32,6 +31,8 @@ import java.util.LinkedList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import static org.jackhuang.hmcl.setting.ConfigHolder.CONFIG;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author huangyuhui
|
* @author huangyuhui
|
||||||
*/
|
*/
|
||||||
@@ -58,7 +59,7 @@ public class HMCLGameDownloadTask extends Task {
|
|||||||
public void execute() {
|
public void execute() {
|
||||||
File jar = profile.getRepository().getVersionJar(version);
|
File jar = profile.getRepository().getVersionJar(version);
|
||||||
|
|
||||||
File cache = new File(ConfigHolder.CONFIG.commonDirectory.get(), "jars/" + gameVersion + ".jar");
|
File cache = new File(CONFIG.commonDirectory.get(), "jars/" + gameVersion + ".jar");
|
||||||
if (cache.exists())
|
if (cache.exists())
|
||||||
try {
|
try {
|
||||||
FileUtils.copyFile(cache, jar);
|
FileUtils.copyFile(cache, jar);
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import com.google.gson.GsonBuilder;
|
|||||||
import org.jackhuang.hmcl.event.EventBus;
|
import org.jackhuang.hmcl.event.EventBus;
|
||||||
import org.jackhuang.hmcl.event.RefreshedVersionsEvent;
|
import org.jackhuang.hmcl.event.RefreshedVersionsEvent;
|
||||||
import org.jackhuang.hmcl.event.RefreshingVersionsEvent;
|
import org.jackhuang.hmcl.event.RefreshingVersionsEvent;
|
||||||
import org.jackhuang.hmcl.setting.ConfigHolder;
|
|
||||||
import org.jackhuang.hmcl.setting.EnumGameDirectory;
|
import org.jackhuang.hmcl.setting.EnumGameDirectory;
|
||||||
import org.jackhuang.hmcl.setting.Profile;
|
import org.jackhuang.hmcl.setting.Profile;
|
||||||
import org.jackhuang.hmcl.setting.VersionSetting;
|
import org.jackhuang.hmcl.setting.VersionSetting;
|
||||||
@@ -34,6 +33,8 @@ import java.io.IOException;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import static org.jackhuang.hmcl.setting.ConfigHolder.CONFIG;
|
||||||
|
|
||||||
public class HMCLGameRepository extends DefaultGameRepository {
|
public class HMCLGameRepository extends DefaultGameRepository {
|
||||||
private final Profile profile;
|
private final Profile profile;
|
||||||
private final Map<String, VersionSetting> versionSettings = new HashMap<>();
|
private final Map<String, VersionSetting> versionSettings = new HashMap<>();
|
||||||
@@ -60,7 +61,7 @@ public class HMCLGameRepository extends DefaultGameRepository {
|
|||||||
if (useSelf(version, assetId))
|
if (useSelf(version, assetId))
|
||||||
return super.getAssetDirectory(version, assetId);
|
return super.getAssetDirectory(version, assetId);
|
||||||
else
|
else
|
||||||
return new File(ConfigHolder.CONFIG.commonDirectory.get(), "assets");
|
return new File(CONFIG.commonDirectory.get(), "assets");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -85,7 +86,7 @@ public class HMCLGameRepository extends DefaultGameRepository {
|
|||||||
if (self.exists() || vs.isNoCommon())
|
if (self.exists() || vs.isNoCommon())
|
||||||
return self;
|
return self;
|
||||||
else
|
else
|
||||||
return new File(ConfigHolder.CONFIG.commonDirectory.get(), "libraries/" + lib.getPath());
|
return new File(CONFIG.commonDirectory.get(), "libraries/" + lib.getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import java.io.IOException;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import static org.jackhuang.hmcl.setting.ConfigHolder.CONFIG;
|
||||||
import static org.jackhuang.hmcl.util.Lang.mapOf;
|
import static org.jackhuang.hmcl.util.Lang.mapOf;
|
||||||
import static org.jackhuang.hmcl.util.Logging.LOG;
|
import static org.jackhuang.hmcl.util.Logging.LOG;
|
||||||
import static org.jackhuang.hmcl.util.Pair.pair;
|
import static org.jackhuang.hmcl.util.Pair.pair;
|
||||||
@@ -71,7 +72,7 @@ public final class Accounts {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static AuthlibInjectorServer getOrCreateAuthlibInjectorServer(String url) {
|
private static AuthlibInjectorServer getOrCreateAuthlibInjectorServer(String url) {
|
||||||
return ConfigHolder.CONFIG.authlibInjectorServers.stream()
|
return CONFIG.authlibInjectorServers.stream()
|
||||||
.filter(server -> url.equals(server.getUrl()))
|
.filter(server -> url.equals(server.getUrl()))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElseGet(() -> {
|
.orElseGet(() -> {
|
||||||
@@ -85,7 +86,7 @@ public final class Accounts {
|
|||||||
LOG.log(Level.WARNING, "Failed to migrate authlib injector server " + url, e);
|
LOG.log(Level.WARNING, "Failed to migrate authlib injector server " + url, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigHolder.CONFIG.authlibInjectorServers.add(server);
|
CONFIG.authlibInjectorServers.add(server);
|
||||||
return server;
|
return server;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.jackhuang.hmcl.setting;
|
package org.jackhuang.hmcl.setting;
|
||||||
|
|
||||||
|
import static org.jackhuang.hmcl.setting.ConfigHolder.CONFIG;
|
||||||
|
|
||||||
import java.net.Authenticator;
|
import java.net.Authenticator;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.PasswordAuthentication;
|
import java.net.PasswordAuthentication;
|
||||||
@@ -35,18 +37,18 @@ public final class ProxyManager {
|
|||||||
|
|
||||||
public static final ObjectBinding<Proxy> proxyProperty = Bindings.createObjectBinding(
|
public static final ObjectBinding<Proxy> proxyProperty = Bindings.createObjectBinding(
|
||||||
() -> {
|
() -> {
|
||||||
String host = ConfigHolder.CONFIG.proxyHost.get();
|
String host = CONFIG.proxyHost.get();
|
||||||
Integer port = Lang.toIntOrNull(ConfigHolder.CONFIG.proxyPort.get());
|
Integer port = Lang.toIntOrNull(CONFIG.proxyPort.get());
|
||||||
if (!ConfigHolder.CONFIG.hasProxy.get() || StringUtils.isBlank(host) || port == null || ConfigHolder.CONFIG.proxyType.get() == Proxy.Type.DIRECT) {
|
if (!CONFIG.hasProxy.get() || StringUtils.isBlank(host) || port == null || CONFIG.proxyType.get() == Proxy.Type.DIRECT) {
|
||||||
return Proxy.NO_PROXY;
|
return Proxy.NO_PROXY;
|
||||||
} else {
|
} else {
|
||||||
return new Proxy(ConfigHolder.CONFIG.proxyType.get(), new InetSocketAddress(host, port));
|
return new Proxy(CONFIG.proxyType.get(), new InetSocketAddress(host, port));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ConfigHolder.CONFIG.proxyType,
|
CONFIG.proxyType,
|
||||||
ConfigHolder.CONFIG.proxyHost,
|
CONFIG.proxyHost,
|
||||||
ConfigHolder.CONFIG.proxyPort,
|
CONFIG.proxyPort,
|
||||||
ConfigHolder.CONFIG.hasProxy);
|
CONFIG.hasProxy);
|
||||||
|
|
||||||
public static Proxy getProxy() {
|
public static Proxy getProxy() {
|
||||||
return proxyProperty.get();
|
return proxyProperty.get();
|
||||||
@@ -65,9 +67,9 @@ public final class ProxyManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected PasswordAuthentication getPasswordAuthentication() {
|
protected PasswordAuthentication getPasswordAuthentication() {
|
||||||
if (ConfigHolder.CONFIG.hasProxyAuth.get()) {
|
if (CONFIG.hasProxyAuth.get()) {
|
||||||
String username = ConfigHolder.CONFIG.proxyUser.get();
|
String username = CONFIG.proxyUser.get();
|
||||||
String password = ConfigHolder.CONFIG.proxyPass.get();
|
String password = CONFIG.proxyPass.get();
|
||||||
if (username != null && password != null) {
|
if (username != null && password != null) {
|
||||||
return new PasswordAuthentication(username, password.toCharArray());
|
return new PasswordAuthentication(username, password.toCharArray());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import java.util.logging.Level;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static java.util.stream.Collectors.toList;
|
import static java.util.stream.Collectors.toList;
|
||||||
|
import static org.jackhuang.hmcl.setting.ConfigHolder.CONFIG;
|
||||||
import static org.jackhuang.hmcl.ui.FXUtils.onInvalidating;
|
import static org.jackhuang.hmcl.ui.FXUtils.onInvalidating;
|
||||||
import static org.jackhuang.hmcl.util.Lang.tryCast;
|
import static org.jackhuang.hmcl.util.Lang.tryCast;
|
||||||
import static org.jackhuang.hmcl.util.Logging.LOG;
|
import static org.jackhuang.hmcl.util.Logging.LOG;
|
||||||
@@ -52,7 +53,7 @@ public class Settings {
|
|||||||
private final boolean firstLaunch;
|
private final boolean firstLaunch;
|
||||||
|
|
||||||
private InvalidationListener accountChangeListener =
|
private InvalidationListener accountChangeListener =
|
||||||
source -> ConfigHolder.CONFIG.accounts.setAll(
|
source -> CONFIG.accounts.setAll(
|
||||||
accounts.values().stream()
|
accounts.values().stream()
|
||||||
.map(account -> {
|
.map(account -> {
|
||||||
Map<Object, Object> storage = account.toStorage();
|
Map<Object, Object> storage = account.toStorage();
|
||||||
@@ -62,12 +63,12 @@ public class Settings {
|
|||||||
.collect(toList()));
|
.collect(toList()));
|
||||||
|
|
||||||
private Settings() {
|
private Settings() {
|
||||||
firstLaunch = ConfigHolder.CONFIG.firstLaunch.get();
|
firstLaunch = CONFIG.firstLaunch.get();
|
||||||
ConfigHolder.CONFIG.firstLaunch.set(false);
|
CONFIG.firstLaunch.set(false);
|
||||||
|
|
||||||
ProxyManager.getProxy(); // init ProxyManager
|
ProxyManager.getProxy(); // init ProxyManager
|
||||||
|
|
||||||
for (Iterator<Map<Object, Object>> iterator = ConfigHolder.CONFIG.accounts.iterator(); iterator.hasNext();) {
|
for (Iterator<Map<Object, Object>> iterator = CONFIG.accounts.iterator(); iterator.hasNext();) {
|
||||||
Map<Object, Object> settings = iterator.next();
|
Map<Object, Object> settings = iterator.next();
|
||||||
AccountFactory<?> factory = Accounts.ACCOUNT_FACTORY.get(tryCast(settings.get("type"), String.class).orElse(""));
|
AccountFactory<?> factory = Accounts.ACCOUNT_FACTORY.get(tryCast(settings.get("type"), String.class).orElse(""));
|
||||||
if (factory == null) {
|
if (factory == null) {
|
||||||
@@ -89,9 +90,9 @@ public class Settings {
|
|||||||
account.addListener(accountChangeListener);
|
account.addListener(accountChangeListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigHolder.CONFIG.authlibInjectorServers.addListener(onInvalidating(this::removeDanglingAuthlibInjectorAccounts));
|
CONFIG.authlibInjectorServers.addListener(onInvalidating(this::removeDanglingAuthlibInjectorAccounts));
|
||||||
|
|
||||||
this.selectedAccount.set(accounts.get(ConfigHolder.CONFIG.selectedAccount.get()));
|
this.selectedAccount.set(accounts.get(CONFIG.selectedAccount.get()));
|
||||||
|
|
||||||
checkProfileMap();
|
checkProfileMap();
|
||||||
|
|
||||||
@@ -105,18 +106,18 @@ public class Settings {
|
|||||||
|
|
||||||
Lang.ignoringException(() -> Runtime.getRuntime().addShutdownHook(new Thread(this::save)));
|
Lang.ignoringException(() -> Runtime.getRuntime().addShutdownHook(new Thread(this::save)));
|
||||||
|
|
||||||
ConfigHolder.CONFIG.addListener(source -> save());
|
CONFIG.addListener(source -> save());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void save() {
|
private void save() {
|
||||||
ConfigHolder.saveConfig(ConfigHolder.CONFIG);
|
ConfigHolder.saveConfig(CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFirstLaunch() {
|
public boolean isFirstLaunch() {
|
||||||
return firstLaunch;
|
return firstLaunch;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Locales.SupportedLocale locale = Locales.getLocaleByName(ConfigHolder.CONFIG.localization.get());
|
private Locales.SupportedLocale locale = Locales.getLocaleByName(CONFIG.localization.get());
|
||||||
|
|
||||||
public Locales.SupportedLocale getLocale() {
|
public Locales.SupportedLocale getLocale() {
|
||||||
return locale;
|
return locale;
|
||||||
@@ -124,24 +125,24 @@ public class Settings {
|
|||||||
|
|
||||||
public void setLocale(Locales.SupportedLocale locale) {
|
public void setLocale(Locales.SupportedLocale locale) {
|
||||||
this.locale = locale;
|
this.locale = locale;
|
||||||
ConfigHolder.CONFIG.localization.set(Locales.getNameByLocale(locale));
|
CONFIG.localization.set(Locales.getNameByLocale(locale));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Font getFont() {
|
public Font getFont() {
|
||||||
return Font.font(ConfigHolder.CONFIG.fontFamily.get(), ConfigHolder.CONFIG.fontSize.get());
|
return Font.font(CONFIG.fontFamily.get(), CONFIG.fontSize.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFont(Font font) {
|
public void setFont(Font font) {
|
||||||
ConfigHolder.CONFIG.fontFamily.set(font.getFamily());
|
CONFIG.fontFamily.set(font.getFamily());
|
||||||
ConfigHolder.CONFIG.fontSize.set(font.getSize());
|
CONFIG.fontSize.set(font.getSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLogLines() {
|
public int getLogLines() {
|
||||||
return Math.max(ConfigHolder.CONFIG.logLines.get(), 100);
|
return Math.max(CONFIG.logLines.get(), 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLogLines(int logLines) {
|
public void setLogLines(int logLines) {
|
||||||
ConfigHolder.CONFIG.logLines.set(logLines);
|
CONFIG.logLines.set(logLines);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************
|
/****************************************
|
||||||
@@ -156,7 +157,7 @@ public class Settings {
|
|||||||
private void removeDanglingAuthlibInjectorAccounts() {
|
private void removeDanglingAuthlibInjectorAccounts() {
|
||||||
accounts.values().stream()
|
accounts.values().stream()
|
||||||
.filter(AuthlibInjectorAccount.class::isInstance)
|
.filter(AuthlibInjectorAccount.class::isInstance)
|
||||||
.filter(it -> !ConfigHolder.CONFIG.authlibInjectorServers.contains(((AuthlibInjectorAccount) it).getServer()))
|
.filter(it -> !CONFIG.authlibInjectorServers.contains(((AuthlibInjectorAccount) it).getServer()))
|
||||||
.collect(toList())
|
.collect(toList())
|
||||||
.forEach(this::deleteAccount);
|
.forEach(this::deleteAccount);
|
||||||
}
|
}
|
||||||
@@ -166,14 +167,14 @@ public class Settings {
|
|||||||
****************************************/
|
****************************************/
|
||||||
|
|
||||||
public DownloadProvider getDownloadProvider() {
|
public DownloadProvider getDownloadProvider() {
|
||||||
return DownloadProviders.getDownloadProvider(ConfigHolder.CONFIG.downloadType.get());
|
return DownloadProviders.getDownloadProvider(CONFIG.downloadType.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDownloadProvider(DownloadProvider downloadProvider) {
|
public void setDownloadProvider(DownloadProvider downloadProvider) {
|
||||||
int index = DownloadProviders.DOWNLOAD_PROVIDERS.indexOf(downloadProvider);
|
int index = DownloadProviders.DOWNLOAD_PROVIDERS.indexOf(downloadProvider);
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
throw new IllegalArgumentException("Unknown download provider: " + downloadProvider);
|
throw new IllegalArgumentException("Unknown download provider: " + downloadProvider);
|
||||||
ConfigHolder.CONFIG.downloadType.set(index);
|
CONFIG.downloadType.set(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************
|
/****************************************
|
||||||
@@ -202,7 +203,7 @@ public class Settings {
|
|||||||
public void invalidated() {
|
public void invalidated() {
|
||||||
super.invalidated();
|
super.invalidated();
|
||||||
|
|
||||||
ConfigHolder.CONFIG.selectedAccount.set(getValue() == null ? "" : Accounts.getAccountId(getValue()));
|
CONFIG.selectedAccount.set(getValue() == null ? "" : Accounts.getAccountId(getValue()));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -260,12 +261,12 @@ public class Settings {
|
|||||||
* THEME *
|
* THEME *
|
||||||
****************************************/
|
****************************************/
|
||||||
|
|
||||||
private final ImmediateObjectProperty<Theme> theme = new ImmediateObjectProperty<Theme>(this, "theme", Theme.getTheme(ConfigHolder.CONFIG.theme.get()).orElse(Theme.BLUE)) {
|
private final ImmediateObjectProperty<Theme> theme = new ImmediateObjectProperty<Theme>(this, "theme", Theme.getTheme(CONFIG.theme.get()).orElse(Theme.BLUE)) {
|
||||||
@Override
|
@Override
|
||||||
public void invalidated() {
|
public void invalidated() {
|
||||||
super.invalidated();
|
super.invalidated();
|
||||||
|
|
||||||
ConfigHolder.CONFIG.theme.set(get().getName().toLowerCase());
|
CONFIG.theme.set(get().getName().toLowerCase());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -288,18 +289,18 @@ public class Settings {
|
|||||||
public Profile getSelectedProfile() {
|
public Profile getSelectedProfile() {
|
||||||
checkProfileMap();
|
checkProfileMap();
|
||||||
|
|
||||||
if (!hasProfile(ConfigHolder.CONFIG.selectedProfile.get())) {
|
if (!hasProfile(CONFIG.selectedProfile.get())) {
|
||||||
getProfileMap().keySet().stream().findFirst().ifPresent(selectedProfile -> {
|
getProfileMap().keySet().stream().findFirst().ifPresent(selectedProfile -> {
|
||||||
ConfigHolder.CONFIG.selectedProfile.set(selectedProfile);
|
CONFIG.selectedProfile.set(selectedProfile);
|
||||||
});
|
});
|
||||||
Schedulers.computation().schedule(this::onProfileChanged);
|
Schedulers.computation().schedule(this::onProfileChanged);
|
||||||
}
|
}
|
||||||
return getProfile(ConfigHolder.CONFIG.selectedProfile.get());
|
return getProfile(CONFIG.selectedProfile.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSelectedProfile(Profile selectedProfile) {
|
public void setSelectedProfile(Profile selectedProfile) {
|
||||||
if (hasProfile(selectedProfile.getName()) && !Objects.equals(selectedProfile.getName(), ConfigHolder.CONFIG.selectedProfile.get())) {
|
if (hasProfile(selectedProfile.getName()) && !Objects.equals(selectedProfile.getName(), CONFIG.selectedProfile.get())) {
|
||||||
ConfigHolder.CONFIG.selectedProfile.set(selectedProfile.getName());
|
CONFIG.selectedProfile.set(selectedProfile.getName());
|
||||||
Schedulers.computation().schedule(this::onProfileChanged);
|
Schedulers.computation().schedule(this::onProfileChanged);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -316,7 +317,7 @@ public class Settings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Profile> getProfileMap() {
|
public Map<String, Profile> getProfileMap() {
|
||||||
return ConfigHolder.CONFIG.configurations;
|
return CONFIG.configurations;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<Profile> getProfiles() {
|
public Collection<Profile> getProfiles() {
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ import java.util.List;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static org.jackhuang.hmcl.setting.ConfigHolder.CONFIG;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author huangyuhui
|
* @author huangyuhui
|
||||||
@@ -517,10 +519,10 @@ public final class VersionSetting {
|
|||||||
.setFullscreen(isFullscreen())
|
.setFullscreen(isFullscreen())
|
||||||
.setServerIp(getServerIp())
|
.setServerIp(getServerIp())
|
||||||
.setWrapper(getWrapper())
|
.setWrapper(getWrapper())
|
||||||
.setProxyHost(ConfigHolder.CONFIG.proxyHost.get())
|
.setProxyHost(CONFIG.proxyHost.get())
|
||||||
.setProxyPort(ConfigHolder.CONFIG.proxyPort.get())
|
.setProxyPort(CONFIG.proxyPort.get())
|
||||||
.setProxyUser(ConfigHolder.CONFIG.proxyUser.get())
|
.setProxyUser(CONFIG.proxyUser.get())
|
||||||
.setProxyPass(ConfigHolder.CONFIG.proxyPass.get())
|
.setProxyPass(CONFIG.proxyPass.get())
|
||||||
.setPrecalledCommand(getPreLaunchCommand())
|
.setPrecalledCommand(getPreLaunchCommand())
|
||||||
.setNoGeneratedJVMArgs(isNoJVMArgs())
|
.setNoGeneratedJVMArgs(isNoJVMArgs())
|
||||||
.create();
|
.create();
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ import org.jackhuang.hmcl.auth.yggdrasil.RemoteAuthenticationException;
|
|||||||
import org.jackhuang.hmcl.auth.yggdrasil.YggdrasilAccount;
|
import org.jackhuang.hmcl.auth.yggdrasil.YggdrasilAccount;
|
||||||
import org.jackhuang.hmcl.game.AccountHelper;
|
import org.jackhuang.hmcl.game.AccountHelper;
|
||||||
import org.jackhuang.hmcl.setting.Accounts;
|
import org.jackhuang.hmcl.setting.Accounts;
|
||||||
import org.jackhuang.hmcl.setting.ConfigHolder;
|
|
||||||
import org.jackhuang.hmcl.setting.ProxyManager;
|
import org.jackhuang.hmcl.setting.ProxyManager;
|
||||||
import org.jackhuang.hmcl.setting.Settings;
|
import org.jackhuang.hmcl.setting.Settings;
|
||||||
import org.jackhuang.hmcl.task.Schedulers;
|
import org.jackhuang.hmcl.task.Schedulers;
|
||||||
@@ -53,6 +52,7 @@ import org.jackhuang.hmcl.ui.construct.SpinnerPane;
|
|||||||
import org.jackhuang.hmcl.ui.construct.Validator;
|
import org.jackhuang.hmcl.ui.construct.Validator;
|
||||||
import org.jackhuang.hmcl.util.Constants;
|
import org.jackhuang.hmcl.util.Constants;
|
||||||
import org.jackhuang.hmcl.util.Logging;
|
import org.jackhuang.hmcl.util.Logging;
|
||||||
|
import static org.jackhuang.hmcl.setting.ConfigHolder.CONFIG;
|
||||||
import static org.jackhuang.hmcl.ui.FXUtils.jfxListCellFactory;
|
import static org.jackhuang.hmcl.ui.FXUtils.jfxListCellFactory;
|
||||||
import static org.jackhuang.hmcl.ui.FXUtils.onInvalidating;
|
import static org.jackhuang.hmcl.ui.FXUtils.onInvalidating;
|
||||||
import static org.jackhuang.hmcl.ui.FXUtils.stringConverter;
|
import static org.jackhuang.hmcl.ui.FXUtils.stringConverter;
|
||||||
@@ -82,7 +82,7 @@ public class AddAccountPane extends StackPane {
|
|||||||
|
|
||||||
cboServers.setCellFactory(jfxListCellFactory(server -> new TwoLineListItem(server.getName(), server.getUrl())));
|
cboServers.setCellFactory(jfxListCellFactory(server -> new TwoLineListItem(server.getName(), server.getUrl())));
|
||||||
cboServers.setConverter(stringConverter(AuthlibInjectorServer::getName));
|
cboServers.setConverter(stringConverter(AuthlibInjectorServer::getName));
|
||||||
Bindings.bindContent(cboServers.getItems(), ConfigHolder.CONFIG.authlibInjectorServers);
|
Bindings.bindContent(cboServers.getItems(), CONFIG.authlibInjectorServers);
|
||||||
cboServers.getItems().addListener(onInvalidating(this::selectDefaultServer));
|
cboServers.getItems().addListener(onInvalidating(this::selectDefaultServer));
|
||||||
selectDefaultServer();
|
selectDefaultServer();
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.jackhuang.hmcl.auth.authlibinjector.AuthlibInjectorServer;
|
import org.jackhuang.hmcl.auth.authlibinjector.AuthlibInjectorServer;
|
||||||
import org.jackhuang.hmcl.setting.ConfigHolder;
|
|
||||||
import org.jackhuang.hmcl.task.Schedulers;
|
import org.jackhuang.hmcl.task.Schedulers;
|
||||||
import org.jackhuang.hmcl.task.Task;
|
import org.jackhuang.hmcl.task.Task;
|
||||||
import org.jackhuang.hmcl.ui.animation.ContainerAnimations;
|
import org.jackhuang.hmcl.ui.animation.ContainerAnimations;
|
||||||
@@ -40,6 +39,8 @@ import javafx.fxml.FXML;
|
|||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.layout.StackPane;
|
import javafx.scene.layout.StackPane;
|
||||||
|
|
||||||
|
import static org.jackhuang.hmcl.setting.ConfigHolder.CONFIG;
|
||||||
|
|
||||||
public class AddAuthlibInjectorServerPane extends StackPane {
|
public class AddAuthlibInjectorServerPane extends StackPane {
|
||||||
|
|
||||||
@FXML private StackPane addServerContainer;
|
@FXML private StackPane addServerContainer;
|
||||||
@@ -132,8 +133,8 @@ public class AddAuthlibInjectorServerPane extends StackPane {
|
|||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void onAddFinish() {
|
private void onAddFinish() {
|
||||||
if (!ConfigHolder.CONFIG.authlibInjectorServers.contains(serverBeingAdded)) {
|
if (!CONFIG.authlibInjectorServers.contains(serverBeingAdded)) {
|
||||||
ConfigHolder.CONFIG.authlibInjectorServers.add(serverBeingAdded);
|
CONFIG.authlibInjectorServers.add(serverBeingAdded);
|
||||||
}
|
}
|
||||||
fireEvent(new DialogCloseEvent());
|
fireEvent(new DialogCloseEvent());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import static org.jackhuang.hmcl.ui.FXUtils.loadFXML;
|
|||||||
import static org.jackhuang.hmcl.ui.FXUtils.smoothScrolling;
|
import static org.jackhuang.hmcl.ui.FXUtils.smoothScrolling;
|
||||||
import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
|
import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
|
||||||
|
|
||||||
import org.jackhuang.hmcl.setting.ConfigHolder;
|
|
||||||
import org.jackhuang.hmcl.ui.wizard.DecoratorPage;
|
import org.jackhuang.hmcl.ui.wizard.DecoratorPage;
|
||||||
|
|
||||||
import javafx.beans.InvalidationListener;
|
import javafx.beans.InvalidationListener;
|
||||||
@@ -34,6 +33,8 @@ import javafx.scene.control.ScrollPane;
|
|||||||
import javafx.scene.layout.StackPane;
|
import javafx.scene.layout.StackPane;
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
|
|
||||||
|
import static org.jackhuang.hmcl.setting.ConfigHolder.CONFIG;
|
||||||
|
|
||||||
public class AuthlibInjectorServersPage extends StackPane implements DecoratorPage {
|
public class AuthlibInjectorServersPage extends StackPane implements DecoratorPage {
|
||||||
private final StringProperty title = new SimpleStringProperty(this, "title", i18n("account.injector.manage.title"));
|
private final StringProperty title = new SimpleStringProperty(this, "title", i18n("account.injector.manage.title"));
|
||||||
|
|
||||||
@@ -48,15 +49,15 @@ public class AuthlibInjectorServersPage extends StackPane implements DecoratorPa
|
|||||||
smoothScrolling(scrollPane);
|
smoothScrolling(scrollPane);
|
||||||
|
|
||||||
serversListener = observable -> updateServersList();
|
serversListener = observable -> updateServersList();
|
||||||
ConfigHolder.CONFIG.authlibInjectorServers.addListener(new WeakInvalidationListener(serversListener));
|
CONFIG.authlibInjectorServers.addListener(new WeakInvalidationListener(serversListener));
|
||||||
updateServersList();
|
updateServersList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateServersList() {
|
private void updateServersList() {
|
||||||
listPane.getChildren().setAll(
|
listPane.getChildren().setAll(
|
||||||
ConfigHolder.CONFIG.authlibInjectorServers.stream()
|
CONFIG.authlibInjectorServers.stream()
|
||||||
.map(server -> new AuthlibInjectorServerItem(server,
|
.map(server -> new AuthlibInjectorServerItem(server,
|
||||||
item -> ConfigHolder.CONFIG.authlibInjectorServers.remove(item.getServer())))
|
item -> CONFIG.authlibInjectorServers.remove(item.getServer())))
|
||||||
.collect(toList()));
|
.collect(toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ import javafx.stage.StageStyle;
|
|||||||
import javafx.util.Duration;
|
import javafx.util.Duration;
|
||||||
import org.jackhuang.hmcl.Launcher;
|
import org.jackhuang.hmcl.Launcher;
|
||||||
import org.jackhuang.hmcl.auth.authlibinjector.AuthlibInjectorDnD;
|
import org.jackhuang.hmcl.auth.authlibinjector.AuthlibInjectorDnD;
|
||||||
import org.jackhuang.hmcl.setting.ConfigHolder;
|
|
||||||
import org.jackhuang.hmcl.setting.EnumBackgroundImage;
|
import org.jackhuang.hmcl.setting.EnumBackgroundImage;
|
||||||
import org.jackhuang.hmcl.setting.Settings;
|
import org.jackhuang.hmcl.setting.Settings;
|
||||||
import org.jackhuang.hmcl.setting.Theme;
|
import org.jackhuang.hmcl.setting.Theme;
|
||||||
@@ -77,6 +76,8 @@ import java.util.Queue;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
|
|
||||||
|
import static org.jackhuang.hmcl.setting.ConfigHolder.CONFIG;
|
||||||
|
|
||||||
public final class Decorator extends StackPane implements TaskExecutorDialogWizardDisplayer {
|
public final class Decorator extends StackPane implements TaskExecutorDialogWizardDisplayer {
|
||||||
private static final SVGGlyph minus = Lang.apply(new SVGGlyph(0, "MINUS", "M804.571 420.571v109.714q0 22.857-16 38.857t-38.857 16h-694.857q-22.857 0-38.857-16t-16-38.857v-109.714q0-22.857 16-38.857t38.857-16h694.857q22.857 0 38.857 16t16 38.857z", Color.WHITE),
|
private static final SVGGlyph minus = Lang.apply(new SVGGlyph(0, "MINUS", "M804.571 420.571v109.714q0 22.857-16 38.857t-38.857 16h-694.857q-22.857 0-38.857-16t-16-38.857v-109.714q0-22.857 16-38.857t38.857-16h694.857q22.857 0 38.857 16t16 38.857z", Color.WHITE),
|
||||||
glyph -> { glyph.setSize(12, 2); glyph.setTranslateY(4); });
|
glyph -> { glyph.setSize(12, 2); glyph.setTranslateY(4); });
|
||||||
@@ -220,10 +221,10 @@ public final class Decorator extends StackPane implements TaskExecutorDialogWiza
|
|||||||
try {
|
try {
|
||||||
Image background;
|
Image background;
|
||||||
|
|
||||||
if (ConfigHolder.CONFIG.backgroundImageType.get() == EnumBackgroundImage.DEFAULT)
|
if (CONFIG.backgroundImageType.get() == EnumBackgroundImage.DEFAULT)
|
||||||
background = searchBackgroundImage(new Image("/assets/img/background.jpg"), "");
|
background = searchBackgroundImage(new Image("/assets/img/background.jpg"), "");
|
||||||
else
|
else
|
||||||
background = searchBackgroundImage(new Image("/assets/img/background.jpg"), ConfigHolder.CONFIG.backgroundImage.get());
|
background = searchBackgroundImage(new Image("/assets/img/background.jpg"), CONFIG.backgroundImage.get());
|
||||||
|
|
||||||
drawerWrapper.setBackground(new Background(new BackgroundImage(background, BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.DEFAULT, new BackgroundSize(800, 480, false, false, true, true))));
|
drawerWrapper.setBackground(new Background(new BackgroundImage(background, BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.DEFAULT, new BackgroundSize(800, 480, false, false, true, true))));
|
||||||
} catch (IllegalArgumentException ignore) {
|
} catch (IllegalArgumentException ignore) {
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ import org.jackhuang.hmcl.ui.wizard.DecoratorPage;
|
|||||||
import org.jackhuang.hmcl.util.Lang;
|
import org.jackhuang.hmcl.util.Lang;
|
||||||
import org.jackhuang.hmcl.util.i18n.Locales;
|
import org.jackhuang.hmcl.util.i18n.Locales;
|
||||||
|
|
||||||
|
import static org.jackhuang.hmcl.setting.ConfigHolder.CONFIG;
|
||||||
import static org.jackhuang.hmcl.ui.FXUtils.onInvalidating;
|
import static org.jackhuang.hmcl.ui.FXUtils.onInvalidating;
|
||||||
import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
|
import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
|
||||||
|
|
||||||
@@ -105,10 +106,10 @@ public final class SettingsPage extends StackPane implements DecoratorPage {
|
|||||||
|
|
||||||
FXUtils.smoothScrolling(scroll);
|
FXUtils.smoothScrolling(scroll);
|
||||||
|
|
||||||
txtProxyHost.textProperty().bindBidirectional(ConfigHolder.CONFIG.proxyHost);
|
txtProxyHost.textProperty().bindBidirectional(CONFIG.proxyHost);
|
||||||
txtProxyPort.textProperty().bindBidirectional(ConfigHolder.CONFIG.proxyPort);
|
txtProxyPort.textProperty().bindBidirectional(CONFIG.proxyPort);
|
||||||
txtProxyUsername.textProperty().bindBidirectional(ConfigHolder.CONFIG.proxyUser);
|
txtProxyUsername.textProperty().bindBidirectional(CONFIG.proxyUser);
|
||||||
txtProxyPassword.textProperty().bindBidirectional(ConfigHolder.CONFIG.proxyPass);
|
txtProxyPassword.textProperty().bindBidirectional(CONFIG.proxyPass);
|
||||||
|
|
||||||
cboDownloadSource.getSelectionModel().select(DownloadProviders.DOWNLOAD_PROVIDERS.indexOf(Settings.INSTANCE.getDownloadProvider()));
|
cboDownloadSource.getSelectionModel().select(DownloadProviders.DOWNLOAD_PROVIDERS.indexOf(Settings.INSTANCE.getDownloadProvider()));
|
||||||
cboDownloadSource.getSelectionModel().selectedIndexProperty().addListener((a, b, newValue) -> Settings.INSTANCE.setDownloadProvider(DownloadProviders.getDownloadProvider(newValue.intValue())));
|
cboDownloadSource.getSelectionModel().selectedIndexProperty().addListener((a, b, newValue) -> Settings.INSTANCE.setDownloadProvider(DownloadProviders.getDownloadProvider(newValue.intValue())));
|
||||||
@@ -148,28 +149,28 @@ public final class SettingsPage extends StackPane implements DecoratorPage {
|
|||||||
chkProxySocks.setToggleGroup(proxyConfigurationGroup);
|
chkProxySocks.setToggleGroup(proxyConfigurationGroup);
|
||||||
|
|
||||||
for (Toggle toggle : proxyConfigurationGroup.getToggles())
|
for (Toggle toggle : proxyConfigurationGroup.getToggles())
|
||||||
if (toggle.getUserData() == ConfigHolder.CONFIG.proxyType.get())
|
if (toggle.getUserData() == CONFIG.proxyType.get())
|
||||||
toggle.setSelected(true);
|
toggle.setSelected(true);
|
||||||
|
|
||||||
ToggleGroup hasProxyGroup = new ToggleGroup();
|
ToggleGroup hasProxyGroup = new ToggleGroup();
|
||||||
chkNoProxy.setToggleGroup(hasProxyGroup);
|
chkNoProxy.setToggleGroup(hasProxyGroup);
|
||||||
chkManualProxy.setToggleGroup(hasProxyGroup);
|
chkManualProxy.setToggleGroup(hasProxyGroup);
|
||||||
if (!ConfigHolder.CONFIG.hasProxy.get())
|
if (!CONFIG.hasProxy.get())
|
||||||
chkNoProxy.setSelected(true);
|
chkNoProxy.setSelected(true);
|
||||||
else
|
else
|
||||||
chkManualProxy.setSelected(true);
|
chkManualProxy.setSelected(true);
|
||||||
proxyPane.disableProperty().bind(chkNoProxy.selectedProperty());
|
proxyPane.disableProperty().bind(chkNoProxy.selectedProperty());
|
||||||
|
|
||||||
hasProxyGroup.selectedToggleProperty().addListener((a, b, newValue) ->
|
hasProxyGroup.selectedToggleProperty().addListener((a, b, newValue) ->
|
||||||
ConfigHolder.CONFIG.hasProxy.set(newValue != chkNoProxy));
|
CONFIG.hasProxy.set(newValue != chkNoProxy));
|
||||||
|
|
||||||
proxyConfigurationGroup.selectedToggleProperty().addListener((a, b, newValue) ->
|
proxyConfigurationGroup.selectedToggleProperty().addListener((a, b, newValue) ->
|
||||||
ConfigHolder.CONFIG.proxyType.set((Proxy.Type) newValue.getUserData()));
|
CONFIG.proxyType.set((Proxy.Type) newValue.getUserData()));
|
||||||
|
|
||||||
chkProxyAuthentication.selectedProperty().bindBidirectional(ConfigHolder.CONFIG.hasProxyAuth);
|
chkProxyAuthentication.selectedProperty().bindBidirectional(CONFIG.hasProxyAuth);
|
||||||
authPane.disableProperty().bind(chkProxyAuthentication.selectedProperty().not());
|
authPane.disableProperty().bind(chkProxyAuthentication.selectedProperty().not());
|
||||||
|
|
||||||
fileCommonLocation.pathProperty().bindBidirectional(ConfigHolder.CONFIG.commonDirectory);
|
fileCommonLocation.pathProperty().bindBidirectional(CONFIG.commonDirectory);
|
||||||
|
|
||||||
FXUtils.installTooltip(btnUpdate, i18n("update.tooltip"));
|
FXUtils.installTooltip(btnUpdate, i18n("update.tooltip"));
|
||||||
checkUpdate();
|
checkUpdate();
|
||||||
@@ -179,17 +180,17 @@ public final class SettingsPage extends StackPane implements DecoratorPage {
|
|||||||
backgroundItem.createChildren(i18n("launcher.background.default"), EnumBackgroundImage.DEFAULT)
|
backgroundItem.createChildren(i18n("launcher.background.default"), EnumBackgroundImage.DEFAULT)
|
||||||
));
|
));
|
||||||
|
|
||||||
FXUtils.bindString(backgroundItem.getTxtCustom(), ConfigHolder.CONFIG.backgroundImage);
|
FXUtils.bindString(backgroundItem.getTxtCustom(), CONFIG.backgroundImage);
|
||||||
|
|
||||||
backgroundItem.setCustomUserData(EnumBackgroundImage.CUSTOM);
|
backgroundItem.setCustomUserData(EnumBackgroundImage.CUSTOM);
|
||||||
backgroundItem.getGroup().getToggles().stream().filter(it -> it.getUserData() == ConfigHolder.CONFIG.backgroundImageType.get()).findFirst().ifPresent(it -> it.setSelected(true));
|
backgroundItem.getGroup().getToggles().stream().filter(it -> it.getUserData() == CONFIG.backgroundImageType.get()).findFirst().ifPresent(it -> it.setSelected(true));
|
||||||
|
|
||||||
ConfigHolder.CONFIG.backgroundImage.addListener(onInvalidating(this::initBackgroundItemSubtitle));
|
CONFIG.backgroundImage.addListener(onInvalidating(this::initBackgroundItemSubtitle));
|
||||||
ConfigHolder.CONFIG.backgroundImageType.addListener(onInvalidating(this::initBackgroundItemSubtitle));
|
CONFIG.backgroundImageType.addListener(onInvalidating(this::initBackgroundItemSubtitle));
|
||||||
initBackgroundItemSubtitle();
|
initBackgroundItemSubtitle();
|
||||||
|
|
||||||
backgroundItem.setToggleSelectedListener(newValue ->
|
backgroundItem.setToggleSelectedListener(newValue ->
|
||||||
ConfigHolder.CONFIG.backgroundImageType.set((EnumBackgroundImage) newValue.getUserData()));
|
CONFIG.backgroundImageType.set((EnumBackgroundImage) newValue.getUserData()));
|
||||||
|
|
||||||
// theme
|
// theme
|
||||||
JFXColorPicker picker = new JFXColorPicker(Color.web(Settings.INSTANCE.getTheme().getColor()), null);
|
JFXColorPicker picker = new JFXColorPicker(Color.web(Settings.INSTANCE.getTheme().getColor()), null);
|
||||||
@@ -206,12 +207,12 @@ public final class SettingsPage extends StackPane implements DecoratorPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initBackgroundItemSubtitle() {
|
private void initBackgroundItemSubtitle() {
|
||||||
switch (ConfigHolder.CONFIG.backgroundImageType.get()) {
|
switch (CONFIG.backgroundImageType.get()) {
|
||||||
case DEFAULT:
|
case DEFAULT:
|
||||||
backgroundItem.setSubtitle(i18n("launcher.background.default"));
|
backgroundItem.setSubtitle(i18n("launcher.background.default"));
|
||||||
break;
|
break;
|
||||||
case CUSTOM:
|
case CUSTOM:
|
||||||
backgroundItem.setSubtitle(ConfigHolder.CONFIG.backgroundImage.get());
|
backgroundItem.setSubtitle(CONFIG.backgroundImage.get());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user