diff options
| author | ilotterytea <iltsu@alright.party> | 2022-09-26 23:25:51 +0600 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2022-09-26 23:25:51 +0600 |
| commit | 3a78c1c14f061ec0ab14849cfe10051d3bb568be (patch) | |
| tree | 7394e8ea488b5e5ba73b8c228e5d0e858f119431 | |
| parent | 23ac5752c30cd90c5d9a1eecebb2f523004024ed (diff) | |
splash and asset loading screens are combined!
| -rw-r--r-- | core/src/com/ilotterytea/maxoning/screens/AssetLoadingScreen.java | 82 | ||||
| -rw-r--r-- | core/src/com/ilotterytea/maxoning/screens/SplashScreen.java | 178 |
2 files changed, 36 insertions, 224 deletions
diff --git a/core/src/com/ilotterytea/maxoning/screens/AssetLoadingScreen.java b/core/src/com/ilotterytea/maxoning/screens/AssetLoadingScreen.java deleted file mode 100644 index e61dc90..0000000 --- a/core/src/com/ilotterytea/maxoning/screens/AssetLoadingScreen.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.ilotterytea.maxoning.screens; - -import com.badlogic.gdx.*; -import com.badlogic.gdx.graphics.GL20; -import com.badlogic.gdx.graphics.Texture; -import com.badlogic.gdx.graphics.g2d.TextureRegion; -import com.badlogic.gdx.math.MathUtils; -import com.badlogic.gdx.scenes.scene2d.Stage; -import com.badlogic.gdx.scenes.scene2d.ui.Label; -import com.badlogic.gdx.scenes.scene2d.ui.Skin; -import com.badlogic.gdx.utils.viewport.ScreenViewport; -import com.ilotterytea.maxoning.MaxonGame; -import com.ilotterytea.maxoning.ui.AnimatedImage; -import com.ilotterytea.maxoning.anim.SpriteUtils; -import com.ilotterytea.maxoning.utils.AssetLoading; - -public class AssetLoadingScreen implements Screen { - final MaxonGame game; - - final Stage stage; - final Skin skin; - final AnimatedImage animatedMaxon; - final Label loadingLabel; - - final Texture M4x0nnes; - - public AssetLoadingScreen(MaxonGame game) { - this.game = game; - - this.M4x0nnes = new Texture("sprites/sheet/loadingCircle.png"); - - this.skin = new Skin(Gdx.files.internal("main.skin")); - this.stage = new Stage(new ScreenViewport()); - - this.loadingLabel = new Label("Loading...", skin); - - TextureRegion[] txrr = SpriteUtils.splitToTextureRegions(M4x0nnes, 112, 112, 10, 5); - this.animatedMaxon = new AnimatedImage(txrr); - - animatedMaxon.setPosition(8, 8); - animatedMaxon.setScale(0.25f); - - loadingLabel.setPosition(animatedMaxon.getWidth() * 0.25f + loadingLabel.getX() + 16, 8); - - stage.addActor(animatedMaxon); - //stage.addActor(loadingLabel); - - AssetLoading.queue(game.assetManager); - } - - @Override public void show() { render(Gdx.graphics.getDeltaTime()); } - - private void update() { - if (game.assetManager.update()) { - AssetLoading.registerItems(game.assetManager, game.locale); - game.setScreen(new SplashScreen(game)); - dispose(); - } - } - - @Override - public void render(float delta) { - Gdx.gl.glClearColor(0, 0, 0, 1); - Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); - - loadingLabel.setText(String.format("%s%% (Loaded %s assets)", MathUtils.floor(game.assetManager.getProgress() * 100), game.assetManager.getLoadedAssets())); - - stage.draw(); - stage.act(delta); - - update(); - } - - @Override - public void resize(int width, int height) { - stage.getViewport().update(width, height, true); - } - @Override public void pause() {} - @Override public void resume() {} - @Override public void hide() { dispose(); } - @Override public void dispose() {} -} diff --git a/core/src/com/ilotterytea/maxoning/screens/SplashScreen.java b/core/src/com/ilotterytea/maxoning/screens/SplashScreen.java index 9eac50d..8a2151e 100644 --- a/core/src/com/ilotterytea/maxoning/screens/SplashScreen.java +++ b/core/src/com/ilotterytea/maxoning/screens/SplashScreen.java @@ -1,133 +1,73 @@ package com.ilotterytea.maxoning.screens; import com.badlogic.gdx.*; -import com.badlogic.gdx.audio.Music; import com.badlogic.gdx.graphics.GL20; -import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.TextureAtlas; import com.badlogic.gdx.scenes.scene2d.Stage; -import com.badlogic.gdx.scenes.scene2d.actions.Actions; import com.badlogic.gdx.scenes.scene2d.ui.Image; -import com.badlogic.gdx.scenes.scene2d.ui.Label; import com.badlogic.gdx.scenes.scene2d.ui.Skin; +import com.badlogic.gdx.scenes.scene2d.ui.Table; +import com.badlogic.gdx.utils.Align; import com.badlogic.gdx.utils.viewport.FillViewport; import com.ilotterytea.maxoning.MaxonGame; -import com.ilotterytea.maxoning.inputprocessors.CrossProcessor; -import com.ilotterytea.maxoning.ui.DebugLabel; +import com.ilotterytea.maxoning.utils.AssetLoading; -public class SplashScreen implements InputProcessor, Screen { +public class SplashScreen implements Screen { final MaxonGame game; final Stage stage; final Skin skin; - final Image whiteSquare, dev, org; - final Label infoLabel, disclaimer, legalLabel; - - final Music introMusic; + TextureAtlas brandAtlas; + Image dev, pub; public SplashScreen(MaxonGame game) { this.game = game; - this.introMusic = game.assetManager.get("mus/menu/mus_menu_intro.ogg", Music.class); - this.stage = new Stage(new FillViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight())); this.skin = new Skin(Gdx.files.internal("main.skin")); - this.infoLabel = new DebugLabel(skin); - this.disclaimer = new Label(game.locale.TranslatableText("splash.disclaimer"), skin, "disclaimer"); - this.legalLabel = new Label("", skin, "disclaimer"); - - this.dev = new Image(game.assetManager.get("sprites/ilotterytea.png", Texture.class)); - this.org = new Image(game.assetManager.get("sprites/supadank.png", Texture.class)); - this.whiteSquare = new Image(game.assetManager.get("sprites/white.png", Texture.class)); - - disclaimer.setBounds(0, 0, 800, 600); - - infoLabel.setPosition( - 8, - (Gdx.graphics.getHeight() - infoLabel.getHeight()) - 8 - ); - - dev.setScale(5f); - - dev.setPosition( - (Gdx.graphics.getWidth() / 2.0f) - (dev.getWidth() * 5f / 2.0f), - (Gdx.graphics.getHeight() / 2.0f) - (dev.getHeight() * 5f / 2.0f) - ); - - org.setPosition( - (Gdx.graphics.getWidth() / 2.0f) - (org.getWidth() / 2.0f), - (Gdx.graphics.getHeight() / 2.0f) - (org.getHeight() / 2.0f) - ); - - disclaimer.setPosition( - (Gdx.graphics.getWidth() / 2.0f) - (800 / 2.0f), - (Gdx.graphics.getHeight() / 2.0f) - (600 / 2.0f) - ); - - whiteSquare.setPosition(0, 0); - whiteSquare.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); - - dev.addAction(Actions.sequence( - Actions.alpha(0), - Actions.fadeIn(1f), - Actions.delay(5f), - Actions.fadeOut(0.25f) - )); - - org.addAction(Actions.sequence( - Actions.alpha(0f), - Actions.delay(7.3f), - Actions.fadeIn(2.5f), - Actions.delay(5f), - Actions.fadeOut(5f) - )); - - disclaimer.addAction( - Actions.sequence( - Actions.alpha(0f), - Actions.delay(19.8f), - Actions.fadeIn(1f), - Actions.delay(3f), - Actions.fadeOut(1f) - ) - ); - - whiteSquare.addAction(Actions.sequence( - Actions.alpha(0), - Actions.fadeIn(0.5f), - Actions.delay(25f), - Actions.fadeOut(0.5f) - )); - disclaimer.setWrap(true); - - stage.addActor(whiteSquare); - stage.addActor(infoLabel); - stage.addActor(dev); - stage.addActor(org); - stage.addActor(disclaimer); - - Gdx.input.setInputProcessor(new InputMultiplexer(this, new CrossProcessor(), stage)); + Table logoTable = new Table(); + + logoTable.setSize(stage.getWidth(), stage.getHeight()); + logoTable.setPosition(0, 0); + logoTable.align(Align.center); + + brandAtlas = new TextureAtlas(Gdx.files.internal("sprites/gui/ilotterytea.atlas")); + + pub = new Image(brandAtlas.findRegion("org")); + logoTable.add(pub).size(pub.getWidth() * 5f, pub.getHeight() * 5f).pad(16f).row(); + + dev = new Image(brandAtlas.findRegion("devOld")); + logoTable.add(dev).size(dev.getWidth() * 5f, dev.getHeight() * 5f); + + stage.addActor(logoTable); + + AssetLoading.queue(game.assetManager); } @Override public void show() { - introMusic.setVolume((game.prefs.getBoolean("music", true)) ? 1f : 0f); - introMusic.play(); render(Gdx.graphics.getDeltaTime()); } + private void update() { + if (game.assetManager.update()) { + AssetLoading.registerItems(game.assetManager, game.locale); + game.setScreen(new MenuScreen(game)); + dispose(); + } + } + @Override public void render(float delta) { - Gdx.gl.glClearColor(0, 0, 0, 1); + Gdx.gl.glClearColor(1, 1, 1, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); stage.draw(); stage.act(delta); - if (!introMusic.isPlaying()) { - game.setScreen(new MenuScreen(game)); - } + update(); } @Override @@ -138,53 +78,7 @@ public class SplashScreen implements InputProcessor, Screen { @Override public void pause() {} @Override public void resume() {} @Override public void hide() { dispose(); } - @Override public void dispose() {} - - @Override - public boolean keyDown(int keycode) { - if (Gdx.input.isKeyPressed(Input.Keys.ESCAPE)) { - Gdx.app.exit(); - } - if (Gdx.input.isKeyPressed(Input.Keys.ANY_KEY)) { - introMusic.stop(); - game.setScreen(new MenuScreen(game)); - dispose(); - } - return false; - } - - @Override - public boolean keyUp(int keycode) { - return false; - } - - @Override - public boolean keyTyped(char character) { - return false; - } - - @Override - public boolean touchDown(int screenX, int screenY, int pointer, int button) { - return false; - } - - @Override - public boolean touchUp(int screenX, int screenY, int pointer, int button) { - return false; - } - - @Override - public boolean touchDragged(int screenX, int screenY, int pointer) { - return false; - } - - @Override - public boolean mouseMoved(int screenX, int screenY) { - return false; - } - - @Override - public boolean scrolled(float amountX, float amountY) { - return false; + @Override public void dispose() { + brandAtlas.dispose(); } } |
