wip eros main gui

This commit is contained in:
Bixilon 2021-07-21 21:24:46 +02:00
parent 5d1b9b4689
commit 8a09f25fe8
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
11 changed files with 282 additions and 6 deletions

10
pom.xml
View File

@ -350,5 +350,15 @@
<artifactId>slf4j-simple</artifactId>
<version>1.7.31</version>
</dependency>
<dependency>
<groupId>org.kordamp.ikonli</groupId>
<artifactId>ikonli-javafx</artifactId>
<version>12.2.0</version>
</dependency>
<dependency>
<groupId>org.kordamp.ikonli</groupId>
<artifactId>ikonli-fontawesome5-pack</artifactId>
<version>12.2.0</version>
</dependency>
</dependencies>
</project>

View File

@ -21,6 +21,7 @@ import de.bixilon.minosoft.data.language.MultiLanguageManager
import de.bixilon.minosoft.data.registries.DefaultRegistries
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.registries.versions.Versions
import de.bixilon.minosoft.gui.eros.Eros
import de.bixilon.minosoft.gui.eros.crash.ErosCrashReport.Companion.crash
import de.bixilon.minosoft.gui.eros.util.JavaFXInitializer
import de.bixilon.minosoft.modding.event.events.FinishInitializingEvent
@ -109,6 +110,8 @@ object Minosoft {
taskWorker += Task(identifier = StartupTasks.INITIALIZE_JAVAFX, executor = { JavaFXInitializer.start() })
// ToDo: Show start up progress window
Eros // Init class
}

View File

