mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-13 09:26:11 -04:00
add hover warning to connect button when minosoft can not connect to it
This commit is contained in:
parent
6a4771bd47
commit
fb0778a309
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minosoft
|
* Minosoft
|
||||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
* Copyright (C) 2020-2024 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 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.
|
||||||
*
|
*
|
||||||
@ -59,6 +59,7 @@ import javafx.scene.Node
|
|||||||
import javafx.scene.control.Button
|
import javafx.scene.control.Button
|
||||||
import javafx.scene.control.CheckBox
|
import javafx.scene.control.CheckBox
|
||||||
import javafx.scene.control.ListView
|
import javafx.scene.control.ListView
|
||||||
|
import javafx.scene.control.Tooltip
|
||||||
import javafx.scene.input.KeyCode
|
import javafx.scene.input.KeyCode
|
||||||
import javafx.scene.layout.Pane
|
import javafx.scene.layout.Pane
|
||||||
|
|
||||||
@ -109,7 +110,7 @@ class ServerListController : EmbeddedJavaFXController<Pane>(), Refreshable {
|
|||||||
return@setOnMouseClicked
|
return@setOnMouseClicked
|
||||||
}
|
}
|
||||||
val card = controller.item ?: return@setOnMouseClicked
|
val card = controller.item ?: return@setOnMouseClicked
|
||||||
if (!card.canConnect(accountProfile.selected ?: return@setOnMouseClicked)) {
|
if (card.canConnect(accountProfile.selected) != null) {
|
||||||
return@setOnMouseClicked
|
return@setOnMouseClicked
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -334,14 +335,21 @@ class ServerListController : EmbeddedJavaFXController<Pane>(), Refreshable {
|
|||||||
isDisable = true
|
isDisable = true
|
||||||
connect(serverCard)
|
connect(serverCard)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isDisable = true // temp state
|
||||||
val selected = account.selected
|
val selected = account.selected
|
||||||
isDisable = selected != null && !serverCard.canConnect(selected)
|
|
||||||
// ToDo: Also disable, if currently connecting
|
// ToDo: Also disable, if currently connecting
|
||||||
ctext = CONNECT
|
ctext = CONNECT
|
||||||
serverCard.ping::state.observeFX(serverCard) { isDisable = selected == null || !serverCard.canConnect(selected) }
|
serverCard.ping::state.observeFX(serverCard, instant = true) {
|
||||||
|
val error = serverCard.canConnect(selected)
|
||||||
|
isDisable = error != null
|
||||||
|
val tooltip = if (error == null) null else Tooltip().apply { ctext = error; styleClass += "tooltip-error" }
|
||||||
|
Tooltip.install(serverInfoFX, tooltip) // can not add to the button, because java fx sucks. disabled nodes don't get click/hover events
|
||||||
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
serverInfoFX.update(serverCard, SERVER_INFO_PROPERTIES, actions)
|
serverInfoFX.update(serverCard, SERVER_INFO_PROPERTIES, actions)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -422,7 +430,7 @@ class ServerListController : EmbeddedJavaFXController<Pane>(), Refreshable {
|
|||||||
|
|
||||||
TranslatableComponents.GENERAL_EMPTY to { " " },
|
TranslatableComponents.GENERAL_EMPTY to { " " },
|
||||||
|
|
||||||
"minosoft:server_info.remote_version".toResourceLocation() to { it.ping.serverVersion ?: "unknown" },
|
"minosoft:server_info.remote_version".toResourceLocation() to { it.ping.serverVersion ?: "§cunknown\nPlease force a specific version!" },
|
||||||
"minosoft:server_info.remote_brand".toResourceLocation() to { it.ping.status?.serverBrand },
|
"minosoft:server_info.remote_brand".toResourceLocation() to { it.ping.status?.serverBrand },
|
||||||
"minosoft:server_info.players_online".toResourceLocation() to { it.ping.status?.let { status -> "${status.usedSlots?.thousands()} / ${status.slots?.thousands()}" } },
|
"minosoft:server_info.players_online".toResourceLocation() to { it.ping.status?.let { status -> "${status.usedSlots?.thousands()} / ${status.slots?.thousands()}" } },
|
||||||
"minosoft:server_info.ping".toResourceLocation() to { it.ping.pong?.latency?.formatNanos() },
|
"minosoft:server_info.ping".toResourceLocation() to { it.ping.pong?.latency?.formatNanos() },
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* Minosoft
|
||||||
|
* Copyright (C) 2020-2024 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.play.server.card
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.data.language.translate.Translatable
|
||||||
|
import de.bixilon.minosoft.data.registries.identified.Namespaces.minosoft
|
||||||
|
|
||||||
|
enum class ConnectError : Translatable {
|
||||||
|
NO_ACCOUNT,
|
||||||
|
ALREADY_CONNECTED,
|
||||||
|
UNKNOWN_VERSION,
|
||||||
|
;
|
||||||
|
|
||||||
|
override val translationKey = minosoft("server_list.error.${name.lowercase()}")
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minosoft
|
* Minosoft
|
||||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
* Copyright (C) 2020-2024 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 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.
|
||||||
*
|
*
|
||||||
@ -44,14 +44,13 @@ class ServerCard(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun canConnect(account: Account): Boolean {
|
fun canConnect(account: Account?): ConnectError? {
|
||||||
if (server in account.connections) {
|
if (account == null) return ConnectError.NO_ACCOUNT
|
||||||
return false
|
if (server in account.connections) return ConnectError.ALREADY_CONNECTED
|
||||||
}
|
|
||||||
if (server.forcedVersion == null && ping.serverVersion == null) {
|
if (server.forcedVersion == null && ping.serverVersion == null) {
|
||||||
return false
|
return ConnectError.UNKNOWN_VERSION
|
||||||
}
|
}
|
||||||
return true
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minosoft
|
* Minosoft
|
||||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
* Copyright (C) 2020-2024 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 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.
|
||||||
*
|
*
|
||||||
@ -45,6 +45,7 @@ import javafx.scene.control.Alert
|
|||||||
import javafx.scene.control.Labeled
|
import javafx.scene.control.Labeled
|
||||||
import javafx.scene.control.TableColumnBase
|
import javafx.scene.control.TableColumnBase
|
||||||
import javafx.scene.control.TextField
|
import javafx.scene.control.TextField
|
||||||
|
import javafx.scene.control.Tooltip
|
||||||
import javafx.scene.image.Image
|
import javafx.scene.image.Image
|
||||||
import javafx.scene.input.KeyCode
|
import javafx.scene.input.KeyCode
|
||||||
import javafx.scene.input.KeyEvent
|
import javafx.scene.input.KeyEvent
|
||||||
@ -166,6 +167,12 @@ object JavaFXUtil {
|
|||||||
this.text = IntegratedLanguage.LANGUAGE.translate(value).message
|
this.text = IntegratedLanguage.LANGUAGE.translate(value).message
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var Tooltip.ctext: Any?
|
||||||
|
get() = this.text
|
||||||
|
set(value) {
|
||||||
|
this.text = IntegratedLanguage.LANGUAGE.translate(value).message
|
||||||
|
}
|
||||||
|
|
||||||
var TableColumnBase<*, *>.ctext: Any?
|
var TableColumnBase<*, *>.ctext: Any?
|
||||||
get() = this.text
|
get() = this.text
|
||||||
set(value) {
|
set(value) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minosoft
|
* Minosoft
|
||||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
* Copyright (C) 2020-2024 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 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.
|
||||||
*
|
*
|
||||||
@ -350,3 +350,15 @@
|
|||||||
.progress-bar > .track {
|
.progress-bar > .track {
|
||||||
-fx-background-color: -secondary-color;
|
-fx-background-color: -secondary-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.tooltip {
|
||||||
|
-fx-background-color: -secondary-color;
|
||||||
|
-fx-border-radius: 2px;
|
||||||
|
-fx-border-width: 1px;
|
||||||
|
-fx-border-color: -secondary-text-color;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tooltip-error {
|
||||||
|
-fx-text-fill: #ff0000;
|
||||||
|
}
|
||||||
|
@ -86,6 +86,9 @@ minosoft:server_list.button.edit=Edit
|
|||||||
minosoft:server_list.refresh.header=Refresh
|
minosoft:server_list.refresh.header=Refresh
|
||||||
minosoft:server_list.refresh.text1=Get the latest
|
minosoft:server_list.refresh.text1=Get the latest
|
||||||
minosoft:server_list.refresh.text2=information
|
minosoft:server_list.refresh.text2=information
|
||||||
|
minosoft:server_list.error.no_account=You don't have an account selected!\nPlease click on the minosoft icon in the right top corner.
|
||||||
|
minosoft:server_list.error.already_connected=You are already connected with the selected account. Please choose a different one!
|
||||||
|
minosoft:server_list.error.unknown_version=The server is using an version that minosoft does not support (yet)!\nPlease edit the server and try forcing a different version.\nFeel free to add that version to minosoft (PR)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user