mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-19 08:46:09 -04:00
将Config中属性替换为JavaFX Property
This commit is contained in:
parent
61db6b8fb2
commit
d875eeb22a
@ -17,256 +17,92 @@
|
|||||||
*/
|
*/
|
||||||
package org.jackhuang.hmcl.setting;
|
package org.jackhuang.hmcl.setting;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import java.util.HashSet;
|
||||||
import org.jackhuang.hmcl.Launcher;
|
import java.util.Map;
|
||||||
import org.jackhuang.hmcl.util.JavaVersion;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
import java.util.*;
|
import org.jackhuang.hmcl.Launcher;
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
import javafx.beans.property.BooleanProperty;
|
||||||
|
import javafx.beans.property.DoubleProperty;
|
||||||
|
import javafx.beans.property.IntegerProperty;
|
||||||
|
import javafx.beans.property.SimpleBooleanProperty;
|
||||||
|
import javafx.beans.property.SimpleDoubleProperty;
|
||||||
|
import javafx.beans.property.SimpleIntegerProperty;
|
||||||
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
|
import javafx.beans.property.StringProperty;
|
||||||
|
import javafx.collections.FXCollections;
|
||||||
|
import javafx.collections.ObservableList;
|
||||||
|
import javafx.collections.ObservableMap;
|
||||||
|
import javafx.collections.ObservableSet;
|
||||||
|
|
||||||
public final class Config implements Cloneable {
|
public final class Config implements Cloneable {
|
||||||
|
|
||||||
@SerializedName("last")
|
@SerializedName("last")
|
||||||
private String selectedProfile = "";
|
public final StringProperty selectedProfile = new SimpleStringProperty("");
|
||||||
|
|
||||||
@SerializedName("backgroundType")
|
@SerializedName("backgroundType")
|
||||||
private int backgroundImageType = 0;
|
public final IntegerProperty backgroundImageType = new SimpleIntegerProperty(0);
|
||||||
|
|
||||||
@SerializedName("bgpath")
|
@SerializedName("bgpath")
|
||||||
private String backgroundImage = null;
|
public final StringProperty backgroundImage = new SimpleStringProperty();
|
||||||
|
|
||||||
@SerializedName("commonpath")
|
@SerializedName("commonpath")
|
||||||
private String commonDirectory = Launcher.MINECRAFT_DIRECTORY.getAbsolutePath();
|
public final StringProperty commonDirectory = new SimpleStringProperty(Launcher.MINECRAFT_DIRECTORY.getAbsolutePath());
|
||||||
|
|
||||||
@SerializedName("hasProxy")
|
@SerializedName("hasProxy")
|
||||||
private boolean hasProxy = false;
|
public final BooleanProperty hasProxy = new SimpleBooleanProperty();
|
||||||
|
|
||||||
@SerializedName("hasProxyAuth")
|
@SerializedName("hasProxyAuth")
|
||||||
private boolean hasProxyAuth = false;
|
public final BooleanProperty hasProxyAuth = new SimpleBooleanProperty();
|
||||||
|
|
||||||
@SerializedName("proxyType")
|
@SerializedName("proxyType")
|
||||||
private int proxyType = 0;
|
public final IntegerProperty proxyType = new SimpleIntegerProperty();
|
||||||
|
|
||||||
@SerializedName("proxyHost")
|
@SerializedName("proxyHost")
|
||||||
private String proxyHost = null;
|
public final StringProperty proxyHost = new SimpleStringProperty();
|
||||||
|
|
||||||
@SerializedName("proxyPort")
|
@SerializedName("proxyPort")
|
||||||
private String proxyPort = null;
|
public final StringProperty proxyPort = new SimpleStringProperty();
|
||||||
|
|
||||||
@SerializedName("proxyUserName")
|
@SerializedName("proxyUserName")
|
||||||
private String proxyUser = null;
|
public final StringProperty proxyUser = new SimpleStringProperty();
|
||||||
|
|
||||||
@SerializedName("proxyPassword")
|
@SerializedName("proxyPassword")
|
||||||
private String proxyPass = null;
|
public final StringProperty proxyPass = new SimpleStringProperty();
|
||||||
|
|
||||||
@SerializedName("theme")
|
@SerializedName("theme")
|
||||||
private String theme = null;
|
public final StringProperty theme = new SimpleStringProperty();
|
||||||
|
|
||||||
@SerializedName("java")
|
|
||||||
private List<JavaVersion> java = null;
|
|
||||||
|
|
||||||
@SerializedName("localization")
|
@SerializedName("localization")
|
||||||
private String localization;
|
public final StringProperty localization = new SimpleStringProperty();
|
||||||
|
|
||||||
@SerializedName("downloadtype")
|
@SerializedName("downloadtype")
|
||||||
private int downloadType = 0;
|
public final IntegerProperty downloadType = new SimpleIntegerProperty();
|
||||||
|
|
||||||
@SerializedName("configurations")
|
@SerializedName("configurations")
|
||||||
private Map<String, Profile> configurations = new TreeMap<>();
|
public final ObservableMap<String, Profile> configurations = FXCollections.observableMap(new TreeMap<>());
|
||||||
|
|
||||||
@SerializedName("accounts")
|
@SerializedName("accounts")
|
||||||
private List<Map<Object, Object>> accounts = new LinkedList<>();
|
public final ObservableList<Map<Object, Object>> accounts = FXCollections.observableArrayList();
|
||||||
|
|
||||||
@SerializedName("selectedAccount")
|
@SerializedName("selectedAccount")
|
||||||
private String selectedAccount = "";
|
public final StringProperty selectedAccount = new SimpleStringProperty("");
|
||||||
|
|
||||||
@SerializedName("fontFamily")
|
@SerializedName("fontFamily")
|
||||||
private String fontFamily = "Consolas";
|
public final StringProperty fontFamily = new SimpleStringProperty("Consolas");
|
||||||
|
|
||||||
@SerializedName("fontSize")
|
@SerializedName("fontSize")
|
||||||
private double fontSize = 12;
|
public final DoubleProperty fontSize = new SimpleDoubleProperty(12);
|
||||||
|
|
||||||
@SerializedName("logLines")
|
@SerializedName("logLines")
|
||||||
private int logLines = 100;
|
public final IntegerProperty logLines = new SimpleIntegerProperty(100);
|
||||||
|
|
||||||
@SerializedName("authlibInjectorServerURLs")
|
@SerializedName("authlibInjectorServerURLs")
|
||||||
private Set<String> authlibInjectorServerURLs = new HashSet<>();
|
public final ObservableSet<String> authlibInjectorServerURLs = FXCollections.observableSet(new HashSet<>());
|
||||||
|
|
||||||
public String getSelectedProfile() {
|
|
||||||
return selectedProfile;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSelectedProfile(String selectedProfile) {
|
|
||||||
this.selectedProfile = selectedProfile;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getBackgroundImage() {
|
|
||||||
return backgroundImage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBackgroundImage(String backgroundImage) {
|
|
||||||
this.backgroundImage = backgroundImage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getBackgroundImageType() {
|
|
||||||
return backgroundImageType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBackgroundImageType(int backgroundImageType) {
|
|
||||||
this.backgroundImageType = backgroundImageType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCommonDirectory() {
|
|
||||||
return commonDirectory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCommonDirectory(String commonDirectory) {
|
|
||||||
this.commonDirectory = commonDirectory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isHasProxy() {
|
|
||||||
return hasProxy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHasProxy(boolean hasProxy) {
|
|
||||||
this.hasProxy = hasProxy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isHasProxyAuth() {
|
|
||||||
return hasProxyAuth;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHasProxyAuth(boolean hasProxyAuth) {
|
|
||||||
this.hasProxyAuth = hasProxyAuth;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getProxyType() {
|
|
||||||
return proxyType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProxyType(int proxyType) {
|
|
||||||
this.proxyType = proxyType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getProxyHost() {
|
|
||||||
return proxyHost;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProxyHost(String proxyHost) {
|
|
||||||
this.proxyHost = proxyHost;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getProxyPort() {
|
|
||||||
return proxyPort;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProxyPort(String proxyPort) {
|
|
||||||
this.proxyPort = proxyPort;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getProxyUser() {
|
|
||||||
return proxyUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProxyUser(String proxyUser) {
|
|
||||||
this.proxyUser = proxyUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getProxyPass() {
|
|
||||||
return proxyPass;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProxyPass(String proxyPass) {
|
|
||||||
this.proxyPass = proxyPass;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTheme() {
|
|
||||||
return theme;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTheme(String theme) {
|
|
||||||
this.theme = theme;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<JavaVersion> getJava() {
|
|
||||||
return java;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setJava(List<JavaVersion> java) {
|
|
||||||
this.java = java;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLocalization() {
|
|
||||||
return localization;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLocalization(String localization) {
|
|
||||||
this.localization = localization;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getDownloadType() {
|
|
||||||
return downloadType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDownloadType(int downloadType) {
|
|
||||||
this.downloadType = downloadType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, Profile> getConfigurations() {
|
|
||||||
return configurations;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setConfigurations(Map<String, Profile> configurations) {
|
|
||||||
this.configurations = configurations;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Map<Object, Object>> getAccounts() {
|
|
||||||
return accounts;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAccounts(List<Map<Object, Object>> accounts) {
|
|
||||||
this.accounts = accounts;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSelectedAccount() {
|
|
||||||
return selectedAccount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSelectedAccount(String selectedAccount) {
|
|
||||||
this.selectedAccount = selectedAccount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFontFamily() {
|
|
||||||
return fontFamily;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFontFamily(String fontFamily) {
|
|
||||||
this.fontFamily = fontFamily;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getFontSize() {
|
|
||||||
return fontSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFontSize(double fontSize) {
|
|
||||||
this.fontSize = fontSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getLogLines() {
|
|
||||||
return logLines;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLogLines(int logLines) {
|
|
||||||
this.logLines = logLines;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<String> getAuthlibInjectorServerURLs() {
|
|
||||||
return authlibInjectorServerURLs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAuthlibInjectorServerURLs(Set<String> authlibInjectorServerURLs) {
|
|
||||||
this.authlibInjectorServerURLs = authlibInjectorServerURLs;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public Config clone() {
|
public Config clone() {
|
||||||
return Settings.GSON.fromJson(Settings.GSON.toJson(this), Config.class);
|
return Settings.GSON.fromJson(Settings.GSON.toJson(this), Config.class);
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,15 @@ import com.google.gson.GsonBuilder;
|
|||||||
import javafx.beans.property.ObjectProperty;
|
import javafx.beans.property.ObjectProperty;
|
||||||
import javafx.beans.property.StringProperty;
|
import javafx.beans.property.StringProperty;
|
||||||
import javafx.beans.value.ObservableValue;
|
import javafx.beans.value.ObservableValue;
|
||||||
|
import javafx.collections.ObservableList;
|
||||||
|
import javafx.collections.ObservableMap;
|
||||||
|
import javafx.collections.ObservableSet;
|
||||||
import javafx.scene.text.Font;
|
import javafx.scene.text.Font;
|
||||||
|
|
||||||
|
import org.hildan.fxgson.creators.ObservableListCreator;
|
||||||
|
import org.hildan.fxgson.creators.ObservableMapCreator;
|
||||||
|
import org.hildan.fxgson.creators.ObservableSetCreator;
|
||||||
|
import org.hildan.fxgson.factories.JavaFxPropertyTypeAdapterFactory;
|
||||||
import org.jackhuang.hmcl.Launcher;
|
import org.jackhuang.hmcl.Launcher;
|
||||||
import org.jackhuang.hmcl.auth.Account;
|
import org.jackhuang.hmcl.auth.Account;
|
||||||
import org.jackhuang.hmcl.auth.AccountFactory;
|
import org.jackhuang.hmcl.auth.AccountFactory;
|
||||||
@ -50,7 +58,12 @@ public class Settings {
|
|||||||
.registerTypeAdapter(VersionSetting.class, VersionSetting.Serializer.INSTANCE)
|
.registerTypeAdapter(VersionSetting.class, VersionSetting.Serializer.INSTANCE)
|
||||||
.registerTypeAdapter(Profile.class, Profile.Serializer.INSTANCE)
|
.registerTypeAdapter(Profile.class, Profile.Serializer.INSTANCE)
|
||||||
.registerTypeAdapter(File.class, FileTypeAdapter.INSTANCE)
|
.registerTypeAdapter(File.class, FileTypeAdapter.INSTANCE)
|
||||||
.setPrettyPrinting().create();
|
.registerTypeAdapter(ObservableList.class, new ObservableListCreator())
|
||||||
|
.registerTypeAdapter(ObservableSet.class, new ObservableSetCreator())
|
||||||
|
.registerTypeAdapter(ObservableMap.class, new ObservableMapCreator())
|
||||||
|
.registerTypeAdapterFactory(new JavaFxPropertyTypeAdapterFactory(true, true))
|
||||||
|
.setPrettyPrinting()
|
||||||
|
.create();
|
||||||
|
|
||||||
public static final String DEFAULT_PROFILE = "Default";
|
public static final String DEFAULT_PROFILE = "Default";
|
||||||
public static final String HOME_PROFILE = "Home";
|
public static final String HOME_PROFILE = "Home";
|
||||||
@ -67,7 +80,7 @@ public class Settings {
|
|||||||
private Settings() {
|
private Settings() {
|
||||||
loadProxy();
|
loadProxy();
|
||||||
|
|
||||||
for (Iterator<Map<Object, Object>> iterator = SETTINGS.getAccounts().iterator(); iterator.hasNext(); ) {
|
for (Iterator<Map<Object, Object>> iterator = SETTINGS.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) {
|
||||||
@ -88,7 +101,6 @@ public class Settings {
|
|||||||
accounts.put(Accounts.getAccountId(account), account);
|
accounts.put(Accounts.getAccountId(account), account);
|
||||||
}
|
}
|
||||||
|
|
||||||
checkAuthlibInjectorServerURLs();
|
|
||||||
checkAuthlibInjectorAccounts();
|
checkAuthlibInjectorAccounts();
|
||||||
checkProfileMap();
|
checkProfileMap();
|
||||||
|
|
||||||
@ -124,11 +136,11 @@ public class Settings {
|
|||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
try {
|
try {
|
||||||
SETTINGS.getAccounts().clear();
|
SETTINGS.accounts.clear();
|
||||||
for (Account account : accounts.values()) {
|
for (Account account : accounts.values()) {
|
||||||
Map<Object, Object> storage = account.toStorage();
|
Map<Object, Object> storage = account.toStorage();
|
||||||
storage.put("type", Accounts.getAccountType(account));
|
storage.put("type", Accounts.getAccountType(account));
|
||||||
SETTINGS.getAccounts().add(storage);
|
SETTINGS.accounts.add(storage);
|
||||||
}
|
}
|
||||||
|
|
||||||
FileUtils.writeText(SETTINGS_FILE, GSON.toJson(SETTINGS));
|
FileUtils.writeText(SETTINGS_FILE, GSON.toJson(SETTINGS));
|
||||||
@ -137,12 +149,12 @@ public class Settings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final StringProperty commonPath = new ImmediateStringProperty(this, "commonPath", SETTINGS.getCommonDirectory()) {
|
private final StringProperty commonPath = new ImmediateStringProperty(this, "commonPath", SETTINGS.commonDirectory.get()) {
|
||||||
@Override
|
@Override
|
||||||
public void invalidated() {
|
public void invalidated() {
|
||||||
super.invalidated();
|
super.invalidated();
|
||||||
|
|
||||||
SETTINGS.setCommonDirectory(get());
|
SETTINGS.commonDirectory.set(get());
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -159,7 +171,7 @@ public class Settings {
|
|||||||
this.commonPath.set(commonPath);
|
this.commonPath.set(commonPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Locales.SupportedLocale locale = Locales.getLocaleByName(SETTINGS.getLocalization());
|
private Locales.SupportedLocale locale = Locales.getLocaleByName(SETTINGS.localization.get());
|
||||||
|
|
||||||
public Locales.SupportedLocale getLocale() {
|
public Locales.SupportedLocale getLocale() {
|
||||||
return locale;
|
return locale;
|
||||||
@ -167,7 +179,7 @@ public class Settings {
|
|||||||
|
|
||||||
public void setLocale(Locales.SupportedLocale locale) {
|
public void setLocale(Locales.SupportedLocale locale) {
|
||||||
this.locale = locale;
|
this.locale = locale;
|
||||||
SETTINGS.setLocalization(Locales.getNameByLocale(locale));
|
SETTINGS.localization.set(Locales.getNameByLocale(locale));
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,7 +189,7 @@ public class Settings {
|
|||||||
return proxy;
|
return proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Proxy.Type proxyType = Proxies.getProxyType(SETTINGS.getProxyType());
|
private Proxy.Type proxyType = Proxies.getProxyType(SETTINGS.proxyType.get());
|
||||||
|
|
||||||
public Proxy.Type getProxyType() {
|
public Proxy.Type getProxyType() {
|
||||||
return proxyType;
|
return proxyType;
|
||||||
@ -185,58 +197,62 @@ public class Settings {
|
|||||||
|
|
||||||
public void setProxyType(Proxy.Type proxyType) {
|
public void setProxyType(Proxy.Type proxyType) {
|
||||||
this.proxyType = proxyType;
|
this.proxyType = proxyType;
|
||||||
SETTINGS.setProxyType(Proxies.PROXIES.indexOf(proxyType));
|
SETTINGS.proxyType.set(Proxies.PROXIES.indexOf(proxyType));
|
||||||
save();
|
save();
|
||||||
loadProxy();
|
loadProxy();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getProxyHost() {
|
public String getProxyHost() {
|
||||||
return SETTINGS.getProxyHost();
|
return SETTINGS.proxyHost.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProxyHost(String proxyHost) {
|
public void setProxyHost(String proxyHost) {
|
||||||
SETTINGS.setProxyHost(proxyHost);
|
SETTINGS.proxyHost.set(proxyHost);
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getProxyPort() {
|
public String getProxyPort() {
|
||||||
return SETTINGS.getProxyPort();
|
return SETTINGS.proxyPort.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProxyPort(String proxyPort) {
|
public void setProxyPort(String proxyPort) {
|
||||||
SETTINGS.setProxyPort(proxyPort);
|
SETTINGS.proxyPort.set(proxyPort);
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getProxyUser() {
|
public String getProxyUser() {
|
||||||
return SETTINGS.getProxyUser();
|
return SETTINGS.proxyUser.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProxyUser(String proxyUser) {
|
public void setProxyUser(String proxyUser) {
|
||||||
SETTINGS.setProxyUser(proxyUser);
|
SETTINGS.proxyUser.set(proxyUser);
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getProxyPass() {
|
public String getProxyPass() {
|
||||||
return SETTINGS.getProxyPass();
|
return SETTINGS.proxyPass.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProxyPass(String proxyPass) {
|
public void setProxyPass(String proxyPass) {
|
||||||
SETTINGS.setProxyPass(proxyPass);
|
SETTINGS.proxyPass.set(proxyPass);
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasProxy() { return SETTINGS.isHasProxy(); }
|
public boolean hasProxy() {
|
||||||
|
return SETTINGS.hasProxy.get();
|
||||||
|
}
|
||||||
|
|
||||||
public void setHasProxy(boolean hasProxy) {
|
public void setHasProxy(boolean hasProxy) {
|
||||||
SETTINGS.setHasProxy(hasProxy);
|
SETTINGS.hasProxy.set(hasProxy);
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasProxyAuth() { return SETTINGS.isHasProxyAuth(); }
|
public boolean hasProxyAuth() {
|
||||||
|
return SETTINGS.hasProxyAuth.get();
|
||||||
|
}
|
||||||
|
|
||||||
public void setHasProxyAuth(boolean hasProxyAuth) {
|
public void setHasProxyAuth(boolean hasProxyAuth) {
|
||||||
SETTINGS.setHasProxyAuth(hasProxyAuth);
|
SETTINGS.hasProxyAuth.set(hasProxyAuth);
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,21 +283,21 @@ public class Settings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Font getFont() {
|
public Font getFont() {
|
||||||
return Font.font(SETTINGS.getFontFamily(), SETTINGS.getFontSize());
|
return Font.font(SETTINGS.fontFamily.get(), SETTINGS.fontSize.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFont(Font font) {
|
public void setFont(Font font) {
|
||||||
SETTINGS.setFontFamily(font.getFamily());
|
SETTINGS.fontFamily.set(font.getFamily());
|
||||||
SETTINGS.setFontSize(font.getSize());
|
SETTINGS.fontSize.set(font.getSize());
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLogLines() {
|
public int getLogLines() {
|
||||||
return Math.max(SETTINGS.getLogLines(), 100);
|
return Math.max(SETTINGS.logLines.get(), 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLogLines(int logLines) {
|
public void setLogLines(int logLines) {
|
||||||
SETTINGS.setLogLines(logLines);
|
SETTINGS.logLines.set(logLines);
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,37 +306,26 @@ public class Settings {
|
|||||||
****************************************/
|
****************************************/
|
||||||
|
|
||||||
public Set<String> getAuthlibInjectorServerURLs() {
|
public Set<String> getAuthlibInjectorServerURLs() {
|
||||||
return SETTINGS.getAuthlibInjectorServerURLs();
|
return SETTINGS.authlibInjectorServerURLs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeAuthlibInjectorServerURL(String serverURL) {
|
public void removeAuthlibInjectorServerURL(String serverURL) {
|
||||||
checkAuthlibInjectorServerURLs();
|
SETTINGS.authlibInjectorServerURLs.remove(serverURL);
|
||||||
|
|
||||||
SETTINGS.getAuthlibInjectorServerURLs().remove(serverURL);
|
|
||||||
|
|
||||||
checkAuthlibInjectorAccounts();
|
checkAuthlibInjectorAccounts();
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addAuthlibInjectorServerURL(String serverURL) {
|
public void addAuthlibInjectorServerURL(String serverURL) {
|
||||||
checkAuthlibInjectorServerURLs();
|
SETTINGS.authlibInjectorServerURLs.add(serverURL);
|
||||||
|
|
||||||
SETTINGS.getAuthlibInjectorServerURLs().add(serverURL);
|
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkAuthlibInjectorServerURLs() {
|
|
||||||
if (SETTINGS.getAuthlibInjectorServerURLs() == null) {
|
|
||||||
SETTINGS.setAuthlibInjectorServerURLs(new HashSet<>());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkAuthlibInjectorAccounts() {
|
private void checkAuthlibInjectorAccounts() {
|
||||||
for (Account account : getAccounts()) {
|
for (Account account : getAccounts()) {
|
||||||
if (account instanceof AuthlibInjectorAccount) {
|
if (account instanceof AuthlibInjectorAccount) {
|
||||||
AuthlibInjectorAccount injectorAccount = (AuthlibInjectorAccount) account;
|
AuthlibInjectorAccount injectorAccount = (AuthlibInjectorAccount) account;
|
||||||
if (!SETTINGS.getAuthlibInjectorServerURLs().contains(injectorAccount.getServerBaseURL()))
|
if (!SETTINGS.authlibInjectorServerURLs.contains(injectorAccount.getServerBaseURL()))
|
||||||
deleteAccount(account);
|
deleteAccount(account);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -331,14 +336,14 @@ public class Settings {
|
|||||||
****************************************/
|
****************************************/
|
||||||
|
|
||||||
public DownloadProvider getDownloadProvider() {
|
public DownloadProvider getDownloadProvider() {
|
||||||
return DownloadProviders.getDownloadProvider(SETTINGS.getDownloadType());
|
return DownloadProviders.getDownloadProvider(SETTINGS.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);
|
||||||
SETTINGS.setDownloadType(index);
|
SETTINGS.downloadType.set(index);
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -346,7 +351,7 @@ public class Settings {
|
|||||||
* ACCOUNTS *
|
* ACCOUNTS *
|
||||||
****************************************/
|
****************************************/
|
||||||
|
|
||||||
private final ImmediateObjectProperty<Account> selectedAccount = new ImmediateObjectProperty<Account>(this, "selectedAccount", accounts.get(SETTINGS.getSelectedAccount())) {
|
private final ImmediateObjectProperty<Account> selectedAccount = new ImmediateObjectProperty<Account>(this, "selectedAccount", accounts.get(SETTINGS.selectedAccount.get())) {
|
||||||
@Override
|
@Override
|
||||||
public Account get() {
|
public Account get() {
|
||||||
Account a = super.get();
|
Account a = super.get();
|
||||||
@ -368,7 +373,7 @@ public class Settings {
|
|||||||
public void invalidated() {
|
public void invalidated() {
|
||||||
super.invalidated();
|
super.invalidated();
|
||||||
|
|
||||||
SETTINGS.setSelectedAccount(getValue() == null ? "" : Accounts.getAccountId(getValue()));
|
SETTINGS.selectedAccount.set(getValue() == null ? "" : Accounts.getAccountId(getValue()));
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -418,12 +423,12 @@ public class Settings {
|
|||||||
* BACKGROUND *
|
* BACKGROUND *
|
||||||
****************************************/
|
****************************************/
|
||||||
|
|
||||||
private final ImmediateStringProperty backgroundImage = new ImmediateStringProperty(this, "backgroundImage", SETTINGS.getBackgroundImage()) {
|
private final ImmediateStringProperty backgroundImage = new ImmediateStringProperty(this, "backgroundImage", SETTINGS.backgroundImage.get()) {
|
||||||
@Override
|
@Override
|
||||||
public void invalidated() {
|
public void invalidated() {
|
||||||
super.invalidated();
|
super.invalidated();
|
||||||
|
|
||||||
SETTINGS.setBackgroundImage(get());
|
SETTINGS.backgroundImage.set(get());
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -440,12 +445,12 @@ public class Settings {
|
|||||||
this.backgroundImage.set(backgroundImage);
|
this.backgroundImage.set(backgroundImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final ImmediateObjectProperty<EnumBackgroundImage> backgroundImageType = new ImmediateObjectProperty<EnumBackgroundImage>(this, "backgroundImageType", EnumBackgroundImage.indexOf(SETTINGS.getBackgroundImageType())) {
|
private final ImmediateObjectProperty<EnumBackgroundImage> backgroundImageType = new ImmediateObjectProperty<EnumBackgroundImage>(this, "backgroundImageType", EnumBackgroundImage.indexOf(SETTINGS.backgroundImageType.get())) {
|
||||||
@Override
|
@Override
|
||||||
public void invalidated() {
|
public void invalidated() {
|
||||||
super.invalidated();
|
super.invalidated();
|
||||||
|
|
||||||
SETTINGS.setBackgroundImageType(get().ordinal());
|
SETTINGS.backgroundImageType.set(get().ordinal());
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -466,12 +471,12 @@ public class Settings {
|
|||||||
* THEME *
|
* THEME *
|
||||||
****************************************/
|
****************************************/
|
||||||
|
|
||||||
private final ImmediateObjectProperty<Theme> theme = new ImmediateObjectProperty<Theme>(this, "theme", Theme.getTheme(SETTINGS.getTheme()).orElse(Theme.BLUE)) {
|
private final ImmediateObjectProperty<Theme> theme = new ImmediateObjectProperty<Theme>(this, "theme", Theme.getTheme(SETTINGS.theme.get()).orElse(Theme.BLUE)) {
|
||||||
@Override
|
@Override
|
||||||
public void invalidated() {
|
public void invalidated() {
|
||||||
super.invalidated();
|
super.invalidated();
|
||||||
|
|
||||||
SETTINGS.setTheme(get().getName().toLowerCase());
|
SETTINGS.theme.set(get().getName().toLowerCase());
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -495,19 +500,19 @@ public class Settings {
|
|||||||
public Profile getSelectedProfile() {
|
public Profile getSelectedProfile() {
|
||||||
checkProfileMap();
|
checkProfileMap();
|
||||||
|
|
||||||
if (!hasProfile(SETTINGS.getSelectedProfile())) {
|
if (!hasProfile(SETTINGS.selectedProfile.get())) {
|
||||||
getProfileMap().keySet().stream().findFirst().ifPresent(selectedProfile -> {
|
getProfileMap().keySet().stream().findFirst().ifPresent(selectedProfile -> {
|
||||||
SETTINGS.setSelectedProfile(selectedProfile);
|
SETTINGS.selectedProfile.set(selectedProfile);
|
||||||
save();
|
save();
|
||||||
});
|
});
|
||||||
Schedulers.computation().schedule(this::onProfileChanged);
|
Schedulers.computation().schedule(this::onProfileChanged);
|
||||||
}
|
}
|
||||||
return getProfile(SETTINGS.getSelectedProfile());
|
return getProfile(SETTINGS.selectedProfile.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSelectedProfile(Profile selectedProfile) {
|
public void setSelectedProfile(Profile selectedProfile) {
|
||||||
if (hasProfile(selectedProfile.getName()) && !Objects.equals(selectedProfile.getName(), SETTINGS.getSelectedProfile())) {
|
if (hasProfile(selectedProfile.getName()) && !Objects.equals(selectedProfile.getName(), SETTINGS.selectedProfile.get())) {
|
||||||
SETTINGS.setSelectedProfile(selectedProfile.getName());
|
SETTINGS.selectedProfile.set(selectedProfile.getName());
|
||||||
save();
|
save();
|
||||||
Schedulers.computation().schedule(this::onProfileChanged);
|
Schedulers.computation().schedule(this::onProfileChanged);
|
||||||
}
|
}
|
||||||
@ -525,7 +530,7 @@ public class Settings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Profile> getProfileMap() {
|
public Map<String, Profile> getProfileMap() {
|
||||||
return SETTINGS.getConfigurations();
|
return SETTINGS.configurations;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<Profile> getProfiles() {
|
public Collection<Profile> getProfiles() {
|
||||||
|
@ -82,17 +82,16 @@ public final class ExportWizardProvider implements WizardProvider {
|
|||||||
try (ZipEngine zip = new ZipEngine(modpackFile)) {
|
try (ZipEngine zip = new ZipEngine(modpackFile)) {
|
||||||
Config config = Settings.INSTANCE.getRawConfig();
|
Config config = Settings.INSTANCE.getRawConfig();
|
||||||
|
|
||||||
config.setHasProxy(false);
|
config.hasProxy.set(false);
|
||||||
config.setSelectedProfile("");
|
config.selectedProfile.set("");
|
||||||
config.setCommonDirectory(null);
|
config.commonDirectory.set(null);
|
||||||
config.setFontFamily("Consolas");
|
config.fontFamily.set("Consolas");
|
||||||
config.setFontSize(12);
|
config.fontSize.set(12);
|
||||||
config.setJava(null);
|
config.localization.set(null);
|
||||||
config.setLocalization(null);
|
config.accounts.clear();
|
||||||
config.setAccounts(null);
|
config.selectedAccount.set("");
|
||||||
config.setSelectedAccount("");
|
config.logLines.set(100);
|
||||||
config.setLogLines(100);
|
config.configurations.clear();
|
||||||
config.setConfigurations(null);
|
|
||||||
|
|
||||||
zip.putTextFile(Settings.GSON.toJson(config), Settings.SETTINGS_FILE_NAME);
|
zip.putTextFile(Settings.GSON.toJson(config), Settings.SETTINGS_FILE_NAME);
|
||||||
zip.putFile(tempModpack, "modpack.zip");
|
zip.putFile(tempModpack, "modpack.zip");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user