@ -0,0 +1,37 @@
/*
* Minosoft
* Copyright (C) 2021 Moritz Zwerger
*
* 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 <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.gui.eros
import de.bixilon.minosoft.Minosoft
import de.bixilon.minosoft.gui.eros.main.MainErosController
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil
import de.bixilon.minosoft.modding.event.CallbackEventInvoker
import de.bixilon.minosoft.modding.event.events.FinishInitializingEvent
import de.bixilon.minosoft.util.KUtil.asResourceLocation
import javafx.application.Platform
object Eros {
private val TITLE = "minosoft:eros_window_title".asResourceLocation()
private val LAYOUT = "minosoft:eros/main/main.fxml".asResourceLocation()
init {
Minosoft.GLOBAL_EVENT_MASTER.registerEvent(CallbackEventInvoker.of<FinishInitializingEvent> {
Platform.runLater {
val mainErosController = JavaFXUtil.openModal<MainErosController>(TITLE, LAYOUT)
mainErosController.stage.show()
}
})
}
}

View File

@ -11,19 +11,28 @@
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.gui.eros
package de.bixilon.minosoft.gui.eros.controller
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil
import de.bixilon.minosoft.util.KUtil.nullCast
import javafx.event.ActionEvent
import javafx.fxml.Initializable
import javafx.scene.control.Labeled
import java.net.URL
import java.util.*
abstract class JavaFXController {
abstract class JavaFXController : Initializable {
fun openURL(actionEvent: ActionEvent) {
actionEvent.target?.nullCast<Labeled>()?.text?.let {
JavaFXUtil.HOST_SERVICES.showDocument(it)
}
}
override fun initialize(p0: URL?, p1: ResourceBundle?) {
init()
}
open fun init() {}
}

View File

@ -0,0 +1,21 @@
/*
* Minosoft
* Copyright (C) 2021 Moritz Zwerger
*
* 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 <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.gui.eros.controller
import javafx.stage.Stage
abstract class JavaFXWindowController : JavaFXController() {
lateinit var stage: Stage
}

View File

@ -14,7 +14,7 @@
package de.bixilon.minosoft.gui.eros.crash
import de.bixilon.minosoft.ShutdownReasons
import de.bixilon.minosoft.gui.eros.JavaFXController
import de.bixilon.minosoft.gui.eros.controller.JavaFXWindowController
import de.bixilon.minosoft.gui.eros.util.JavaFXInitializer
import de.bixilon.minosoft.terminal.CommandLineArguments
import de.bixilon.minosoft.terminal.RunConfiguration
@ -42,7 +42,7 @@ import java.nio.charset.StandardCharsets
import java.text.SimpleDateFormat
class ErosCrashReport : JavaFXController() {
class ErosCrashReport : JavaFXWindowController() {
@FXML
private lateinit var crashReportPathDescriptionFX: TextFlow
@ -160,6 +160,7 @@ class ErosCrashReport : JavaFXController() {
crashReport.exception = this
crashReport.details = details
crashReport.crashReportPath = crashReportPath
crashReport.stage = stage
stage.setOnCloseRequest { ShutdownManager.shutdown(this?.message, ShutdownReasons.CRITICAL_EXCEPTION) }
stage.show()

View File

@ -0,0 +1,76 @@
/*
* Minosoft
* Copyright (C) 2021 Moritz Zwerger
*
* 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 <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.gui.eros.main
import de.bixilon.minosoft.gui.eros.controller.JavaFXWindowController
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil
import de.bixilon.minosoft.util.GitInfo
import de.bixilon.minosoft.util.KUtil.decide
import javafx.fxml.FXML
import javafx.scene.image.ImageView
import javafx.scene.layout.HBox
import javafx.scene.paint.Color
import javafx.scene.text.Text
import org.kordamp.ikonli.javafx.FontIcon
class MainErosController : JavaFXWindowController() {
@FXML
private lateinit var logoFX: ImageView
@FXML
private lateinit var versionTextFX: Text
@FXML
private lateinit var playIconFX: FontIcon
@FXML
private lateinit var settingsIconFX: FontIcon
@FXML
private lateinit var helpIconFX: FontIcon
@FXML
private lateinit var aboutIconFX: FontIcon
@FXML
private lateinit var exitIconFX: FontIcon
@FXML
private lateinit var contentFX: HBox
private lateinit var icons: List<FontIcon>
fun select(iconToSelect: FontIcon) {
for (icon in icons) {
if (icon === iconToSelect) {
continue
}
icon.isDisable = true
icon.iconColor = Color.GRAY
}
iconToSelect.isDisable = false
iconToSelect.iconColor = Color.BLACK
}
override fun init() {
logoFX.image = JavaFXUtil.MINOSOFT_LOGO
versionTextFX.text = "Minosoft " + GitInfo.IS_INITIALIZED.decide(GitInfo.GIT_COMMIT_ID, "v?")
icons = listOf(playIconFX, settingsIconFX, helpIconFX, aboutIconFX, exitIconFX)
select(playIconFX)
}
}

View File

@ -13,12 +13,15 @@
package de.bixilon.minosoft.gui.eros.util
import de.bixilon.minosoft.Minosoft
import de.bixilon.minosoft.util.CountUpAndDownLatch
import de.bixilon.minosoft.util.KUtil.asResourceLocation
import de.bixilon.minosoft.util.logging.Log
import de.bixilon.minosoft.util.logging.LogLevels
import de.bixilon.minosoft.util.logging.LogMessageType
import javafx.application.Application
import javafx.application.Platform
import javafx.scene.image.Image
import javafx.stage.Stage
class JavaFXInitializer internal constructor() : Application() {
@ -27,6 +30,7 @@ class JavaFXInitializer internal constructor() : Application() {
Platform.setImplicitExit(false)
JavaFXUtil.HOST_SERVICES = hostServices
JavaFXUtil.MINOSOFT_LOGO = Image(Minosoft.MINOSOFT_ASSETS_MANAGER.readAssetAsStream("minosoft:textures/icons/window_icon.png".asResourceLocation()))
Log.log(LogMessageType.JAVAFX, LogLevels.VERBOSE) { "Initialized JavaFX Toolkit!" }
LATCH.dec()

View File

@ -13,13 +13,36 @@
package de.bixilon.minosoft.gui.eros.util
import de.bixilon.minosoft.Minosoft
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.gui.eros.controller.JavaFXController
import de.bixilon.minosoft.gui.eros.controller.JavaFXWindowController
import javafx.application.HostServices
import javafx.fxml.FXMLLoader
import javafx.scene.Parent
import javafx.scene.Scene
import javafx.scene.image.Image
import javafx.stage.Modality
import javafx.stage.Stage
object JavaFXUtil {
lateinit var MINOSOFT_LOGO: Image
lateinit var HOST_SERVICES: HostServices
fun openModal(layout: ResourceLocation) {
TODO()
fun <T : JavaFXController> openModal(title: ResourceLocation, layout: ResourceLocation, modality: Modality = Modality.WINDOW_MODAL): T {
val fxmlLoader = FXMLLoader()
val parent = fxmlLoader.load<Parent>(Minosoft.MINOSOFT_ASSETS_MANAGER.readAssetAsStream(layout))
val stage = Stage()
stage.initModality(modality)
stage.title = Minosoft.LANGUAGE_MANAGER.translate(title).message
stage.scene = Scene(parent)
val controller = fxmlLoader.getController<T>()
if (controller is JavaFXWindowController) {
controller.stage = stage
}
return controller
}
}

View File

@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.*?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.Text?>
<?import org.kordamp.ikonli.javafx.*?>
<HBox xmlns:fx="http://javafx.com/fxml/1" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="1000.0" fx:controller="de.bixilon.minosoft.gui.eros.main.MainErosController">
<GridPane HBox.hgrow="ALWAYS">
<columnConstraints>
<ColumnConstraints hgrow="ALWAYS" minWidth="10.0" prefWidth="100.0"/>
</columnConstraints>
<rowConstraints>
<RowConstraints maxHeight="Infinity" minHeight="50.0" prefHeight="50.0" vgrow="NEVER"/>
<RowConstraints maxHeight="Infinity" minHeight="10.0" vgrow="ALWAYS"/>
</rowConstraints>
<GridPane>
<columnConstraints>
<ColumnConstraints hgrow="NEVER"/>
<ColumnConstraints hgrow="NEVER"/>
<ColumnConstraints hgrow="ALWAYS" maxWidth="Infinity" minWidth="0.0"/>
<ColumnConstraints hgrow="NEVER" maxWidth="Infinity" minWidth="10.0"/>
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
</rowConstraints>
<GridPane>
<columnConstraints>
<ColumnConstraints hgrow="NEVER"/>
<ColumnConstraints hgrow="ALWAYS"/>
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" vgrow="ALWAYS"/>
</rowConstraints>
<ImageView fx:id="logoFX" fitHeight="50.0" fitWidth="50.0" pickOnBounds="true" preserveRatio="true" GridPane.hgrow="ALWAYS" GridPane.vgrow="ALWAYS">
</ImageView>
<Text fx:id="versionTextFX" text="Minosoft 0.1" GridPane.columnIndex="1"/>
<GridPane.margin>
<Insets right="20.0"/>
</GridPane.margin>
</GridPane>
<GridPane GridPane.columnIndex="1">
<columnConstraints>
<ColumnConstraints hgrow="NEVER" minWidth="10.0"/>
<ColumnConstraints hgrow="NEVER" minWidth="10.0"/>
<ColumnConstraints hgrow="NEVER" minWidth="10.0"/>
<ColumnConstraints hgrow="NEVER" minWidth="10.0"/>
<ColumnConstraints hgrow="NEVER" minWidth="10.0"/>
<ColumnConstraints hgrow="NEVER" minWidth="10.0"/>
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
</rowConstraints>
<FontIcon fx:id="playIconFX" accessibleText="Play" iconLiteral="fas-play" iconSize="30" GridPane.columnIndex="1">
<GridPane.margin>
<Insets bottom="2.0" left="5.0" right="5.0" top="2.0"/>
</GridPane.margin>
</FontIcon>
<FontIcon fx:id="settingsIconFX" accessibleText="Settings" iconLiteral="fas-cogs" iconSize="30" GridPane.columnIndex="2">
<GridPane.margin>
<Insets bottom="2.0" left="5.0" right="5.0" top="2.0"/>
</GridPane.margin>
</FontIcon>
<FontIcon fx:id="helpIconFX" accessibleText="Help" iconLiteral="fas-life-ring" iconSize="30" GridPane.columnIndex="3">
<GridPane.margin>
<Insets bottom="2.0" left="5.0" right="5.0" top="2.0"/>
</GridPane.margin>
</FontIcon>
<FontIcon fx:id="aboutIconFX" accessibleText="About" iconLiteral="fas-info" iconSize="30" GridPane.columnIndex="4">
<GridPane.margin>
<Insets bottom="2.0" left="5.0" right="5.0" top="2.0"/>
</GridPane.margin>
</FontIcon>
<FontIcon fx:id="exitIconFX" accessibleText="Exit" iconLiteral="fas-door-open" iconSize="30" GridPane.columnIndex="5">
<GridPane.margin>
<Insets bottom="2.0" left="5.0" right="5.0" top="2.0"/>
</GridPane.margin>
</FontIcon>
</GridPane>
<Text text="Account" GridPane.columnIndex="3"/>
<GridPane.margin>
<Insets bottom="3.0" left="5.0" right="5.0" top="3.0"/>
</GridPane.margin>
</GridPane>
<HBox fx:id="contentFX" prefHeight="100.0" prefWidth="200.0" GridPane.rowIndex="1">
<GridPane.margin>
<Insets bottom="5.0" left="10.0" right="10.0" top="5.0"/>
</GridPane.margin>
</HBox>
</GridPane>
</HBox>

View File

@ -1 +1,2 @@
minosoft:hello.world=§aHi, my name is §e%1$s§a. I am §e%2$s §ayears old and I want to say the following: §cHello world!
minosoft:eros_window_title=Minosoft