Feat: Add highscore popup UI and lobby display #293

Merged
jona.walpert merged 2 commits from feat/highscore-window-ui into main 2026-04-21 20:35:40 +02:00
4 changed files with 51 additions and 3 deletions
Showing only changes of commit 15c998d549 - Show all commits
@@ -3,8 +3,10 @@ package ch.unibas.dmi.dbis.cs108.casono.client.ui.gameui.gameuicomponents;
import ch.unibas.dmi.dbis.cs108.casono.client.network.LobbyClient; import ch.unibas.dmi.dbis.cs108.casono.client.network.LobbyClient;
import java.util.List; import java.util.List;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.control.ListView; import javafx.scene.control.ListView;
import javafx.scene.input.MouseEvent;
import javafx.stage.Stage; import javafx.stage.Stage;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@@ -16,13 +18,49 @@ public class HighscoreViewController {
@FXML private ListView<String> highscoreList; @FXML private ListView<String> highscoreList;
@FXML private Label statusLabel; @FXML private Label statusLabel;
@FXML private Node highscoreRoot;
private LobbyClient lobbyClient; private LobbyClient lobbyClient;
private double dragOffsetX;
private double dragOffsetY;
public void setLobbyClient(LobbyClient lobbyClient) { public void setLobbyClient(LobbyClient lobbyClient) {
this.lobbyClient = lobbyClient; this.lobbyClient = lobbyClient;
} }
/** Starts dragging the window from anywhere in the popup. */
@FXML
public void onPopupPressed(MouseEvent event) {
Stage stage = getStage();
if (stage == null) {
return;
}
dragOffsetX = stage.getX() - event.getScreenX();
dragOffsetY = stage.getY() - event.getScreenY();
}
/** Moves the popup window while the mouse is dragged anywhere on the popup. */
@FXML
public void onPopupDragged(MouseEvent event) {
Stage stage = getStage();
if (stage == null) {
return;
}
stage.setX(event.getScreenX() + dragOffsetX);
stage.setY(event.getScreenY() + dragOffsetY);
}
/** Returns the popup stage if the root is already attached to a scene. */
private Stage getStage() {
if (highscoreRoot == null || highscoreRoot.getScene() == null) {
return null;
}
return (Stage) highscoreRoot.getScene().getWindow();
}
/** Loads current highscores from the server and refreshes the list. */ /** Loads current highscores from the server and refreshes the list. */
@FXML @FXML
public void refreshHighscores() { public void refreshHighscores() {
@@ -1108,12 +1108,15 @@ public class TaskbarController {
controller.refreshHighscores(); controller.refreshHighscores();
javafx.stage.Stage stage = new javafx.stage.Stage(); javafx.stage.Stage stage = new javafx.stage.Stage();
stage.initStyle(javafx.stage.StageStyle.TRANSPARENT);
stage.setTitle("Casono Highscores"); stage.setTitle("Casono Highscores");
javafx.scene.image.Image icon = javafx.scene.image.Image icon =
new javafx.scene.image.Image( new javafx.scene.image.Image(
getClass().getResource("/images/logoinverted.png").toExternalForm()); getClass().getResource("/images/logoinverted.png").toExternalForm());
stage.getIcons().add(icon); stage.getIcons().add(icon);
stage.setScene(new javafx.scene.Scene(root)); javafx.scene.Scene scene = new javafx.scene.Scene(root);
scene.setFill(javafx.scene.paint.Color.TRANSPARENT);
stage.setScene(scene);
stage.show(); stage.show();
stage.setAlwaysOnTop(true); stage.setAlwaysOnTop(true);
stage.toFront(); stage.toFront();
@@ -24,6 +24,7 @@ import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.VBox; import javafx.scene.layout.VBox;
import javafx.scene.shape.Rectangle; import javafx.scene.shape.Rectangle;
import javafx.stage.Stage; import javafx.stage.Stage;
import javafx.stage.StageStyle;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@@ -308,10 +309,13 @@ public class CasinomainuiController {
controller.refreshHighscores(); controller.refreshHighscores();
Stage stage = new Stage(); Stage stage = new Stage();
stage.initStyle(StageStyle.TRANSPARENT);
stage.setTitle("Casono Highscores"); stage.setTitle("Casono Highscores");
String iconPath = getClass().getResource("/images/logoinverted.png").toExternalForm(); String iconPath = getClass().getResource("/images/logoinverted.png").toExternalForm();
stage.getIcons().add(new Image(iconPath)); stage.getIcons().add(new Image(iconPath));
stage.setScene(new Scene(root)); Scene scene = new Scene(root);
scene.setFill(javafx.scene.paint.Color.TRANSPARENT);
stage.setScene(scene);
stage.show(); stage.show();
stage.setAlwaysOnTop(true); stage.setAlwaysOnTop(true);
stage.toFront(); stage.toFront();
@@ -7,11 +7,14 @@
<?import javafx.scene.layout.HBox?> <?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?> <?import javafx.scene.layout.VBox?>
<VBox xmlns="http://javafx.com/javafx/21" <VBox fx:id="highscoreRoot"
xmlns="http://javafx.com/javafx/21"
xmlns:fx="http://javafx.com/fxml/1" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="ch.unibas.dmi.dbis.cs108.casono.client.ui.gameui.gameuicomponents.HighscoreViewController" fx:controller="ch.unibas.dmi.dbis.cs108.casono.client.ui.gameui.gameuicomponents.HighscoreViewController"
spacing="12" spacing="12"
styleClass="highscore-root" styleClass="highscore-root"
onMousePressed="#onPopupPressed"
onMouseDragged="#onPopupDragged"
stylesheets="@HighscoreView.css"> stylesheets="@HighscoreView.css">
<padding> <padding>