Use static import for ConfigHolder.CONFIG

This commit is contained in:
yushijinhun
2018-07-17 23:12:46 +08:00
parent ea6108dca7
commit 8236f613e0
11 changed files with 90 additions and 78 deletions

View File

@@ -17,7 +17,6 @@
*/
package org.jackhuang.hmcl.game;
import org.jackhuang.hmcl.setting.ConfigHolder;
import org.jackhuang.hmcl.setting.Profile;
import org.jackhuang.hmcl.task.FileDownloadTask;
import org.jackhuang.hmcl.task.FileDownloadTask.IntegrityCheck;
@@ -32,6 +31,8 @@ import java.util.LinkedList;
import java.util.List;
import java.util.logging.Level;
import static org.jackhuang.hmcl.setting.ConfigHolder.CONFIG;
/**
* @author huangyuhui
*/
@@ -58,7 +59,7 @@ public class HMCLGameDownloadTask extends Task {
public void execute() {
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())
try {
FileUtils.copyFile(cache, jar);

View File

@@ -22,7 +22,6 @@ import com.google.gson.GsonBuilder;
import org.jackhuang.hmcl.event.EventBus;
import org.jackhuang.hmcl.event.RefreshedVersionsEvent;
import org.jackhuang.hmcl.event.RefreshingVersionsEvent;
import org.jackhuang.hmcl.setting.ConfigHolder;
import org.jackhuang.hmcl.setting.EnumGameDirectory;
import org.jackhuang.hmcl.setting.Profile;
import org.jackhuang.hmcl.setting.VersionSetting;
@@ -34,6 +33,8 @@ import java.io.IOException;
import java.util.*;
import java.util.logging.Level;
import static org.jackhuang.hmcl.setting.ConfigHolder.CONFIG;
public class HMCLGameRepository extends DefaultGameRepository {
private final Profile profile;
private final Map<String, VersionSetting> versionSettings = new HashMap<>();
@@ -60,7 +61,7 @@ public class HMCLGameRepository extends DefaultGameRepository {
if (useSelf(version, assetId))
return super.getAssetDirectory(version, assetId);
else
return new File(ConfigHolder.CONFIG.commonDirectory.get(), "assets");
return new File(CONFIG.commonDirectory.get(), "assets");
}
@Override
@@ -85,7 +86,7 @@ public class HMCLGameRepository extends DefaultGameRepository {
if (self.exists() || vs.isNoCommon())
return self;
else
return new File(ConfigHolder.CONFIG.commonDirectory.get(), "libraries/" + lib.getPath());
return new File(CONFIG.commonDirectory.get(), "libraries/" + lib.getPath());
}

View File

@@ -33,6 +33,7 @@ import java.io.IOException;
import java.util.Map;
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.Logging.LOG;
import static org.jackhuang.hmcl.util.Pair.pair;
@@ -71,7 +72,7 @@ public final class Accounts {
}
private static AuthlibInjectorServer getOrCreateAuthlibInjectorServer(String url) {
return ConfigHolder.CONFIG.authlibInjectorServers.stream()
return CONFIG.authlibInjectorServers.stream()
.filter(server -> url.equals(server.getUrl()))
.findFirst()
.orElseGet(() -> {
@@ -85,7 +86,7 @@ public final class Accounts {
LOG.log(Level.WARNING, "Failed to migrate authlib injector server " + url, e);
}
ConfigHolder.CONFIG.authlibInjectorServers.add(server);
CONFIG.authlibInjectorServers.add(server);
return server;
});
}

View File

@@ -17,6 +17,8 @@
*/
package org.jackhuang.hmcl.setting;
import static org.jackhuang.hmcl.setting.ConfigHolder.CONFIG;
import java.net.Authenticator;
import java.net.InetSocketAddress;
import java.net.PasswordAuthentication;
@@ -35,18 +37,18 @@ public final class ProxyManager {
public static final ObjectBinding<Proxy> proxyProperty = Bindings.createObjectBinding(
() -> {
String host = ConfigHolder.CONFIG.proxyHost.get();
Integer port = Lang.toIntOrNull(ConfigHolder.CONFIG.proxyPort.get());
if (!ConfigHolder.CONFIG.hasProxy.get() || StringUtils.isBlank(host) || port == null || ConfigHolder.CONFIG.proxyType.get() == Proxy.Type.DIRECT) {
String host = CONFIG.proxyHost.get();
Integer port = Lang.toIntOrNull(CONFIG.proxyPort.get());
if (!CONFIG.hasProxy.get() || StringUtils.isBlank(host) || port == null || CONFIG.proxyType.get() == Proxy.Type.DIRECT) {
return Proxy.NO_PROXY;
} 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,
ConfigHolder.CONFIG.proxyHost,
ConfigHolder.CONFIG.proxyPort,
ConfigHolder.CONFIG.hasProxy);
CONFIG.proxyType,
CONFIG.proxyHost,
CONFIG.proxyPort,
CONFIG.hasProxy);
public static Proxy getProxy() {
return proxyProperty.get();
@@ -65,9 +67,9 @@ public final class ProxyManager {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
if (ConfigHolder.CONFIG.hasProxyAuth.get()) {
String username = ConfigHolder.CONFIG.proxyUser.get();
String password = ConfigHolder.CONFIG.proxyPass.get();
if (CONFIG.hasProxyAuth.get()) {
String username = CONFIG.proxyUser.get();
String password = CONFIG.proxyPass.get();
if (username != null && password != null) {
return new PasswordAuthentication(username, password.toCharArray());
}

View File

@@ -39,6 +39,7 @@ import java.util.logging.Level;
import java.util.stream.Collectors;
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.util.Lang.tryCast;
import static org.jackhuang.hmcl.util.Logging.LOG;
@@ -52,7 +53,7 @@ public class Settings {
private final boolean firstLaunch;
private InvalidationListener accountChangeListener =
source -> ConfigHolder.CONFIG.accounts.setAll(
source -> CONFIG.accounts.setAll(
accounts.values().stream()
.map(account -> {
Map<Object, Object> storage = account.toStorage();
@@ -62,12 +63,12 @@ public class Settings {
.collect(toList()));
private Settings() {
firstLaunch = ConfigHolder.CONFIG.firstLaunch.get();
ConfigHolder.CONFIG.firstLaunch.set(false);
firstLaunch = CONFIG.firstLaunch.get();
CONFIG.firstLaunch.set(false);
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();
AccountFactory<?> factory = Accounts.ACCOUNT_FACTORY.get(tryCast(settings.get("type"), String.class).orElse(""));
if (factory == null) {
@@ -89,9 +90,9 @@ public class Settings {
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();
@@ -105,18 +106,18 @@ public class Settings {
Lang.ignoringException(() -> Runtime.getRuntime().addShutdownHook(new Thread(this::save)));
ConfigHolder.CONFIG.addListener(source -> save());
CONFIG.addListener(source -> save());
}
private void save() {
ConfigHolder.saveConfig(ConfigHolder.CONFIG);
ConfigHolder.saveConfig(CONFIG);
}
public boolean isFirstLaunch() {
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() {
return locale;
@@ -124,24 +125,24 @@ public class Settings {
public void setLocale(Locales.SupportedLocale locale) {
this.locale = locale;
ConfigHolder.CONFIG.localization.set(Locales.getNameByLocale(locale));
CONFIG.localization.set(Locales.getNameByLocale(locale));
}
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) {
ConfigHolder.CONFIG.fontFamily.set(font.getFamily());
ConfigHolder.CONFIG.fontSize.set(font.getSize());
CONFIG.fontFamily.set(font.getFamily());
CONFIG.fontSize.set(font.getSize());
}
public int getLogLines() {
return Math.max(ConfigHolder.CONFIG.logLines.get(), 100);
return Math.max(CONFIG.logLines.get(), 100);
}
public void setLogLines(int logLines) {
ConfigHolder.CONFIG.logLines.set(logLines);
CONFIG.logLines.set(logLines);
}
/****************************************
@@ -156,7 +157,7 @@ public class Settings {
private void removeDanglingAuthlibInjectorAccounts() {
accounts.values().stream()
.filter(AuthlibInjectorAccount.class::isInstance)
.filter(it -> !ConfigHolder.CONFIG.authlibInjectorServers.contains(((AuthlibInjectorAccount) it).getServer()))
.filter(it -> !CONFIG.authlibInjectorServers.contains(((AuthlibInjectorAccount) it).getServer()))
.collect(toList())
.forEach(this::deleteAccount);
}
@@ -166,14 +167,14 @@ public class Settings {
****************************************/
public DownloadProvider getDownloadProvider() {
return DownloadProviders.getDownloadProvider(ConfigHolder.CONFIG.downloadType.get());
return DownloadProviders.getDownloadProvider(CONFIG.downloadType.get());
}
public void setDownloadProvider(DownloadProvider downloadProvider) {
int index = DownloadProviders.DOWNLOAD_PROVIDERS.indexOf(downloadProvider);
if (index == -1)
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() {
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 *
****************************************/
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
public void 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() {
checkProfileMap();
if (!hasProfile(ConfigHolder.CONFIG.selectedProfile.get())) {
if (!hasProfile(CONFIG.selectedProfile.get())) {
getProfileMap().keySet().stream().findFirst().ifPresent(selectedProfile -> {
ConfigHolder.CONFIG.selectedProfile.set(selectedProfile);
CONFIG.selectedProfile.set(selectedProfile);
});
Schedulers.computation().schedule(this::onProfileChanged);
}
return getProfile(ConfigHolder.CONFIG.selectedProfile.get());
return getProfile(CONFIG.selectedProfile.get());
}
public void setSelectedProfile(Profile selectedProfile) {
if (hasProfile(selectedProfile.getName()) && !Objects.equals(selectedProfile.getName(), ConfigHolder.CONFIG.selectedProfile.get())) {
ConfigHolder.CONFIG.selectedProfile.set(selectedProfile.getName());
if (hasProfile(selectedProfile.getName()) && !Objects.equals(selectedProfile.getName(), CONFIG.selectedProfile.get())) {
CONFIG.selectedProfile.set(selectedProfile.getName());
Schedulers.computation().schedule(this::onProfileChanged);
}
}
@@ -316,7 +317,7 @@ public class Settings {
}
public Map<String, Profile> getProfileMap() {
return ConfigHolder.CONFIG.configurations;
return CONFIG.configurations;
}
public Collection<Profile> getProfiles() {

View File

@@ -30,6 +30,8 @@ import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import static org.jackhuang.hmcl.setting.ConfigHolder.CONFIG;
/**
*
* @author huangyuhui
@@ -517,10 +519,10 @@ public final class VersionSetting {
.setFullscreen(isFullscreen())
.setServerIp(getServerIp())
.setWrapper(getWrapper())
.setProxyHost(ConfigHolder.CONFIG.proxyHost.get())
.setProxyPort(ConfigHolder.CONFIG.proxyPort.get())
.setProxyUser(ConfigHolder.CONFIG.proxyUser.get())
.setProxyPass(ConfigHolder.CONFIG.proxyPass.get())
.setProxyHost(CONFIG.proxyHost.get())
.setProxyPort(CONFIG.proxyPort.get())
.setProxyUser(CONFIG.proxyUser.get())
.setProxyPass(CONFIG.proxyPass.get())
.setPrecalledCommand(getPreLaunchCommand())
.setNoGeneratedJVMArgs(isNoJVMArgs())
.create();

View File

@@ -41,7 +41,6 @@ import org.jackhuang.hmcl.auth.yggdrasil.RemoteAuthenticationException;
import org.jackhuang.hmcl.auth.yggdrasil.YggdrasilAccount;
import org.jackhuang.hmcl.game.AccountHelper;
import org.jackhuang.hmcl.setting.Accounts;
import org.jackhuang.hmcl.setting.ConfigHolder;
import org.jackhuang.hmcl.setting.ProxyManager;
import org.jackhuang.hmcl.setting.Settings;
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.util.Constants;
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.onInvalidating;
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.setConverter(stringConverter(AuthlibInjectorServer::getName));
Bindings.bindContent(cboServers.getItems(), ConfigHolder.CONFIG.authlibInjectorServers);
Bindings.bindContent(cboServers.getItems(), CONFIG.authlibInjectorServers);
cboServers.getItems().addListener(onInvalidating(this::selectDefaultServer));
selectDefaultServer();

View File

@@ -22,7 +22,6 @@ import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
import java.io.IOException;
import org.jackhuang.hmcl.auth.authlibinjector.AuthlibInjectorServer;
import org.jackhuang.hmcl.setting.ConfigHolder;
import org.jackhuang.hmcl.task.Schedulers;
import org.jackhuang.hmcl.task.Task;
import org.jackhuang.hmcl.ui.animation.ContainerAnimations;
@@ -40,6 +39,8 @@ import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import static org.jackhuang.hmcl.setting.ConfigHolder.CONFIG;
public class AddAuthlibInjectorServerPane extends StackPane {
@FXML private StackPane addServerContainer;
@@ -132,8 +133,8 @@ public class AddAuthlibInjectorServerPane extends StackPane {
@FXML
private void onAddFinish() {
if (!ConfigHolder.CONFIG.authlibInjectorServers.contains(serverBeingAdded)) {
ConfigHolder.CONFIG.authlibInjectorServers.add(serverBeingAdded);
if (!CONFIG.authlibInjectorServers.contains(serverBeingAdded)) {
CONFIG.authlibInjectorServers.add(serverBeingAdded);
}
fireEvent(new DialogCloseEvent());
}

View File

@@ -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.util.i18n.I18n.i18n;
import org.jackhuang.hmcl.setting.ConfigHolder;
import org.jackhuang.hmcl.ui.wizard.DecoratorPage;
import javafx.beans.InvalidationListener;
@@ -34,6 +33,8 @@ import javafx.scene.control.ScrollPane;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import static org.jackhuang.hmcl.setting.ConfigHolder.CONFIG;
public class AuthlibInjectorServersPage extends StackPane implements DecoratorPage {
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);
serversListener = observable -> updateServersList();
ConfigHolder.CONFIG.authlibInjectorServers.addListener(new WeakInvalidationListener(serversListener));
CONFIG.authlibInjectorServers.addListener(new WeakInvalidationListener(serversListener));
updateServersList();
}
private void updateServersList() {
listPane.getChildren().setAll(
ConfigHolder.CONFIG.authlibInjectorServers.stream()
CONFIG.authlibInjectorServers.stream()
.map(server -> new AuthlibInjectorServerItem(server,
item -> ConfigHolder.CONFIG.authlibInjectorServers.remove(item.getServer())))
item -> CONFIG.authlibInjectorServers.remove(item.getServer())))
.collect(toList()));
}

View File

@@ -55,7 +55,6 @@ import javafx.stage.StageStyle;
import javafx.util.Duration;
import org.jackhuang.hmcl.Launcher;
import org.jackhuang.hmcl.auth.authlibinjector.AuthlibInjectorDnD;
import org.jackhuang.hmcl.setting.ConfigHolder;
import org.jackhuang.hmcl.setting.EnumBackgroundImage;
import org.jackhuang.hmcl.setting.Settings;
import org.jackhuang.hmcl.setting.Theme;
@@ -77,6 +76,8 @@ import java.util.Queue;
import java.util.Random;
import java.util.concurrent.ConcurrentLinkedQueue;
import static org.jackhuang.hmcl.setting.ConfigHolder.CONFIG;
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),
glyph -> { glyph.setSize(12, 2); glyph.setTranslateY(4); });
@@ -220,10 +221,10 @@ public final class Decorator extends StackPane implements TaskExecutorDialogWiza
try {
Image background;
if (ConfigHolder.CONFIG.backgroundImageType.get() == EnumBackgroundImage.DEFAULT)
if (CONFIG.backgroundImageType.get() == EnumBackgroundImage.DEFAULT)
background = searchBackgroundImage(new Image("/assets/img/background.jpg"), "");
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))));
} catch (IllegalArgumentException ignore) {

View File

@@ -44,6 +44,7 @@ import org.jackhuang.hmcl.ui.wizard.DecoratorPage;
import org.jackhuang.hmcl.util.Lang;
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.util.i18n.I18n.i18n;
@@ -105,10 +106,10 @@ public final class SettingsPage extends StackPane implements DecoratorPage {
FXUtils.smoothScrolling(scroll);
txtProxyHost.textProperty().bindBidirectional(ConfigHolder.CONFIG.proxyHost);
txtProxyPort.textProperty().bindBidirectional(ConfigHolder.CONFIG.proxyPort);
txtProxyUsername.textProperty().bindBidirectional(ConfigHolder.CONFIG.proxyUser);
txtProxyPassword.textProperty().bindBidirectional(ConfigHolder.CONFIG.proxyPass);
txtProxyHost.textProperty().bindBidirectional(CONFIG.proxyHost);
txtProxyPort.textProperty().bindBidirectional(CONFIG.proxyPort);
txtProxyUsername.textProperty().bindBidirectional(CONFIG.proxyUser);
txtProxyPassword.textProperty().bindBidirectional(CONFIG.proxyPass);
cboDownloadSource.getSelectionModel().select(DownloadProviders.DOWNLOAD_PROVIDERS.indexOf(Settings.INSTANCE.getDownloadProvider()));
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);
for (Toggle toggle : proxyConfigurationGroup.getToggles())
if (toggle.getUserData() == ConfigHolder.CONFIG.proxyType.get())
if (toggle.getUserData() == CONFIG.proxyType.get())
toggle.setSelected(true);
ToggleGroup hasProxyGroup = new ToggleGroup();
chkNoProxy.setToggleGroup(hasProxyGroup);
chkManualProxy.setToggleGroup(hasProxyGroup);
if (!ConfigHolder.CONFIG.hasProxy.get())
if (!CONFIG.hasProxy.get())
chkNoProxy.setSelected(true);
else
chkManualProxy.setSelected(true);
proxyPane.disableProperty().bind(chkNoProxy.selectedProperty());
hasProxyGroup.selectedToggleProperty().addListener((a, b, newValue) ->
ConfigHolder.CONFIG.hasProxy.set(newValue != chkNoProxy));
CONFIG.hasProxy.set(newValue != chkNoProxy));
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());
fileCommonLocation.pathProperty().bindBidirectional(ConfigHolder.CONFIG.commonDirectory);
fileCommonLocation.pathProperty().bindBidirectional(CONFIG.commonDirectory);
FXUtils.installTooltip(btnUpdate, i18n("update.tooltip"));
checkUpdate();
@@ -179,17 +180,17 @@ public final class SettingsPage extends StackPane implements DecoratorPage {
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.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));
ConfigHolder.CONFIG.backgroundImageType.addListener(onInvalidating(this::initBackgroundItemSubtitle));
CONFIG.backgroundImage.addListener(onInvalidating(this::initBackgroundItemSubtitle));
CONFIG.backgroundImageType.addListener(onInvalidating(this::initBackgroundItemSubtitle));
initBackgroundItemSubtitle();
backgroundItem.setToggleSelectedListener(newValue ->
ConfigHolder.CONFIG.backgroundImageType.set((EnumBackgroundImage) newValue.getUserData()));
CONFIG.backgroundImageType.set((EnumBackgroundImage) newValue.getUserData()));
// theme
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() {
switch (ConfigHolder.CONFIG.backgroundImageType.get()) {
switch (CONFIG.backgroundImageType.get()) {
case DEFAULT:
backgroundItem.setSubtitle(i18n("launcher.background.default"));
break;
case CUSTOM:
backgroundItem.setSubtitle(ConfigHolder.CONFIG.backgroundImage.get());
backgroundItem.setSubtitle(CONFIG.backgroundImage.get());
break;
}
}