mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-18 20:05:02 -04:00
wip: eros reconnecting
This commit is contained in:
parent
ac528e5f1f
commit
4fdb8e4c79
@ -18,6 +18,7 @@ import de.bixilon.minosoft.data.text.ChatComponent
|
||||
import de.bixilon.minosoft.gui.eros.controller.DialogController
|
||||
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil
|
||||
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil.text
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
import javafx.fxml.FXML
|
||||
import javafx.scene.control.Button
|
||||
@ -28,6 +29,7 @@ class KickDialog(
|
||||
val header: Any,
|
||||
val description: Any? = null,
|
||||
val reason: ChatComponent,
|
||||
val connection: PlayConnection? = null,
|
||||
) : DialogController() {
|
||||
@FXML private lateinit var headerFX: TextFlow
|
||||
@FXML private lateinit var descriptionFX: TextFlow
|
||||
@ -48,10 +50,12 @@ class KickDialog(
|
||||
descriptionFX.text = description?.let { Minosoft.LANGUAGE_MANAGER.translate(it) } ?: ChatComponent.EMPTY
|
||||
reasonFX.text = reason
|
||||
|
||||
reconnectButtonFX.isDisable = true // ToDo
|
||||
closeButtonFX.setOnAction {
|
||||
stage.hide()
|
||||
if (connection == null) {
|
||||
reconnectButtonFX.isDisable = true
|
||||
} else {
|
||||
reconnectButtonFX.setOnAction { connection.connect() }
|
||||
}
|
||||
closeButtonFX.setOnAction { stage.hide() }
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
@ -149,6 +149,7 @@ class ServerListController : EmbeddedJavaFXController<Pane>(), Refreshable {
|
||||
header = "minosoft:connection.kick.header".toResourceLocation(),
|
||||
description = TranslatableComponents.CONNECTION_KICK_DESCRIPTION(server, account),
|
||||
reason = event.reason,
|
||||
connection = connection,
|
||||
).show()
|
||||
})
|
||||
connection.registerEvent(JavaFXEventInvoker.of<LoginKickEvent> { event ->
|
||||
@ -159,11 +160,7 @@ class ServerListController : EmbeddedJavaFXController<Pane>(), Refreshable {
|
||||
reason = event.reason,
|
||||
).show()
|
||||
})
|
||||
val latch = CountUpAndDownLatch(0)
|
||||
val assetsDialog = VerifyAssetsDialog(latch = latch).apply { show() }
|
||||
connection.registerEvent(JavaFXEventInvoker.of<PlayConnectionStateChangeEvent> { if (it.state.disconnected) assetsDialog.close() })
|
||||
ConnectingDialog(connection).show()
|
||||
connection.connect(latch)
|
||||
connect(connection)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -407,5 +404,13 @@ class ServerListController : EmbeddedJavaFXController<Pane>(), Refreshable {
|
||||
|
||||
"minosoft:server_info.active_connections".toResourceLocation() to { it.connections.size },
|
||||
)
|
||||
|
||||
fun connect(connection: PlayConnection) {
|
||||
val latch = CountUpAndDownLatch(0)
|
||||
val assetsDialog = VerifyAssetsDialog(latch = latch).apply { show() }
|
||||
connection.registerEvent(JavaFXEventInvoker.of<PlayConnectionStateChangeEvent> { if (it.state.disconnected) assetsDialog.close() })
|
||||
ConnectingDialog(connection).show()
|
||||
connection.connect(latch)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -215,7 +215,9 @@ class PlayConnection(
|
||||
|
||||
fun connect(latch: CountUpAndDownLatch = CountUpAndDownLatch(0)) {
|
||||
val count = latch.count
|
||||
check(!wasConnected) { "Connection was already connected!" }
|
||||
if (protocolState != ProtocolStates.DISCONNECTED) {
|
||||
throw IllegalStateException("Still connected!")
|
||||
}
|
||||
try {
|
||||
state = PlayConnectionStates.LOADING_ASSETS
|
||||
fireEvent(RegistriesLoadEvent(this, registries, RegistriesLoadEvent.States.PRE))
|
||||
|
Loading…
x
Reference in New Issue
Block a user