mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-16 23:37:14 -04:00
Version setting pane context menu
This commit is contained in:
parent
a67bfabea4
commit
b40b0ec47c
@ -32,9 +32,7 @@ import javafx.fxml.FXMLLoader
|
|||||||
import javafx.scene.Node
|
import javafx.scene.Node
|
||||||
import javafx.scene.Parent
|
import javafx.scene.Parent
|
||||||
import javafx.scene.Scene
|
import javafx.scene.Scene
|
||||||
import javafx.scene.control.ListView
|
import javafx.scene.control.*
|
||||||
import javafx.scene.control.ScrollBar
|
|
||||||
import javafx.scene.control.ScrollPane
|
|
||||||
import javafx.scene.image.WritableImage
|
import javafx.scene.image.WritableImage
|
||||||
import javafx.scene.input.MouseEvent
|
import javafx.scene.input.MouseEvent
|
||||||
import javafx.scene.input.ScrollEvent
|
import javafx.scene.input.ScrollEvent
|
||||||
@ -42,6 +40,11 @@ import javafx.scene.layout.Region
|
|||||||
import javafx.scene.shape.Rectangle
|
import javafx.scene.shape.Rectangle
|
||||||
import javafx.util.Duration
|
import javafx.util.Duration
|
||||||
import org.jackhuang.hmcl.Main
|
import org.jackhuang.hmcl.Main
|
||||||
|
import org.jackhuang.hmcl.util.LOG
|
||||||
|
import org.jackhuang.hmcl.util.OS
|
||||||
|
import java.io.File
|
||||||
|
import java.io.IOException
|
||||||
|
import java.util.logging.Level
|
||||||
|
|
||||||
fun Node.loadFXML(absolutePath: String) {
|
fun Node.loadFXML(absolutePath: String) {
|
||||||
val fxmlLoader = FXMLLoader(this.javaClass.getResource(absolutePath), Main.RESOURCE_BUNDLE)
|
val fxmlLoader = FXMLLoader(this.javaClass.getResource(absolutePath), Main.RESOURCE_BUNDLE)
|
||||||
@ -188,3 +191,41 @@ fun JFXMasonryPane.resetChildren(children: List<Node>) {
|
|||||||
ReflectionHelper.setFieldContent(JFXMasonryPane::class.java, this, "oldBoxes", null)
|
ReflectionHelper.setFieldContent(JFXMasonryPane::class.java, this, "oldBoxes", null)
|
||||||
this.children.setAll(children)
|
this.children.setAll(children)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun openFolder(f: File) {
|
||||||
|
f.mkdirs()
|
||||||
|
val path = f.absolutePath
|
||||||
|
when (OS.CURRENT_OS) {
|
||||||
|
OS.OSX ->
|
||||||
|
try {
|
||||||
|
Runtime.getRuntime().exec(arrayOf("/usr/bin/open", path));
|
||||||
|
} catch (ex: IOException) {
|
||||||
|
LOG.log(Level.SEVERE, "Failed to open $path through /usr/bin/open", ex);
|
||||||
|
}
|
||||||
|
else ->
|
||||||
|
try {
|
||||||
|
java.awt.Desktop.getDesktop().open(f);
|
||||||
|
} catch (ex: Throwable) {
|
||||||
|
LOG.log(Level.SEVERE, "Failed to open $path through java.awt.Desktop.getDesktop().open()", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmOverloads
|
||||||
|
fun alert(type: Alert.AlertType, title: String, contentText: String, headerText: String? = null): Boolean {
|
||||||
|
Alert(type).apply {
|
||||||
|
this.title = title
|
||||||
|
this.headerText = headerText
|
||||||
|
this.contentText = contentText
|
||||||
|
}.showAndWait().run {
|
||||||
|
return isPresent && get() == ButtonType.OK
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmOverloads
|
||||||
|
fun inputDialog(title: String, contentText: String, headerText: String? = null, defaultValue: String = "") =
|
||||||
|
TextInputDialog(defaultValue).apply {
|
||||||
|
this.title = title
|
||||||
|
this.headerText = headerText
|
||||||
|
this.contentText = contentText
|
||||||
|
}.showAndWait()
|
@ -18,36 +18,97 @@
|
|||||||
package org.jackhuang.hmcl.ui
|
package org.jackhuang.hmcl.ui
|
||||||
|
|
||||||
import com.jfoenix.controls.*
|
import com.jfoenix.controls.*
|
||||||
import javafx.beans.InvalidationListener
|
|
||||||
import javafx.beans.property.Property
|
|
||||||
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.control.Label
|
import javafx.scene.control.Alert
|
||||||
import javafx.scene.control.ScrollPane
|
|
||||||
import javafx.scene.layout.*
|
import javafx.scene.layout.*
|
||||||
import javafx.stage.DirectoryChooser
|
import org.jackhuang.hmcl.download.GameAssetIndexDownloadTask
|
||||||
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.VersionSetting
|
|
||||||
import org.jackhuang.hmcl.ui.wizard.DecoratorPage
|
import org.jackhuang.hmcl.ui.wizard.DecoratorPage
|
||||||
import org.jackhuang.hmcl.util.OS
|
|
||||||
|
|
||||||
class VersionPage : StackPane(), DecoratorPage {
|
class VersionPage : StackPane(), DecoratorPage {
|
||||||
override val titleProperty: StringProperty = SimpleStringProperty(this, "title", null)
|
override val titleProperty: StringProperty = SimpleStringProperty(this, "title", null)
|
||||||
|
|
||||||
@FXML lateinit var versionSettingsController: VersionSettingsController
|
@FXML lateinit var versionSettingsController: VersionSettingsController
|
||||||
@FXML lateinit var modController: ModController
|
@FXML lateinit var modController: ModController
|
||||||
|
@FXML lateinit var browseList: JFXListView<*>
|
||||||
|
@FXML lateinit var managementList: JFXListView<*>
|
||||||
|
@FXML lateinit var btnBrowseMenu: JFXButton
|
||||||
|
@FXML lateinit var btnManagementMenu: JFXButton
|
||||||
|
val browsePopup: JFXPopup
|
||||||
|
val managementPopup: JFXPopup
|
||||||
|
lateinit var profile: Profile
|
||||||
|
lateinit var version: String
|
||||||
|
|
||||||
init {
|
init {
|
||||||
loadFXML("/assets/fxml/version.fxml")
|
loadFXML("/assets/fxml/version.fxml")
|
||||||
|
|
||||||
|
children -= browseList
|
||||||
|
children -= managementList
|
||||||
|
|
||||||
|
browsePopup = JFXPopup(browseList)
|
||||||
|
managementPopup = JFXPopup(managementList)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun load(id: String, profile: Profile) {
|
fun load(id: String, profile: Profile) {
|
||||||
|
this.version = id
|
||||||
|
this.profile = profile
|
||||||
titleProperty.set(i18n("launcher.title.game") + " - " + id)
|
titleProperty.set(i18n("launcher.title.game") + " - " + id)
|
||||||
|
|
||||||
versionSettingsController.loadVersionSetting(profile.getVersionSetting(id))
|
versionSettingsController.loadVersionSetting(profile.getVersionSetting(id))
|
||||||
modController.loadMods(profile.modManager, id)
|
modController.loadMods(profile.modManager, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun onBrowseMenu() {
|
||||||
|
browseList.selectionModel.select(-1)
|
||||||
|
browsePopup.show(btnBrowseMenu, JFXPopup.PopupVPosition.TOP, JFXPopup.PopupHPosition.RIGHT, -12.0, 15.0)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun onManagementMenu() {
|
||||||
|
managementList.selectionModel.select(-1)
|
||||||
|
managementPopup.show(btnManagementMenu, JFXPopup.PopupVPosition.TOP, JFXPopup.PopupHPosition.RIGHT, -12.0, 15.0)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun onBrowse() {
|
||||||
|
openFolder(profile.repository.getRunDirectory(version).resolve(when (browseList.selectionModel.selectedIndex) {
|
||||||
|
0 -> ""
|
||||||
|
1 -> "mods"
|
||||||
|
2 -> "coremods"
|
||||||
|
3 -> "config"
|
||||||
|
4 -> "resourcepacks"
|
||||||
|
5 -> "screenshots"
|
||||||
|
6 -> "saves"
|
||||||
|
else -> throw Error()
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
fun onManagement() {
|
||||||
|
when(managementList.selectionModel.selectedIndex) {
|
||||||
|
0 -> { // rename a version
|
||||||
|
val res = inputDialog(title = "Input", contentText = i18n("versions.manage.rename.message"), defaultValue = version)
|
||||||
|
if (res.isPresent)
|
||||||
|
if (profile.repository.renameVersion(version, res.get())) {
|
||||||
|
profile.repository.refreshVersions()
|
||||||
|
Controllers.navigate(null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
1 -> { // remove a version
|
||||||
|
if (alert(Alert.AlertType.CONFIRMATION, "Confirm", i18n("versions.manage.remove.confirm") + version))
|
||||||
|
if (profile.repository.removeVersionFromDisk(version)) {
|
||||||
|
profile.repository.refreshVersions()
|
||||||
|
Controllers.navigate(null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
2 -> { // redownload asset index
|
||||||
|
GameAssetIndexDownloadTask(profile.dependency, profile.repository.getVersion(version).resolve(profile.repository)).start()
|
||||||
|
}
|
||||||
|
3 -> { // delete libraries
|
||||||
|
profile.repository.baseDirectory.resolve("libraries").deleteRecursively()
|
||||||
|
}
|
||||||
|
else -> throw Error()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,8 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<?import java.lang.*?>
|
|
||||||
<?import java.util.*?>
|
|
||||||
<?import javafx.scene.*?>
|
|
||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
|
|
||||||
@ -13,14 +10,13 @@
|
|||||||
type="StackPane">
|
type="StackPane">
|
||||||
<JFXDialogLayout>
|
<JFXDialogLayout>
|
||||||
<heading>
|
<heading>
|
||||||
<Label>JFoenix Dialog</Label>
|
<Label text="%message.info" />
|
||||||
</heading>
|
</heading>
|
||||||
<body>
|
<body>
|
||||||
<Label fx:id="content" textAlignment="JUSTIFY" wrapText="true" />
|
<Label fx:id="content" textAlignment="JUSTIFY" wrapText="true" />
|
||||||
</body>
|
</body>
|
||||||
<actions>
|
<actions>
|
||||||
<JFXButton fx:id="acceptButton" styleClass="dialog-accept">ACCEPT
|
<JFXButton fx:id="acceptButton" styleClass="dialog-accept" text="%button.ok" />
|
||||||
</JFXButton>
|
|
||||||
</actions>
|
</actions>
|
||||||
</JFXDialogLayout>
|
</JFXDialogLayout>
|
||||||
</fx:root>
|
</fx:root>
|
||||||
|
@ -15,12 +15,33 @@
|
|||||||
</Tab>
|
</Tab>
|
||||||
</JFXTabPane>
|
</JFXTabPane>
|
||||||
|
|
||||||
<JFXRippler fx:id="optionsRippler" maskType="CIRCLE"
|
<HBox alignment="TOP_RIGHT" style="-fx-padding: 3px;" pickOnBounds="false">
|
||||||
style="-fx-ripple-color:WHITE;"
|
<JFXButton fx:id="btnBrowseMenu" maxHeight="28.0" minHeight="28.0" onMouseClicked="#onBrowseMenu" styleClass="toggle-icon3" ripplerFill="white">
|
||||||
StackPane.alignment="TOP_RIGHT" maxWidth="15" maxHeight="15">
|
<graphic>
|
||||||
<StackPane fx:id="optionsBurger">
|
<fx:include source="/assets/svg/folder-open.fxml"/>
|
||||||
<JFXHamburger styleClass="jfx-options-burger">
|
</graphic>
|
||||||
</JFXHamburger>
|
</JFXButton>
|
||||||
</StackPane>
|
<JFXButton fx:id="btnManagementMenu" maxHeight="28.0" minHeight="28.0" onMouseClicked="#onManagementMenu" styleClass="toggle-icon3" ripplerFill="white">
|
||||||
</JFXRippler>
|
<graphic>
|
||||||
|
<fx:include source="/assets/svg/wrench-black.fxml"/>
|
||||||
|
</graphic>
|
||||||
|
</JFXButton>
|
||||||
|
</HBox>
|
||||||
|
|
||||||
|
<JFXListView fx:id="browseList" styleClass="option-list-view" onMouseClicked="#onBrowse" maxWidth="150.0" minWidth="150.0">
|
||||||
|
<Label text="%folder.game" />
|
||||||
|
<Label text="%folder.mod" />
|
||||||
|
<Label text="%folder.coremod" />
|
||||||
|
<Label text="%folder.config" />
|
||||||
|
<Label text="%folder.resourcepacks" />
|
||||||
|
<Label text="%folder.screenshots" />
|
||||||
|
<Label text="%folder.saves" />
|
||||||
|
</JFXListView>
|
||||||
|
|
||||||
|
<JFXListView fx:id="managementList" styleClass="option-list-view" onMouseClicked="#onManagement" maxWidth="300.0" minWidth="300.0">
|
||||||
|
<Label text="%versions.manage.rename" />
|
||||||
|
<Label text="%versions.manage.remove" />
|
||||||
|
<Label text="%versions.manage.redownload_assets_index" />
|
||||||
|
<Label text="%versions.manage.remove_libraries" />
|
||||||
|
</JFXListView>
|
||||||
</fx:root>
|
</fx:root>
|
||||||
|
@ -353,7 +353,7 @@ versions.manage.remove=Delete this version
|
|||||||
versions.manage.remove.confirm=Sure to remove the version
|
versions.manage.remove.confirm=Sure to remove the version
|
||||||
versions.manage.redownload_json=Redownload Minecraft Configuration(minecraft.json)
|
versions.manage.redownload_json=Redownload Minecraft Configuration(minecraft.json)
|
||||||
versions.manage.redownload_assets_index=Redownload Assets Index
|
versions.manage.redownload_assets_index=Redownload Assets Index
|
||||||
versions.mamage.remove_libraries=Delete library files
|
versions.manage.remove_libraries=Delete library files
|
||||||
|
|
||||||
advice.os64butjdk32=Your OS is 64-Bit but your Java is 32-Bit. The 64-Bit Java is recommended.
|
advice.os64butjdk32=Your OS is 64-Bit but your Java is 32-Bit. The 64-Bit Java is recommended.
|
||||||
advice.java8=Java 8 is suggested, which can make game run more fluently. And many mods and Minecraft 1.12 and newer versions requires Java 8.
|
advice.java8=Java 8 is suggested, which can make game run more fluently. And many mods and Minecraft 1.12 and newer versions requires Java 8.
|
||||||
|
@ -353,7 +353,7 @@ versions.manage.remove=Удалить версию
|
|||||||
versions.manage.remove.confirm=Не забудьте удалить версию
|
versions.manage.remove.confirm=Не забудьте удалить версию
|
||||||
versions.manage.redownload_json=Повторная загрузка конфигурации в Minecraft(minecraft.json)
|
versions.manage.redownload_json=Повторная загрузка конфигурации в Minecraft(minecraft.json)
|
||||||
versions.manage.redownload_assets_index=Перекачать библиотеки
|
versions.manage.redownload_assets_index=Перекачать библиотеки
|
||||||
versions.mamage.remove_libraries=Библиотека удалить файлы
|
versions.manage.remove_libraries=Библиотека удалить файлы
|
||||||
|
|
||||||
advice.os64butjdk32=Ваша ОС 64-битная, но ваш java является 32-разрядной. Вам рекомендуется 64-разрядная версия java.
|
advice.os64butjdk32=Ваша ОС 64-битная, но ваш java является 32-разрядной. Вам рекомендуется 64-разрядная версия java.
|
||||||
advice.java8=Java 8 представляет предположил, что может сделать игру работать более производительной. Многие моды и Minecraft 1.12 и новые версии требуют java 8.
|
advice.java8=Java 8 представляет предположил, что может сделать игру работать более производительной. Многие моды и Minecraft 1.12 и новые версии требуют java 8.
|
||||||
|
@ -351,7 +351,7 @@ versions.manage.remove=Xóa phiên bản này
|
|||||||
versions.manage.remove.confirm=Bạn có chắc để xóa phiên bản này không?
|
versions.manage.remove.confirm=Bạn có chắc để xóa phiên bản này không?
|
||||||
versions.manage.redownload_json=Download lại cấu hình của minecraft(minecraft.json)
|
versions.manage.redownload_json=Download lại cấu hình của minecraft(minecraft.json)
|
||||||
versions.manage.redownload_assets_index=Download lại Assets Index
|
versions.manage.redownload_assets_index=Download lại Assets Index
|
||||||
versions.mamage.remove_libraries=Xóa libraries file
|
versions.manage.remove_libraries=Xóa libraries file
|
||||||
|
|
||||||
advice.os64butjdk32=Hệ điều hành của bạn là 64-Bit nhưng phiên bản Java của bạn là 32-Bit. Khuyên bạn nên dùng Java 64-Bit.
|
advice.os64butjdk32=Hệ điều hành của bạn là 64-Bit nhưng phiên bản Java của bạn là 32-Bit. Khuyên bạn nên dùng Java 64-Bit.
|
||||||
advice.java8=Java 8 is suggested, which can make game run more fluently. And many mods and Minecraft 1.12 and newer versions requires Java 8.
|
advice.java8=Java 8 is suggested, which can make game run more fluently. And many mods and Minecraft 1.12 and newer versions requires Java 8.
|
||||||
|
@ -353,7 +353,7 @@ versions.manage.remove=刪除該版本
|
|||||||
versions.manage.remove.confirm=真的要刪除版本
|
versions.manage.remove.confirm=真的要刪除版本
|
||||||
versions.manage.redownload_json=重新下載版本配置(minecraft.json)
|
versions.manage.redownload_json=重新下載版本配置(minecraft.json)
|
||||||
versions.manage.redownload_assets_index=重新下載資源配置(assets_index.json)
|
versions.manage.redownload_assets_index=重新下載資源配置(assets_index.json)
|
||||||
versions.mamage.remove_libraries=刪除所有庫檔
|
versions.manage.remove_libraries=刪除所有庫檔
|
||||||
|
|
||||||
advice.os64butjdk32=您的系統是64-bit,但是Java是32位的,推薦您安裝64位Java.
|
advice.os64butjdk32=您的系統是64-bit,但是Java是32位的,推薦您安裝64位Java.
|
||||||
advice.java8=檢測到您未使用Java 8及更新版本,Java 8能使遊戲更流暢而且Minecraft 1.12及更新版本和很多Mod強制需要需要Java 8。
|
advice.java8=檢測到您未使用Java 8及更新版本,Java 8能使遊戲更流暢而且Minecraft 1.12及更新版本和很多Mod強制需要需要Java 8。
|
||||||
|
@ -353,7 +353,7 @@ versions.manage.remove=删除该版本
|
|||||||
versions.manage.remove.confirm=真的要删除版本
|
versions.manage.remove.confirm=真的要删除版本
|
||||||
versions.manage.redownload_json=重新下载版本配置(minecraft.json)
|
versions.manage.redownload_json=重新下载版本配置(minecraft.json)
|
||||||
versions.manage.redownload_assets_index=重新下载资源配置(assets_index.json)
|
versions.manage.redownload_assets_index=重新下载资源配置(assets_index.json)
|
||||||
versions.mamage.remove_libraries=删除所有库文件
|
versions.manage.remove_libraries=删除所有库文件
|
||||||
|
|
||||||
advice.os64butjdk32=您的系统是64位的但是Java是32位的,推荐您安装64位Java.
|
advice.os64butjdk32=您的系统是64位的但是Java是32位的,推荐您安装64位Java.
|
||||||
advice.java8=检测到您未使用Java 8及更新版本,Java 8能使游戏更流畅而且Minecraft 1.12及更新版本和很多Mod强制需要需要Java 8。
|
advice.java8=检测到您未使用Java 8及更新版本,Java 8能使游戏更流畅而且Minecraft 1.12及更新版本和很多Mod强制需要需要Java 8。
|
||||||
|
2
HMCL/src/main/resources/assets/svg/folder-black.fxml
Normal file
2
HMCL/src/main/resources/assets/svg/folder-black.fxml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<javafx.scene.shape.SVGPath fill="black" content="M10,4H4C2.89,4 2,4.89 2,6V18A2,2 0 0,0 4,20H20A2,2 0 0,0 22,18V8C22,6.89 21.1,6 20,6H12L10,4Z" />
|
2
HMCL/src/main/resources/assets/svg/wrench-black.fxml
Normal file
2
HMCL/src/main/resources/assets/svg/wrench-black.fxml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<javafx.scene.shape.SVGPath fill="black" content="M22.7,19L13.6,9.9C14.5,7.6 14,4.9 12.1,3C10.1,1 7.1,0.6 4.7,1.7L9,6L6,9L1.6,4.7C0.4,7.1 0.9,10.1 2.9,12.1C4.8,14 7.5,14.5 9.8,13.6L18.9,22.7C19.3,23.1 19.9,23.1 20.3,22.7L22.6,20.4C23.1,20 23.1,19.3 22.7,19Z" />
|
@ -111,8 +111,10 @@ open class Version(
|
|||||||
protected open fun resolve(provider: VersionProvider, resolvedSoFar: MutableSet<String>): Version {
|
protected open fun resolve(provider: VersionProvider, resolvedSoFar: MutableSet<String>): Version {
|
||||||
if (this.inheritsFrom == null)
|
if (this.inheritsFrom == null)
|
||||||
return this
|
return this
|
||||||
if (!resolvedSoFar.add(this.id))
|
if (!resolvedSoFar.add(this.id)) {
|
||||||
throw CircleDependencyException(resolvedSoFar.toString())
|
LOG.warning("Found circular dependency versions: $resolvedSoFar")
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
// It is supposed to auto install an version in getVersion.
|
// It is supposed to auto install an version in getVersion.
|
||||||
val parent = provider.getVersion(this.inheritsFrom).resolve(provider, resolvedSoFar)
|
val parent = provider.getVersion(this.inheritsFrom).resolve(provider, resolvedSoFar)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user