multiple bugfixes
This commit is contained in:
parent
6b1bca63a7
commit
659f85e5d3
@ -1,5 +1,6 @@
|
||||
package eu.jonahbauer.wizard.client.libgdx.actors;
|
||||
|
||||
import com.badlogic.gdx.Input;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||
import com.badlogic.gdx.math.MathUtils;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
@ -60,6 +61,7 @@ public class CardsGroup extends WidgetGroup {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
if (pointer != 0) return false;
|
||||
if (button != Input.Buttons.LEFT) return false;
|
||||
if (event.getTarget() instanceof CardActor card) {
|
||||
dragTarget = card;
|
||||
dragStartX = x;
|
||||
@ -93,6 +95,7 @@ public class CardsGroup extends WidgetGroup {
|
||||
@Override
|
||||
public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
|
||||
if (pointer != 0) return;
|
||||
if (button != Input.Buttons.LEFT) return;
|
||||
if (!dragging && dragTarget != null) {
|
||||
if (onClickListener != null) {
|
||||
onClickListener.accept(dragTarget);
|
||||
|
@ -14,6 +14,7 @@ import lombok.extern.log4j.Log4j2;
|
||||
|
||||
@Log4j2
|
||||
public class CreateGameScreen extends MenuScreen {
|
||||
private static final int MAX_SESSION_NAME_LENGTH = 20;
|
||||
|
||||
private TextButton buttonBack;
|
||||
private TextButton buttonContinue;
|
||||
@ -60,7 +61,7 @@ public class CreateGameScreen extends MenuScreen {
|
||||
sessionName = new TextField("", skin);
|
||||
sessionName.setPosition(WizardGame.WIDTH * 0.3f, WizardGame.HEIGHT * 0.5f);
|
||||
sessionName.setSize(0.4f * WizardGame.WIDTH, 64);
|
||||
sessionName.setMaxLength(20);
|
||||
sessionName.setMaxLength(MAX_SESSION_NAME_LENGTH);
|
||||
sessionName.addListener(errorListener);
|
||||
sessionName.setProgrammaticChangeEvents(true);
|
||||
|
||||
@ -75,7 +76,11 @@ public class CreateGameScreen extends MenuScreen {
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
var player = playerName.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()) {
|
||||
sessionName.setText("");
|
||||
} else {
|
||||
|
@ -318,6 +318,7 @@ public class GameScreen extends WizardScreen {
|
||||
}
|
||||
|
||||
if (currentAction == null && pendingSync.getAndSet(false)) {
|
||||
doSetPersistentMessage(null);
|
||||
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));
|
||||
}
|
||||
|
||||
public void showColoredCardOverlay(@NotNull Card card, long timeout) {
|
||||
public PlayColoredCardOverlay showColoredCardOverlay(@NotNull Card card, long timeout) {
|
||||
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) {
|
||||
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 {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
@ -808,21 +813,23 @@ public class GameScreen extends WizardScreen {
|
||||
|
||||
public void setPersistentMessage(String key, Object...args) {
|
||||
var text = key == null ? null : args != null ? messages.format(key, args) : messages.get(key);
|
||||
execute(() -> {
|
||||
if (persistentMessage != null) {
|
||||
persistentMessage.addAction(sequence(
|
||||
delay(AnimationTimings.MESSAGE_HOLD),
|
||||
alpha(0, AnimationTimings.MESSAGE_FADE),
|
||||
removeActor()
|
||||
));
|
||||
persistentMessage = null;
|
||||
}
|
||||
execute(() -> doSetPersistentMessage(text));
|
||||
}
|
||||
|
||||
if (text != null) {
|
||||
persistentMessage = new Label(text, skin);
|
||||
messageStack.addActor(persistentMessage);
|
||||
}
|
||||
});
|
||||
private void doSetPersistentMessage(String message) {
|
||||
if (persistentMessage != null) {
|
||||
persistentMessage.addAction(sequence(
|
||||
delay(AnimationTimings.MESSAGE_HOLD),
|
||||
alpha(0, AnimationTimings.MESSAGE_FADE),
|
||||
removeActor()
|
||||
));
|
||||
persistentMessage = null;
|
||||
}
|
||||
|
||||
if (message != null) {
|
||||
persistentMessage = new Label(message, skin);
|
||||
messageStack.addActor(persistentMessage);
|
||||
}
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
@ -838,6 +845,11 @@ public class GameScreen extends WizardScreen {
|
||||
|
||||
public void sync() {
|
||||
pendingSync.set(true);
|
||||
execute(() -> {
|
||||
if (pendingSync.get()) {
|
||||
doSetPersistentMessage(messages.get("game.message.sync"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void closeInteractionOverlay() {
|
||||
|
@ -331,13 +331,16 @@ public final class Game extends BaseState {
|
||||
if (isActive()) {
|
||||
if (currentInteraction.action() == PLAY_CARD) {
|
||||
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 {
|
||||
send(client, new PlayCardMessage(card));
|
||||
}
|
||||
return Optional.empty();
|
||||
} else if (currentInteraction.action() == JUGGLE_CARD) {
|
||||
if (send(client, new JuggleMessage(juggleCard))) {
|
||||
if (send(client, new JuggleMessage(card))) {
|
||||
juggleCard = card;
|
||||
}
|
||||
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.timeout=Timed out
|
||||
game.message.sync=Waiting for other players...
|
||||
game.message.nack.not_allowed=You cannot do that right now
|
||||
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.timeout=Zeit abgelaufen
|
||||
game.message.sync=Warte auf andere Spieler...
|
||||
game.message.nack.not_allowed=Du kannst das jetzt nicht tun
|
||||
game.message.nack.too_fast=Nicht so schnell
|
||||
|
||||
|
@ -8,7 +8,6 @@ public class DesktopLauncher {
|
||||
public static void main (String[] arg) {
|
||||
Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
|
||||
config.setTitle("Wizard Jubilaeumsedition 2021");
|
||||
config.setForegroundFPS(60);
|
||||
config.setWindowSizeLimits(853, 480, -1, -1);
|
||||
config.setBackBufferConfig(8, 8, 8, 8, 16, 0, 32);
|
||||
new Lwjgl3Application(new WizardGame(), config);
|
||||
|
@ -61,9 +61,12 @@ public class DebugSession extends Session {
|
||||
protected void startGame() {}
|
||||
|
||||
public void close() {
|
||||
for (var player : getPlayers().values()) {
|
||||
for (var sessionPlayer : getPlayers().values()) {
|
||||
try {
|
||||
player.getPlayer().disconnect();
|
||||
var player = sessionPlayer.getPlayer();
|
||||
if (player != null) {
|
||||
player.disconnect();
|
||||
}
|
||||
} catch (IOException ignored) {}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user