Challenge popups "Fixed"

This commit is contained in:
lieght
2025-12-04 20:46:59 +01:00
parent 27a35c8117
commit 4608135ee5
4 changed files with 11 additions and 7 deletions

View File

@@ -158,10 +158,12 @@ public final class Server {
private void sendChallenge(String opponent) { private void sendChallenge(String opponent) {
if (!isPolling) return; if (!isPolling) return;
new SendChallengePopup(this, opponent, (playerInformation, gameType) -> { var a = new SendChallengePopup(this, opponent, (playerInformation, gameType) -> {
new EventFlow().addPostEvent(new NetworkEvents.SendChallenge(clientId, opponent, gameType)).postEvent(); new EventFlow().addPostEvent(new NetworkEvents.SendChallenge(clientId, opponent, gameType)).postEvent();
isSingleGame.set(true); isSingleGame.set(true);
}); });
a.show(Pos.CENTER);
} }
private void handleMatchResponse(NetworkEvents.GameMatchResponse response) { private void handleMatchResponse(NetworkEvents.GameMatchResponse response) {
@@ -251,11 +253,13 @@ public final class Server {
String challengerName = extractQuotedValue(response.challengerName()); String challengerName = extractQuotedValue(response.challengerName());
String gameType = extractQuotedValue(response.gameType()); String gameType = extractQuotedValue(response.gameType());
final String finalGameType = gameType; final String finalGameType = gameType;
new ChallengePopup(challengerName, gameType, (playerInformation) -> { var a = new ChallengePopup(challengerName, gameType, (playerInformation) -> {
final int challengeId = Integer.parseInt(response.challengeId().replaceAll("\\D", "")); final int challengeId = Integer.parseInt(response.challengeId().replaceAll("\\D", ""));
new EventFlow().addPostEvent(new NetworkEvents.SendAcceptChallenge(clientId, challengeId)).postEvent(); new EventFlow().addPostEvent(new NetworkEvents.SendAcceptChallenge(clientId, challengeId)).postEvent();
isSingleGame.set(true); isSingleGame.set(true);
}); });
a.show(Pos.CENTER);
} }
private void sendMessage(String message) { private void sendMessage(String message) {

View File

@@ -8,6 +8,7 @@ import org.toop.app.widget.complex.PopupWidget;
import java.util.function.Consumer; import java.util.function.Consumer;
import javafx.geometry.Pos; import javafx.geometry.Pos;
import org.toop.local.AppContext;
public final class ChallengePopup extends PopupWidget { public final class ChallengePopup extends PopupWidget {
private final GameInformation.Player playerInformation; private final GameInformation.Player playerInformation;
@@ -28,11 +29,9 @@ public final class ChallengePopup extends PopupWidget {
private void setupLayout() { private void setupLayout() {
var challengeText = Primitive.text("you-were-challenged-by"); var challengeText = Primitive.text("you-were-challenged-by");
var challengerHeader = Primitive.header(""); var challengerHeader = Primitive.header(challenger, false);
challengerHeader.setText(challenger);
var gameText = Primitive.text("to-a-game-of"); var gameText = Primitive.text(AppContext.getString("to-a-game-of") + " " + game, false);
gameText.setText(gameText.getText() + " " + game);
var acceptButton = Primitive.button("accept", () -> onAccept.accept(playerInformation)); var acceptButton = Primitive.button("accept", () -> onAccept.accept(playerInformation));
var denyButton = Primitive.button("deny", () -> hide()); var denyButton = Primitive.button("deny", () -> hide());

View File

@@ -34,7 +34,7 @@ public final class SendChallengePopup extends PopupWidget {
// --- Left side: challenge text and buttons --- // --- Left side: challenge text and buttons ---
var challengeText = Primitive.text("challenge"); var challengeText = Primitive.text("challenge");
var opponentHeader = Primitive.header(opponent); var opponentHeader = Primitive.header(opponent, false);
var gameText = Primitive.text("to-a-game-of"); var gameText = Primitive.text("to-a-game-of");

View File

@@ -24,6 +24,7 @@ error=Error
exit=Exit exit=Exit
forfeit=Forfeit forfeit=Forfeit
fullscreen=Fullscreen fullscreen=Fullscreen
game=REPLACE ME
game-over=Game Over game-over=Game Over
general=General general=General
high-contrast=High contrast high-contrast=High contrast