mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-15 10:25:06 -04:00
eros: kick/disconnect dialog
This commit is contained in:
parent
ba57efa4be
commit
a5df0fc8f7
@ -12,4 +12,4 @@ followed by `in`. So `vinPosition` is a valid name.
|
|||||||
|
|
||||||
## Uniforms
|
## Uniforms
|
||||||
|
|
||||||
Prefixed with u
|
Prefixed with `u`
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
package de.bixilon.minosoft.data.text
|
package de.bixilon.minosoft.data.text
|
||||||
|
|
||||||
import de.bixilon.minosoft.Minosoft
|
import de.bixilon.minosoft.Minosoft
|
||||||
|
import de.bixilon.minosoft.config.server.Server
|
||||||
|
import de.bixilon.minosoft.data.accounts.Account
|
||||||
import de.bixilon.minosoft.util.KUtil.asResourceLocation
|
import de.bixilon.minosoft.util.KUtil.asResourceLocation
|
||||||
|
|
||||||
object TranslatableComponents {
|
object TranslatableComponents {
|
||||||
@ -24,4 +26,6 @@ object TranslatableComponents {
|
|||||||
|
|
||||||
val EROS_DELETE_SERVER_CONFIRM_DESCRIPTION = { name: ChatComponent, address: String -> Minosoft.LANGUAGE_MANAGER.translate("minosoft:server_info.delete.dialog.description".asResourceLocation(), null, name, address) }
|
val EROS_DELETE_SERVER_CONFIRM_DESCRIPTION = { name: ChatComponent, address: String -> Minosoft.LANGUAGE_MANAGER.translate("minosoft:server_info.delete.dialog.description".asResourceLocation(), null, name, address) }
|
||||||
val ACCOUNT_CARD_CONNECTION_COUNT = { count: Int -> Minosoft.LANGUAGE_MANAGER.translate("minosoft:main.account.card.connection_count".asResourceLocation(), null, count) }
|
val ACCOUNT_CARD_CONNECTION_COUNT = { count: Int -> Minosoft.LANGUAGE_MANAGER.translate("minosoft:main.account.card.connection_count".asResourceLocation(), null, count) }
|
||||||
|
val CONNECTION_KICK_DESCRIPTION = { server: Server, account: Account -> Minosoft.LANGUAGE_MANAGER.translate("minosoft:connection.kick.description".asResourceLocation(), null, server.name, account.username) }
|
||||||
|
val CONNECTION_LOGIN_KICK_DESCRIPTION = { server: Server, account: Account -> Minosoft.LANGUAGE_MANAGER.translate("minosoft:connection.login_kick.description".asResourceLocation(), null, server.name, account.username) }
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* 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.dialogs.connection
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.Minosoft
|
||||||
|
import de.bixilon.minosoft.data.text.ChatComponent
|
||||||
|
import de.bixilon.minosoft.gui.eros.controller.JavaFXWindowController
|
||||||
|
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil
|
||||||
|
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil.text
|
||||||
|
import de.bixilon.minosoft.util.KUtil.asResourceLocation
|
||||||
|
import javafx.application.Platform
|
||||||
|
import javafx.fxml.FXML
|
||||||
|
import javafx.scene.control.Button
|
||||||
|
import javafx.scene.text.TextFlow
|
||||||
|
|
||||||
|
class KickDialog(
|
||||||
|
val title: Any,
|
||||||
|
val header: Any,
|
||||||
|
val description: Any? = null,
|
||||||
|
val reason: ChatComponent,
|
||||||
|
) : JavaFXWindowController() {
|
||||||
|
@FXML private lateinit var headerFX: TextFlow
|
||||||
|
@FXML private lateinit var descriptionFX: TextFlow
|
||||||
|
@FXML private lateinit var reasonFX: TextFlow
|
||||||
|
@FXML private lateinit var reconnectButtonFX: Button
|
||||||
|
@FXML private lateinit var closeButtonFX: Button
|
||||||
|
|
||||||
|
fun show() {
|
||||||
|
Platform.runLater {
|
||||||
|
JavaFXUtil.openModal(title, LAYOUT, this)
|
||||||
|
stage.show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
override fun init() {
|
||||||
|
headerFX.text = Minosoft.LANGUAGE_MANAGER.translate(header)
|
||||||
|
descriptionFX.text = description?.let { Minosoft.LANGUAGE_MANAGER.translate(it) } ?: ChatComponent.EMPTY
|
||||||
|
reasonFX.text = reason
|
||||||
|
|
||||||
|
reconnectButtonFX.isDisable = true // ToDo
|
||||||
|
closeButtonFX.setOnAction {
|
||||||
|
stage.hide()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val LAYOUT = "minosoft:eros/dialog/connection/kick.fxml".asResourceLocation()
|
||||||
|
}
|
||||||
|
}
|
@ -22,9 +22,12 @@ import de.bixilon.minosoft.gui.eros.Eros
|
|||||||
import de.bixilon.minosoft.gui.eros.controller.EmbeddedJavaFXController
|
import de.bixilon.minosoft.gui.eros.controller.EmbeddedJavaFXController
|
||||||
import de.bixilon.minosoft.gui.eros.dialogs.SimpleErosConfirmationDialog
|
import de.bixilon.minosoft.gui.eros.dialogs.SimpleErosConfirmationDialog
|
||||||
import de.bixilon.minosoft.gui.eros.dialogs.UpdateServerDialog
|
import de.bixilon.minosoft.gui.eros.dialogs.UpdateServerDialog
|
||||||
|
import de.bixilon.minosoft.gui.eros.dialogs.connection.KickDialog
|
||||||
import de.bixilon.minosoft.gui.eros.main.play.server.card.ServerCard
|
import de.bixilon.minosoft.gui.eros.main.play.server.card.ServerCard
|
||||||
import de.bixilon.minosoft.gui.eros.main.play.server.card.ServerCardController
|
import de.bixilon.minosoft.gui.eros.main.play.server.card.ServerCardController
|
||||||
import de.bixilon.minosoft.gui.eros.modding.invoker.JavaFXEventInvoker
|
import de.bixilon.minosoft.gui.eros.modding.invoker.JavaFXEventInvoker
|
||||||
|
import de.bixilon.minosoft.modding.event.events.KickEvent
|
||||||
|
import de.bixilon.minosoft.modding.event.events.LoginKickEvent
|
||||||
import de.bixilon.minosoft.modding.event.events.connection.play.PlayConnectionStateChangeEvent
|
import de.bixilon.minosoft.modding.event.events.connection.play.PlayConnectionStateChangeEvent
|
||||||
import de.bixilon.minosoft.modding.event.events.connection.status.StatusConnectionStateChangeEvent
|
import de.bixilon.minosoft.modding.event.events.connection.status.StatusConnectionStateChangeEvent
|
||||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||||
@ -239,6 +242,23 @@ class ServerListController : EmbeddedJavaFXController<Pane>(), Refreshable {
|
|||||||
}
|
}
|
||||||
Platform.runLater { updateServer(serverCard.server) }
|
Platform.runLater { updateServer(serverCard.server) }
|
||||||
})
|
})
|
||||||
|
|
||||||
|
connection.registerEvent(JavaFXEventInvoker.of<KickEvent> { event ->
|
||||||
|
KickDialog(
|
||||||
|
title = "minosoft:connection.kick.title".asResourceLocation(),
|
||||||
|
header = "minosoft:connection.kick.header".asResourceLocation(),
|
||||||
|
description = TranslatableComponents.CONNECTION_KICK_DESCRIPTION(serverCard.server, account),
|
||||||
|
reason = event.reason,
|
||||||
|
).show()
|
||||||
|
})
|
||||||
|
connection.registerEvent(JavaFXEventInvoker.of<LoginKickEvent> { event ->
|
||||||
|
KickDialog(
|
||||||
|
title = "minosoft:connection.login_kick.title".asResourceLocation(),
|
||||||
|
header = "minosoft:connection.login_kick.header".asResourceLocation(),
|
||||||
|
description = TranslatableComponents.CONNECTION_LOGIN_KICK_DESCRIPTION(serverCard.server, account),
|
||||||
|
reason = event.reason,
|
||||||
|
).show()
|
||||||
|
})
|
||||||
connection.connect()
|
connection.connect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,57 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.geometry.*?>
|
||||||
|
<?import javafx.scene.control.Button?>
|
||||||
|
<?import javafx.scene.layout.*?>
|
||||||
|
<?import javafx.scene.text.*?>
|
||||||
|
<HBox xmlns:fx="http://javafx.com/fxml/1" fx:id="root" prefWidth="600.0" xmlns="http://javafx.com/javafx/16">
|
||||||
|
<GridPane HBox.hgrow="ALWAYS">
|
||||||
|
<rowConstraints>
|
||||||
|
<RowConstraints vgrow="NEVER"/>
|
||||||
|
<RowConstraints vgrow="NEVER"/>
|
||||||
|
<RowConstraints vgrow="ALWAYS"/>
|
||||||
|
<RowConstraints vgrow="NEVER"/>
|
||||||
|
</rowConstraints>
|
||||||
|
<TextFlow fx:id="headerFX" style="-fx-font-size: 30;">
|
||||||
|
<GridPane.margin>
|
||||||
|
<Insets bottom="5.0" left="5.0" right="5.0" top="10.0"/>
|
||||||
|
</GridPane.margin>
|
||||||
|
<Text text="Kicked"/>
|
||||||
|
</TextFlow>
|
||||||
|
<TextFlow fx:id="descriptionFX" GridPane.rowIndex="1">
|
||||||
|
<GridPane.margin>
|
||||||
|
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
|
||||||
|
</GridPane.margin>
|
||||||
|
<Text text="You got kicked from example.de. Used account: Testuser"/>
|
||||||
|
</TextFlow>
|
||||||
|
<TextFlow fx:id="reasonFX" textAlignment="CENTER" GridPane.rowIndex="2">
|
||||||
|
<GridPane.margin>
|
||||||
|
<Insets bottom="5.0" left="5.0" right="5.0" top="10.0"/>
|
||||||
|
</GridPane.margin>
|
||||||
|
<Text text="Kick reason Can be multiple lines long "/>
|
||||||
|
</TextFlow>
|
||||||
|
<GridPane GridPane.rowIndex="3">
|
||||||
|
<columnConstraints>
|
||||||
|
<ColumnConstraints hgrow="ALWAYS"/>
|
||||||
|
<ColumnConstraints hgrow="NEVER"/>
|
||||||
|
<ColumnConstraints hgrow="NEVER"/>
|
||||||
|
</columnConstraints>
|
||||||
|
<rowConstraints>
|
||||||
|
<RowConstraints vgrow="NEVER"/>
|
||||||
|
</rowConstraints>
|
||||||
|
<Button fx:id="reconnectButtonFX" text="Reconnect" GridPane.columnIndex="2">
|
||||||
|
<GridPane.margin>
|
||||||
|
<Insets bottom="5.0" left="5.0" right="5.0" top="10.0"/>
|
||||||
|
</GridPane.margin>
|
||||||
|
</Button>
|
||||||
|
<Button fx:id="closeButtonFX" text="Close" GridPane.columnIndex="1">
|
||||||
|
<GridPane.margin>
|
||||||
|
<Insets bottom="5.0" left="5.0" right="5.0" top="10.0"/>
|
||||||
|
</GridPane.margin>
|
||||||
|
</Button>
|
||||||
|
</GridPane>
|
||||||
|
<columnConstraints>
|
||||||
|
<ColumnConstraints hgrow="ALWAYS"/>
|
||||||
|
</columnConstraints>
|
||||||
|
</GridPane>
|
||||||
|
</HBox>
|
@ -19,7 +19,7 @@
|
|||||||
<RowConstraints vgrow="ALWAYS"/>
|
<RowConstraints vgrow="ALWAYS"/>
|
||||||
<RowConstraints vgrow="NEVER"/>
|
<RowConstraints vgrow="NEVER"/>
|
||||||
</rowConstraints>
|
</rowConstraints>
|
||||||
<TextFlow fx:id="headerFX">
|
<TextFlow style="-fx-font-size: 30;" fx:id="headerFX">
|
||||||
<GridPane.margin>
|
<GridPane.margin>
|
||||||
<Insets bottom="10.0" left="5.0" right="5.0" top="10.0"/>
|
<Insets bottom="10.0" left="5.0" right="5.0" top="10.0"/>
|
||||||
</GridPane.margin>
|
</GridPane.margin>
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<RowConstraints vgrow="ALWAYS"/>
|
<RowConstraints vgrow="ALWAYS"/>
|
||||||
<RowConstraints vgrow="NEVER"/>
|
<RowConstraints vgrow="NEVER"/>
|
||||||
</rowConstraints>
|
</rowConstraints>
|
||||||
<TextFlow fx:id="headerFX">
|
<TextFlow style="-fx-font-size: 30;" fx:id="headerFX">
|
||||||
<GridPane.margin>
|
<GridPane.margin>
|
||||||
<Insets bottom="10.0" left="5.0" right="5.0" top="10.0"/>
|
<Insets bottom="10.0" left="5.0" right="5.0" top="10.0"/>
|
||||||
</GridPane.margin>
|
</GridPane.margin>
|
||||||
|
@ -87,3 +87,14 @@ minosoft:main.account.add.mojang.password.label=Password
|
|||||||
minosoft:main.account.add.mojang.password.placeholder=********
|
minosoft:main.account.add.mojang.password.placeholder=********
|
||||||
minosoft:main.account.add.mojang.add_button=Add
|
minosoft:main.account.add.mojang.add_button=Add
|
||||||
minosoft:main.account.add.mojang.cancel_button=Cancel
|
minosoft:main.account.add.mojang.cancel_button=Cancel
|
||||||
|
|
||||||
|
|
||||||
|
minosoft:connection.kick.title=Kicked from server
|
||||||
|
minosoft:connection.kick.header=You got kicked
|
||||||
|
minosoft:connection.kick.description=You got kicked from %1$s (connected with: %2$s)
|
||||||
|
minosoft:connection.kick.reconnect_button=Reconnect
|
||||||
|
minosoft:connection.kick.close_button=Close
|
||||||
|
|
||||||
|
minosoft:connection.login_kick.title=Kicked from server
|
||||||
|
minosoft:connection.login_kick.header=You got kicked
|
||||||
|
minosoft:connection.login_kick.description=You got kicked while logging in from %1$s (connected with: %2$s)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user