From c902241230c4441debf31da9fff34d87a0aba04e Mon Sep 17 00:00:00 2001 From: Emi Boucly Date: Thu, 27 Mar 2025 11:28:41 +0100 Subject: [PATCH] feat: ajout label statut de connexion --- .../fr/emiko/graphicalapp/DrawController.java | 20 ++++++++++++++++++- .../fr/emiko/graphicalapp/draw-view.fxml | 4 ++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/graphical-app/src/main/java/fr/emiko/graphicalapp/DrawController.java b/graphical-app/src/main/java/fr/emiko/graphicalapp/DrawController.java index e0437b2..96d5477 100644 --- a/graphical-app/src/main/java/fr/emiko/graphicalapp/DrawController.java +++ b/graphical-app/src/main/java/fr/emiko/graphicalapp/DrawController.java @@ -55,6 +55,8 @@ public class DrawController implements Initializable { public ListView layerListView; public Button addLayerButton; public Button removeLayerButton; + public MenuItem aboutMenuItem; + public Label statusLabel; private double posX = 0; private double posY = 0; private double mouseX = 0; @@ -99,6 +101,19 @@ public class DrawController implements Initializable { //addLayerButton.setOnAction(this::onActionAddLayer); //removeLayerButton.setOnAction(this::onActionRemoveLayer); //layerListView.setOnMouseClicked(this::onActionSelectCanvas); + + aboutMenuItem.setOnAction(this::onActionAbout); + } + + private void onActionAbout(ActionEvent actionEvent) { + Alert alert = new Alert(Alert.AlertType.INFORMATION); + alert.setTitle("About Yet Another Whiteboard App"); + alert.setHeaderText(null); + alert.setContentText("Hey ! This is my first ever game jam. :D \n" + "I made this in my free time, though a lot of things " + + "still don't work. This is basically yet another collaborative whiteboard app, you can host, someone can" + + " join, create a canvas and draw lines. For now, it works pretty horrendously; but i'll keep maintaining it " + + "and try to make something functional. \nFor now, the layers system doesn't work."); + alert.showAndWait(); } private void onActionSelectCanvas(MouseEvent mouseEvent) { @@ -139,6 +154,7 @@ public class DrawController implements Initializable { private void onActionDisconnect(ActionEvent actionEvent) { client.close(); + statusLabel.setText("Disconnected"); hostButtonToggle.setSelected(false); } @@ -155,7 +171,8 @@ public class DrawController implements Initializable { matcher.matches(); String host = matcher.group(1); String port = matcher.group(2); - connectClient(host, port == null ? 8090 : Integer.parseInt(port)); + int finalPort = port == null ? 8090 : Integer.parseInt(port); + connectClient(host, finalPort); client.sendEvent(new Event(Event.LINELST, new JSONObject())); } catch (NumberFormatException e) { showErrorDialog(e, "Invalid distant address"); @@ -188,6 +205,7 @@ public class DrawController implements Initializable { this.client = new DrawClient(host, port, this); hostButtonToggle.setSelected(true); client.sendAuthEvent(String.valueOf(new Random().nextInt())); + statusLabel.setText("Connected to %s:%d".formatted(host, port)); } private void showErrorDialog(Exception ex, String context) { diff --git a/graphical-app/src/main/resources/fr/emiko/graphicalapp/draw-view.fxml b/graphical-app/src/main/resources/fr/emiko/graphicalapp/draw-view.fxml index d28da7c..19a9cb0 100644 --- a/graphical-app/src/main/resources/fr/emiko/graphicalapp/draw-view.fxml +++ b/graphical-app/src/main/resources/fr/emiko/graphicalapp/draw-view.fxml @@ -45,7 +45,7 @@ - + @@ -116,7 +116,7 @@