mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-18 20:05:02 -04:00
Launcher: fix connected state
This commit is contained in:
parent
ac0eb4f2f1
commit
2bee414802
@ -127,7 +127,7 @@ public class ServerListCell extends ListCell<Server> implements Initializable {
|
|||||||
}
|
}
|
||||||
faviconField.setImage(favicon);
|
faviconField.setImage(favicon);
|
||||||
if (server.isConnected()) {
|
if (server.isConnected()) {
|
||||||
setStyle("-fx-background-color: darkseagreen;");
|
getStyleClass().add("list-cell-connected");
|
||||||
optionsSessions.setDisable(false);
|
optionsSessions.setDisable(false);
|
||||||
} else {
|
} else {
|
||||||
optionsSessions.setDisable(true);
|
optionsSessions.setDisable(true);
|
||||||
@ -144,13 +144,13 @@ public class ServerListCell extends ListCell<Server> implements Initializable {
|
|||||||
resetCell();
|
resetCell();
|
||||||
|
|
||||||
if (server.isConnected()) {
|
if (server.isConnected()) {
|
||||||
setStyle("-fx-background-color: darkseagreen;");
|
getStyleClass().add("list-cell-connected");
|
||||||
}
|
}
|
||||||
if (ping == null) {
|
if (ping == null) {
|
||||||
// Offline
|
// Offline
|
||||||
playersField.setText("");
|
playersField.setText("");
|
||||||
versionField.setText(LocaleManager.translate(Strings.OFFLINE));
|
versionField.setText(LocaleManager.translate(Strings.OFFLINE));
|
||||||
versionField.setStyle("-fx-text-fill: red;");
|
versionField.getStyleClass().add("version-error");
|
||||||
setErrorMotd(String.format("%s", server.getLastPing().getLastConnectionException()));
|
setErrorMotd(String.format("%s", server.getLastPing().getLastConnectionException()));
|
||||||
optionsConnect.setDisable(true);
|
optionsConnect.setDisable(true);
|
||||||
canConnect = false;
|
canConnect = false;
|
||||||
@ -208,11 +208,13 @@ public class ServerListCell extends ListCell<Server> implements Initializable {
|
|||||||
private void resetCell() {
|
private void resetCell() {
|
||||||
// clear all cells
|
// clear all cells
|
||||||
setStyle(null);
|
setStyle(null);
|
||||||
|
getStyleClass().remove("list-cell-connected");
|
||||||
motdField.getChildren().clear();
|
motdField.getChildren().clear();
|
||||||
brandField.setText("");
|
brandField.setText("");
|
||||||
brandField.setTooltip(null);
|
brandField.setTooltip(null);
|
||||||
motdField.setStyle(null);
|
motdField.setStyle(null);
|
||||||
versionField.setText(LocaleManager.translate(Strings.CONNECTING));
|
versionField.setText(LocaleManager.translate(Strings.CONNECTING));
|
||||||
|
versionField.getStyleClass().remove("version-error");
|
||||||
versionField.setStyle(null);
|
versionField.setStyle(null);
|
||||||
playersField.setText("");
|
playersField.setText("");
|
||||||
optionsConnect.setDisable(true);
|
optionsConnect.setDisable(true);
|
||||||
@ -273,7 +275,7 @@ public class ServerListCell extends ListCell<Server> implements Initializable {
|
|||||||
}
|
}
|
||||||
optionsConnect.setDisable(true);
|
optionsConnect.setDisable(true);
|
||||||
connection.connect(server.getLastPing().getAddress(), version);
|
connection.connect(server.getLastPing().getAddress(), version);
|
||||||
connection.registerEvent(new EventInvokerCallback<>(this::handleConnectionCallback));
|
connection.registerEvent(new EventInvokerCallback<>(ConnectionStateChangeEvent.class, this::handleConnectionCallback));
|
||||||
server.addConnection(connection);
|
server.addConnection(connection);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -293,16 +295,15 @@ public class ServerListCell extends ListCell<Server> implements Initializable {
|
|||||||
// maybe we got disconnected
|
// maybe we got disconnected
|
||||||
if (!server.isConnected()) {
|
if (!server.isConnected()) {
|
||||||
setStyle(null);
|
setStyle(null);
|
||||||
|
getStyleClass().remove("list-cell-connected");
|
||||||
optionsSessions.setDisable(true);
|
optionsSessions.setDisable(true);
|
||||||
optionsConnect.setDisable(false);
|
optionsConnect.setDisable(false);
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Minosoft.getSelectedAccount() != connection.getPlayer().getAccount()) {
|
|
||||||
optionsConnect.setDisable(false);
|
|
||||||
}
|
}
|
||||||
setStyle("-fx-background-color: darkseagreen;");
|
|
||||||
|
optionsConnect.setDisable(Minosoft.getSelectedAccount() == connection.getPlayer().getAccount());
|
||||||
|
getStyleClass().add("list-cell-connected");
|
||||||
optionsSessions.setDisable(false);
|
optionsSessions.setDisable(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ public class SessionListCell extends ListCell<Connection> implements Initializab
|
|||||||
}
|
}
|
||||||
setStyle(null);
|
setStyle(null);
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
connection.registerEvent(new EventInvokerCallback<>(this::handleConnectionCallback));
|
connection.registerEvent(new EventInvokerCallback<>(ConnectionStateChangeEvent.class, this::handleConnectionCallback));
|
||||||
connectionId.setText(String.format("#%d", connection.getConnectionId()));
|
connectionId.setText(String.format("#%d", connection.getConnectionId()));
|
||||||
account.setText(connection.getPlayer().getAccount().getPlayerName());
|
account.setText(connection.getPlayer().getAccount().getPlayerName());
|
||||||
}
|
}
|
||||||
|
@ -33,10 +33,6 @@ public class EventInvokerCallback<V extends ConnectionEvent> extends EventInvoke
|
|||||||
this.eventType = eventType; // ToDo: how to get the class of V? seems to be impossible
|
this.eventType = eventType; // ToDo: how to get the class of V? seems to be impossible
|
||||||
}
|
}
|
||||||
|
|
||||||
public EventInvokerCallback(InvokerCallback<V> callback) {
|
|
||||||
this(false, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void invoke(ConnectionEvent event) {
|
public void invoke(ConnectionEvent event) {
|
||||||
if (eventType != event.getClass()) {
|
if (eventType != event.getClass()) {
|
||||||
|
@ -104,7 +104,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.menu-item:disabled {
|
.menu-item:disabled {
|
||||||
-fx-opacity: 80%;
|
-fx-opacity: 60%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.menu-button {
|
.menu-button {
|
||||||
@ -165,3 +165,11 @@
|
|||||||
.list-view {
|
.list-view {
|
||||||
-fx-background-color: -secondary-color;
|
-fx-background-color: -secondary-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.version-error {
|
||||||
|
-fx-text-fill: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
.list-cell-connected {
|
||||||
|
-fx-background-color: darkseagreen;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user