diff --git a/HMCL/src/main/kotlin/org/jackhuang/hmcl/MainApplication.kt b/HMCL/src/main/kotlin/org/jackhuang/hmcl/Main.kt similarity index 96% rename from HMCL/src/main/kotlin/org/jackhuang/hmcl/MainApplication.kt rename to HMCL/src/main/kotlin/org/jackhuang/hmcl/Main.kt index a63a6d4c8..65e0d79ea 100644 --- a/HMCL/src/main/kotlin/org/jackhuang/hmcl/MainApplication.kt +++ b/HMCL/src/main/kotlin/org/jackhuang/hmcl/Main.kt @@ -25,7 +25,7 @@ import org.jackhuang.hmcl.util.DEFAULT_USER_AGENT import org.jackhuang.hmcl.util.OS import java.io.File -class MainApplication : Application() { +class Main : Application() { override fun start(stage: Stage) { PRIMARY_STAGE = stage @@ -46,7 +46,7 @@ class MainApplication : Application() { fun main(args: Array) { DEFAULT_USER_AGENT = "Hello Minecraft! Launcher" - launch(MainApplication::class.java, *args) + launch(Main::class.java, *args) } fun getWorkingDirectory(folder: String): File { diff --git a/HMCL/src/main/kotlin/org/jackhuang/hmcl/setting/Config.kt b/HMCL/src/main/kotlin/org/jackhuang/hmcl/setting/Config.kt index 901d7e39f..fa4b19f88 100644 --- a/HMCL/src/main/kotlin/org/jackhuang/hmcl/setting/Config.kt +++ b/HMCL/src/main/kotlin/org/jackhuang/hmcl/setting/Config.kt @@ -18,7 +18,7 @@ package org.jackhuang.hmcl.setting import com.google.gson.annotations.SerializedName -import org.jackhuang.hmcl.MainApplication +import org.jackhuang.hmcl.Main import org.jackhuang.hmcl.util.JavaVersion import java.io.File import java.util.TreeMap @@ -37,7 +37,7 @@ class Config { Settings.save() } @SerializedName("commonpath") - var commonpath: File = MainApplication.getMinecraftDirectory() + var commonpath: File = Main.getMinecraftDirectory() set(value) { field = value Settings.save() diff --git a/HMCL/src/main/kotlin/org/jackhuang/hmcl/setting/Settings.kt b/HMCL/src/main/kotlin/org/jackhuang/hmcl/setting/Settings.kt index 2b05398b6..813b6779c 100644 --- a/HMCL/src/main/kotlin/org/jackhuang/hmcl/setting/Settings.kt +++ b/HMCL/src/main/kotlin/org/jackhuang/hmcl/setting/Settings.kt @@ -20,7 +20,7 @@ package org.jackhuang.hmcl.setting import com.google.gson.GsonBuilder import javafx.beans.InvalidationListener import java.io.IOException -import org.jackhuang.hmcl.MainApplication +import org.jackhuang.hmcl.Main import org.jackhuang.hmcl.download.BMCLAPIDownloadProvider import org.jackhuang.hmcl.download.DownloadProvider import org.jackhuang.hmcl.download.MojangDownloadProvider @@ -117,7 +117,7 @@ object Settings { else { LOG.config("No settings file here, may be first loading.") if (!c.configurations.containsKey(HOME_PROFILE)) - c.configurations[HOME_PROFILE] = Profile(HOME_PROFILE, MainApplication.getMinecraftDirectory()) + c.configurations[HOME_PROFILE] = Profile(HOME_PROFILE, Main.getMinecraftDirectory()) } return c } diff --git a/HMCL/src/main/kotlin/org/jackhuang/hmcl/setting/VersionSetting.kt b/HMCL/src/main/kotlin/org/jackhuang/hmcl/setting/VersionSetting.kt index d97be135a..30e573054 100644 --- a/HMCL/src/main/kotlin/org/jackhuang/hmcl/setting/VersionSetting.kt +++ b/HMCL/src/main/kotlin/org/jackhuang/hmcl/setting/VersionSetting.kt @@ -19,7 +19,7 @@ package org.jackhuang.hmcl.setting import com.google.gson.* import javafx.beans.InvalidationListener -import org.jackhuang.hmcl.MainApplication +import org.jackhuang.hmcl.Main import org.jackhuang.hmcl.game.LaunchOptions import org.jackhuang.hmcl.util.* import org.jackhuang.hmcl.util.property.* @@ -189,8 +189,8 @@ class VersionSetting() { gameDir = gameDir, java = if (java == null) JavaVersion.fromCurrentEnvironment() else JavaVersion.fromExecutable(File(java)), - versionName = MainApplication.TITLE, - profileName = MainApplication.TITLE, + versionName = Main.TITLE, + profileName = Main.TITLE, minecraftArgs = minecraftArgs, javaArgs = javaArgs, maxMemory = maxMemory, diff --git a/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/AdvancedListBox.kt b/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/AdvancedListBox.kt new file mode 100644 index 000000000..40195d59d --- /dev/null +++ b/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/AdvancedListBox.kt @@ -0,0 +1,54 @@ +/* + * 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 + +import javafx.scene.Node +import javafx.scene.control.ScrollPane +import javafx.scene.layout.Pane +import javafx.scene.layout.StackPane +import javafx.scene.layout.VBox + +class AdvancedListBox: ScrollPane() { + val container = VBox() + + init { + content = container + + smoothScrolling() + + isFitToHeight = true + isFitToWidth = true + + container.spacing = 5.0 + container.styleClass += "advanced-list-box-content" + } + + fun add(child: Node): AdvancedListBox { + if (child is Pane) { + container.children += child + } else { + val pane = StackPane() + pane.styleClass += "advanced-list-box-item" + pane.children.setAll(child) + container.children += pane + } + return this + } + + fun startCategory(category: String): AdvancedListBox = add(ClassTitle(category)) +} \ No newline at end of file diff --git a/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/Controllers.kt b/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/Controllers.kt index c84acdee4..3e4f5c015 100644 --- a/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/Controllers.kt +++ b/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/Controllers.kt @@ -32,6 +32,7 @@ object Controllers { val versionPane = VersionPage() lateinit var leftPaneController: LeftPaneController + lateinit var sidePaneController: SidePaneController lateinit var decorator: Decorator @@ -41,6 +42,7 @@ object Controllers { decorator = Decorator(stage, mainPane, max = false) decorator.showPage(null) leftPaneController = LeftPaneController(decorator.leftPane) + sidePaneController = SidePaneController(decorator.sidePane) decorator.isCustomMaximize = false diff --git a/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/Decorator.kt b/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/Decorator.kt index fbb2d47d6..e505ffbe2 100644 --- a/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/Decorator.kt +++ b/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/Decorator.kt @@ -18,6 +18,8 @@ package org.jackhuang.hmcl.ui import com.jfoenix.controls.JFXButton +import com.jfoenix.controls.JFXDrawer +import com.jfoenix.controls.JFXHamburger import com.jfoenix.effects.JFXDepthManager import com.jfoenix.svg.SVGGlyph import javafx.animation.* @@ -33,6 +35,7 @@ import javafx.geometry.Insets import javafx.scene.Cursor import javafx.scene.Node import javafx.scene.control.Label +import javafx.scene.control.ScrollPane import javafx.scene.control.Tooltip import javafx.scene.input.MouseEvent import javafx.scene.layout.* @@ -40,7 +43,7 @@ import javafx.scene.paint.Color import javafx.stage.Screen import javafx.stage.Stage import javafx.stage.StageStyle -import org.jackhuang.hmcl.MainApplication +import org.jackhuang.hmcl.Main import org.jackhuang.hmcl.ui.animation.AnimationProducer import org.jackhuang.hmcl.ui.animation.ContainerAnimations import org.jackhuang.hmcl.ui.animation.TransitionHandler @@ -49,7 +52,7 @@ import org.jackhuang.hmcl.util.* import java.util.* import java.util.concurrent.ConcurrentLinkedQueue -class Decorator @JvmOverloads constructor(private val primaryStage: Stage, private val mainPage: Node, private val max: Boolean = true, min: Boolean = true) : GridPane(), AbstractWizardDisplayer { +class Decorator @JvmOverloads constructor(private val primaryStage: Stage, private val mainPage: Node, private val max: Boolean = true, min: Boolean = true) : StackPane(), AbstractWizardDisplayer { override val wizardController: WizardController = WizardController(this) private var xOffset: Double = 0.0 @@ -70,9 +73,13 @@ class Decorator @JvmOverloads constructor(private val primaryStage: Stage, priva @FXML lateinit var refreshMenuButton: JFXButton @FXML lateinit var addMenuButton: JFXButton @FXML lateinit var titleLabel: Label - @FXML lateinit var leftPane: VBox + @FXML lateinit var leftPane: AdvancedListBox + @FXML lateinit var drawer: JFXDrawer + @FXML lateinit var sidePane: AdvancedListBox + @FXML lateinit var titleBurgerContainer: StackPane + @FXML lateinit var titleBurger: JFXHamburger - private val onCloseButtonActionProperty: ObjectProperty = SimpleObjectProperty(Runnable { MainApplication.stop() }) + private val onCloseButtonActionProperty: ObjectProperty = SimpleObjectProperty(Runnable { Main.stop() }) @JvmName("onCloseButtonActionProperty") get var onCloseButtonAction: Runnable by onCloseButtonActionProperty @@ -123,6 +130,26 @@ class Decorator @JvmOverloads constructor(private val primaryStage: Stage, priva animationHandler = TransitionHandler(contentPlaceHolder) setOverflowHidden(lookup("#contentPlaceHolderRoot") as Pane) + setOverflowHidden(lookup("#drawerWrapper") as Pane) + + // init the title hamburger icon + drawer.setOnDrawerOpening { + val animation = titleBurger.getAnimation() + animation.setRate(1.0) + animation.play() + } + drawer.setOnDrawerClosing { + val animation = titleBurger.getAnimation() + animation.setRate(-1.0) + animation.play() + } + titleBurgerContainer.setOnMouseClicked({ + if (drawer.isHidden || drawer.isHiding) { + drawer.open() + } else { + drawer.close() + } + }) } fun onMouseMoved(mouseEvent: MouseEvent) { 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 df12b53fb..8c4b622a7 100644 --- a/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/LeftPaneController.kt +++ b/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/LeftPaneController.kt @@ -18,9 +18,7 @@ package org.jackhuang.hmcl.ui import com.jfoenix.controls.JFXComboBox -import javafx.beans.property.StringProperty import javafx.beans.value.ChangeListener -import javafx.scene.Node import javafx.scene.layout.* import javafx.scene.paint.Paint import org.jackhuang.hmcl.ProfileChangedEvent @@ -33,24 +31,23 @@ import org.jackhuang.hmcl.game.minecraftVersion import org.jackhuang.hmcl.setting.Settings import org.jackhuang.hmcl.ui.download.DownloadWizardProvider -class LeftPaneController(val leftPane: VBox) { +class LeftPaneController(leftPane: AdvancedListBox) { val versionsPane = VBox() val cboProfiles = JFXComboBox().apply { items.add("Default"); prefWidthProperty().bind(leftPane.widthProperty()) } val accountItem = VersionListItem("mojang@mojang.com", "Yggdrasil") init { - addChildren(ClassTitle("ACCOUNTS")) - addChildren(RipplerContainer(accountItem).apply { - accountItem.onSettingsButtonClicked { - Controllers.navigate(AccountsPage()) - } - }) - addChildren(ClassTitle("LAUNCHER")) - addChildren(IconedItem(SVG.gear("black"), "Settings").apply { prefWidthProperty().bind(leftPane.widthProperty()) }) - addChildren(ClassTitle("PROFILES")) - addChildren(cboProfiles) - addChildren(ClassTitle("VERSIONS")) - addChildren(versionsPane) + leftPane + .startCategory("ACCOUNTS") + .add(RipplerContainer(accountItem).apply { + accountItem.onSettingsButtonClicked { + Controllers.navigate(AccountsPage()) + } + }) + .startCategory("PROFILES") + .add(cboProfiles) + .startCategory("VERSIONS") + .add(versionsPane) EVENT_BUS.channel() += this::loadVersions EVENT_BUS.channel() += this::onProfilesLoading @@ -82,17 +79,6 @@ class LeftPaneController(val leftPane: VBox) { Controllers.navigate(AccountsPage()) } - private fun addChildren(content: Node) { - if (content is Pane) { - leftPane.children += content - } else { - val pane = StackPane() - pane.styleClass += "left-pane-item" - pane.children.setAll(content) - leftPane.children += pane - } - } - fun onProfilesLoading() { // TODO: Profiles } diff --git a/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/SidePaneController.kt b/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/SidePaneController.kt new file mode 100644 index 000000000..5d6a34eb4 --- /dev/null +++ b/HMCL/src/main/kotlin/org/jackhuang/hmcl/ui/SidePaneController.kt @@ -0,0 +1,26 @@ +/* + * 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 + +class SidePaneController(sidePane: AdvancedListBox) { + init { + sidePane + .startCategory("LAUNCHER") + .add(IconedItem(SVG.gear("black"), "Settings").apply { prefWidthProperty().bind(sidePane.widthProperty()) }) + } +} \ No newline at end of file diff --git a/HMCL/src/main/resources/assets/css/jfoenix-main-demo.css b/HMCL/src/main/resources/assets/css/jfoenix-main-demo.css index 1cd9db15c..e77b7bc35 100644 --- a/HMCL/src/main/resources/assets/css/jfoenix-main-demo.css +++ b/HMCL/src/main/resources/assets/css/jfoenix-main-demo.css @@ -25,22 +25,22 @@ -fx-text-fill: rgba(0.0, 0.0, 0.0, 0.87); } -.class-title { - -fx-font-size: 12px; - -fx-padding: 0 16 0 16; -} - .rippler-container HBox { -fx-font-size: 14px; -fx-padding: 10 16 10 16; -fx-spacing: 10; } -.left-pane-item { +.class-title { + -fx-font-size: 12px; + -fx-padding: 0 16 0 16; +} + +.advanced-list-box-item { -fx-padding: 10 16 10 16; } -.jfx-decorator-left-pane { +.advanced-list-box-content { -fx-padding: 20 0 20 0; } diff --git a/HMCL/src/main/resources/assets/fxml/decorator.fxml b/HMCL/src/main/resources/assets/fxml/decorator.fxml index 0342964e2..b4b37788c 100644 --- a/HMCL/src/main/resources/assets/fxml/decorator.fxml +++ b/HMCL/src/main/resources/assets/fxml/decorator.fxml @@ -1,130 +1,160 @@ - - - - + + - + + + + + + type="StackPane" + xmlns:fx="http://javafx.com/fxml"> - - + + - - - - - - - - - - -
+ +
+ + + + + + + -
- - - - -
- - - - - - - - - - - - - - - - -
-
- - - -
- - - - - - - - - - - - -
-
- - - -
-
-
- - - - - - - - + + +
+ +
+ +
+ + + + + + + + + + + + + + + + + + +
+
+ + + +
+
- - - - - - - - - - - - - - - - - - - - - +
+ + + + + + + + +
-
- - - - - - - - - - - - - -
+ +
+ + + + +
+ + + + + + + + + +
+ + + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+
+
\ No newline at end of file