shrank client size
This commit is contained in:
parent
71f66194e6
commit
2ab0a4d5bb
@ -51,11 +51,9 @@ object LibGDX {
|
||||
const val group = "com.badlogicgames.gdx"
|
||||
|
||||
const val api = "$group:gdx:$version"
|
||||
const val box2d = "$group:gdx-box2d:$version"
|
||||
|
||||
const val backend_lwjgl3 = "$group:gdx-backend-lwjgl3:$version"
|
||||
const val platform_desktop = "$group:gdx-platform:$version:natives-desktop"
|
||||
const val box2d_platform_desktop = "$group:gdx-box2d-platform:$version:natives-desktop"
|
||||
|
||||
const val tools = "$group:gdx-tools:$version"
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ project(":wizard-client:wizard-client-libgdx:desktop") {
|
||||
implementation(project(":wizard-client:wizard-client-libgdx:core"))
|
||||
api(LibGDX.backend_lwjgl3)
|
||||
api(LibGDX.platform_desktop)
|
||||
api(LibGDX.box2d_platform_desktop)
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,6 +14,5 @@ project(":wizard-client:wizard-client-libgdx:core") {
|
||||
|
||||
dependencies {
|
||||
api(LibGDX.api)
|
||||
api(LibGDX.box2d)
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ public class WizardGame extends Game {
|
||||
messages = I18NBundle.createBundle(Gdx.files.internal("i18n/messages"), Locale.getDefault());
|
||||
|
||||
// background music
|
||||
Music backgroundMusic = Gdx.audio.newMusic(Gdx.files.internal("background.wav"));
|
||||
Music backgroundMusic = Gdx.audio.newMusic(Gdx.files.internal("background.mp3"));
|
||||
backgroundMusic.setLooping(true);
|
||||
backgroundMusic.setVolume(0.07f);
|
||||
backgroundMusic.play();
|
||||
|
@ -1,6 +1,7 @@
|
||||
package eu.jonahbauer.wizard.client.libgdx.actors.game;
|
||||
|
||||
import com.badlogic.gdx.scenes.scene2d.*;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||
import eu.jonahbauer.wizard.client.libgdx.WizardGame;
|
||||
import eu.jonahbauer.wizard.client.libgdx.screens.GameScreen;
|
||||
import lombok.Data;
|
||||
@ -10,22 +11,39 @@ import java.util.*;
|
||||
import static com.badlogic.gdx.scenes.scene2d.actions.Actions.*;
|
||||
|
||||
public class CardStack extends Group {
|
||||
private static final float EXPAND_DURATION = 0.25f;
|
||||
private static final float EXPANDED_ROTATION_DEVIATION = 20;
|
||||
private static final float COLLAPSE_DURATION = 0.25f;
|
||||
private static final float COLLAPSED_ROTATION_DEVIATION = 60;
|
||||
private static final float COLLAPSED_POSITION_DEVIATION = 15;
|
||||
|
||||
private final Random random = new Random();
|
||||
private final List<Entry> cards = new ArrayList<>();
|
||||
|
||||
private final Actor hover = new Actor();
|
||||
private boolean expanded;
|
||||
|
||||
public CardStack() {
|
||||
this.addListener(new InputListener() {
|
||||
this.addActor(hover);
|
||||
this.addListener(new ClickListener() {
|
||||
|
||||
@Override
|
||||
public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) {
|
||||
if (fromActor == null || !isAscendantOf(fromActor)) {
|
||||
cards.forEach(Entry::expand);
|
||||
public void exit(InputEvent event, float x, float y, int pointer, Actor toActor) {
|
||||
super.exit(event, x, y, pointer, toActor);
|
||||
|
||||
if (event.getTarget() == hover && expanded) {
|
||||
expanded = false;
|
||||
cards.forEach(Entry::collapse);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit(InputEvent event, float x, float y, int pointer, Actor toActor) {
|
||||
if (toActor == null || !isAscendantOf(toActor)) {
|
||||
cards.forEach(Entry::collapse);
|
||||
public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) {
|
||||
super.enter(event, x, y, pointer, fromActor);
|
||||
|
||||
if (event.getTarget() == hover && !expanded) {
|
||||
expanded = true;
|
||||
cards.forEach(Entry::expand);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -35,20 +53,31 @@ public class CardStack extends Group {
|
||||
var entry = new Entry(
|
||||
card,
|
||||
seat,
|
||||
(float) random.nextGaussian((WizardGame.WIDTH - card.getWidth()) / 2, 15),
|
||||
(float) random.nextGaussian((WizardGame.HEIGHT - card.getHeight()) / 2, 15),
|
||||
(float) random.nextGaussian(0, 60),
|
||||
(float) random.nextGaussian(0, 20)
|
||||
(float) random.nextGaussian((WizardGame.WIDTH - card.getWidth()) / 2, COLLAPSED_POSITION_DEVIATION),
|
||||
(float) random.nextGaussian((WizardGame.HEIGHT - card.getHeight()) / 2, COLLAPSED_POSITION_DEVIATION),
|
||||
(float) random.nextGaussian(0, COLLAPSED_ROTATION_DEVIATION),
|
||||
(float) random.nextGaussian(0, EXPANDED_ROTATION_DEVIATION)
|
||||
);
|
||||
addActor(card);
|
||||
entry.collapse();
|
||||
if (expanded) entry.expand();
|
||||
else entry.collapse();
|
||||
cards.add(entry);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void childrenChanged() {
|
||||
hover.toFront();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearChildren(boolean unfocus) {
|
||||
super.clearChildren(unfocus);
|
||||
cards.clear();
|
||||
addActor(hover);
|
||||
}
|
||||
|
||||
public void setHoverBounds(float x, float y, float width, float height) {
|
||||
hover.setBounds(x, y, width, height);
|
||||
}
|
||||
|
||||
@Data
|
||||
@ -58,30 +87,26 @@ public class CardStack extends Group {
|
||||
private final float x;
|
||||
private final float y;
|
||||
private final float rotation;
|
||||
private final float rotation2;
|
||||
private final float expandedRotation;
|
||||
private Action action;
|
||||
|
||||
public void expand() {
|
||||
if (action != null) {
|
||||
actor.removeAction(action);
|
||||
}
|
||||
if (action != null) actor.removeAction(action);
|
||||
|
||||
action = parallel(
|
||||
moveTo(seat.getCardX() - actor.getWidth() / 2, seat.getCardY() - actor.getHeight() / 2, 0.25f),
|
||||
rotateTo(rotation2, 0.25f)
|
||||
moveTo(seat.getCardX() - actor.getWidth() / 2, seat.getCardY() - actor.getHeight() / 2, EXPAND_DURATION),
|
||||
rotateTo(expandedRotation, EXPAND_DURATION)
|
||||
);
|
||||
|
||||
actor.addAction(action);
|
||||
}
|
||||
|
||||
public void collapse() {
|
||||
if (action != null) {
|
||||
actor.removeAction(action);
|
||||
}
|
||||
if (action != null) actor.removeAction(action);
|
||||
|
||||
action = parallel(
|
||||
moveTo(x, y, 0.25f),
|
||||
rotateTo(rotation, 0.25f)
|
||||
moveTo(x, y, COLLAPSE_DURATION),
|
||||
rotateTo(rotation, COLLAPSE_DURATION)
|
||||
);
|
||||
|
||||
actor.addAction(action);
|
||||
|
@ -13,8 +13,11 @@ import lombok.Setter;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static com.badlogic.gdx.scenes.scene2d.actions.Actions.*;
|
||||
|
||||
public class CardsGroup extends WidgetGroup {
|
||||
private static final float TARGET_SPACING = -50f;
|
||||
private static final float LAYOUT_DURATION = 0.15f;
|
||||
|
||||
@Getter
|
||||
private final float prefWidth = 0;
|
||||
@ -26,6 +29,7 @@ public class CardsGroup extends WidgetGroup {
|
||||
private float[] cardX;
|
||||
private float spacing;
|
||||
private float cardWidth;
|
||||
private boolean animate;
|
||||
|
||||
private CardActor target;
|
||||
|
||||
@ -71,7 +75,7 @@ public class CardsGroup extends WidgetGroup {
|
||||
float oldX = dragTarget.getX();
|
||||
getChildren().removeValue(dragTarget, true);
|
||||
getChildren().insert(index, dragTarget);
|
||||
layout();
|
||||
invalidate();
|
||||
dragTarget.setHeight(1.3f * getHeight());
|
||||
dragStartX += (dragTarget.getX() - oldX);
|
||||
}
|
||||
@ -148,10 +152,24 @@ public class CardsGroup extends WidgetGroup {
|
||||
|
||||
for (int i = 0; i < children.size; i++) {
|
||||
var child = children.get(i);
|
||||
child.setBounds(x, y, cardWidth, height);
|
||||
|
||||
// position
|
||||
if (animate) {
|
||||
child.addAction(moveTo(x, y, LAYOUT_DURATION));
|
||||
} else {
|
||||
child.setPosition(x, y);
|
||||
}
|
||||
|
||||
// size
|
||||
child.setWidth(cardWidth);
|
||||
if (child != dragTarget && child != target) {
|
||||
child.setHeight(height);
|
||||
}
|
||||
|
||||
cardX[i] = x;
|
||||
x += cardWidth + spacing;
|
||||
}
|
||||
animate = false;
|
||||
}
|
||||
|
||||
public void update(List<Card> cards) {
|
||||
@ -160,10 +178,11 @@ public class CardsGroup extends WidgetGroup {
|
||||
cards.stream()
|
||||
.map(card -> new CardActor(card, atlas))
|
||||
.forEach(this::addActor);
|
||||
layout();
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public CardActor remove(Card card) {
|
||||
// find actor
|
||||
CardActor actor = null;
|
||||
var children = getChildren();
|
||||
for (int i = 0; i < children.size; i++) {
|
||||
@ -177,6 +196,7 @@ public class CardsGroup extends WidgetGroup {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
||||
// adjust actor
|
||||
actor.setY(getY() + actor.getHeight() - getHeight());
|
||||
var pos = localToStageCoordinates(Pools.get(Vector2.class).obtain().set(actor.getX(), actor.getY()));
|
||||
actor.setHeight(getHeight());
|
||||
@ -184,8 +204,11 @@ public class CardsGroup extends WidgetGroup {
|
||||
if (target == actor) {
|
||||
target = null;
|
||||
}
|
||||
|
||||
// remove actor
|
||||
animate = true;
|
||||
actor.clearActions();
|
||||
actor.remove();
|
||||
layout();
|
||||
return actor;
|
||||
}
|
||||
|
||||
|
@ -13,9 +13,11 @@ import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
|
||||
public class PadOfTruth extends Table {
|
||||
private static final float EXPAND_DURATION = 0.25f;
|
||||
private static final float EXTENDED_WIDTH = 636;
|
||||
private static final float EXTENDED_HEIGHT = 824;
|
||||
private static final float SMALL_SCALE = 0.2f;
|
||||
private static final float COLLAPSE_DURATION = 0.25f;
|
||||
private static final float COLLAPSED_SCALE = 0.2f;
|
||||
|
||||
private final Label[] names = new Label[6];
|
||||
private final Label[][] predictions = new Label[20][];
|
||||
@ -31,7 +33,7 @@ public class PadOfTruth extends Table {
|
||||
|
||||
setTransform(true);
|
||||
setOrigin(0, 0);
|
||||
setScale(SMALL_SCALE);
|
||||
setScale(COLLAPSED_SCALE);
|
||||
|
||||
addListener(new InputListener() {
|
||||
private ScaleToAction action;
|
||||
@ -39,10 +41,9 @@ public class PadOfTruth extends Table {
|
||||
@Override
|
||||
public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) {
|
||||
if (fromActor != null && isAscendantOf(fromActor)) return;
|
||||
System.out.println("ENTER");
|
||||
if (action != null) action.finish();
|
||||
if (action != null) removeAction(action);
|
||||
action = new ScaleToAction();
|
||||
action.setDuration(0.25f);
|
||||
action.setDuration(EXPAND_DURATION);
|
||||
action.setScale(1);
|
||||
addAction(action);
|
||||
}
|
||||
@ -50,11 +51,10 @@ public class PadOfTruth extends Table {
|
||||
@Override
|
||||
public void exit(InputEvent event, float x, float y, int pointer, Actor toActor) {
|
||||
if (toActor != null && isAscendantOf(toActor)) return;
|
||||
System.out.println("EXIT");
|
||||
if (action != null) action.finish();
|
||||
if (action != null) removeAction(action);
|
||||
action = new ScaleToAction();
|
||||
action.setDuration(0.25f);
|
||||
action.setScale(SMALL_SCALE);
|
||||
action.setDuration(COLLAPSE_DURATION);
|
||||
action.setScale(COLLAPSED_SCALE);
|
||||
addAction(action);
|
||||
}
|
||||
});
|
||||
|
@ -104,6 +104,7 @@ public class GameScreen extends MenuScreen {
|
||||
padOfTruth.setOrigin(636f, 0);
|
||||
|
||||
cardStack = new CardStack();
|
||||
cardStack.setHoverBounds(0.5f * WizardGame.WIDTH - 50, 0.5f * WizardGame.HEIGHT - 50, 100, 100);
|
||||
|
||||
setNames();
|
||||
|
||||
|
@ -69,14 +69,12 @@ public class LobbyScreen extends MenuScreen {
|
||||
});
|
||||
|
||||
var listContainer = new AutoFocusScrollPane(sessions, data.skin);
|
||||
listContainer.layout();
|
||||
|
||||
var content = new HorizontalGroup().grow().space(20);
|
||||
content.setPosition(0.25f * WizardGame.WIDTH, 0.3f * WizardGame.HEIGHT);
|
||||
content.setSize(0.5f * WizardGame.WIDTH, 400);
|
||||
content.addActor(new Container<>(listContainer).width(0.2f * WizardGame.WIDTH).height(400));
|
||||
content.addActor(createInfoTable());
|
||||
content.layout();
|
||||
|
||||
var buttons = new HorizontalGroup();
|
||||
buttons.setPosition(WizardGame.WIDTH * 0.2f, BUTTON_BAR_Y);
|
||||
@ -110,8 +108,7 @@ public class LobbyScreen extends MenuScreen {
|
||||
for (SessionData session : sessions) {
|
||||
this.sessions.getItems().add(session);
|
||||
}
|
||||
this.sessions.layout();
|
||||
((ScrollPane)this.sessions.getParent()).layout();
|
||||
this.sessions.invalidateHierarchy();
|
||||
}
|
||||
|
||||
private void updateData(SessionData data) {
|
||||
|
@ -64,14 +64,12 @@ public class WaitingScreen extends MenuScreen {
|
||||
};
|
||||
|
||||
var listContainer = new AutoFocusScrollPane(players, data.skin);
|
||||
listContainer.layout();
|
||||
|
||||
var content = new HorizontalGroup().grow().space(20);
|
||||
content.setPosition(0.25f * WizardGame.WIDTH, 0.3f * WizardGame.HEIGHT);
|
||||
content.setSize(0.5f * WizardGame.WIDTH, 400);
|
||||
content.addActor(new Container<>(listContainer).width(0.2f * WizardGame.WIDTH).height(400));
|
||||
content.addActor(createInfoTable());
|
||||
content.layout();
|
||||
|
||||
Gdx.input.setInputProcessor(data.stage);
|
||||
data.stage.addActor(buttonLeave);
|
||||
@ -85,7 +83,7 @@ public class WaitingScreen extends MenuScreen {
|
||||
for (int i = 1; i <= 4; i++) {
|
||||
players.getItems().add(new PlayerData(UUID.randomUUID(), "Player " + i, false));
|
||||
}
|
||||
players.layout();
|
||||
players.invalidateHierarchy();
|
||||
}
|
||||
|
||||
private void ready(boolean ready) {
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 265 KiB After Width: | Height: | Size: 322 KiB |
@ -1,7 +1,7 @@
|
||||
{
|
||||
"BitmapFont": {
|
||||
"default-font": {
|
||||
"file": "font/coolvetica.fnt"
|
||||
"file": "font/coolvetica.fnt",
|
||||
},
|
||||
"enchanted": {
|
||||
"file": "font/enchanted.fnt"
|
||||
@ -15,8 +15,10 @@
|
||||
"white": { "a": 1.0, "b": 1.0, "g": 1.0, "r": 1.0 },
|
||||
"red": { "a": 1.0, "b": 0.0, "g": 0.0, "r": 1.0 },
|
||||
"black": { "a": 1.0, "b": 0.0, "g": 0.0, "r": 0.0 },
|
||||
"gold": { "a": 1.0, "b": 0.125, "g": 0.75, "r": 0.9 },
|
||||
"light_gray": { "a": 1.0, "b": 0.6, "g": 0.6, "r": 0.6 }
|
||||
"gold": { "a": 1.0, "b": 0.318, "g": 0.753, "r": 0.89 },
|
||||
"dark_gold": { "a": 1.0, "b": 0.034, "g": 0.565, "r": 0.80 },
|
||||
"darker_gold": { "a": 1.0, "b": 0.191, "g": 0.452, "r": 0.534 },
|
||||
"light_gray": { "a": 1.0, "b": 0.6, "g": 0.6, "r": 0.6}
|
||||
},
|
||||
"TintedDrawable": {
|
||||
"dialogDim": {
|
||||
@ -43,9 +45,9 @@
|
||||
"TextButtonStyle": {
|
||||
"default": {
|
||||
"font": "enchanted",
|
||||
"fontColor": "white",
|
||||
"downFontColor": "gold",
|
||||
"disabledFontColor" : "light_gray"
|
||||
"fontColor": "gold",
|
||||
"downFontColor": "dark_gold",
|
||||
"disabledFontColor" : "darker_gold"
|
||||
},
|
||||
"toggle": {
|
||||
"down": "default-round-down",
|
||||
|
Loading…
x
Reference in New Issue
Block a user