mooore stuff
Some checks failed
Linux arm64 / Build (push) Failing after 5m5s

This commit is contained in:
2025-01-26 13:46:23 +01:00
parent caf7011f08
commit e51cc23459
20 changed files with 395 additions and 65 deletions

View File

@@ -0,0 +1,60 @@
package gui.menu;
import java.io.IOException;
import java.net.UnknownHostException;
import imgui.ImGui;
import network.client.Client;
import network.server.Server;
public class ConnexionStatusView extends BaseView {
private Client client;
private Server server;
public ConnexionStatusView(StateMachine stateMachine, String address, short port) throws UnknownHostException, IOException {
this(stateMachine, null, new Client(address, port));
}
public ConnexionStatusView(StateMachine stateMachine, short port) throws UnknownHostException, IOException {
this(stateMachine, new Server(port), new Client("localhost", port));
}
private ConnexionStatusView(StateMachine stateMachine, Server server, Client client) {
super(stateMachine);
this.client = client;
this.client.onConnect.connect(this::onConnect);
this.client.onClosed.connect(this::onLeave);
this.server = server;
}
public void onConnect() {
// System.out.println("Connecté");
this.stateMachine.pushState(new MultiPlayerView(stateMachine, client));
}
public void onLeave() {
// System.out.println("Quitté !");
this.client.onDisconnect.clear();
this.client = null;
// on passe le menu de la connexion
this.closeMenu();
}
@Override
public void render() {
ImGui.text("Connecting ...");
}
@Override
public void cleanResources() {
// System.out.println("Bye bye !");
if (this.server != null) {
this.server.stop();
}
if (this.client != null) {
this.client.stop();
}
}
}