mirror of
https://github.com/Akomry/makeyourownapp-jam.git
synced 2025-12-06 08:43:54 +00:00
feat: ajout label statut de connexion
This commit is contained in:
parent
f923dba578
commit
c902241230
2 changed files with 21 additions and 3 deletions
|
|
@ -55,6 +55,8 @@ public class DrawController implements Initializable {
|
||||||
public ListView<Canvas> layerListView;
|
public ListView<Canvas> layerListView;
|
||||||
public Button addLayerButton;
|
public Button addLayerButton;
|
||||||
public Button removeLayerButton;
|
public Button removeLayerButton;
|
||||||
|
public MenuItem aboutMenuItem;
|
||||||
|
public Label statusLabel;
|
||||||
private double posX = 0;
|
private double posX = 0;
|
||||||
private double posY = 0;
|
private double posY = 0;
|
||||||
private double mouseX = 0;
|
private double mouseX = 0;
|
||||||
|
|
@ -99,6 +101,19 @@ public class DrawController implements Initializable {
|
||||||
//addLayerButton.setOnAction(this::onActionAddLayer);
|
//addLayerButton.setOnAction(this::onActionAddLayer);
|
||||||
//removeLayerButton.setOnAction(this::onActionRemoveLayer);
|
//removeLayerButton.setOnAction(this::onActionRemoveLayer);
|
||||||
//layerListView.setOnMouseClicked(this::onActionSelectCanvas);
|
//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) {
|
private void onActionSelectCanvas(MouseEvent mouseEvent) {
|
||||||
|
|
@ -139,6 +154,7 @@ public class DrawController implements Initializable {
|
||||||
|
|
||||||
private void onActionDisconnect(ActionEvent actionEvent) {
|
private void onActionDisconnect(ActionEvent actionEvent) {
|
||||||
client.close();
|
client.close();
|
||||||
|
statusLabel.setText("Disconnected");
|
||||||
hostButtonToggle.setSelected(false);
|
hostButtonToggle.setSelected(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -155,7 +171,8 @@ public class DrawController implements Initializable {
|
||||||
matcher.matches();
|
matcher.matches();
|
||||||
String host = matcher.group(1);
|
String host = matcher.group(1);
|
||||||
String port = matcher.group(2);
|
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()));
|
client.sendEvent(new Event(Event.LINELST, new JSONObject()));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
showErrorDialog(e, "Invalid distant address");
|
showErrorDialog(e, "Invalid distant address");
|
||||||
|
|
@ -188,6 +205,7 @@ public class DrawController implements Initializable {
|
||||||
this.client = new DrawClient(host, port, this);
|
this.client = new DrawClient(host, port, this);
|
||||||
hostButtonToggle.setSelected(true);
|
hostButtonToggle.setSelected(true);
|
||||||
client.sendAuthEvent(String.valueOf(new Random().nextInt()));
|
client.sendAuthEvent(String.valueOf(new Random().nextInt()));
|
||||||
|
statusLabel.setText("Connected to %s:%d".formatted(host, port));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showErrorDialog(Exception ex, String context) {
|
private void showErrorDialog(Exception ex, String context) {
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@
|
||||||
</Menu>
|
</Menu>
|
||||||
<Menu mnemonicParsing="false" text="Help">
|
<Menu mnemonicParsing="false" text="Help">
|
||||||
<items>
|
<items>
|
||||||
<MenuItem mnemonicParsing="false" text="About" />
|
<MenuItem fx:id="aboutMenuItem" mnemonicParsing="false" text="About" />
|
||||||
</items>
|
</items>
|
||||||
</Menu>
|
</Menu>
|
||||||
</menus>
|
</menus>
|
||||||
|
|
@ -116,7 +116,7 @@
|
||||||
<HBox>
|
<HBox>
|
||||||
<children>
|
<children>
|
||||||
<Label text="Status : " />
|
<Label text="Status : " />
|
||||||
<Label text="Disconnected" />
|
<Label fx:id="statusLabel" text="Disconnected" />
|
||||||
</children>
|
</children>
|
||||||
<VBox.margin>
|
<VBox.margin>
|
||||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue