show player names
Some checks failed
Linux arm64 / Build (push) Failing after 5m3s

This commit is contained in:
2025-01-26 18:22:20 +01:00
parent 47dc35ebfa
commit 6658b0e884
4 changed files with 31 additions and 6 deletions

View File

@@ -57,7 +57,7 @@ public class ConnexionStatusView extends BaseView {
}
public void onConnect() {
this.stateMachine.pushState(new MultiPlayerView(stateMachine, client));
this.stateMachine.pushState(new MultiPlayerView(stateMachine, client, server));
}
public void onDisconnect() {

View File

@@ -1,15 +1,19 @@
package gui.menu;
import game.Player;
import imgui.ImGui;
import network.client.Client;
import network.server.Server;
public class MultiPlayerView extends BaseView {
private final Client client;
public MultiPlayerView(StateMachine stateMachine, Client client) {
private final Client client;
private final Server server;
public MultiPlayerView(StateMachine stateMachine, Client client, Server server) {
super(stateMachine);
this.client = client;
this.server = server;
this.client.onDisconnect.connect(this::onDisconnect);
}
@@ -23,9 +27,25 @@ public class MultiPlayerView extends BaseView {
this.stateMachine.popState();
}
public void renderGameStatus() {
if (this.server == null) {
ImGui.text("En attente de l'administrateur du serveur ...");
} else {
if (ImGui.button("Démarrer")) {
// start the game
}
}
}
@Override
public void render() {
ImGui.text("Tema le gameplay");
ImGui.text("Joueurs :");
{
for (Player player : this.client.getGame().getPlayers().values()) {
ImGui.bulletText(player.getPseudo());
}
}
renderGameStatus();
}
}

View File

@@ -45,6 +45,7 @@ public class StateMachine {
| ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoBackground);
menus.get(menus.size() - 1).render();
ImGui.end();
// ImGui.showDemoWindow();
checkEscape();
}

View File

@@ -2,6 +2,7 @@ package network.client;
import java.io.IOException;
import java.net.UnknownHostException;
import java.util.Random;
import common.Signal;
import game.Game;
@@ -15,13 +16,16 @@ public class Client {
public final Signal onConnect = new Signal();
public final Signal onDisconnect = new Signal();
public final Signal onClosed = new Signal();
public final Signal onGameStarted = new Signal();
String disconnectReason = null;
public Client(String address, short port) throws UnknownHostException, IOException {
this.clientConnection = new ClientConnexion(address, port, this);
this.game = new Game();
login("Player2" + Math.random());
// temp
Random r = new Random();
login("Player" + r.nextInt());
}
public void login(String pseudo) {