@ -0,0 +1,50 @@
|
||||
package eu.jonahbauer.wizard.client.libgdx.actions.overlay;
|
||||
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.Group;
|
||||
import eu.jonahbauer.wizard.client.libgdx.WizardGame;
|
||||
import eu.jonahbauer.wizard.client.libgdx.actors.PadOfTruth;
|
||||
import eu.jonahbauer.wizard.client.libgdx.screens.GameScreen;
|
||||
import eu.jonahbauer.wizard.client.libgdx.util.AnimationTimings;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.badlogic.gdx.scenes.scene2d.actions.Actions.*;
|
||||
import static eu.jonahbauer.wizard.client.libgdx.actions.MyActions.changeParent;
|
||||
|
||||
public class ScoreOverlay extends Overlay {
|
||||
private final PadOfTruth padOfTruth;
|
||||
|
||||
public ScoreOverlay(@NotNull GameScreen gameScreen) {
|
||||
super(gameScreen, Long.MAX_VALUE);
|
||||
padOfTruth = Objects.requireNonNull(gameScreen.getPadOfTruth());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Actor createContent() {
|
||||
return padOfTruth;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void show(Group parent) {
|
||||
super.show(parent);
|
||||
|
||||
var root = getRoot();
|
||||
root.addAction(sequence(
|
||||
run(() -> padOfTruth.setEnabled(false)),
|
||||
parallel(
|
||||
targeting(padOfTruth, scaleTo(1, 1, AnimationTimings.OVERLAY_SHARED_ELEMENT)),
|
||||
targeting(padOfTruth, moveTo((WizardGame.WIDTH - padOfTruth.getWidth()) / 2, (WizardGame.HEIGHT - padOfTruth.getHeight()) / 2, AnimationTimings.OVERLAY_SHARED_ELEMENT))
|
||||
),
|
||||
delay(AnimationTimings.OVERLAY_HOLD),
|
||||
parallel(
|
||||
targeting(padOfTruth, scaleTo(PadOfTruth.COLLAPSED_SCALE, PadOfTruth.COLLAPSED_SCALE, AnimationTimings.OVERLAY_SHARED_ELEMENT)),
|
||||
targeting(padOfTruth, moveTo(WizardGame.WIDTH - 10 - PadOfTruth.EXTENDED_WIDTH, 10, AnimationTimings.OVERLAY_SHARED_ELEMENT))
|
||||
),
|
||||
targeting(padOfTruth, changeParent(screen.getContentRoot())),
|
||||
run(() -> padOfTruth.setEnabled(true)),
|
||||
run(this::close)
|
||||
));
|
||||
}
|
||||
}
|
@ -1,146 +1,50 @@
|
||||
package eu.jonahbauer.wizard.client.libgdx.screens;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Screen;
|
||||
import com.badlogic.gdx.audio.Sound;
|
||||
import com.badlogic.gdx.graphics.GL20;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||
import com.badlogic.gdx.utils.I18NBundle;
|
||||
import com.badlogic.gdx.utils.viewport.ExtendViewport;
|
||||
import com.badlogic.gdx.utils.viewport.FitViewport;
|
||||
import eu.jonahbauer.wizard.client.libgdx.MenuAtlas;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||
import eu.jonahbauer.wizard.client.libgdx.UiskinAtlas;
|
||||
import eu.jonahbauer.wizard.client.libgdx.WizardGame;
|
||||
import eu.jonahbauer.wizard.client.libgdx.listeners.AutoFocusListener;
|
||||
import eu.jonahbauer.wizard.client.libgdx.listeners.ButtonKeyListener;
|
||||
import eu.jonahbauer.wizard.client.libgdx.util.WizardAssetManager;
|
||||
|
||||
public abstract class MenuScreen implements Screen {
|
||||
public abstract class MenuScreen extends WizardScreen {
|
||||
protected final float BUTTON_BAR_Y = WizardGame.HEIGHT * 0.15f;
|
||||
|
||||
protected final WizardGame game;
|
||||
protected final WizardAssetManager assets;
|
||||
protected final SpriteBatch batch;
|
||||
|
||||
protected Stage stage;
|
||||
protected FitViewport fitViewport;
|
||||
protected ExtendViewport extendViewport;
|
||||
|
||||
// assets
|
||||
protected Skin skin;
|
||||
protected TextureAtlas atlas;
|
||||
protected Sound sfxClick;
|
||||
protected I18NBundle messages;
|
||||
|
||||
// textures
|
||||
protected TextureRegion background;
|
||||
protected TextureRegion title;
|
||||
protected TextureRegion[] corners;
|
||||
private Image[] corners;
|
||||
|
||||
public MenuScreen(WizardGame game) {
|
||||
this.game = game;
|
||||
this.assets = game.assets;
|
||||
this.batch = game.batch;
|
||||
super(game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
assets.loadMenu();
|
||||
assets.finishLoading();
|
||||
|
||||
skin = assets.get(WizardAssetManager.SKIN);
|
||||
atlas = assets.get(WizardAssetManager.ATLAS_MENU);
|
||||
sfxClick = assets.get(WizardAssetManager.SFX_CLICK);
|
||||
messages = assets.get(WizardAssetManager.MESSAGES);
|
||||
|
||||
skin.getAll(BitmapFont.class).forEach(entry -> {
|
||||
entry.value.getRegion().getTexture().setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
|
||||
});
|
||||
|
||||
extendViewport = new ExtendViewport(WizardGame.WIDTH, WizardGame.HEIGHT);
|
||||
fitViewport = new FitViewport(WizardGame.WIDTH, WizardGame.HEIGHT);
|
||||
|
||||
stage = new Stage(fitViewport);
|
||||
stage.addListener(new ButtonKeyListener());
|
||||
stage.addListener(new AutoFocusListener());
|
||||
|
||||
background = atlas.findRegion(MenuAtlas.BACKGROUND);
|
||||
title = atlas.findRegion(MenuAtlas.TITLE);
|
||||
corners = new TextureRegion[] {
|
||||
atlas.findRegion(MenuAtlas.CORNER_TOP_LEFT),
|
||||
atlas.findRegion(MenuAtlas.CORNER_BOTTOM_LEFT),
|
||||
atlas.findRegion(MenuAtlas.CORNER_BOTTOM_RIGHT),
|
||||
atlas.findRegion(MenuAtlas.CORNER_TOP_RIGHT),
|
||||
};
|
||||
|
||||
Gdx.input.setInputProcessor(stage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void render(float delta) {
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT | (Gdx.graphics.getBufferFormat().coverageSampling?GL20.GL_COVERAGE_BUFFER_BIT_NV:0));
|
||||
|
||||
extendViewport.apply(true);
|
||||
batch.setProjectionMatrix(extendViewport.getCamera().combined);
|
||||
batch.begin();
|
||||
renderBackground(delta);
|
||||
batch.end();
|
||||
|
||||
fitViewport.apply();
|
||||
batch.setProjectionMatrix(fitViewport.getCamera().combined);
|
||||
batch.begin();
|
||||
renderForeground(delta);
|
||||
batch.end();
|
||||
super.show();
|
||||
|
||||
stage.act(delta);
|
||||
stage.draw();
|
||||
corners = new Image[4];
|
||||
corners[0] = new Image(skin.get(UiskinAtlas.CORNER_TOP_LEFT, TextureRegion.class));
|
||||
corners[1] = new Image(skin.get(UiskinAtlas.CORNER_BOTTOM_LEFT, TextureRegion.class));
|
||||
corners[2] = new Image(skin.get(UiskinAtlas.CORNER_BOTTOM_RIGHT, TextureRegion.class));
|
||||
corners[3] = new Image(skin.get(UiskinAtlas.CORNER_TOP_RIGHT, TextureRegion.class));
|
||||
for (var corner : corners) {
|
||||
stage.addActor(corner);
|
||||
}
|
||||
|
||||
protected void renderBackground(float delta) {
|
||||
batch.setColor(1, 1, 1, 1);
|
||||
float scale = Math.max(
|
||||
extendViewport.getWorldWidth() / WizardGame.WIDTH,
|
||||
extendViewport.getWorldHeight() / WizardGame.HEIGHT
|
||||
);
|
||||
batch.draw(background, 0, 0, scale * WizardGame.WIDTH, scale * WizardGame.HEIGHT);
|
||||
batch.draw(corners[0], 0, extendViewport.getWorldHeight() - corners[0].getRegionHeight());
|
||||
batch.draw(corners[1], 0, 0);
|
||||
batch.draw(corners[2], extendViewport.getWorldWidth() - corners[2].getRegionWidth(), 0);
|
||||
batch.draw(corners[3], extendViewport.getWorldWidth() - corners[3].getRegionWidth(), extendViewport.getWorldHeight() - corners[3].getRegionHeight());
|
||||
var title = new Image(skin.get(UiskinAtlas.TITLE, TextureRegion.class));
|
||||
title.setSize(810, 192);
|
||||
title.setPosition(555, WizardGame.HEIGHT - 192 - 96);
|
||||
stage.addActor(title);
|
||||
}
|
||||
|
||||
protected void renderForeground(float delta) {
|
||||
batch.setColor(1, 1, 1, 1);
|
||||
batch.draw(title, 555, WizardGame.HEIGHT - 192 - 96, 810, 192);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void resize(int width, int height) {
|
||||
extendViewport.update(width, height);
|
||||
fitViewport.update(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pause() {}
|
||||
|
||||
@Override
|
||||
public void resume() {}
|
||||
|
||||
@Override
|
||||
public void hide() {}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
assets.unloadMenu();
|
||||
stage.dispose();
|
||||
}
|
||||
|
||||
protected void sfxClick() {
|
||||
sfxClick.play(0.6f);
|
||||
public void resize(int width, int height) {
|
||||
super.resize(width, height);
|
||||
|
||||
var worldWidth = viewport.getWorldWidth();
|
||||
var worldHeight = viewport.getWorldHeight();
|
||||
var offsetX = (worldWidth - WizardGame.WIDTH) / 2;
|
||||
var offsetY = (worldHeight - WizardGame.HEIGHT) / 2;
|
||||
|
||||
corners[0].setPosition(- offsetX, worldHeight - corners[0].getHeight() - offsetY);
|
||||
corners[1].setPosition(- offsetX, - offsetY);
|
||||
corners[2].setPosition(worldWidth - corners[2].getWidth() - offsetX, - offsetY);
|
||||
corners[3].setPosition(worldWidth - corners[3].getWidth() - offsetX, worldHeight - corners[3].getHeight() - offsetY);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,117 @@
|
||||
package eu.jonahbauer.wizard.client.libgdx.screens;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Screen;
|
||||
import com.badlogic.gdx.audio.Sound;
|
||||
import com.badlogic.gdx.graphics.GL20;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||
import com.badlogic.gdx.utils.I18NBundle;
|
||||
import com.badlogic.gdx.utils.Scaling;
|
||||
import com.badlogic.gdx.utils.viewport.ExtendViewport;
|
||||
import com.badlogic.gdx.utils.viewport.Viewport;
|
||||
import eu.jonahbauer.wizard.client.libgdx.UiskinAtlas;
|
||||
import eu.jonahbauer.wizard.client.libgdx.WizardGame;
|
||||
import eu.jonahbauer.wizard.client.libgdx.listeners.AutoFocusListener;
|
||||
import eu.jonahbauer.wizard.client.libgdx.listeners.ButtonKeyListener;
|
||||
import eu.jonahbauer.wizard.client.libgdx.util.WizardAssetManager;
|
||||
import org.jetbrains.annotations.MustBeInvokedByOverriders;
|
||||
|
||||
public abstract class WizardScreen implements Screen {
|
||||
protected final WizardGame game;
|
||||
protected final WizardAssetManager assets;
|
||||
|
||||
protected Skin skin;
|
||||
protected I18NBundle messages;
|
||||
|
||||
protected Stage stage;
|
||||
protected Viewport viewport;
|
||||
|
||||
private Image background;
|
||||
private Sound sfxClick;
|
||||
|
||||
protected float offsetX;
|
||||
protected float offsetY;
|
||||
protected float worldWidth;
|
||||
protected float worldHeight;
|
||||
|
||||
protected WizardScreen(WizardGame game) {
|
||||
this.game = game;
|
||||
this.assets = game.assets;
|
||||
}
|
||||
|
||||
@MustBeInvokedByOverriders
|
||||
protected void load() {
|
||||
messages = assets.get(WizardAssetManager.MESSAGES);
|
||||
skin = assets.get(WizardAssetManager.SKIN);
|
||||
skin.getAll(BitmapFont.class).forEach(entry -> {
|
||||
entry.value.getRegion().getTexture().setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
|
||||
});
|
||||
|
||||
viewport = new ExtendViewport(WizardGame.WIDTH, WizardGame.HEIGHT);
|
||||
|
||||
stage = new Stage(viewport);
|
||||
stage.addListener(new ButtonKeyListener());
|
||||
stage.addListener(new AutoFocusListener());
|
||||
stage.setDebugAll(WizardGame.DEBUG);
|
||||
|
||||
Gdx.input.setInputProcessor(stage);
|
||||
|
||||
sfxClick = assets.get(WizardAssetManager.SFX_CLICK);
|
||||
}
|
||||
|
||||
@Override
|
||||
@MustBeInvokedByOverriders
|
||||
public void show() {
|
||||
load();
|
||||
|
||||
background = new Image(skin.get(UiskinAtlas.BACKGROUND, TextureRegion.class));
|
||||
background.setScaling(Scaling.fill);
|
||||
background.setPosition(0,0);
|
||||
stage.addActor(background);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void render(float delta) {
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT | (Gdx.graphics.getBufferFormat().coverageSampling?GL20.GL_COVERAGE_BUFFER_BIT_NV:0));
|
||||
|
||||
stage.act(delta);
|
||||
stage.draw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resize(int width, int height) {
|
||||
viewport.update(width, height, true);
|
||||
|
||||
worldWidth = viewport.getWorldWidth();
|
||||
worldHeight = viewport.getWorldHeight();
|
||||
offsetX = (worldWidth - WizardGame.WIDTH) / 2;
|
||||
offsetY = (worldHeight - WizardGame.HEIGHT) / 2;
|
||||
|
||||
stage.getRoot().setPosition(offsetX, offsetY);
|
||||
background.setBounds(-offsetX, -offsetY, worldWidth, worldHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pause() {}
|
||||
|
||||
@Override
|
||||
public void resume() {}
|
||||
|
||||
@Override
|
||||
public void hide() {}
|
||||
|
||||
@Override
|
||||
@MustBeInvokedByOverriders
|
||||
public void dispose() {
|
||||
stage.dispose();
|
||||
}
|
||||
|
||||
protected void sfxClick() {
|
||||
sfxClick.play(0.6f);
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package eu.jonahbauer.wizard.client.libgdx.util;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class SavedData {
|
||||
public @NotNull String uri = "wss://webdev.jonahbauer.eu/wizard/";
|
||||
public @Nullable String playerName;
|
||||
public @Nullable SessionCredentials credentials;
|
||||
|
||||
public record SessionCredentials(@NotNull UUID session, @NotNull UUID player, @NotNull String secret) {}
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
{
|
||||
"maxWidth": 2048,
|
||||
"maxHeight": 2048,
|
||||
"useIndexes": false
|
||||
}
|
Before Width: | Height: | Size: 2.2 MiB After Width: | Height: | Size: 2.2 MiB |
After Width: | Height: | Size: 178 B |
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 62 KiB |
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 59 KiB |
Before Width: | Height: | Size: 56 KiB After Width: | Height: | Size: 56 KiB |
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 58 KiB |
After Width: | Height: | Size: 124 B |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
@ -1,5 +1,8 @@
|
||||
{
|
||||
"duplicatePadding": false,
|
||||
"paddingX": 1,
|
||||
"paddingY": 1
|
||||
"paddingY": 1,
|
||||
"maxWidth": 2048,
|
||||
"maxHeight": 2048,
|
||||
"useIndexes": false
|
||||
}
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 94 KiB After Width: | Height: | Size: 94 KiB |
Before Width: | Height: | Size: 107 KiB After Width: | Height: | Size: 107 KiB |
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 52 KiB |
Before Width: | Height: | Size: 82 KiB After Width: | Height: | Size: 82 KiB |
Before Width: | Height: | Size: 300 KiB After Width: | Height: | Size: 300 KiB |