multiple bugfixes
This commit is contained in:
parent
61a4b2b5ec
commit
20107fc8cc
@ -1,5 +1,6 @@
|
|||||||
package eu.jonahbauer.wizard.client.libgdx.actors;
|
package eu.jonahbauer.wizard.client.libgdx.actors;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Input;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||||
import com.badlogic.gdx.math.MathUtils;
|
import com.badlogic.gdx.math.MathUtils;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
@ -60,6 +61,7 @@ public class CardsGroup extends WidgetGroup {
|
|||||||
@Override
|
@Override
|
||||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||||
if (pointer != 0) return false;
|
if (pointer != 0) return false;
|
||||||
|
if (button != Input.Buttons.LEFT) return false;
|
||||||
if (event.getTarget() instanceof CardActor card) {
|
if (event.getTarget() instanceof CardActor card) {
|
||||||
dragTarget = card;
|
dragTarget = card;
|
||||||
dragStartX = x;
|
dragStartX = x;
|
||||||
@ -93,6 +95,7 @@ public class CardsGroup extends WidgetGroup {
|
|||||||
@Override
|
@Override
|
||||||
public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
|
public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
|
||||||
if (pointer != 0) return;
|
if (pointer != 0) return;
|
||||||
|
if (button != Input.Buttons.LEFT) return;
|
||||||
if (!dragging && dragTarget != null) {
|
if (!dragging && dragTarget != null) {
|
||||||
if (onClickListener != null) {
|
if (onClickListener != null) {
|
||||||
onClickListener.accept(dragTarget);
|
onClickListener.accept(dragTarget);
|
||||||
|
@ -14,6 +14,7 @@ import lombok.extern.log4j.Log4j2;
|
|||||||
|
|
||||||
@Log4j2
|
@Log4j2
|
||||||
public class CreateGameScreen extends MenuScreen {
|
public class CreateGameScreen extends MenuScreen {
|
||||||
|
private static final int MAX_SESSION_NAME_LENGTH = 20;
|
||||||
|
|
||||||
private TextButton buttonBack;
|
private TextButton buttonBack;
|
||||||
private TextButton buttonContinue;
|
private TextButton buttonContinue;
|
||||||
@ -60,7 +61,7 @@ public class CreateGameScreen extends MenuScreen {
|
|||||||
sessionName = new TextField("", skin);
|
sessionName = new TextField("", skin);
|
||||||
sessionName.setPosition(WizardGame.WIDTH * 0.3f, WizardGame.HEIGHT * 0.5f);
|
sessionName.setPosition(WizardGame.WIDTH * 0.3f, WizardGame.HEIGHT * 0.5f);
|
||||||
sessionName.setSize(0.4f * WizardGame.WIDTH, 64);
|
sessionName.setSize(0.4f * WizardGame.WIDTH, 64);
|
||||||
sessionName.setMaxLength(20);
|
sessionName.setMaxLength(MAX_SESSION_NAME_LENGTH);
|
||||||
sessionName.addListener(errorListener);
|
sessionName.addListener(errorListener);
|
||||||
sessionName.setProgrammaticChangeEvents(true);
|
sessionName.setProgrammaticChangeEvents(true);
|
||||||
|
|
||||||
@ -75,7 +76,11 @@ public class CreateGameScreen extends MenuScreen {
|
|||||||
public void changed(ChangeEvent event, Actor actor) {
|
public void changed(ChangeEvent event, Actor actor) {
|
||||||
var player = playerName.getText();
|
var player = playerName.getText();
|
||||||
var session = sessionName.getText();
|
var session = sessionName.getText();
|
||||||
if (session.isEmpty() || session.equals(format.formatted(oldPlayerName))) {
|
var previousSuggestion = format.formatted(oldPlayerName);
|
||||||
|
|
||||||
|
boolean shouldApplySuggestion = session.isEmpty()
|
||||||
|
|| previousSuggestion.startsWith(session) && (session.length() == MAX_SESSION_NAME_LENGTH || session.length() == previousSuggestion.length());
|
||||||
|
if (shouldApplySuggestion) {
|
||||||
if (player.isEmpty()) {
|
if (player.isEmpty()) {
|
||||||
sessionName.setText("");
|
sessionName.setText("");
|
||||||
} else {
|
} else {
|
||||||
|
@ -318,6 +318,7 @@ public class GameScreen extends WizardScreen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (currentAction == null && pendingSync.getAndSet(false)) {
|
if (currentAction == null && pendingSync.getAndSet(false)) {
|
||||||
|
doSetPersistentMessage(null);
|
||||||
game.getClient().execute(Game.class, Game::sync);
|
game.getClient().execute(Game.class, Game::sync);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -732,11 +733,15 @@ public class GameScreen extends WizardScreen {
|
|||||||
execute(new TrumpOverlay(this, players.get(player), trumpCard, trumpSuit));
|
execute(new TrumpOverlay(this, players.get(player), trumpCard, trumpSuit));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showColoredCardOverlay(@NotNull Card card, long timeout) {
|
public PlayColoredCardOverlay showColoredCardOverlay(@NotNull Card card, long timeout) {
|
||||||
if (card == Card.JUGGLER) {
|
if (card == Card.JUGGLER) {
|
||||||
execute(new PlayColoredCardOverlay(this, timeout, card, Card.JUGGLER_RED, Card.JUGGLER_GREEN, Card.JUGGLER_BLUE, Card.JUGGLER_YELLOW));
|
var overlay = new PlayColoredCardOverlay(this, timeout, card, Card.JUGGLER_RED, Card.JUGGLER_GREEN, Card.JUGGLER_BLUE, Card.JUGGLER_YELLOW);
|
||||||
|
execute(overlay);
|
||||||
|
return overlay;
|
||||||
} else if (card == Card.CLOUD) {
|
} else if (card == Card.CLOUD) {
|
||||||
execute(new PlayColoredCardOverlay(this, timeout, card, Card.CLOUD_RED, Card.CLOUD_GREEN, Card.CLOUD_BLUE, Card.CLOUD_YELLOW));
|
var overlay = new PlayColoredCardOverlay(this, timeout, card, Card.CLOUD_RED, Card.CLOUD_GREEN, Card.CLOUD_BLUE, Card.CLOUD_YELLOW);
|
||||||
|
execute(overlay);
|
||||||
|
return overlay;
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
@ -808,7 +813,10 @@ public class GameScreen extends WizardScreen {
|
|||||||
|
|
||||||
public void setPersistentMessage(String key, Object...args) {
|
public void setPersistentMessage(String key, Object...args) {
|
||||||
var text = key == null ? null : args != null ? messages.format(key, args) : messages.get(key);
|
var text = key == null ? null : args != null ? messages.format(key, args) : messages.get(key);
|
||||||
execute(() -> {
|
execute(() -> doSetPersistentMessage(text));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doSetPersistentMessage(String message) {
|
||||||
if (persistentMessage != null) {
|
if (persistentMessage != null) {
|
||||||
persistentMessage.addAction(sequence(
|
persistentMessage.addAction(sequence(
|
||||||
delay(AnimationTimings.MESSAGE_HOLD),
|
delay(AnimationTimings.MESSAGE_HOLD),
|
||||||
@ -818,11 +826,10 @@ public class GameScreen extends WizardScreen {
|
|||||||
persistentMessage = null;
|
persistentMessage = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (text != null) {
|
if (message != null) {
|
||||||
persistentMessage = new Label(text, skin);
|
persistentMessage = new Label(message, skin);
|
||||||
messageStack.addActor(persistentMessage);
|
messageStack.addActor(persistentMessage);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
|
|
||||||
@ -838,6 +845,11 @@ public class GameScreen extends WizardScreen {
|
|||||||
|
|
||||||
public void sync() {
|
public void sync() {
|
||||||
pendingSync.set(true);
|
pendingSync.set(true);
|
||||||
|
execute(() -> {
|
||||||
|
if (pendingSync.get()) {
|
||||||
|
doSetPersistentMessage(messages.get("game.message.sync"));
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void closeInteractionOverlay() {
|
public void closeInteractionOverlay() {
|
||||||
|
@ -331,13 +331,16 @@ public final class Game extends BaseState {
|
|||||||
if (isActive()) {
|
if (isActive()) {
|
||||||
if (currentInteraction.action() == PLAY_CARD) {
|
if (currentInteraction.action() == PLAY_CARD) {
|
||||||
if (card == Card.CLOUD || card == Card.JUGGLER) {
|
if (card == Card.CLOUD || card == Card.JUGGLER) {
|
||||||
gameScreen.showColoredCardOverlay(card, currentInteraction.timeout());
|
var oldOverlay = currentInteraction.overlay();
|
||||||
|
if (oldOverlay != null) oldOverlay.close();
|
||||||
|
|
||||||
|
currentInteraction.overlay(gameScreen.showColoredCardOverlay(card, currentInteraction.timeout()));
|
||||||
} else {
|
} else {
|
||||||
send(client, new PlayCardMessage(card));
|
send(client, new PlayCardMessage(card));
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
} else if (currentInteraction.action() == JUGGLE_CARD) {
|
} else if (currentInteraction.action() == JUGGLE_CARD) {
|
||||||
if (send(client, new JuggleMessage(juggleCard))) {
|
if (send(client, new JuggleMessage(card))) {
|
||||||
juggleCard = card;
|
juggleCard = card;
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
|
@ -162,6 +162,7 @@ game.message.change_prediction.all=Everybody must change their prediction
|
|||||||
game.message.change_prediction.self=It is your turn to change your prediction
|
game.message.change_prediction.self=It is your turn to change your prediction
|
||||||
|
|
||||||
game.message.timeout=Timed out
|
game.message.timeout=Timed out
|
||||||
|
game.message.sync=Waiting for other players...
|
||||||
game.message.nack.not_allowed=You cannot do that right now
|
game.message.nack.not_allowed=You cannot do that right now
|
||||||
game.message.nack.too_fast=Please slow down
|
game.message.nack.too_fast=Please slow down
|
||||||
|
|
||||||
|
@ -159,6 +159,7 @@ game.message.change_prediction.all=Jeder muss seine Vorhersage ändern
|
|||||||
game.message.change_prediction.self=Du musst deine Vorhersage ändern
|
game.message.change_prediction.self=Du musst deine Vorhersage ändern
|
||||||
|
|
||||||
game.message.timeout=Zeit abgelaufen
|
game.message.timeout=Zeit abgelaufen
|
||||||
|
game.message.sync=Warte auf andere Spieler...
|
||||||
game.message.nack.not_allowed=Du kannst das jetzt nicht tun
|
game.message.nack.not_allowed=Du kannst das jetzt nicht tun
|
||||||
game.message.nack.too_fast=Nicht so schnell
|
game.message.nack.too_fast=Nicht so schnell
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ public class DesktopLauncher {
|
|||||||
public static void main (String[] arg) {
|
public static void main (String[] arg) {
|
||||||
Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
|
Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
|
||||||
config.setTitle("Wizard Jubilaeumsedition 2021");
|
config.setTitle("Wizard Jubilaeumsedition 2021");
|
||||||
config.setForegroundFPS(60);
|
|
||||||
config.setWindowSizeLimits(853, 480, -1, -1);
|
config.setWindowSizeLimits(853, 480, -1, -1);
|
||||||
config.setBackBufferConfig(8, 8, 8, 8, 16, 0, 32);
|
config.setBackBufferConfig(8, 8, 8, 8, 16, 0, 32);
|
||||||
new Lwjgl3Application(new WizardGame(), config);
|
new Lwjgl3Application(new WizardGame(), config);
|
||||||
|
@ -61,9 +61,12 @@ public class DebugSession extends Session {
|
|||||||
protected void startGame() {}
|
protected void startGame() {}
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
for (var player : getPlayers().values()) {
|
for (var sessionPlayer : getPlayers().values()) {
|
||||||
try {
|
try {
|
||||||
player.getPlayer().disconnect();
|
var player = sessionPlayer.getPlayer();
|
||||||
|
if (player != null) {
|
||||||
|
player.disconnect();
|
||||||
|
}
|
||||||
} catch (IOException ignored) {}
|
} catch (IOException ignored) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user