diff --git a/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/AccountItem.kt b/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/AccountItem.kt index 9a4bd285e..a218b409b 100644 --- a/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/AccountItem.kt +++ b/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/AccountItem.kt @@ -25,9 +25,12 @@ import javafx.beans.binding.Bindings import javafx.fxml.FXML import javafx.scene.control.Label import javafx.scene.control.ToggleGroup +import javafx.scene.effect.BlurType +import javafx.scene.effect.DropShadow import javafx.scene.layout.Pane import javafx.scene.layout.StackPane import javafx.scene.layout.VBox +import javafx.scene.paint.Color import java.util.concurrent.Callable class AccountItem(i: Int, group: ToggleGroup) : StackPane() { @@ -43,14 +46,17 @@ class AccountItem(i: Int, group: ToggleGroup) : StackPane() { init { loadFXML("/assets/fxml/account-item.fxml") - JFXDepthManager.setDepth(this, 1) + limitWidth(150.0) + limitHeight(140.0) + + effect = DropShadow(BlurType.GAUSSIAN, Color.rgb(0, 0, 0, 0.26), 5.0, 0.12, -0.5, 1.0) chkSelected.toggleGroup = group btnDelete.graphic = SVG.delete("white", 15.0, 15.0) // create content val headerColor = getDefaultColor(i % 12) - header.style = "-fx-background-radius: 5 5 0 0; -fx-background-color: " + headerColor + header.style = "-fx-background-radius: 2 2 0 0; -fx-background-color: " + headerColor body.minHeight = Math.random() * 20 + 50 // create image view diff --git a/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/AdvancedListBox.kt b/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/AdvancedListBox.kt index f94f9aa0d..9f191083b 100644 --- a/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/AdvancedListBox.kt +++ b/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/AdvancedListBox.kt @@ -41,13 +41,11 @@ class AdvancedListBox: ScrollPane() { fun add(child: Node): AdvancedListBox { if (child is Pane) { - //child.maxWidthProperty().bind(this.widthProperty()) container.children += child } else { val pane = StackPane() pane.styleClass += "advanced-list-box-item" pane.children.setAll(child) - //pane.maxWidthProperty().bind(this.widthProperty()) container.children += pane } return this diff --git a/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/FXUtils.kt b/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/FXUtils.kt index a73239bdf..acd841fc3 100644 --- a/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/FXUtils.kt +++ b/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/FXUtils.kt @@ -121,7 +121,17 @@ val stylesheets = arrayOf( Controllers::class.java.getResource("/css/jfoenix-design.css").toExternalForm(), Controllers::class.java.getResource("/assets/css/jfoenix-main-demo.css").toExternalForm()) +fun Region.limitWidth(width: Double) { + maxWidth = width + minWidth = width + prefWidth = width +} +fun Region.limitHeight(height: Double) { + maxHeight = height + minHeight = height + prefHeight = height +} fun bindInt(textField: JFXTextField, property: Property<*>) { textField.textProperty().unbind() diff --git a/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/LeftPaneController.kt b/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/LeftPaneController.kt index b84d4bea1..88bb031ca 100644 --- a/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/LeftPaneController.kt +++ b/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/LeftPaneController.kt @@ -47,7 +47,14 @@ class LeftPaneController(private val leftPane: AdvancedListBox) { }) .startCategory(i18n("ui.label.profile")) .add(cboProfiles) - .startCategory(i18n("ui.label.version")) + .startCategory("LAUNCHER") + .add(IconedItem(SVG.gear("black"), "Settings").apply { + prefWidthProperty().bind(leftPane.widthProperty()) + setOnMouseClicked { + Controllers.navigate(Controllers.settingsPane) + } + }) +/* .startCategory(i18n("ui.label.version")) .add(versionsPane) EVENT_BUS.channel() += this::loadVersions @@ -62,7 +69,7 @@ class LeftPaneController(private val leftPane: AdvancedListBox) { Controllers.decorator.refreshMenuButton.setOnMouseClicked { Settings.selectedProfile.repository.refreshVersions() } - Controllers.mainPane.buttonLaunch.setOnMouseClicked { LauncherHelper.launch() } + Controllers.mainPane.buttonLaunch.setOnMouseClicked { LauncherHelper.launch() }*/ Settings.selectedAccountProperty.addListener { _, _, newValue -> if (newValue == null) { @@ -78,7 +85,7 @@ class LeftPaneController(private val leftPane: AdvancedListBox) { if (Settings.getAccounts().isEmpty()) Controllers.navigate(AccountsPage()) } - +/* fun onProfilesLoading() { // TODO: Profiles } @@ -119,5 +126,5 @@ class LeftPaneController(private val leftPane: AdvancedListBox) { versionsPane.children .filter { it is RipplerContainer && it.properties["version"] is Pair<*, *> } .forEach { (it as RipplerContainer).selected = (it.properties["version"] as Pair).first == selectedVersion } - } + }*/ } \ No newline at end of file diff --git a/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/MainPage.kt b/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/MainPage.kt index dcd36aa68..ddfc2c807 100644 --- a/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/MainPage.kt +++ b/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/MainPage.kt @@ -48,25 +48,21 @@ import org.jackhuang.hmcl.ui.wizard.DecoratorPage class MainPage : StackPane(), DecoratorPage { override val titleProperty: StringProperty = SimpleStringProperty(this, "title", i18n("launcher.title.main")) - @FXML lateinit var buttonLaunch: JFXButton + @FXML lateinit var btnLaunch: JFXButton @FXML lateinit var masonryPane: JFXMasonryPane init { loadFXML("/assets/fxml/main.fxml") - //EVENT_BUS.channel() += this::loadVersions - //EVENT_BUS.channel() += this::onProfilesLoading - //EVENT_BUS.channel() += this::onProfileChanged + EVENT_BUS.channel() += this::loadVersions + EVENT_BUS.channel() += this::onProfilesLoading + EVENT_BUS.channel() += this::onProfileChanged - //Settings.onProfileLoading() + Settings.onProfileLoading() - //Controllers.decorator.addMenuButton.setOnMouseClicked { // Controllers.decorator.startWizard(DownloadWizardProvider(), "Install New Game") - //} - //Controllers.decorator.refreshMenuButton.setOnMouseClicked { // Settings.selectedProfile.repository.refreshVersions() - //} - //buttonLaunch.setOnMouseClicked { LauncherHelper.launch() } + btnLaunch.setOnMouseClicked { LauncherHelper.launch() } } private fun buildNode(i: Int, profile: Profile, version: String, game: String, group: ToggleGroup): Node { @@ -79,6 +75,10 @@ class MainPage : StackPane(), DecoratorPage { profile.repository.removeVersionFromDisk(version) Platform.runLater(this@MainPage::loadVersions) } + btnSettings.setOnMouseClicked { + Controllers.decorator.showPage(Controllers.versionPane) + Controllers.versionPane.load(version, profile) + } } } diff --git a/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/SidePaneController.kt b/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/SidePaneController.kt index da9642751..666d6143a 100644 --- a/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/SidePaneController.kt +++ b/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/SidePaneController.kt @@ -21,14 +21,5 @@ import com.jfoenix.controls.JFXDrawer class SidePaneController(sidePane: AdvancedListBox, drawer: JFXDrawer) { init { - sidePane - .startCategory("LAUNCHER") - .add(IconedItem(SVG.gear("black"), "Settings").apply { - prefWidthProperty().bind(sidePane.widthProperty()) - setOnMouseClicked { - Controllers.navigate(Controllers.settingsPane) - drawer.close() - } - }) } } \ No newline at end of file diff --git a/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/VersionItem.kt b/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/VersionItem.kt index 507d0f4ec..e51c90e91 100644 --- a/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/VersionItem.kt +++ b/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/VersionItem.kt @@ -25,9 +25,12 @@ import javafx.beans.binding.Bindings import javafx.fxml.FXML import javafx.scene.control.Label import javafx.scene.control.ToggleGroup +import javafx.scene.effect.BlurType +import javafx.scene.effect.DropShadow import javafx.scene.layout.Pane import javafx.scene.layout.StackPane import javafx.scene.layout.VBox +import javafx.scene.paint.Color import java.util.concurrent.Callable class VersionItem(i: Int, group: ToggleGroup) : StackPane() { @@ -36,6 +39,7 @@ class VersionItem(i: Int, group: ToggleGroup) : StackPane() { @FXML lateinit var header: StackPane @FXML lateinit var body: StackPane @FXML lateinit var btnDelete: JFXButton + @FXML lateinit var btnSettings: JFXButton @FXML lateinit var lblVersionName: Label @FXML lateinit var chkSelected: JFXRadioButton @FXML lateinit var lblGameVersion: Label @@ -43,18 +47,21 @@ class VersionItem(i: Int, group: ToggleGroup) : StackPane() { init { loadFXML("/assets/fxml/version-item.fxml") - JFXDepthManager.setDepth(this, 1) + limitWidth(190.0) + limitHeight(156.0) + + effect = DropShadow(BlurType.GAUSSIAN, Color.rgb(0, 0, 0, 0.26), 5.0, 0.12, -1.0, 1.0) chkSelected.toggleGroup = group - btnDelete.graphic = SVG.delete("white", 15.0, 15.0) + btnSettings.graphic = SVG.gear("black", 15.0, 15.0) + btnDelete.graphic = SVG.delete("black", 15.0, 15.0) // create content val headerColor = getDefaultColor(i % 12) - header.style = "-fx-background-radius: 5 5 0 0; -fx-background-color: " + headerColor - body.minHeight = 50.0 + header.style = "-fx-background-radius: 2 2 0 0; -fx-background-color: " + headerColor // create image view - icon.translateYProperty().bind(Bindings.createDoubleBinding(Callable { header.boundsInParent.height - icon.height / 2 }, header.boundsInParentProperty(), icon.heightProperty())) + icon.translateYProperty().bind(Bindings.createDoubleBinding(Callable { header.boundsInParent.height - icon.height }, header.boundsInParentProperty(), icon.heightProperty())) } private fun getDefaultColor(i: Int): String { diff --git a/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/construct/NoneMultipleSelectionModel.kt b/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/construct/NoneMultipleSelectionModel.kt new file mode 100644 index 000000000..44371d855 --- /dev/null +++ b/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/construct/NoneMultipleSelectionModel.kt @@ -0,0 +1,40 @@ +/* + * Hello Minecraft! Launcher. + * Copyright (C) 2017 huangyuhui + * + * 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 javafx.collections.FXCollections +import javafx.collections.ObservableList +import javafx.scene.control.MultipleSelectionModel + +class NoneMultipleSelectionModel : MultipleSelectionModel() { + override fun isEmpty() = true + override fun selectAll() = Unit + override fun selectIndices(index: Int, vararg indices: Int) = Unit + override fun select(obj: T) = Unit + override fun select(index: Int) = Unit + override fun selectLast() = Unit + override fun selectFirst() = Unit + override fun selectNext() = Unit + override fun clearSelection(index: Int) = Unit + override fun clearSelection() = Unit + override fun clearAndSelect(index: Int) = Unit + override fun selectPrevious() = Unit + override fun isSelected(index: Int) = false + override fun getSelectedItems(): ObservableList = FXCollections.emptyObservableList() + override fun getSelectedIndices(): ObservableList = FXCollections.emptyObservableList() +} \ No newline at end of file diff --git a/HMCL/src/main/resources/assets/fxml/account-item.fxml b/HMCL/src/main/resources/assets/fxml/account-item.fxml index f0e2cdbcd..782111f5a 100644 --- a/HMCL/src/main/resources/assets/fxml/account-item.fxml +++ b/HMCL/src/main/resources/assets/fxml/account-item.fxml @@ -12,25 +12,22 @@ xmlns:fx="http://javafx.com/fxml" type="StackPane"> - + - - + +
- - + - +
- +
diff --git a/HMCL/src/main/resources/assets/fxml/decorator.fxml b/HMCL/src/main/resources/assets/fxml/decorator.fxml index 977357d0c..23450ea0b 100644 --- a/HMCL/src/main/resources/assets/fxml/decorator.fxml +++ b/HMCL/src/main/resources/assets/fxml/decorator.fxml @@ -4,13 +4,10 @@ - - - @@ -37,24 +34,6 @@
- - - - - - - - - - - - - - - - - - diff --git a/HMCL/src/main/resources/assets/fxml/main.fxml b/HMCL/src/main/resources/assets/fxml/main.fxml index 91b1bfe6f..1e4b3eb24 100644 --- a/HMCL/src/main/resources/assets/fxml/main.fxml +++ b/HMCL/src/main/resources/assets/fxml/main.fxml @@ -7,25 +7,30 @@ maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" styleClass="transparent" type="StackPane" xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1"> - - -
- -
- - - - - - - - - - -
+ + + + + + + + + + + + + + + + + + +
diff --git a/HMCL/src/main/resources/assets/fxml/version-item.fxml b/HMCL/src/main/resources/assets/fxml/version-item.fxml index 97b97c6d7..83968f18b 100644 --- a/HMCL/src/main/resources/assets/fxml/version-item.fxml +++ b/HMCL/src/main/resources/assets/fxml/version-item.fxml @@ -12,26 +12,36 @@ xmlns:fx="http://javafx.com/fxml" type="StackPane"> - + - - +
- -
- - + + + + + + + + + + + + +
- + diff --git a/HMCL/src/main/resources/assets/fxml/version-list-item.fxml b/HMCL/src/main/resources/assets/fxml/version-list-item.fxml index ebaf550df..5f465f633 100644 --- a/HMCL/src/main/resources/assets/fxml/version-list-item.fxml +++ b/HMCL/src/main/resources/assets/fxml/version-list-item.fxml @@ -19,10 +19,10 @@ - - diff --git a/HMCL/src/main/resources/assets/svg/rocket.fxml b/HMCL/src/main/resources/assets/svg/rocket.fxml index 8558b678b..dad02ad60 100644 --- a/HMCL/src/main/resources/assets/svg/rocket.fxml +++ b/HMCL/src/main/resources/assets/svg/rocket.fxml @@ -1,2 +1,2 @@ - +