mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 03:15:35 -04:00
eros: select different main activities, wip accounting
This commit is contained in:
parent
1588f135e6
commit
f490aa7305
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.gui.eros.main.account.AccountController
|
||||
import de.bixilon.minosoft.gui.eros.main.play.PlayController
|
||||
import de.bixilon.minosoft.util.KUtil
|
||||
import de.bixilon.minosoft.util.KUtil.asResourceLocation
|
||||
import de.bixilon.minosoft.util.enum.ValuesEnum
|
||||
|
||||
enum class ErosMainActivities(
|
||||
val layout: ResourceLocation,
|
||||
) {
|
||||
PlAY(PlayController.LAYOUT),
|
||||
SETTINGS("".asResourceLocation()),
|
||||
HELP("".asResourceLocation()),
|
||||
ABOUT("".asResourceLocation()),
|
||||
|
||||
ACCOUNT(AccountController.LAYOUT),
|
||||
;
|
||||
|
||||
companion object : ValuesEnum<ErosMainActivities> {
|
||||
override val VALUES: Array<ErosMainActivities> = values()
|
||||
override val NAME_MAP: Map<String, ErosMainActivities> = KUtil.getEnumValues(VALUES)
|
||||
}
|
||||
}
|
@ -17,8 +17,8 @@ import de.bixilon.minosoft.Minosoft
|
||||
import de.bixilon.minosoft.ShutdownReasons
|
||||
import de.bixilon.minosoft.config.StaticConfiguration
|
||||
import de.bixilon.minosoft.data.accounts.Account
|
||||
import de.bixilon.minosoft.gui.eros.controller.EmbeddedJavaFXController
|
||||
import de.bixilon.minosoft.gui.eros.controller.JavaFXWindowController
|
||||
import de.bixilon.minosoft.gui.eros.main.play.PlayMainController
|
||||
import de.bixilon.minosoft.gui.eros.modding.invoker.JavaFXEventInvoker
|
||||
import de.bixilon.minosoft.gui.eros.util.JavaFXAccountUtil.avatar
|
||||
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil
|
||||
@ -45,11 +45,8 @@ class MainErosController : JavaFXWindowController() {
|
||||
|
||||
@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: Pane
|
||||
@ -58,40 +55,65 @@ class MainErosController : JavaFXWindowController() {
|
||||
|
||||
@FXML private lateinit var accountNameFX: Text
|
||||
|
||||
|
||||
private lateinit var icons: List<FontIcon>
|
||||
private lateinit var iconMap: Map<ErosMainActivities, FontIcon>
|
||||
|
||||
|
||||
fun select(iconToSelect: FontIcon) {
|
||||
for (icon in icons) {
|
||||
private var activity: ErosMainActivities = ErosMainActivities.ABOUT // other value (not the default)
|
||||
set(value) {
|
||||
field = value
|
||||
contentFX.children.setAll(JavaFXUtil.loadEmbeddedController<EmbeddedJavaFXController<*>>(field.layout).root)
|
||||
|
||||
highlightIcon(iconMap[value])
|
||||
}
|
||||
|
||||
private fun highlightIcon(iconToSelect: FontIcon?) {
|
||||
for (icon in iconMap.values) {
|
||||
if (icon === iconToSelect) {
|
||||
continue
|
||||
}
|
||||
icon.isDisable = false
|
||||
icon.iconColor = Color.BLACK
|
||||
}
|
||||
iconToSelect.isDisable = true
|
||||
iconToSelect.iconColor = Color.LIGHTBLUE
|
||||
iconToSelect?.apply {
|
||||
isDisable = true
|
||||
iconColor = Color.LIGHTBLUE
|
||||
}
|
||||
}
|
||||
|
||||
override fun init() {
|
||||
logoFX.image = JavaFXUtil.MINOSOFT_LOGO
|
||||
versionTextFX.text = "Minosoft " + GitInfo.IS_INITIALIZED.decide(GitInfo.GIT_COMMIT_ID, StaticConfiguration.VERSION)
|
||||
icons = listOf(playIconFX, settingsIconFX, helpIconFX, aboutIconFX, exitIconFX)
|
||||
iconMap = mapOf(
|
||||
ErosMainActivities.PlAY to playIconFX,
|
||||
ErosMainActivities.SETTINGS to settingsIconFX,
|
||||
ErosMainActivities.HELP to helpIconFX,
|
||||
ErosMainActivities.ABOUT to aboutIconFX,
|
||||
)
|
||||
|
||||
select(playIconFX)
|
||||
highlightIcon(playIconFX)
|
||||
|
||||
playIconFX.setOnMouseClicked {
|
||||
activity = ErosMainActivities.PlAY
|
||||
}
|
||||
settingsIconFX.setOnMouseClicked {
|
||||
activity = ErosMainActivities.SETTINGS
|
||||
}
|
||||
helpIconFX.setOnMouseClicked {
|
||||
activity = ErosMainActivities.HELP
|
||||
}
|
||||
aboutIconFX.setOnMouseClicked {
|
||||
activity = ErosMainActivities.ABOUT
|
||||
}
|
||||
exitIconFX.setOnMouseClicked {
|
||||
ShutdownManager.shutdown(reason = ShutdownReasons.REQUESTED_BY_USER)
|
||||
}
|
||||
|
||||
contentFX.children.setAll(JavaFXUtil.loadEmbeddedController<PlayMainController>("minosoft:eros/main/play/play.fxml".asResourceLocation()).root)
|
||||
|
||||
|
||||
GlobalEventMaster.registerEvent(JavaFXEventInvoker.of<AccountSelectEvent> {
|
||||
accountImageFX.image = it.account?.avatar
|
||||
accountNameFX.ctext = it.account?.username ?: NO_ACCOUNT_SELECTED
|
||||
})
|
||||
|
||||
activity = ErosMainActivities.PlAY
|
||||
}
|
||||
|
||||
override fun postInit() {
|
||||
@ -100,13 +122,9 @@ class MainErosController : JavaFXWindowController() {
|
||||
}
|
||||
}
|
||||
|
||||
fun requestAccountSelect() {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
fun verifyAccount(account: Account? = Minosoft.config.config.account.selected, onSuccess: (Account) -> Unit) {
|
||||
if (account == null) {
|
||||
requestAccountSelect()
|
||||
activity = ErosMainActivities.ACCOUNT
|
||||
return
|
||||
}
|
||||
|
||||
@ -120,6 +138,12 @@ class MainErosController : JavaFXWindowController() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@FXML
|
||||
fun openAccountActivity() {
|
||||
activity = ErosMainActivities.ACCOUNT
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val NO_ACCOUNT_SELECTED = "minosoft:main.account.no_account_selected".asResourceLocation()
|
||||
}
|
||||
|
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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.account
|
||||
|
||||
import de.bixilon.minosoft.data.accounts.Account
|
||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.gui.eros.controller.EmbeddedJavaFXController
|
||||
import de.bixilon.minosoft.util.KUtil.asResourceLocation
|
||||
import javafx.fxml.FXML
|
||||
import javafx.scene.control.ListView
|
||||
import javafx.scene.layout.AnchorPane
|
||||
import javafx.scene.layout.Pane
|
||||
|
||||
class AccountController : EmbeddedJavaFXController<Pane>() {
|
||||
@FXML private lateinit var accountTypeListViewFX: ListView<ResourceLocation>
|
||||
|
||||
@FXML private lateinit var accountListViewFX: ListView<Account>
|
||||
@FXML private lateinit var accountInfoFX: AnchorPane
|
||||
|
||||
|
||||
override fun init() {
|
||||
|
||||
}
|
||||
|
||||
companion object {
|
||||
val LAYOUT = "minosoft:eros/main/account/account.fxml".asResourceLocation()
|
||||
}
|
||||
}
|
@ -33,7 +33,7 @@ import javafx.scene.layout.GridPane
|
||||
import javafx.scene.layout.Pane
|
||||
import javafx.scene.text.TextFlow
|
||||
|
||||
class PlayMainController : EmbeddedJavaFXController<Pane>() {
|
||||
class PlayController : EmbeddedJavaFXController<Pane>() {
|
||||
@FXML private lateinit var playTypeContentFX: Pane
|
||||
|
||||
@FXML private lateinit var playTypeListViewFX: ListView<ServerTypes>
|
||||
@ -103,6 +103,7 @@ class PlayMainController : EmbeddedJavaFXController<Pane>() {
|
||||
}
|
||||
|
||||
companion object {
|
||||
val LAYOUT = "minosoft:eros/main/play/play.fxml".asResourceLocation()
|
||||
private val CUSTOM_SERVER_TYPE = "minosoft:server_type.custom".asResourceLocation()
|
||||
private val LAN_SERVER_TYPE = "minosoft:server_type.lan".asResourceLocation()
|
||||
private val REFRESH_HEADER = "minosoft:server_list.refresh.header".asResourceLocation()
|
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.control.ListView?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<HBox xmlns:fx="http://javafx.com/fxml/1" prefHeight="500.0" prefWidth="900.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" xmlns="http://javafx.com/javafx/16" fx:controller="de.bixilon.minosoft.gui.eros.main.account.AccountController">
|
||||
<GridPane HBox.hgrow="ALWAYS">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="NEVER" maxWidth="190.0" minWidth="10.0" prefWidth="190.0"/>
|
||||
<ColumnConstraints hgrow="ALWAYS" maxWidth="Infinity"/>
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints maxHeight="Infinity" minHeight="10.0" prefHeight="30.0" vgrow="ALWAYS"/>
|
||||
</rowConstraints>
|
||||
<GridPane GridPane.columnIndex="1">
|
||||
<ListView fx:id="accountListViewFX" GridPane.hgrow="ALWAYS" GridPane.vgrow="ALWAYS"/>
|
||||
<AnchorPane fx:id="accountInfoFX" minHeight="0.0" minWidth="0.0" GridPane.columnIndex="1"/>
|
||||
</GridPane>
|
||||
<ListView fx:id="accountTypeListViewFX" maxHeight="Infinity" maxWidth="Infinity" GridPane.hgrow="ALWAYS" GridPane.vgrow="ALWAYS"/>
|
||||
</GridPane>
|
||||
</HBox>
|
@ -77,7 +77,7 @@
|
||||
</GridPane.margin>
|
||||
</FontIcon>
|
||||
</GridPane>
|
||||
<GridPane GridPane.columnIndex="3">
|
||||
<GridPane onMouseClicked="#openAccountActivity" GridPane.columnIndex="3">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="NEVER" minWidth="10.0"/>
|
||||
<ColumnConstraints hgrow="NEVER"/>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
<?import org.kordamp.ikonli.javafx.FontIcon?>
|
||||
<HBox xmlns:fx="http://javafx.com/fxml/1" prefHeight="500.0" prefWidth="900.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" xmlns="http://javafx.com/javafx/16" fx:controller="de.bixilon.minosoft.gui.eros.main.play.PlayMainController">
|
||||
<HBox xmlns:fx="http://javafx.com/fxml/1" prefHeight="500.0" prefWidth="900.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" xmlns="http://javafx.com/javafx/16" fx:controller="de.bixilon.minosoft.gui.eros.main.play.PlayController">
|
||||
<GridPane HBox.hgrow="ALWAYS">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="NEVER" minWidth="10.0" prefWidth="190.0"/>
|
||||
|
@ -44,13 +44,6 @@
|
||||
</GridPane.margin>
|
||||
</GridPane>
|
||||
<GridPane>
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/>
|
||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="0.0"/>
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
|
||||
</rowConstraints>
|
||||
<ListView fx:id="serverListViewFX" GridPane.hgrow="ALWAYS" GridPane.vgrow="ALWAYS"/>
|
||||
<AnchorPane fx:id="serverInfoFX" minHeight="0.0" minWidth="0.0" GridPane.columnIndex="1"/>
|
||||
</GridPane>
|
||||
|
Loading…
x
Reference in New Issue
Block a user