Settings page refined
This commit is contained in:
@@ -22,12 +22,10 @@ import javafx.stage.Stage
|
|||||||
import org.jackhuang.hmcl.setting.Settings
|
import org.jackhuang.hmcl.setting.Settings
|
||||||
import org.jackhuang.hmcl.task.Scheduler
|
import org.jackhuang.hmcl.task.Scheduler
|
||||||
import org.jackhuang.hmcl.ui.Controllers
|
import org.jackhuang.hmcl.ui.Controllers
|
||||||
import org.jackhuang.hmcl.ui.UTF8Control
|
|
||||||
import org.jackhuang.hmcl.util.DEFAULT_USER_AGENT
|
import org.jackhuang.hmcl.util.DEFAULT_USER_AGENT
|
||||||
import org.jackhuang.hmcl.util.LOG
|
import org.jackhuang.hmcl.util.LOG
|
||||||
import org.jackhuang.hmcl.util.OS
|
import org.jackhuang.hmcl.util.OS
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.*
|
|
||||||
import java.util.logging.Level
|
import java.util.logging.Level
|
||||||
|
|
||||||
fun i18n(key: String): String {
|
fun i18n(key: String): String {
|
||||||
@@ -83,6 +81,6 @@ class Main : Application() {
|
|||||||
Scheduler.shutdown()
|
Scheduler.shutdown()
|
||||||
}
|
}
|
||||||
|
|
||||||
val RESOURCE_BUNDLE = Settings.LANG.resourceBundle
|
val RESOURCE_BUNDLE = Settings.locale.resourceBundle
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -31,7 +31,7 @@ object LauncherHelper {
|
|||||||
repository = repository,
|
repository = repository,
|
||||||
versionId = profile.selectedVersion,
|
versionId = profile.selectedVersion,
|
||||||
options = profile.getVersionSetting(profile.selectedVersion).toLaunchOptions(profile.gameDir),
|
options = profile.getVersionSetting(profile.selectedVersion).toLaunchOptions(profile.gameDir),
|
||||||
account = account.logIn(Settings.PROXY)
|
account = account.logIn(Settings.proxy)
|
||||||
)
|
)
|
||||||
|
|
||||||
profile.dependency.checkGameCompletionAsync(version)
|
profile.dependency.checkGameCompletionAsync(version)
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class Config {
|
|||||||
Settings.save()
|
Settings.save()
|
||||||
}
|
}
|
||||||
@SerializedName("commonpath")
|
@SerializedName("commonpath")
|
||||||
var commonpath: File = Main.getMinecraftDirectory()
|
var commonpath: String = Main.getMinecraftDirectory().absolutePath
|
||||||
set(value) {
|
set(value) {
|
||||||
field = value
|
field = value
|
||||||
Settings.save()
|
Settings.save()
|
||||||
|
|||||||
@@ -19,12 +19,10 @@ package org.jackhuang.hmcl.setting
|
|||||||
|
|
||||||
import com.google.gson.*
|
import com.google.gson.*
|
||||||
import javafx.beans.InvalidationListener
|
import javafx.beans.InvalidationListener
|
||||||
import org.jackhuang.hmcl.download.BMCLAPIDownloadProvider
|
|
||||||
import org.jackhuang.hmcl.download.DefaultDependencyManager
|
import org.jackhuang.hmcl.download.DefaultDependencyManager
|
||||||
import org.jackhuang.hmcl.game.HMCLGameRepository
|
import org.jackhuang.hmcl.game.HMCLGameRepository
|
||||||
import org.jackhuang.hmcl.mod.ModManager
|
import org.jackhuang.hmcl.mod.ModManager
|
||||||
import org.jackhuang.hmcl.util.*
|
import org.jackhuang.hmcl.util.*
|
||||||
import org.jackhuang.hmcl.util.property.ImmediateBooleanProperty
|
|
||||||
import org.jackhuang.hmcl.util.property.ImmediateObjectProperty
|
import org.jackhuang.hmcl.util.property.ImmediateObjectProperty
|
||||||
import org.jackhuang.hmcl.util.property.ImmediateStringProperty
|
import org.jackhuang.hmcl.util.property.ImmediateStringProperty
|
||||||
import java.io.File
|
import java.io.File
|
||||||
@@ -41,7 +39,7 @@ class Profile(var name: String = "Default", initialGameDir: File = File(".minecr
|
|||||||
var gameDir: File by gameDirProperty
|
var gameDir: File by gameDirProperty
|
||||||
|
|
||||||
var repository = HMCLGameRepository(initialGameDir)
|
var repository = HMCLGameRepository(initialGameDir)
|
||||||
val dependency: DefaultDependencyManager get() = DefaultDependencyManager(repository, Settings.DOWNLOAD_PROVIDER, Settings.PROXY)
|
val dependency: DefaultDependencyManager get() = DefaultDependencyManager(repository, Settings.downloadProvider, Settings.proxy)
|
||||||
var modManager = ModManager(repository)
|
var modManager = ModManager(repository)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import org.jackhuang.hmcl.auth.Account
|
|||||||
import org.jackhuang.hmcl.util.*
|
import org.jackhuang.hmcl.util.*
|
||||||
import org.jackhuang.hmcl.event.EVENT_BUS
|
import org.jackhuang.hmcl.event.EVENT_BUS
|
||||||
import org.jackhuang.hmcl.util.property.ImmediateObjectProperty
|
import org.jackhuang.hmcl.util.property.ImmediateObjectProperty
|
||||||
|
import org.jackhuang.hmcl.util.property.ImmediateStringProperty
|
||||||
import java.net.Authenticator
|
import java.net.Authenticator
|
||||||
import java.net.InetSocketAddress
|
import java.net.InetSocketAddress
|
||||||
import java.net.PasswordAuthentication
|
import java.net.PasswordAuthentication
|
||||||
@@ -46,14 +47,14 @@ object Settings {
|
|||||||
.registerTypeAdapter(File::class.java, FileTypeAdapter)
|
.registerTypeAdapter(File::class.java, FileTypeAdapter)
|
||||||
.setPrettyPrinting().create()
|
.setPrettyPrinting().create()
|
||||||
|
|
||||||
val DEFAULT_PROFILE = "Default"
|
const val DEFAULT_PROFILE = "Default"
|
||||||
val HOME_PROFILE = "Home"
|
const val HOME_PROFILE = "Home"
|
||||||
|
|
||||||
val SETTINGS_FILE = File("hmcl.json").absoluteFile
|
val SETTINGS_FILE: File = File("hmcl.json").absoluteFile
|
||||||
|
|
||||||
private val SETTINGS: Config
|
private val SETTINGS: Config
|
||||||
|
|
||||||
private val ACCOUNTS = mutableMapOf<String, Account>()
|
private val accounts = mutableMapOf<String, Account>()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
SETTINGS = initSettings();
|
SETTINGS = initSettings();
|
||||||
@@ -72,7 +73,7 @@ object Settings {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
ACCOUNTS[name] = account
|
accounts[name] = account
|
||||||
}
|
}
|
||||||
|
|
||||||
save()
|
save()
|
||||||
@@ -117,7 +118,7 @@ object Settings {
|
|||||||
fun save() {
|
fun save() {
|
||||||
try {
|
try {
|
||||||
SETTINGS.accounts.clear()
|
SETTINGS.accounts.clear()
|
||||||
for ((name, account) in ACCOUNTS) {
|
for ((name, account) in accounts) {
|
||||||
val storage = account.toStorage()
|
val storage = account.toStorage()
|
||||||
storage["type"] = Accounts.getAccountType(account)
|
storage["type"] = Accounts.getAccountType(account)
|
||||||
SETTINGS.accounts[name] = storage
|
SETTINGS.accounts[name] = storage
|
||||||
@@ -129,37 +130,46 @@ object Settings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var LANG: Locales.SupportedLocale = Locales.getLocaleByName(SETTINGS.localization)
|
val commonPathProperty = object : ImmediateStringProperty(this, "commonPath", SETTINGS.commonpath) {
|
||||||
|
override fun invalidated() {
|
||||||
|
super.invalidated()
|
||||||
|
|
||||||
|
SETTINGS.commonpath = get()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var commonPath: String by commonPathProperty
|
||||||
|
|
||||||
|
var locale: Locales.SupportedLocale = Locales.getLocaleByName(SETTINGS.localization)
|
||||||
set(value) {
|
set(value) {
|
||||||
field = value
|
field = value
|
||||||
SETTINGS.localization = Locales.getNameByLocal(value)
|
SETTINGS.localization = Locales.getNameByLocal(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
var PROXY: Proxy = Proxy.NO_PROXY
|
var proxy: Proxy = Proxy.NO_PROXY
|
||||||
var PROXY_TYPE: Proxy.Type? = Proxies.getProxyType(SETTINGS.proxyType)
|
var proxyType: Proxy.Type? = Proxies.getProxyType(SETTINGS.proxyType)
|
||||||
set(value) {
|
set(value) {
|
||||||
field = value
|
field = value
|
||||||
SETTINGS.proxyType = Proxies.PROXIES.indexOf(value)
|
SETTINGS.proxyType = Proxies.PROXIES.indexOf(value)
|
||||||
loadProxy()
|
loadProxy()
|
||||||
}
|
}
|
||||||
|
|
||||||
var PROXY_HOST: String? get() = SETTINGS.proxyHost; set(value) { SETTINGS.proxyHost = value }
|
var proxyHost: String? get() = SETTINGS.proxyHost; set(value) { SETTINGS.proxyHost = value }
|
||||||
var PROXY_PORT: String? get() = SETTINGS.proxyPort; set(value) { SETTINGS.proxyPort = value }
|
var proxyPort: String? get() = SETTINGS.proxyPort; set(value) { SETTINGS.proxyPort = value }
|
||||||
var PROXY_USER: String? get() = SETTINGS.proxyUserName; set(value) { SETTINGS.proxyUserName = value }
|
var proxyUser: String? get() = SETTINGS.proxyUserName; set(value) { SETTINGS.proxyUserName = value }
|
||||||
var PROXY_PASS: String? get() = SETTINGS.proxyPassword; set(value) { SETTINGS.proxyPassword = value }
|
var proxyPass: String? get() = SETTINGS.proxyPassword; set(value) { SETTINGS.proxyPassword = value }
|
||||||
|
|
||||||
private fun loadProxy() {
|
private fun loadProxy() {
|
||||||
val host = PROXY_HOST
|
val host = proxyHost
|
||||||
val port = PROXY_PORT?.toIntOrNull()
|
val port = proxyPort?.toIntOrNull()
|
||||||
if (host == null || host.isBlank() || port == null)
|
if (host == null || host.isBlank() || port == null)
|
||||||
PROXY = Proxy.NO_PROXY
|
proxy = Proxy.NO_PROXY
|
||||||
else {
|
else {
|
||||||
System.setProperty("http.proxyHost", PROXY_HOST)
|
System.setProperty("http.proxyHost", proxyHost)
|
||||||
System.setProperty("http.proxyPort", PROXY_PORT)
|
System.setProperty("http.proxyPort", proxyPort)
|
||||||
PROXY = Proxy(PROXY_TYPE, InetSocketAddress(host, port))
|
proxy = Proxy(proxyType, InetSocketAddress(host, port))
|
||||||
|
|
||||||
val user = PROXY_USER
|
val user = proxyUser
|
||||||
val pass = PROXY_PASS
|
val pass = proxyPass
|
||||||
if (user != null && user.isNotBlank() && pass != null && pass.isNotBlank()) {
|
if (user != null && user.isNotBlank() && pass != null && pass.isNotBlank()) {
|
||||||
System.setProperty("http.proxyUser", user)
|
System.setProperty("http.proxyUser", user)
|
||||||
System.setProperty("http.proxyPassword", pass)
|
System.setProperty("http.proxyPassword", pass)
|
||||||
@@ -175,7 +185,7 @@ object Settings {
|
|||||||
|
|
||||||
init { loadProxy() }
|
init { loadProxy() }
|
||||||
|
|
||||||
var DOWNLOAD_PROVIDER: DownloadProvider
|
var downloadProvider: DownloadProvider
|
||||||
get() = when (SETTINGS.downloadtype) {
|
get() = when (SETTINGS.downloadtype) {
|
||||||
0 -> MojangDownloadProvider
|
0 -> MojangDownloadProvider
|
||||||
1 -> BMCLAPIDownloadProvider
|
1 -> BMCLAPIDownloadProvider
|
||||||
@@ -196,15 +206,15 @@ object Settings {
|
|||||||
val selectedAccountProperty = object : ImmediateObjectProperty<Account?>(this, "selectedAccount", getAccount(SETTINGS.selectedAccount)) {
|
val selectedAccountProperty = object : ImmediateObjectProperty<Account?>(this, "selectedAccount", getAccount(SETTINGS.selectedAccount)) {
|
||||||
override fun get(): Account? {
|
override fun get(): Account? {
|
||||||
val a = super.get()
|
val a = super.get()
|
||||||
if (a == null || !ACCOUNTS.containsKey(a.username)) {
|
if (a == null || !accounts.containsKey(a.username)) {
|
||||||
val acc = if (ACCOUNTS.isEmpty()) null else ACCOUNTS.values.first()
|
val acc = if (accounts.isEmpty()) null else accounts.values.first()
|
||||||
set(acc)
|
set(acc)
|
||||||
return acc
|
return acc
|
||||||
} else return a
|
} else return a
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun set(newValue: Account?) {
|
override fun set(newValue: Account?) {
|
||||||
if (newValue == null || ACCOUNTS.containsKey(newValue.username)) {
|
if (newValue == null || accounts.containsKey(newValue.username)) {
|
||||||
super.set(newValue)
|
super.set(newValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -218,19 +228,19 @@ object Settings {
|
|||||||
var selectedAccount: Account? by selectedAccountProperty
|
var selectedAccount: Account? by selectedAccountProperty
|
||||||
|
|
||||||
fun addAccount(account: Account) {
|
fun addAccount(account: Account) {
|
||||||
ACCOUNTS[account.username] = account
|
accounts[account.username] = account
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getAccount(name: String): Account? {
|
fun getAccount(name: String): Account? {
|
||||||
return ACCOUNTS[name]
|
return accounts[name]
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getAccounts(): Map<String, Account> {
|
fun getAccounts(): Map<String, Account> {
|
||||||
return Collections.unmodifiableMap(ACCOUNTS)
|
return Collections.unmodifiableMap(accounts)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun deleteAccount(name: String) {
|
fun deleteAccount(name: String) {
|
||||||
ACCOUNTS.remove(name)
|
accounts.remove(name)
|
||||||
|
|
||||||
selectedAccountProperty.get()
|
selectedAccountProperty.get()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import org.jackhuang.hmcl.auth.OfflineAccount
|
|||||||
import org.jackhuang.hmcl.auth.yggdrasil.YggdrasilAccount
|
import org.jackhuang.hmcl.auth.yggdrasil.YggdrasilAccount
|
||||||
import org.jackhuang.hmcl.download.BMCLAPIDownloadProvider
|
import org.jackhuang.hmcl.download.BMCLAPIDownloadProvider
|
||||||
import org.jackhuang.hmcl.download.MojangDownloadProvider
|
import org.jackhuang.hmcl.download.MojangDownloadProvider
|
||||||
import org.jackhuang.hmcl.ui.UTF8Control
|
import org.jackhuang.hmcl.ui.construct.UTF8Control
|
||||||
import java.net.Proxy
|
import java.net.Proxy
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
|||||||
@@ -207,10 +207,10 @@ class VersionSetting() {
|
|||||||
fullscreen = fullscreen,
|
fullscreen = fullscreen,
|
||||||
serverIp = serverIp,
|
serverIp = serverIp,
|
||||||
wrapper = wrapper,
|
wrapper = wrapper,
|
||||||
proxyHost = Settings.PROXY_HOST,
|
proxyHost = Settings.proxyHost,
|
||||||
proxyPort = Settings.PROXY_PORT,
|
proxyPort = Settings.proxyPort,
|
||||||
proxyUser = Settings.PROXY_USER,
|
proxyUser = Settings.proxyUser,
|
||||||
proxyPass = Settings.PROXY_PASS,
|
proxyPass = Settings.proxyPass,
|
||||||
precalledCommand = precalledCommand,
|
precalledCommand = precalledCommand,
|
||||||
noGeneratedJVMArgs = noJVMArgs
|
noGeneratedJVMArgs = noJVMArgs
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ class AccountsPage() : StackPane(), DecoratorPage {
|
|||||||
else -> throw UnsupportedOperationException()
|
else -> throw UnsupportedOperationException()
|
||||||
}
|
}
|
||||||
|
|
||||||
account.logIn(Settings.PROXY)
|
account.logIn(Settings.proxy)
|
||||||
account
|
account
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e
|
e
|
||||||
|
|||||||
@@ -18,19 +18,11 @@
|
|||||||
package org.jackhuang.hmcl.ui
|
package org.jackhuang.hmcl.ui
|
||||||
|
|
||||||
import com.jfoenix.controls.JFXComboBox
|
import com.jfoenix.controls.JFXComboBox
|
||||||
import javafx.beans.value.ChangeListener
|
|
||||||
import javafx.scene.layout.*
|
import javafx.scene.layout.*
|
||||||
import javafx.scene.paint.Paint
|
|
||||||
import org.jackhuang.hmcl.ProfileChangedEvent
|
|
||||||
import org.jackhuang.hmcl.ProfileLoadingEvent
|
|
||||||
import org.jackhuang.hmcl.auth.Account
|
|
||||||
import org.jackhuang.hmcl.event.EVENT_BUS
|
|
||||||
import org.jackhuang.hmcl.event.RefreshedVersionsEvent
|
|
||||||
import org.jackhuang.hmcl.game.LauncherHelper
|
|
||||||
import org.jackhuang.hmcl.game.minecraftVersion
|
|
||||||
import org.jackhuang.hmcl.i18n
|
import org.jackhuang.hmcl.i18n
|
||||||
import org.jackhuang.hmcl.setting.Settings
|
import org.jackhuang.hmcl.setting.Settings
|
||||||
import org.jackhuang.hmcl.ui.download.DownloadWizardProvider
|
import org.jackhuang.hmcl.ui.construct.IconedItem
|
||||||
|
import org.jackhuang.hmcl.ui.construct.RipplerContainer
|
||||||
|
|
||||||
class LeftPaneController(private val leftPane: AdvancedListBox) {
|
class LeftPaneController(private val leftPane: AdvancedListBox) {
|
||||||
val versionsPane = VBox()
|
val versionsPane = VBox()
|
||||||
|
|||||||
@@ -22,24 +22,20 @@ import com.jfoenix.controls.JFXMasonryPane
|
|||||||
import javafx.application.Platform
|
import javafx.application.Platform
|
||||||
import javafx.beans.property.SimpleStringProperty
|
import javafx.beans.property.SimpleStringProperty
|
||||||
import javafx.beans.property.StringProperty
|
import javafx.beans.property.StringProperty
|
||||||
import javafx.beans.value.ChangeListener
|
|
||||||
import javafx.fxml.FXML
|
import javafx.fxml.FXML
|
||||||
import javafx.scene.Node
|
import javafx.scene.Node
|
||||||
import javafx.scene.control.ToggleGroup
|
import javafx.scene.control.ToggleGroup
|
||||||
import javafx.scene.layout.StackPane
|
import javafx.scene.layout.StackPane
|
||||||
import javafx.scene.paint.Paint
|
|
||||||
import org.jackhuang.hmcl.ProfileChangedEvent
|
import org.jackhuang.hmcl.ProfileChangedEvent
|
||||||
import org.jackhuang.hmcl.ProfileLoadingEvent
|
import org.jackhuang.hmcl.ProfileLoadingEvent
|
||||||
import org.jackhuang.hmcl.auth.Account
|
|
||||||
import org.jackhuang.hmcl.event.EVENT_BUS
|
import org.jackhuang.hmcl.event.EVENT_BUS
|
||||||
import org.jackhuang.hmcl.event.RefreshedVersionsEvent
|
import org.jackhuang.hmcl.event.RefreshedVersionsEvent
|
||||||
import org.jackhuang.hmcl.game.LauncherHelper
|
import org.jackhuang.hmcl.game.LauncherHelper
|
||||||
import org.jackhuang.hmcl.game.Version
|
|
||||||
import org.jackhuang.hmcl.game.minecraftVersion
|
import org.jackhuang.hmcl.game.minecraftVersion
|
||||||
import org.jackhuang.hmcl.i18n
|
import org.jackhuang.hmcl.i18n
|
||||||
import org.jackhuang.hmcl.setting.Profile
|
import org.jackhuang.hmcl.setting.Profile
|
||||||
import org.jackhuang.hmcl.setting.Settings
|
import org.jackhuang.hmcl.setting.Settings
|
||||||
import org.jackhuang.hmcl.ui.download.DownloadWizardProvider
|
import org.jackhuang.hmcl.ui.construct.RipplerContainer
|
||||||
import org.jackhuang.hmcl.ui.wizard.DecoratorPage
|
import org.jackhuang.hmcl.ui.wizard.DecoratorPage
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -59,9 +59,7 @@ object SVG {
|
|||||||
fun expand(fill: String = "white", width: Double = 20.0, height: Double = 20.0) = createSVGPath("M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z", fill, width, height)
|
fun expand(fill: String = "white", width: Double = 20.0, height: Double = 20.0) = createSVGPath("M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z", fill, width, height)
|
||||||
fun collapse(fill: String = "white", width: Double = 20.0, height: Double = 20.0) = createSVGPath("M12 8l-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14z", fill, width, height)
|
fun collapse(fill: String = "white", width: Double = 20.0, height: Double = 20.0) = createSVGPath("M12 8l-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14z", fill, width, height)
|
||||||
fun navigate(fill: String = "white", width: Double = 20.0, height: Double = 20.0) = createSVGPath("M14,3V5H17.59L7.76,14.83L9.17,16.24L19,6.41V10H21V3M19,19H5V5H12V3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V12H19V19Z", fill, width, height)
|
fun navigate(fill: String = "white", width: Double = 20.0, height: Double = 20.0) = createSVGPath("M14,3V5H17.59L7.76,14.83L9.17,16.24L19,6.41V10H21V3M19,19H5V5H12V3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V12H19V19Z", fill, width, height)
|
||||||
fun launch(fill: String = "white", width: Double = 20.0, height: Double = 20.0) = createSVGPath("M1008 6.286q18.857 13.714 15.429 36.571l-146.286 877.714q-2.857 16.571-18.286 25.714-8 4.571-17.714 4.571-6.286 "
|
fun launch(fill: String = "white", width: Double = 20.0, height: Double = 20.0) = createSVGPath("M1008 6.286q18.857 13.714 15.429 36.571l-146.286 877.714q-2.857 16.571-18.286 25.714-8 4.571-17.714 4.571-6.286 0-13.714-2.857l-258.857-105.714-138.286 168.571q-10.286 13.143-28 13.143-7.429 0-12.571-2.286-10.857-4-17.429-13.429t-6.571-20.857v-199.429l493.714-605.143-610.857 528.571-225.714-92.571q-21.143-8-22.857-31.429-1.143-22.857 18.286-33.714l950.857-548.571q8.571-5.143 18.286-5.14311.429 0 20.571 6.286z", fill, width, height)
|
||||||
+ "0-13.714-2.857l-258.857-105.714-138.286 168.571q-10.286 13.143-28 13.143-7.429 "
|
fun pencil(fill: String = "white", width: Double = 20.0, height: Double = 20.0) = createSVGPath("M20.71,4.04C21.1,3.65 21.1,3 20.71,2.63L18.37,0.29C18,-0.1 17.35,-0.1 16.96,0.29L15,2.25L18.75,6M17.75,7L14,3.25L4,13.25V17H7.75L17.75,7Z", fill, width, height)
|
||||||
+ "0-12.571-2.286-10.857-4-17.429-13.429t-6.571-20.857v-199.429l493.714-605.143-610.857 "
|
|
||||||
+ "528.571-225.714-92.571q-21.143-8-22.857-31.429-1.143-22.857 18.286-33.714l950.857-548.571q8.571-5.143 18.286-5.143"
|
|
||||||
+ " 11.429 0 20.571 6.286z", fill, width, height)
|
|
||||||
}
|
}
|
||||||
@@ -19,7 +19,6 @@ package org.jackhuang.hmcl.ui
|
|||||||
|
|
||||||
import com.jfoenix.controls.JFXComboBox
|
import com.jfoenix.controls.JFXComboBox
|
||||||
import com.jfoenix.controls.JFXTextField
|
import com.jfoenix.controls.JFXTextField
|
||||||
import javafx.beans.binding.Bindings
|
|
||||||
import javafx.beans.property.SimpleStringProperty
|
import javafx.beans.property.SimpleStringProperty
|
||||||
import javafx.beans.property.StringProperty
|
import javafx.beans.property.StringProperty
|
||||||
import javafx.collections.FXCollections
|
import javafx.collections.FXCollections
|
||||||
@@ -31,6 +30,7 @@ import org.jackhuang.hmcl.setting.DownloadProviders
|
|||||||
import org.jackhuang.hmcl.setting.Locales
|
import org.jackhuang.hmcl.setting.Locales
|
||||||
import org.jackhuang.hmcl.setting.Proxies
|
import org.jackhuang.hmcl.setting.Proxies
|
||||||
import org.jackhuang.hmcl.setting.Settings
|
import org.jackhuang.hmcl.setting.Settings
|
||||||
|
import org.jackhuang.hmcl.ui.construct.FileItem
|
||||||
import org.jackhuang.hmcl.ui.wizard.DecoratorPage
|
import org.jackhuang.hmcl.ui.wizard.DecoratorPage
|
||||||
|
|
||||||
class SettingsPage : StackPane(), DecoratorPage {
|
class SettingsPage : StackPane(), DecoratorPage {
|
||||||
@@ -43,6 +43,8 @@ class SettingsPage : StackPane(), DecoratorPage {
|
|||||||
@FXML lateinit var cboProxyType: JFXComboBox<*>
|
@FXML lateinit var cboProxyType: JFXComboBox<*>
|
||||||
@FXML lateinit var cboLanguage: JFXComboBox<*>
|
@FXML lateinit var cboLanguage: JFXComboBox<*>
|
||||||
@FXML lateinit var cboDownloadSource: JFXComboBox<*>
|
@FXML lateinit var cboDownloadSource: JFXComboBox<*>
|
||||||
|
@FXML lateinit var fileCommonLocation: FileItem
|
||||||
|
@FXML lateinit var fileBackgroundLocation: FileItem
|
||||||
|
|
||||||
init {
|
init {
|
||||||
loadFXML("/assets/fxml/setting.fxml")
|
loadFXML("/assets/fxml/setting.fxml")
|
||||||
@@ -50,45 +52,47 @@ class SettingsPage : StackPane(), DecoratorPage {
|
|||||||
cboLanguage.limitWidth(400.0)
|
cboLanguage.limitWidth(400.0)
|
||||||
cboDownloadSource.limitWidth(400.0)
|
cboDownloadSource.limitWidth(400.0)
|
||||||
|
|
||||||
txtProxyHost.text = Settings.PROXY_HOST
|
txtProxyHost.text = Settings.proxyHost
|
||||||
txtProxyHost.textProperty().addListener { _, _, newValue ->
|
txtProxyHost.textProperty().addListener { _, _, newValue ->
|
||||||
Settings.PROXY_HOST = newValue
|
Settings.proxyHost = newValue
|
||||||
}
|
}
|
||||||
|
|
||||||
txtProxyPort.text = Settings.PROXY_PORT
|
txtProxyPort.text = Settings.proxyPort
|
||||||
txtProxyPort.textProperty().addListener { _, _, newValue ->
|
txtProxyPort.textProperty().addListener { _, _, newValue ->
|
||||||
Settings.PROXY_PORT = newValue
|
Settings.proxyPort = newValue
|
||||||
}
|
}
|
||||||
|
|
||||||
txtProxyUsername.text = Settings.PROXY_USER
|
txtProxyUsername.text = Settings.proxyUser
|
||||||
txtProxyUsername.textProperty().addListener { _, _, newValue ->
|
txtProxyUsername.textProperty().addListener { _, _, newValue ->
|
||||||
Settings.PROXY_USER = newValue
|
Settings.proxyUser = newValue
|
||||||
}
|
}
|
||||||
|
|
||||||
txtProxyPassword.text = Settings.PROXY_PASS
|
txtProxyPassword.text = Settings.proxyPass
|
||||||
txtProxyPassword.textProperty().addListener { _, _, newValue ->
|
txtProxyPassword.textProperty().addListener { _, _, newValue ->
|
||||||
Settings.PROXY_PASS = newValue
|
Settings.proxyPass = newValue
|
||||||
}
|
}
|
||||||
|
|
||||||
cboDownloadSource.selectionModel.select(DownloadProviders.DOWNLOAD_PROVIDERS.indexOf(Settings.DOWNLOAD_PROVIDER))
|
cboDownloadSource.selectionModel.select(DownloadProviders.DOWNLOAD_PROVIDERS.indexOf(Settings.downloadProvider))
|
||||||
cboDownloadSource.selectionModel.selectedIndexProperty().addListener { _, _, newValue ->
|
cboDownloadSource.selectionModel.selectedIndexProperty().addListener { _, _, newValue ->
|
||||||
Settings.DOWNLOAD_PROVIDER = DownloadProviders.getDownloadProvider(newValue.toInt())
|
Settings.downloadProvider = DownloadProviders.getDownloadProvider(newValue.toInt())
|
||||||
}
|
}
|
||||||
|
|
||||||
val list = FXCollections.observableArrayList<Label>()
|
val list = FXCollections.observableArrayList<Label>()
|
||||||
for (locale in Locales.LOCALES) {
|
for (locale in Locales.LOCALES) {
|
||||||
list += Label(locale.getName(Settings.LANG.resourceBundle))
|
list += Label(locale.getName(Settings.locale.resourceBundle))
|
||||||
}
|
}
|
||||||
cboLanguage.items = list
|
cboLanguage.items = list
|
||||||
cboLanguage.selectionModel.select(Locales.LOCALES.indexOf(Settings.LANG))
|
cboLanguage.selectionModel.select(Locales.LOCALES.indexOf(Settings.locale))
|
||||||
cboLanguage.selectionModel.selectedIndexProperty().addListener { _, _, newValue ->
|
cboLanguage.selectionModel.selectedIndexProperty().addListener { _, _, newValue ->
|
||||||
Settings.LANG = Locales.getLocale(newValue.toInt())
|
Settings.locale = Locales.getLocale(newValue.toInt())
|
||||||
}
|
}
|
||||||
|
|
||||||
cboProxyType.selectionModel.select(Proxies.PROXIES.indexOf(Settings.PROXY_TYPE))
|
cboProxyType.selectionModel.select(Proxies.PROXIES.indexOf(Settings.proxyType))
|
||||||
cboProxyType.selectionModel.selectedIndexProperty().addListener { _, _, newValue ->
|
cboProxyType.selectionModel.selectedIndexProperty().addListener { _, _, newValue ->
|
||||||
Settings.PROXY_TYPE = Proxies.getProxyType(newValue.toInt())
|
Settings.proxyType = Proxies.getProxyType(newValue.toInt())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fileCommonLocation.setProperty(Settings.commonPathProperty)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import javafx.stage.DirectoryChooser
|
|||||||
import org.jackhuang.hmcl.i18n
|
import org.jackhuang.hmcl.i18n
|
||||||
import org.jackhuang.hmcl.setting.VersionSetting
|
import org.jackhuang.hmcl.setting.VersionSetting
|
||||||
import org.jackhuang.hmcl.ui.construct.ComponentList
|
import org.jackhuang.hmcl.ui.construct.ComponentList
|
||||||
|
import org.jackhuang.hmcl.ui.construct.NumberValidator
|
||||||
import org.jackhuang.hmcl.util.OS
|
import org.jackhuang.hmcl.util.OS
|
||||||
|
|
||||||
class VersionSettingsController {
|
class VersionSettingsController {
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
* Hello Minecraft! Launcher.
|
||||||
|
* Copyright (C) 2017 huangyuhui <huanghongxun2008@126.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see {http://www.gnu.org/licenses/}.
|
||||||
|
*/
|
||||||
|
package org.jackhuang.hmcl.ui.construct
|
||||||
|
|
||||||
|
import com.jfoenix.controls.JFXButton
|
||||||
|
import javafx.beans.property.Property
|
||||||
|
import javafx.beans.property.SimpleStringProperty
|
||||||
|
import javafx.scene.control.Label
|
||||||
|
import javafx.scene.control.Tooltip
|
||||||
|
import javafx.scene.layout.BorderPane
|
||||||
|
import javafx.scene.layout.VBox
|
||||||
|
import javafx.stage.DirectoryChooser
|
||||||
|
import org.jackhuang.hmcl.ui.Controllers
|
||||||
|
import org.jackhuang.hmcl.ui.SVG
|
||||||
|
import org.jackhuang.hmcl.util.*
|
||||||
|
|
||||||
|
class FileItem : BorderPane() {
|
||||||
|
val nameProperty = SimpleStringProperty(this, "name")
|
||||||
|
var name: String by nameProperty
|
||||||
|
|
||||||
|
val titleProperty = SimpleStringProperty(this, "title")
|
||||||
|
var title: String by titleProperty
|
||||||
|
|
||||||
|
val tooltipProperty = SimpleStringProperty(this, "tooltip")
|
||||||
|
var tooltip: String by tooltipProperty
|
||||||
|
|
||||||
|
private lateinit var property: Property<String>
|
||||||
|
|
||||||
|
private val x = Label()
|
||||||
|
init {
|
||||||
|
left = VBox().apply {
|
||||||
|
children += Label().apply { textProperty().bind(nameProperty) }
|
||||||
|
children += x.apply { style += "-fx-text-fill: gray;" }
|
||||||
|
}
|
||||||
|
|
||||||
|
right = JFXButton().apply {
|
||||||
|
graphic = SVG.pencil("black", 15.0, 15.0)
|
||||||
|
styleClass += "toggle-icon4"
|
||||||
|
setOnMouseClicked {
|
||||||
|
val chooser = DirectoryChooser()
|
||||||
|
chooser.titleProperty().bind(titleProperty)
|
||||||
|
val selectedDir = chooser.showDialog(Controllers.stage)
|
||||||
|
if (selectedDir != null)
|
||||||
|
property.value = selectedDir.absolutePath
|
||||||
|
chooser.titleProperty().unbind()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Tooltip.install(this, Tooltip().apply {
|
||||||
|
textProperty().bind(tooltipProperty)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setProperty(property: Property<String>) {
|
||||||
|
this.property = property
|
||||||
|
x.textProperty().bind(property)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see {http://www.gnu.org/licenses/}.
|
* along with this program. If not, see {http://www.gnu.org/licenses/}.
|
||||||
*/
|
*/
|
||||||
package org.jackhuang.hmcl.ui
|
package org.jackhuang.hmcl.ui.construct
|
||||||
|
|
||||||
import javafx.geometry.Pos
|
import javafx.geometry.Pos
|
||||||
import javafx.scene.Node
|
import javafx.scene.Node
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see {http://www.gnu.org/licenses/}.
|
* along with this program. If not, see {http://www.gnu.org/licenses/}.
|
||||||
*/
|
*/
|
||||||
package org.jackhuang.hmcl.ui
|
package org.jackhuang.hmcl.ui.construct
|
||||||
|
|
||||||
import com.jfoenix.validation.base.ValidatorBase
|
import com.jfoenix.validation.base.ValidatorBase
|
||||||
import javafx.scene.control.TextInputControl
|
import javafx.scene.control.TextInputControl
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see {http://www.gnu.org/licenses/}.
|
* along with this program. If not, see {http://www.gnu.org/licenses/}.
|
||||||
*/
|
*/
|
||||||
package org.jackhuang.hmcl.ui
|
package org.jackhuang.hmcl.ui.construct
|
||||||
|
|
||||||
import javafx.scene.canvas.GraphicsContext
|
import javafx.scene.canvas.GraphicsContext
|
||||||
import javafx.scene.paint.Color
|
import javafx.scene.paint.Color
|
||||||
@@ -15,25 +15,21 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see {http://www.gnu.org/licenses/}.
|
* along with this program. If not, see {http://www.gnu.org/licenses/}.
|
||||||
*/
|
*/
|
||||||
package org.jackhuang.hmcl.ui
|
package org.jackhuang.hmcl.ui.construct
|
||||||
|
|
||||||
import com.jfoenix.controls.JFXRippler
|
import com.jfoenix.controls.JFXRippler
|
||||||
import javafx.animation.Transition
|
import javafx.animation.Transition
|
||||||
import javafx.beans.DefaultProperty
|
import javafx.beans.DefaultProperty
|
||||||
import javafx.beans.NamedArg
|
import javafx.beans.NamedArg
|
||||||
import javafx.beans.Observable
|
|
||||||
import javafx.beans.binding.Bindings
|
import javafx.beans.binding.Bindings
|
||||||
import javafx.beans.property.SimpleBooleanProperty
|
import javafx.beans.property.SimpleBooleanProperty
|
||||||
import javafx.beans.property.SimpleObjectProperty
|
import javafx.beans.property.SimpleObjectProperty
|
||||||
import javafx.geometry.Insets
|
import javafx.geometry.Insets
|
||||||
import javafx.geometry.Pos
|
|
||||||
import javafx.scene.Node
|
import javafx.scene.Node
|
||||||
import javafx.scene.control.Label
|
|
||||||
import javafx.scene.layout.*
|
import javafx.scene.layout.*
|
||||||
import javafx.scene.paint.Color
|
import javafx.scene.paint.Color
|
||||||
import javafx.scene.paint.Paint
|
import javafx.scene.paint.Paint
|
||||||
import javafx.scene.shape.Rectangle
|
import javafx.scene.shape.Rectangle
|
||||||
import javafx.scene.shape.Shape
|
|
||||||
import org.jackhuang.hmcl.util.getValue
|
import org.jackhuang.hmcl.util.getValue
|
||||||
import org.jackhuang.hmcl.util.setValue
|
import org.jackhuang.hmcl.util.setValue
|
||||||
import java.util.concurrent.Callable
|
import java.util.concurrent.Callable
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see {http://www.gnu.org/licenses/}.
|
* along with this program. If not, see {http://www.gnu.org/licenses/}.
|
||||||
*/
|
*/
|
||||||
package org.jackhuang.hmcl.ui
|
package org.jackhuang.hmcl.ui.construct
|
||||||
|
|
||||||
import java.io.InputStreamReader
|
import java.io.InputStreamReader
|
||||||
import java.util.PropertyResourceBundle
|
import java.util.PropertyResourceBundle
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
<?import javafx.collections.FXCollections?>
|
<?import javafx.collections.FXCollections?>
|
||||||
<?import com.jfoenix.controls.JFXTextField?>
|
<?import com.jfoenix.controls.JFXTextField?>
|
||||||
<?import org.jackhuang.hmcl.ui.construct.ComponentList?>
|
<?import org.jackhuang.hmcl.ui.construct.ComponentList?>
|
||||||
|
<?import org.jackhuang.hmcl.ui.construct.FileItem?>
|
||||||
<fx:root xmlns="http://javafx.com/javafx"
|
<fx:root xmlns="http://javafx.com/javafx"
|
||||||
xmlns:fx="http://javafx.com/fxml"
|
xmlns:fx="http://javafx.com/fxml"
|
||||||
type="StackPane">
|
type="StackPane">
|
||||||
@@ -15,8 +16,8 @@
|
|||||||
fitToHeight="true" fitToWidth="true">
|
fitToHeight="true" fitToWidth="true">
|
||||||
<VBox fx:id="rootPane" style="-fx-padding: 20;">
|
<VBox fx:id="rootPane" style="-fx-padding: 20;">
|
||||||
<ComponentList fx:id="settingsPane">
|
<ComponentList fx:id="settingsPane">
|
||||||
<BorderPane><left><Label text="%launcher.common_location" /></left><right></right></BorderPane>
|
<FileItem fx:id="fileCommonLocation" name="%launcher.common_location" title="%launcher.choose_commonpath" tooltip="%launcher.commpath_tooltip" />
|
||||||
<BorderPane><left><Label text="%launcher.background_location" /></left><right></right></BorderPane>
|
<!--FileItem fx:id="fileBackgroundLocation" name="%launcher.background_location" title="%launcher.choose_bgpath" tooltip="%launcher.background_tooltip" /-->
|
||||||
<BorderPane><left><Label text="%launcher.download_source" /></left><right><JFXComboBox fx:id="cboDownloadSource">
|
<BorderPane><left><Label text="%launcher.download_source" /></left><right><JFXComboBox fx:id="cboDownloadSource">
|
||||||
<items>
|
<items>
|
||||||
<FXCollections fx:factory="observableArrayList">
|
<FXCollections fx:factory="observableArrayList">
|
||||||
|
|||||||
@@ -35,13 +35,10 @@
|
|||||||
</VBox>
|
</VBox>
|
||||||
</ComponentList>
|
</ComponentList>
|
||||||
|
|
||||||
<VBox>
|
|
||||||
<BorderPane> <!-- Max Memory -->
|
<BorderPane> <!-- Max Memory -->
|
||||||
<left><Label text="%settings.max_memory" BorderPane.alignment="CENTER_LEFT" /></left>
|
<left><VBox><Label text="%settings.max_memory" BorderPane.alignment="CENTER_LEFT" /><Label fx:id="lblPhysicalMemory" style="-fx-text-fill: gray;" /></VBox></left>
|
||||||
<right><JFXTextField fx:id="txtMaxMemory" BorderPane.alignment="CENTER_RIGHT" /></right>
|
<right><JFXTextField fx:id="txtMaxMemory" BorderPane.alignment="CENTER_RIGHT" /></right>
|
||||||
</BorderPane>
|
</BorderPane>
|
||||||
<Label fx:id="lblPhysicalMemory" style="-fx-text-fill: gray;" />
|
|
||||||
</VBox>
|
|
||||||
|
|
||||||
<BorderPane> <!-- Launcher Visibility -->
|
<BorderPane> <!-- Launcher Visibility -->
|
||||||
<left><Label text="%advancedsettings.launcher_visible" BorderPane.alignment="CENTER_LEFT" /></left>
|
<left><Label text="%advancedsettings.launcher_visible" BorderPane.alignment="CENTER_LEFT" /></left>
|
||||||
|
|||||||
Reference in New Issue
Block a user