Files
Sudoku/app/src/main/java/gui/menu/MultiMenu.java
Persson-dev 47dc35ebfa
Some checks failed
Linux arm64 / Build (push) Failing after 5m1s
more stable connexion
2025-01-26 14:54:46 +01:00

69 lines
1.7 KiB
Java

package gui.menu;
import java.io.IOException;
import imgui.ImGui;
import imgui.ImVec2;
import imgui.type.ImInt;
import imgui.type.ImString;
public class MultiMenu extends BaseView {
private final ImInt port = new ImInt(25565);
private final ImString address = new ImString("localhost");
public MultiMenu(StateMachine stateMachine) {
super(stateMachine);
address.resize(20);
}
private void renderCreate() {
ImVec2 displaySize = ImGui.getIO().getDisplaySize();
ImGui.beginChild("##CreateGame", new ImVec2(displaySize.x / 2.0f, displaySize.y * 8.0f / 9.0f));
ImGui.inputInt("Port", port);
if (ImGui.button("Créer")) {
try {
this.stateMachine.pushState(new ConnexionStatusView(stateMachine, (short) port.get()));
} catch (IOException e) {
e.printStackTrace();
}
}
ImGui.endChild();
}
private void renderJoin() {
ImVec2 displaySize = ImGui.getIO().getDisplaySize();
ImGui.beginChild("##JoinGame", new ImVec2(displaySize.x / 2.0f, displaySize.y * 8.0f / 9.0f));
ImGui.inputText("Adresse", address);
ImGui.inputInt("Port", port);
if (ImGui.button("Rejoindre")) {
try {
this.stateMachine.pushState(new ConnexionStatusView(stateMachine, address.get(), (short) port.get()));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
ImGui.endChild();
}
@Override
public void render() {
renderCreate();
ImGui.sameLine();
renderJoin();
ImVec2 displaySize = ImGui.getIO().getDisplaySize();
ImVec2 buttonSize = new ImVec2(500, 70.0f);
float centerX = displaySize.x / 2.0f - buttonSize.x / 2.0f;
ImGui.setCursorPosX(centerX);
if (ImGui.button("Retour", buttonSize)) {
closeMenu();
}
}
}