From ad64cf2608e210b2e322892528b38ca07c614db3 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Mon, 26 Sep 2022 22:37:00 +0600 Subject: creating a class for one fuckin function lol --- core/src/com/ilotterytea/maxoning/utils/math/Math.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 core/src/com/ilotterytea/maxoning/utils/math/Math.java (limited to 'core/src/com') diff --git a/core/src/com/ilotterytea/maxoning/utils/math/Math.java b/core/src/com/ilotterytea/maxoning/utils/math/Math.java new file mode 100644 index 0000000..0bb8aa8 --- /dev/null +++ b/core/src/com/ilotterytea/maxoning/utils/math/Math.java @@ -0,0 +1,13 @@ +package com.ilotterytea.maxoning.utils.math; + +public class Math { + /** + * Get random number from min value to max value + * @param min Minimal value + * @param max Maximum value + * @return Random number between minimal and maximum values + */ + public static int getRandomNumber(int min, int max) { + return (int) ((java.lang.Math.random() * (max - min)) + min); + } +} -- cgit v1.2.3 From 3a78c1c14f061ec0ab14849cfe10051d3bb568be Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Mon, 26 Sep 2022 23:25:51 +0600 Subject: splash and asset loading screens are combined! --- .../maxoning/screens/AssetLoadingScreen.java | 82 ---------- .../ilotterytea/maxoning/screens/SplashScreen.java | 178 +++++---------------- 2 files changed, 36 insertions(+), 224 deletions(-) delete mode 100644 core/src/com/ilotterytea/maxoning/screens/AssetLoadingScreen.java (limited to 'core/src/com') 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(); } } -- cgit v1.2.3 From 42b6b4f47cb5cba213851757aeb973610a2e5b62 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Tue, 27 Sep 2022 00:01:36 +0600 Subject: loading texture atlases --- .../ilotterytea/maxoning/utils/AssetLoading.java | 25 +++++++--------------- 1 file changed, 8 insertions(+), 17 deletions(-) (limited to 'core/src/com') diff --git a/core/src/com/ilotterytea/maxoning/utils/AssetLoading.java b/core/src/com/ilotterytea/maxoning/utils/AssetLoading.java index beb6e07..a85f68a 100644 --- a/core/src/com/ilotterytea/maxoning/utils/AssetLoading.java +++ b/core/src/com/ilotterytea/maxoning/utils/AssetLoading.java @@ -3,6 +3,7 @@ package com.ilotterytea.maxoning.utils; import com.badlogic.gdx.assets.AssetManager; import com.badlogic.gdx.audio.Music; import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.TextureAtlas; import com.ilotterytea.maxoning.anim.SpriteUtils; import com.ilotterytea.maxoning.player.MaxonItemEnum; import com.ilotterytea.maxoning.player.MaxonItemRegister; @@ -10,10 +11,14 @@ import com.ilotterytea.maxoning.ui.AnimatedImage; public class AssetLoading { public static void queue(AssetManager am) { + // Texture atlases: + am.load("sprites/env/environment.atlas", TextureAtlas.class); + am.load("sprites/gui/brand.atlas", TextureAtlas.class); + am.load("sprites/gui/icons.atlas", TextureAtlas.class); + am.load("sprites/gui/ilotterytea.atlas", TextureAtlas.class); + am.load("sprites/gui/widgets.atlas", TextureAtlas.class); - // Textures: - am.load("sprites/supadank.png", Texture.class); - + // Cat item textures: am.load("sprites/sheet/loadingCircle.png", Texture.class); am.load("sprites/sheet/bror.png", Texture.class); am.load("sprites/sheet/manlooshka.png", Texture.class); @@ -21,20 +26,6 @@ public class AssetLoading { am.load("sprites/sheet/sandwich_cat.png", Texture.class); am.load("sprites/sheet/thirsty_cat.png", Texture.class); - am.load("sprites/white.png", Texture.class); - am.load("sprites/black.png", Texture.class); - am.load("sprites/brand.png", Texture.class); - am.load("sprites/ilotterytea.png", Texture.class); - - am.load("sprites/menu/tile_1.png", Texture.class); - am.load("sprites/menu/tile_2.png", Texture.class); - - // // Ninepatches: - am.load("sprites/ui/sqrbutton.png", Texture.class); - am.load("sprites/ui/sqrbutton_down.png", Texture.class); - am.load("sprites/ui/sqrbutton_over.png", Texture.class); - am.load("sprites/ui/sqrbutton_disabled.png", Texture.class); - // Music: am.load("mus/menu/mus_menu_intro.ogg", Music.class); am.load("mus/menu/mus_menu_loop.ogg", Music.class); -- cgit v1.2.3 From eab69c79df6abd56744031a889d0fdd4bd60d44f Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Tue, 27 Sep 2022 00:09:41 +0600 Subject: one widget skin instead of many ninepatches --- .../ilotterytea/maxoning/screens/GameScreen.java | 31 +++++++--------------- .../ilotterytea/maxoning/screens/MenuScreen.java | 13 ++++----- .../com/ilotterytea/maxoning/ui/OptionsTable.java | 22 ++++++--------- .../com/ilotterytea/maxoning/ui/PurchaseItem.java | 5 ++-- 4 files changed, 27 insertions(+), 44 deletions(-) (limited to 'core/src/com') diff --git a/core/src/com/ilotterytea/maxoning/screens/GameScreen.java b/core/src/com/ilotterytea/maxoning/screens/GameScreen.java index 263f282..9c6f08a 100644 --- a/core/src/com/ilotterytea/maxoning/screens/GameScreen.java +++ b/core/src/com/ilotterytea/maxoning/screens/GameScreen.java @@ -36,7 +36,9 @@ public class GameScreen implements Screen, InputProcessor { MaxonPlayer player; Stage stage; - Skin skin; + Skin skin, widgetSkin; + + TextureAtlas widgetAtlas, environmentAtlas; Label pointsLabel; Image blackBg, inventoryBg, shopBg, pointsBg; @@ -46,10 +48,6 @@ public class GameScreen implements Screen, InputProcessor { Table petTable, inventoryTable, mainTable; ScrollPane petScroll; - NinePatch btnUp, btnDown, btnOver, btnDisabled; - - Texture bgTile, bgTileAlt; - ArrayList items; Map invItems; @@ -66,13 +64,10 @@ public class GameScreen implements Screen, InputProcessor { // Initializing the stage and skin: stage = new Stage(new FillViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight())); skin = new Skin(Gdx.files.internal("main.skin")); + widgetSkin = new Skin(Gdx.files.internal("sprites/gui/widgets.skin")); - // Ninepatch textures for buttons: - btnUp = new NinePatch(game.assetManager.get("sprites/ui/sqrbutton.png", Texture.class), 8, 8, 8, 8); - btnDown = new NinePatch(game.assetManager.get("sprites/ui/sqrbutton_down.png", Texture.class), 8, 8, 8, 8); - btnOver = new NinePatch(game.assetManager.get("sprites/ui/sqrbutton_over.png", Texture.class), 8, 8, 8, 8); - btnDisabled = new NinePatch(game.assetManager.get("sprites/ui/sqrbutton_disabled.png", Texture.class), 8, 8, 8, 8); - + widgetAtlas = game.assetManager.get("sprites/gui/widgets.atlas", TextureAtlas.class); + environmentAtlas = game.assetManager.get("sprites/env/environment.atlas", TextureAtlas.class); items = new ArrayList<>(); @@ -87,7 +82,7 @@ public class GameScreen implements Screen, InputProcessor { stage.addActor(blackBg); // Setting the background for inventory: - inventoryBg = new Image(btnDisabled); + inventoryBg = new Image(widgetSkin, "button_disabled"); inventoryBg.setSize((Gdx.graphics.getWidth() / 2.0f) - 512f, (Gdx.graphics.getHeight() / 2.0f) - 8f); inventoryBg.setPosition(8, 4); stage.addActor(inventoryBg); @@ -104,12 +99,6 @@ public class GameScreen implements Screen, InputProcessor { inventoryTable.setSize(inventoryBg.getWidth(), inventoryBg.getHeight() - inventoryLabel.getHeight()); inventoryTable.setPosition(inventoryBg.getX(), inventoryBg.getY()); - TextTooltip.TextTooltipStyle textTooltipStyle = new TextTooltip.TextTooltipStyle(); - textTooltipStyle.label = new Label.LabelStyle(); - textTooltipStyle.label.font = skin.getFont("default"); - textTooltipStyle.label.fontColor = skin.getColor("white"); - textTooltipStyle.background = new NinePatchDrawable(btnUp); - invItems = new HashMap<>(); for (Integer id : player.purchasedItems) { @@ -135,7 +124,7 @@ public class GameScreen implements Screen, InputProcessor { stage.addActor(inventoryTable); // Setting the background for pet shop: - shopBg = new Image(btnDisabled); + shopBg = new Image(widgetSkin, "button_disabled"); shopBg.setSize((Gdx.graphics.getWidth() / 2.0f) - 512f, (Gdx.graphics.getHeight() / 2.0f) - 8f); shopBg.setPosition(8, inventoryBg.getY() + inventoryBg.getHeight() + 8f); stage.addActor(shopBg); @@ -153,7 +142,7 @@ public class GameScreen implements Screen, InputProcessor { // Adding the pet items in pet table: for (final MaxonItem item : MaxonItemRegister.getItems()) { PurchaseItem purchaseItem = new PurchaseItem( - skin, btnUp, item.icon, item.name, item.desc, item.price + skin, widgetSkin, item.icon, item.name, item.desc, item.price ); purchaseItem.addListener(new ClickListener() { @@ -202,7 +191,7 @@ public class GameScreen implements Screen, InputProcessor { stage.addActor(petScroll); // Background for points label: - pointsBg = new Image(btnDisabled); + pointsBg = new Image(widgetSkin, "button_disabled"); pointsBg.setSize((Gdx.graphics.getWidth() - (shopBg.getX() + shopBg.getWidth()) - 8f), 64f); pointsBg.setPosition(shopBg.getX() + shopBg.getWidth() + 4f, Gdx.graphics.getHeight() - pointsBg.getHeight() - 4f); diff --git a/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java b/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java index 7acdf66..f1d63df 100644 --- a/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java +++ b/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java @@ -26,12 +26,12 @@ public class MenuScreen implements Screen, InputProcessor { final MaxonGame game; final Stage stage; - final Skin skin; + final Skin skin, widgetSkin; Image brandLogo, blackBg; Label startLabel, infoLabel; - NinepatchButton singlePlayerButton, optionsButton, quitButton; + TextButton singlePlayerButton, optionsButton, quitButton; final Music menuMusic; Table menuTable, optionsTable; @@ -69,6 +69,7 @@ public class MenuScreen implements Screen, InputProcessor { this.stage = new Stage(new FillViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight())); this.skin = new Skin(Gdx.files.internal("main.skin")); + this.widgetSkin = new Skin(Gdx.files.internal("sprites/gui/widgets.skin")); this.menuMusic = game.assetManager.get("mus/menu/mus_menu_loop.ogg", Music.class); @@ -81,9 +82,9 @@ public class MenuScreen implements Screen, InputProcessor { // Menu Buttons: menuTable = new Table(); - singlePlayerButton = new NinepatchButton(buttonUp, buttonDown, buttonOver, game.locale.TranslatableText("menu.playGame"), skin, "default"); - optionsButton = new NinepatchButton(buttonUp, buttonDown, buttonOver, game.locale.TranslatableText("menu.options"), skin, "default"); - quitButton = new NinepatchButton(buttonUp, buttonDown, buttonOver, game.locale.TranslatableText("menu.quit"), skin, "default"); + singlePlayerButton = new TextButton(game.locale.TranslatableText("menu.playGame"), widgetSkin, "default"); + optionsButton = new TextButton(game.locale.TranslatableText("menu.options"), widgetSkin, "default"); + quitButton = new TextButton(game.locale.TranslatableText("menu.quit"), widgetSkin, "default"); singlePlayerButton.addListener(new ClickListener() { @Override @@ -137,7 +138,7 @@ public class MenuScreen implements Screen, InputProcessor { blackBg.addAction(Actions.alpha(0.25f)); // Options table: - optionsTable = new OptionsTable(game, skin, buttonUp, buttonDown, buttonOver, menuMusic, menuTable, blackBg, brandLogo); + optionsTable = new OptionsTable(game, skin, widgetSkin, menuMusic, menuTable, blackBg, brandLogo); stage.addActor(blackBg); stage.addActor(infoLabel); diff --git a/core/src/com/ilotterytea/maxoning/ui/OptionsTable.java b/core/src/com/ilotterytea/maxoning/ui/OptionsTable.java index 2dbe61f..0794e31 100644 --- a/core/src/com/ilotterytea/maxoning/ui/OptionsTable.java +++ b/core/src/com/ilotterytea/maxoning/ui/OptionsTable.java @@ -3,14 +3,10 @@ package com.ilotterytea.maxoning.ui; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.audio.Music; import com.badlogic.gdx.files.FileHandle; -import com.badlogic.gdx.graphics.g2d.NinePatch; import com.badlogic.gdx.math.Interpolation; import com.badlogic.gdx.scenes.scene2d.InputEvent; 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.scenes.scene2d.ui.*; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.badlogic.gdx.utils.Align; import com.ilotterytea.maxoning.MaxonConstants; @@ -25,9 +21,7 @@ public class OptionsTable extends Table { public OptionsTable( final MaxonGame game, Skin skin, - NinePatch buttonUp, - NinePatch buttonDown, - NinePatch buttonOver, + Skin widgetSkin, final Music music, final Table menuTable, final Image bgImage, @@ -42,7 +36,7 @@ public class OptionsTable extends Table { Table lidlOptionsTable = new Table(); // Music button: - final NinepatchButton musicButton = new NinepatchButton(buttonUp, buttonDown, buttonOver, game.locale.FormattedText("options.music", (game.prefs.getBoolean("music", true)) ? "ON" : "OFF"), skin, "default"); + final TextButton musicButton = new TextButton(game.locale.FormattedText("options.music", (game.prefs.getBoolean("music", true)) ? "ON" : "OFF"), widgetSkin, "default"); musicButton.addListener(new ClickListener() { @Override @@ -64,7 +58,7 @@ public class OptionsTable extends Table { lidlOptionsTable.add(musicButton).size(512f, 81f).pad(10f).left(); - final NinepatchButton soundButton = new NinepatchButton(buttonUp, buttonDown, buttonOver, game.locale.FormattedText("options.sound", (game.prefs.getBoolean("sound", true)) ? "ON" : "OFF"), skin, "default"); + final TextButton soundButton = new TextButton(game.locale.FormattedText("options.sound", (game.prefs.getBoolean("sound", true)) ? "ON" : "OFF"), widgetSkin, "default"); soundButton.addListener(new ClickListener() { @Override @@ -78,7 +72,7 @@ public class OptionsTable extends Table { lidlOptionsTable.add(soundButton).size(512f, 81f).pad(10f).right().row(); - final NinepatchButton vsyncButton = new NinepatchButton(buttonUp, buttonDown, buttonOver, game.locale.FormattedText("options.vsync", (game.prefs.getBoolean("vsync", true)) ? "ON" : "OFF"), skin, "default"); + final TextButton vsyncButton = new TextButton(game.locale.FormattedText("options.vsync", (game.prefs.getBoolean("vsync", true)) ? "ON" : "OFF"), widgetSkin, "default"); vsyncButton.addListener(new ClickListener() { @Override @@ -98,7 +92,7 @@ public class OptionsTable extends Table { lidlOptionsTable.add(vsyncButton).size(512f, 81f).pad(10f).left(); - final NinepatchButton fullscreenButton = new NinepatchButton(buttonUp, buttonDown, buttonOver, game.locale.FormattedText("options.fullscreen", (game.prefs.getBoolean("fullscreen", false)) ? "ON" : "OFF"), skin, "default"); + final TextButton fullscreenButton = new TextButton(game.locale.FormattedText("options.fullscreen", (game.prefs.getBoolean("fullscreen", false)) ? "ON" : "OFF"), widgetSkin, "default"); fullscreenButton.addListener(new ClickListener() { @Override @@ -123,7 +117,7 @@ public class OptionsTable extends Table { String[] fh4Locale = game.locale.getFileHandle().nameWithoutExtension().split("_"); Locale locale = new Locale(fh4Locale[0], fh4Locale[1]); - final NinepatchButton switchLangButton = new NinepatchButton(buttonUp, buttonDown, buttonOver, game.locale.FormattedText("options.language", locale.getDisplayLanguage(), locale.getDisplayCountry()), skin, "default"); + final TextButton switchLangButton = new TextButton(game.locale.FormattedText("options.language", locale.getDisplayLanguage(), locale.getDisplayCountry()), widgetSkin, "default"); switchLangButton.addListener(new ClickListener() { @Override @@ -154,7 +148,7 @@ public class OptionsTable extends Table { super.add(switchLangButton).size(1024f, 81f).padTop(91f).center().row(); - final NinepatchButton optionsCloseButton = new NinepatchButton(buttonUp, buttonDown, buttonOver, game.locale.TranslatableText("options.close"), skin, "default"); + final TextButton optionsCloseButton = new TextButton(game.locale.TranslatableText("options.close"), widgetSkin, "default"); optionsCloseButton.addListener(new ClickListener() { @Override diff --git a/core/src/com/ilotterytea/maxoning/ui/PurchaseItem.java b/core/src/com/ilotterytea/maxoning/ui/PurchaseItem.java index 97a78e7..c530950 100644 --- a/core/src/com/ilotterytea/maxoning/ui/PurchaseItem.java +++ b/core/src/com/ilotterytea/maxoning/ui/PurchaseItem.java @@ -1,19 +1,18 @@ package com.ilotterytea.maxoning.ui; -import com.badlogic.gdx.graphics.g2d.NinePatch; import com.badlogic.gdx.scenes.scene2d.ui.*; import com.badlogic.gdx.utils.Align; public class PurchaseItem extends Stack { public PurchaseItem( Skin skin, - NinePatch ninepatch, + Skin widgetSkin, AnimatedImage icon, CharSequence name, CharSequence desc, float price ) { - super(new Image(ninepatch)); + super(new Image(widgetSkin, "button")); Table summary = new Table(); summary.setHeight(super.getHeight()); -- cgit v1.2.3 From 9e6bb56f372a55c1f1c20f63c4a5237947fb5781 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Tue, 27 Sep 2022 00:10:51 +0600 Subject: oops forgor moment --- core/src/com/ilotterytea/maxoning/MaxonGame.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'core/src/com') diff --git a/core/src/com/ilotterytea/maxoning/MaxonGame.java b/core/src/com/ilotterytea/maxoning/MaxonGame.java index 4ee3861..6f26b12 100644 --- a/core/src/com/ilotterytea/maxoning/MaxonGame.java +++ b/core/src/com/ilotterytea/maxoning/MaxonGame.java @@ -7,7 +7,7 @@ import com.badlogic.gdx.assets.AssetManager; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.ilotterytea.maxoning.player.MaxonPlayer; -import com.ilotterytea.maxoning.screens.AssetLoadingScreen; +import com.ilotterytea.maxoning.screens.SplashScreen; import com.ilotterytea.maxoning.utils.I18N; import com.ilotterytea.maxoning.utils.serialization.GameDataSystem; @@ -53,7 +53,7 @@ public class MaxonGame extends Game { assetManager = new AssetManager(); - this.setScreen(new AssetLoadingScreen(this)); + this.setScreen(new SplashScreen(this)); } @Override -- cgit v1.2.3 From e8ca277450c0c4fd482c8439a53098fcfd614f5c Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Tue, 27 Sep 2022 00:12:07 +0600 Subject: πŸš— Alpha 1.1 -> Alpha 1.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/src/com/ilotterytea/maxoning/MaxonConstants.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'core/src/com') diff --git a/core/src/com/ilotterytea/maxoning/MaxonConstants.java b/core/src/com/ilotterytea/maxoning/MaxonConstants.java index ee0a375..6db18a9 100644 --- a/core/src/com/ilotterytea/maxoning/MaxonConstants.java +++ b/core/src/com/ilotterytea/maxoning/MaxonConstants.java @@ -6,8 +6,8 @@ import com.ilotterytea.maxoning.utils.OsUtils; public class MaxonConstants { public static final String GAME_NAME = "Maxon Petting Simulator"; - public static final String GAME_VERSION = "Alpha 1.1"; - public static final String GAME_GHTAG = "alpha-1.1"; + public static final String GAME_VERSION = "Alpha 1.2"; + public static final String GAME_GHTAG = "alpha-1.2"; public static final String GAME_PUBLISHER = "iLotterytea"; public static final String GAME_MAIN_FOLDER = OsUtils.getUserDataDirectory(".Maxoning"); -- cgit v1.2.3 From 35126f0c675f000fefeb10758cadf5d8a5af9c48 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Tue, 27 Sep 2022 00:13:14 +0600 Subject: unused garbage --- core/src/com/ilotterytea/maxoning/screens/GameScreen.java | 4 ---- 1 file changed, 4 deletions(-) (limited to 'core/src/com') diff --git a/core/src/com/ilotterytea/maxoning/screens/GameScreen.java b/core/src/com/ilotterytea/maxoning/screens/GameScreen.java index 9c6f08a..ad4a7e7 100644 --- a/core/src/com/ilotterytea/maxoning/screens/GameScreen.java +++ b/core/src/com/ilotterytea/maxoning/screens/GameScreen.java @@ -3,7 +3,6 @@ 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.NinePatch; import com.badlogic.gdx.graphics.g2d.Sprite; import com.badlogic.gdx.math.Interpolation; import com.badlogic.gdx.scenes.scene2d.InputEvent; @@ -11,7 +10,6 @@ import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.actions.Actions; import com.badlogic.gdx.scenes.scene2d.ui.*; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; -import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable; import com.badlogic.gdx.utils.Align; import com.badlogic.gdx.utils.Timer; import com.badlogic.gdx.utils.viewport.FillViewport; @@ -51,8 +49,6 @@ public class GameScreen implements Screen, InputProcessor { ArrayList items; Map invItems; - boolean isShopping = true; - ArrayList> bgTiles; public GameScreen(MaxonGame game) throws IOException, ClassNotFoundException { -- cgit v1.2.3 From c8c86db42e24915a8adc379b62fb129493c79ae0 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Tue, 27 Sep 2022 00:15:52 +0600 Subject: make generation of new bg tiles as a function --- .../ilotterytea/maxoning/screens/GameScreen.java | 49 ++++++++-------------- .../ilotterytea/maxoning/screens/MenuScreen.java | 46 +++++++++++--------- 2 files changed, 43 insertions(+), 52 deletions(-) (limited to 'core/src/com') diff --git a/core/src/com/ilotterytea/maxoning/screens/GameScreen.java b/core/src/com/ilotterytea/maxoning/screens/GameScreen.java index ad4a7e7..6ed9240 100644 --- a/core/src/com/ilotterytea/maxoning/screens/GameScreen.java +++ b/core/src/com/ilotterytea/maxoning/screens/GameScreen.java @@ -4,6 +4,7 @@ import com.badlogic.gdx.*; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.Sprite; +import com.badlogic.gdx.graphics.g2d.TextureAtlas; import com.badlogic.gdx.math.Interpolation; import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.Stage; @@ -72,7 +73,8 @@ public class GameScreen implements Screen, InputProcessor { } // Make the background a little dimmed: - blackBg = new Image(game.assetManager.get("sprites/black.png", Texture.class)); + blackBg = new Image(); + blackBg.setColor(0f, 0f, 0f, 1f); blackBg.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); blackBg.addAction(Actions.parallel(Actions.alpha(0.25f))); stage.addActor(blackBg); @@ -205,30 +207,10 @@ public class GameScreen implements Screen, InputProcessor { stage.addActor(pointsLabel); - bgTile = game.assetManager.get("sprites/menu/tile_1.png", Texture.class); - bgTileAlt = game.assetManager.get("sprites/menu/tile_2.png", Texture.class); - // Generate the background: bgTiles = new ArrayList<>(); - for (int i = 0; i < Gdx.graphics.getHeight() / bgTile.getHeight() + 1; i++) { - bgTiles.add(i, new ArrayList()); - - for (int j = -1; j < Gdx.graphics.getWidth() / bgTile.getWidth(); j++) { - Sprite spr = new Sprite(); - - if ((j + i) % 2 == 0) { - spr.setTexture(bgTile); - } else { - spr.setTexture(bgTileAlt); - } - - spr.setSize(bgTile.getWidth(), bgTile.getHeight()); - - spr.setPosition(bgTile.getWidth() * j, bgTile.getHeight() * i); - bgTiles.get(i).add(spr); - } - } + genNewBgTiles((int) stage.getWidth(), (int) stage.getHeight()); // Table for Maxon cat: mainTable = new Table(); @@ -359,26 +341,29 @@ public class GameScreen implements Screen, InputProcessor { public void resize(int width, int height) { bgTiles.clear(); - for (int i = 0; i < Gdx.graphics.getHeight() / bgTile.getHeight() + 1; i++) { - bgTiles.add(i, new ArrayList()); + genNewBgTiles(width, height); - for (int j = -1; j < Gdx.graphics.getWidth() / bgTile.getWidth(); j++) { - Sprite spr = new Sprite(); + stage.getViewport().update(width, height, true); + } + + private void genNewBgTiles(int width, int height) { + for (int i = 0; i < height / environmentAtlas.findRegion("tile").getRegionHeight() + 1; i++) { + bgTiles.add(i, new ArrayList()); + for (int j = -1; j < width / environmentAtlas.findRegion("tile").getRegionWidth(); j++) { + Sprite spr = new Sprite(environmentAtlas.findRegion("tile")); if ((j + i) % 2 == 0) { - spr.setTexture(bgTile); + spr.setColor(0.98f, 0.71f, 0.22f, 1f); } else { - spr.setTexture(bgTileAlt); + spr.setColor(0.84f, 0.61f, 0.20f, 1f); } - spr.setSize(bgTile.getWidth(), bgTile.getHeight()); + spr.setSize(64, 64); - spr.setPosition(bgTile.getWidth() * j, bgTile.getHeight() * i); + spr.setPosition(spr.getWidth() * j, spr.getHeight() * i); bgTiles.get(i).add(spr); } } - - stage.getViewport().update(width, height, true); } @Override public void pause() {} diff --git a/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java b/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java index f1d63df..0b3888d 100644 --- a/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java +++ b/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java @@ -3,8 +3,8 @@ package com.ilotterytea.maxoning.screens; import com.badlogic.gdx.*; import com.badlogic.gdx.audio.Music; import com.badlogic.gdx.graphics.*; -import com.badlogic.gdx.graphics.g2d.NinePatch; import com.badlogic.gdx.graphics.g2d.Sprite; +import com.badlogic.gdx.graphics.g2d.TextureAtlas; import com.badlogic.gdx.math.Interpolation; import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.Stage; @@ -36,9 +36,8 @@ public class MenuScreen implements Screen, InputProcessor { Table menuTable, optionsTable; - final Texture bgTile1, bgTile2; - - NinePatch buttonUp, buttonDown, buttonOver, buttonDisabled; + // Atlases: + TextureAtlas environmentAtlas, brandAtlas; private ArrayList> bgMenuTiles; @@ -47,13 +46,8 @@ public class MenuScreen implements Screen, InputProcessor { public MenuScreen(final MaxonGame game) { this.game = game; - buttonUp = new NinePatch(game.assetManager.get("sprites/ui/sqrbutton.png", Texture.class), 8, 8, 8, 8); - buttonDown = new NinePatch(game.assetManager.get("sprites/ui/sqrbutton_down.png", Texture.class), 8, 8, 8, 8); - buttonOver = new NinePatch(game.assetManager.get("sprites/ui/sqrbutton_over.png", Texture.class), 8, 8, 8, 8); - buttonDisabled = new NinePatch(game.assetManager.get("sprites/ui/sqrbutton_disabled.png", Texture.class), 8, 8, 8, 8); - - bgTile1 = game.assetManager.get("sprites/menu/tile_1.png", Texture.class); - bgTile2 = game.assetManager.get("sprites/menu/tile_2.png", Texture.class); + // Environment atlas for leafs, snowflakes and background tiles: + environmentAtlas = game.assetManager.get("sprites/env/environment.atlas", TextureAtlas.class); bgMenuTiles = new ArrayList<>(); @@ -158,6 +152,11 @@ public class MenuScreen implements Screen, InputProcessor { menuMusic.setVolume((game.prefs.getBoolean("music", true)) ? 1f : 0f); menuMusic.play(); } + + // Generate background tiles: + bgMenuTiles = new ArrayList<>(); + + genNewBgTiles((int) stage.getWidth(), (int) stage.getHeight()); } @Override public void show() { @@ -305,24 +304,31 @@ public class MenuScreen implements Screen, InputProcessor { public void resize(int width, int height) { bgMenuTiles.clear(); - for (int i = 0; i < height / bgTile1.getHeight() + 1; i++) { + genNewBgTiles(width, height); + + stage.getViewport().update(width, height, true); + } + + private void genNewBgTiles(int width, int height) { + bgMenuTiles.clear(); + + for (int i = 0; i < height / environmentAtlas.findRegion("tile").getRegionHeight() + 1; i++) { bgMenuTiles.add(i, new ArrayList()); - for (int j = -1; j < width / bgTile1.getWidth(); j++) { - Sprite spr = new Sprite(); + for (int j = -1; j < width / environmentAtlas.findRegion("tile").getRegionWidth(); j++) { + Sprite spr = new Sprite(environmentAtlas.findRegion("tile")); if ((j + i) % 2 == 0) { - spr.setTexture(bgTile1); + spr.setColor(0.98f, 0.71f, 0.22f, 1f); } else { - spr.setTexture(bgTile2); + spr.setColor(0.84f, 0.61f, 0.20f, 1f); } - spr.setSize(bgTile1.getWidth(), bgTile1.getHeight()); - spr.setPosition(bgTile1.getWidth() * j, bgTile1.getHeight() * i); + spr.setSize(64, 64); + + spr.setPosition(spr.getWidth() * j, spr.getHeight() * i); bgMenuTiles.get(i).add(spr); } } - - stage.getViewport().update(width, height, true); } @Override public void pause() {} -- cgit v1.2.3 From f94063ba8dc3c0bf7e466f01dc2218f07fd90fc2 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Tue, 27 Sep 2022 00:16:50 +0600 Subject: brand atlas okaj --- .../ilotterytea/maxoning/screens/MenuScreen.java | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'core/src/com') diff --git a/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java b/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java index 0b3888d..5e98c0a 100644 --- a/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java +++ b/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java @@ -49,26 +49,21 @@ public class MenuScreen implements Screen, InputProcessor { // Environment atlas for leafs, snowflakes and background tiles: environmentAtlas = game.assetManager.get("sprites/env/environment.atlas", TextureAtlas.class); - bgMenuTiles = new ArrayList<>(); - - for (int i = 0; i < Gdx.graphics.getHeight() / bgTile1.getHeight() + 1; i++) { - bgMenuTiles.add(i, new ArrayList()); - for (int j = -1; j < Gdx.graphics.getWidth() / bgTile1.getWidth(); j++) { - Sprite spr = new Sprite((j + i % 2 == 0) ? bgTile1 : bgTile2); - - spr.setPosition(bgTile1.getWidth() * j, bgTile1.getHeight() * i); - bgMenuTiles.get(i).add(spr); - } - } + // Brand atlas: + brandAtlas = game.assetManager.get("sprites/gui/brand.atlas", TextureAtlas.class); + // Stage and skin: this.stage = new Stage(new FillViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight())); this.skin = new Skin(Gdx.files.internal("main.skin")); this.widgetSkin = new Skin(Gdx.files.internal("sprites/gui/widgets.skin")); + // Main Menu music: this.menuMusic = game.assetManager.get("mus/menu/mus_menu_loop.ogg", Music.class); - brandLogo = new Image(game.assetManager.get("sprites/brand.png", Texture.class)); - blackBg = new Image(game.assetManager.get("sprites/black.png", Texture.class)); + brandLogo = new Image(brandAtlas.findRegion("brand")); + blackBg = new Image(); + + blackBg.setColor(0f, 0f, 0f, 1f); this.startLabel = new Label(game.locale.TranslatableText("menu.pressStart"), skin, "press"); this.infoLabel = new DebugLabel(skin); -- cgit v1.2.3 From 79604a7f359eec931ebe1ff44994aae1134532ce Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Wed, 28 Sep 2022 21:24:21 +0600 Subject: Π½Π°ΠΈΠ±ΠΎΠ»Π΅Π΅ Π΄Π°Π½ΠΊΠΎΠ²Ρ‹ΠΉ фикс (#11) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ilotterytea/maxoning/screens/GameScreen.java | 35 ++++++++++++---------- 1 file changed, 19 insertions(+), 16 deletions(-) (limited to 'core/src/com') diff --git a/core/src/com/ilotterytea/maxoning/screens/GameScreen.java b/core/src/com/ilotterytea/maxoning/screens/GameScreen.java index 6ed9240..e548b20 100644 --- a/core/src/com/ilotterytea/maxoning/screens/GameScreen.java +++ b/core/src/com/ilotterytea/maxoning/screens/GameScreen.java @@ -108,14 +108,7 @@ public class GameScreen implements Screen, InputProcessor { } // Put the items in the inventory table: - for (Integer id : invItems.keySet()) { - MaxonItem item = MaxonItemRegister.get(id); - - if (item != null) { - InventoryAnimatedItem invItem = new InventoryAnimatedItem(item, skin, invItems.get(id)); - inventoryTable.add(invItem).size(64, 64).pad(5f); - } - } + reorderInvItems(); inventoryTable.align(Align.left|Align.top); @@ -164,14 +157,7 @@ public class GameScreen implements Screen, InputProcessor { } // Put the items in the inventory table: - for (Integer id : invItems.keySet()) { - MaxonItem item = MaxonItemRegister.get(id); - - if (item != null) { - InventoryAnimatedItem invItem = new InventoryAnimatedItem(item, skin, invItems.get(id)); - inventoryTable.add(invItem).size(64, 64).pad(5f); - } - } + reorderInvItems(); } } }); @@ -346,6 +332,23 @@ public class GameScreen implements Screen, InputProcessor { stage.getViewport().update(width, height, true); } + private void reorderInvItems() { + inventoryTable.clear(); + + for (int i = 0; i < invItems.keySet().size(); i++) { + MaxonItem item = MaxonItemRegister.get(i); + + if (item != null) { + InventoryAnimatedItem invItem = new InventoryAnimatedItem(item, skin, invItems.get(i)); + Cell cell = inventoryTable.add(invItem).size(64, 64).pad(5f); + + if (i != 0 && i % 5 == 0) { + cell.row(); + } + } + } + } + private void genNewBgTiles(int width, int height) { for (int i = 0; i < height / environmentAtlas.findRegion("tile").getRegionHeight() + 1; i++) { bgTiles.add(i, new ArrayList()); -- cgit v1.2.3 From 559b961f3ad9d66fd0b6fa3cf9585ea57bbac71e Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Wed, 28 Sep 2022 21:28:28 +0600 Subject: make the background a little darker --- core/src/com/ilotterytea/maxoning/screens/GameScreen.java | 7 +++---- core/src/com/ilotterytea/maxoning/screens/MenuScreen.java | 8 ++++++-- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'core/src/com') diff --git a/core/src/com/ilotterytea/maxoning/screens/GameScreen.java b/core/src/com/ilotterytea/maxoning/screens/GameScreen.java index e548b20..ce3bbed 100644 --- a/core/src/com/ilotterytea/maxoning/screens/GameScreen.java +++ b/core/src/com/ilotterytea/maxoning/screens/GameScreen.java @@ -72,11 +72,10 @@ public class GameScreen implements Screen, InputProcessor { items.add(MaxonItemRegister.get(id)); } - // Make the background a little dimmed: - blackBg = new Image(); - blackBg.setColor(0f, 0f, 0f, 1f); + // Make the background a little darker: + blackBg = new Image(environmentAtlas.findRegion("tile")); + blackBg.setColor(0f, 0f, 0f, 0.5f); blackBg.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); - blackBg.addAction(Actions.parallel(Actions.alpha(0.25f))); stage.addActor(blackBg); // Setting the background for inventory: diff --git a/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java b/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java index 5e98c0a..663a97c 100644 --- a/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java +++ b/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java @@ -60,10 +60,14 @@ public class MenuScreen implements Screen, InputProcessor { // Main Menu music: this.menuMusic = game.assetManager.get("mus/menu/mus_menu_loop.ogg", Music.class); + // Make the background a little darker: brandLogo = new Image(brandAtlas.findRegion("brand")); - blackBg = new Image(); + blackBg = new Image(environmentAtlas.findRegion("tile")); - blackBg.setColor(0f, 0f, 0f, 1f); + blackBg.setColor(0f, 0f, 0f, 0.25f); + blackBg.setSize(stage.getWidth(), stage.getHeight()); + + stage.addActor(blackBg); this.startLabel = new Label(game.locale.TranslatableText("menu.pressStart"), skin, "press"); this.infoLabel = new DebugLabel(skin); -- cgit v1.2.3 From 689ab7866e25a7c6a02c35e29e89498889b9d9e5 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Wed, 28 Sep 2022 21:55:49 +0600 Subject: ΠΊΠ°ΠΊ завСряСт ΠΌ-Ρ€. greddyss это Π΄ΠΎΠ»ΠΆΠ½ΠΎ ΠΏΠΎΡ„ΠΈΠΊΡΠΈΡ‚ΡŒ (#4) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/src/com/ilotterytea/maxoning/MaxonConstants.java | 4 ++++ core/src/com/ilotterytea/maxoning/screens/GameScreen.java | 9 +++++---- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'core/src/com') diff --git a/core/src/com/ilotterytea/maxoning/MaxonConstants.java b/core/src/com/ilotterytea/maxoning/MaxonConstants.java index 6db18a9..9790f80 100644 --- a/core/src/com/ilotterytea/maxoning/MaxonConstants.java +++ b/core/src/com/ilotterytea/maxoning/MaxonConstants.java @@ -4,6 +4,8 @@ import com.badlogic.gdx.Gdx; import com.badlogic.gdx.files.FileHandle; import com.ilotterytea.maxoning.utils.OsUtils; +import java.text.DecimalFormat; + public class MaxonConstants { public static final String GAME_NAME = "Maxon Petting Simulator"; public static final String GAME_VERSION = "Alpha 1.2"; @@ -16,4 +18,6 @@ public class MaxonConstants { public static final FileHandle FILE_EN_US = Gdx.files.internal("i18n/en_us.json"); public static final FileHandle FILE_RU_RU = Gdx.files.internal("i18n/ru_ru.json"); + + public static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("###,###.##"); } diff --git a/core/src/com/ilotterytea/maxoning/screens/GameScreen.java b/core/src/com/ilotterytea/maxoning/screens/GameScreen.java index ce3bbed..bb55484 100644 --- a/core/src/com/ilotterytea/maxoning/screens/GameScreen.java +++ b/core/src/com/ilotterytea/maxoning/screens/GameScreen.java @@ -14,6 +14,7 @@ import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.badlogic.gdx.utils.Align; import com.badlogic.gdx.utils.Timer; import com.badlogic.gdx.utils.viewport.FillViewport; +import com.ilotterytea.maxoning.MaxonConstants; import com.ilotterytea.maxoning.MaxonGame; import com.ilotterytea.maxoning.anim.SpriteUtils; import com.ilotterytea.maxoning.inputprocessors.CrossProcessor; @@ -246,7 +247,7 @@ public class GameScreen implements Screen, InputProcessor { player.points += multiplier; - final TypingLabel label = new TypingLabel(game.locale.FormattedText("game.newPoint", String.valueOf(1 * player.multiplier)), skin, "default"); + final TypingLabel label = new TypingLabel(game.locale.FormattedText("game.newPoint", MaxonConstants.DECIMAL_FORMAT.format(1 * player.multiplier)), skin, "default"); label.setPosition( mainTable.getX() + actor.getActorX(), @@ -314,8 +315,8 @@ public class GameScreen implements Screen, InputProcessor { // Update the points label: pointsLabel.setText(game.locale.FormattedText("game.points", - String.valueOf(player.points), - String.valueOf(player.multiplier) + MaxonConstants.DECIMAL_FORMAT.format(player.points), + MaxonConstants.DECIMAL_FORMAT.format(player.multiplier) )); stage.draw(); @@ -406,7 +407,7 @@ public class GameScreen implements Screen, InputProcessor { player.points += 1 * player.multiplier; - final TypingLabel label = new TypingLabel(game.locale.FormattedText("game.newPoint", String.valueOf(1 * player.multiplier)), skin, "default"); + final TypingLabel label = new TypingLabel(game.locale.FormattedText("game.newPoint", MaxonConstants.DECIMAL_FORMAT.format(1 * player.multiplier)), skin, "default"); label.setPosition( mainTable.getX() + actor.getActorX(), -- cgit v1.2.3 From 275ac74bdd3b7a273737065e898b01888145c47b Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Wed, 28 Sep 2022 22:05:42 +0600 Subject: particle class for leafs, snowflakes and other natural shit --- .../com/ilotterytea/maxoning/ui/LeafParticle.java | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 core/src/com/ilotterytea/maxoning/ui/LeafParticle.java (limited to 'core/src/com') diff --git a/core/src/com/ilotterytea/maxoning/ui/LeafParticle.java b/core/src/com/ilotterytea/maxoning/ui/LeafParticle.java new file mode 100644 index 0000000..24df879 --- /dev/null +++ b/core/src/com/ilotterytea/maxoning/ui/LeafParticle.java @@ -0,0 +1,30 @@ +package com.ilotterytea.maxoning.ui; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.graphics.g2d.Batch; +import com.badlogic.gdx.graphics.g2d.Sprite; +import com.badlogic.gdx.graphics.g2d.TextureRegion; + +public class LeafParticle extends Sprite { + private float angle, x, y, vertAngle, rotation, time; + + public LeafParticle(TextureRegion region, float x, float y, float angle, float vertAngle, float rotation) { + super(region); + this.angle = angle; + this.vertAngle = vertAngle; + this.rotation = rotation; + this.x = x; + this.y = y; + } + + @Override + public void draw(Batch batch) { + this.time = Gdx.graphics.getDeltaTime(); + this.x -= (float) Math.sin(time) * this.angle; + this.y -= (float) Math.sin(time) * this.vertAngle; + + super.setPosition(x, y); + super.setRotation(super.getRotation() + this.rotation); + super.draw(batch); + } +} -- cgit v1.2.3 From 948dd52b9e237e6a823ddec2d9ae3af9ee585855 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Thu, 6 Oct 2022 01:07:30 +0600 Subject: sorry epileptics --- .../ilotterytea/maxoning/screens/SplashScreen.java | 54 +++++++++++++++++++++- 1 file changed, 52 insertions(+), 2 deletions(-) (limited to 'core/src/com') diff --git a/core/src/com/ilotterytea/maxoning/screens/SplashScreen.java b/core/src/com/ilotterytea/maxoning/screens/SplashScreen.java index 8a2151e..31a1023 100644 --- a/core/src/com/ilotterytea/maxoning/screens/SplashScreen.java +++ b/core/src/com/ilotterytea/maxoning/screens/SplashScreen.java @@ -1,16 +1,22 @@ package com.ilotterytea.maxoning.screens; import com.badlogic.gdx.*; +import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.GL20; +import com.badlogic.gdx.graphics.g2d.Sprite; import com.badlogic.gdx.graphics.g2d.TextureAtlas; 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.scenes.scene2d.ui.Table; import com.badlogic.gdx.utils.Align; +import com.badlogic.gdx.utils.Timer; import com.badlogic.gdx.utils.viewport.FillViewport; import com.ilotterytea.maxoning.MaxonGame; import com.ilotterytea.maxoning.utils.AssetLoading; +import com.ilotterytea.maxoning.utils.math.Math; + +import java.util.ArrayList; public class SplashScreen implements Screen { @@ -19,7 +25,8 @@ public class SplashScreen implements Screen { final Stage stage; final Skin skin; - TextureAtlas brandAtlas; + TextureAtlas brandAtlas, envAtlas; + ArrayList contribList; Image dev, pub; public SplashScreen(MaxonGame game) { @@ -35,6 +42,8 @@ public class SplashScreen implements Screen { logoTable.align(Align.center); brandAtlas = new TextureAtlas(Gdx.files.internal("sprites/gui/ilotterytea.atlas")); + envAtlas = new TextureAtlas(Gdx.files.internal("sprites/env/environment.atlas")); + contribList = new ArrayList<>(); pub = new Image(brandAtlas.findRegion("org")); logoTable.add(pub).size(pub.getWidth() * 5f, pub.getHeight() * 5f).pad(16f).row(); @@ -48,6 +57,40 @@ public class SplashScreen implements Screen { } @Override public void show() { + int size = 64; + for (int i = 0; i < stage.getHeight() / size; i++) { + for (int j = 0; j < stage.getWidth() / size; j++) { + Sprite spr = new Sprite(envAtlas.findRegion("tile")); + spr.setSize(size, size); + spr.setPosition(size * j, size * i); + switch (Math.getRandomNumber(0, 5)) { + case 0: spr.setColor(Color.SKY); break; + case 1: spr.setColor(Color.PURPLE); break; + case 2: spr.setColor(Color.PINK); break; + case 3: spr.setColor(Color.CHARTREUSE); break; + case 4: spr.setColor(Color.ORANGE); break; + } + spr.setAlpha(0.25f); + contribList.add(spr); + } + } + + Timer.schedule(new Timer.Task() { + @Override + public void run() { + for (Sprite spr : contribList) { + switch (Math.getRandomNumber(0, 5)) { + case 0: spr.setColor(Color.SKY); break; + case 1: spr.setColor(Color.PURPLE); break; + case 2: spr.setColor(Color.PINK); break; + case 3: spr.setColor(Color.CHARTREUSE); break; + case 4: spr.setColor(Color.ORANGE); break; + } + spr.setAlpha(0.25f); + } + } + }, 1f, 1f); + render(Gdx.graphics.getDeltaTime()); } @@ -61,9 +104,15 @@ public class SplashScreen implements Screen { @Override public void render(float delta) { - Gdx.gl.glClearColor(1, 1, 1, 1); + Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); + game.batch.begin(); + for (Sprite spr : contribList) { + spr.draw(game.batch); + } + game.batch.end(); + stage.draw(); stage.act(delta); @@ -80,5 +129,6 @@ public class SplashScreen implements Screen { @Override public void hide() { dispose(); } @Override public void dispose() { brandAtlas.dispose(); + envAtlas.dispose(); } } -- cgit v1.2.3 From bb4d02f9b7d4018b2fbf508cd882a57b54565d95 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Thu, 6 Oct 2022 01:08:17 +0600 Subject: widget for savegame slots --- .../ilotterytea/maxoning/ui/SaveGameWidget.java | 69 ++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 core/src/com/ilotterytea/maxoning/ui/SaveGameWidget.java (limited to 'core/src/com') diff --git a/core/src/com/ilotterytea/maxoning/ui/SaveGameWidget.java b/core/src/com/ilotterytea/maxoning/ui/SaveGameWidget.java new file mode 100644 index 0000000..cd6fa72 --- /dev/null +++ b/core/src/com/ilotterytea/maxoning/ui/SaveGameWidget.java @@ -0,0 +1,69 @@ +package com.ilotterytea.maxoning.ui; + + +import com.badlogic.gdx.scenes.scene2d.ui.*; +import com.badlogic.gdx.utils.Align; +import com.ilotterytea.maxoning.player.MaxonPlayer; +import com.ilotterytea.maxoning.utils.formatters.NumberFormatter; + + +public class SaveGameWidget extends Button { + public SaveGameWidget( + Skin skin, + Skin widgetSkin, + MaxonPlayer sav + ) { + // Setting the stack: + super(widgetSkin, "slot"); + + // // // Save slot data: + // // Info row: + Table infoTable = new Table(); + + // Top left label: + Label topleftLabel = new Label(String.format("%s Squish Points", (sav != null) ? NumberFormatter.format((long) sav.points) : "---"), skin); + topleftLabel.setAlignment(Align.left); + infoTable.add(topleftLabel).width(256f); + + // Top right label: + Label toprightLabel = new Label( + String.format("%s purchased items", (sav != null) ? sav.purchasedItems.size() : "---"), + skin + ); + toprightLabel.setAlignment(Align.right); + infoTable.add(toprightLabel).width(256f); + + // // Description row: + Table descTable = new Table(); + + // Bottom left label: + Label bottomleftLabel = new Label( + String.format( + "x%s", + (sav != null) ? NumberFormatter.format((long) sav.multiplier) : "?" + ), + skin + ); + bottomleftLabel.setAlignment(Align.left); + descTable.add(bottomleftLabel).width(256f); + + /* NOT IN USE. Bottom right label: + Label pointsLabel = new Label( + String.format( + "%s$/x%s", + NumberFormatter.format(points), + NumberFormatter.format(multiplier) + ), + skin + ); + pointsLabel.setAlignment(Align.right); + descTable.add(pointsLabel).width(256f);*/ + + // Adding the tables to main table: + Table summaryTable = new Table(); + summaryTable.add(infoTable).pad(5f).row(); + summaryTable.add(descTable).pad(5f).row(); + + super.add(summaryTable); + } +} -- cgit v1.2.3 From 504825282ff0e781891621672028e706c2655773 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Thu, 6 Oct 2022 01:09:24 +0600 Subject: number formatter (thx to guy from stackoverflow) --- .../maxoning/utils/formatters/NumberFormatter.java | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 core/src/com/ilotterytea/maxoning/utils/formatters/NumberFormatter.java (limited to 'core/src/com') diff --git a/core/src/com/ilotterytea/maxoning/utils/formatters/NumberFormatter.java b/core/src/com/ilotterytea/maxoning/utils/formatters/NumberFormatter.java new file mode 100644 index 0000000..96c0258 --- /dev/null +++ b/core/src/com/ilotterytea/maxoning/utils/formatters/NumberFormatter.java @@ -0,0 +1,32 @@ +package com.ilotterytea.maxoning.utils.formatters; + +import java.util.Map; +import java.util.NavigableMap; +import java.util.TreeMap; + +public class NumberFormatter { + private static final NavigableMap suffixes = new TreeMap<>(); + static { + suffixes.put(1_000L, "k"); + suffixes.put(1_000_000L, "M"); + suffixes.put(1_000_000_000L, "G"); + suffixes.put(1_000_000_000_000L, "T"); + suffixes.put(1_000_000_000_000_000L, "P"); + suffixes.put(1_000_000_000_000_000_000L, "E"); + } + + public static String format(long value) { + //Long.MIN_VALUE == -Long.MIN_VALUE so we need an adjustment here + if (value == Long.MIN_VALUE) return format(Long.MIN_VALUE + 1); + if (value < 0) return "-" + format(-value); + if (value < 1000) return Long.toString(value); //deal with easy case + + Map.Entry e = suffixes.floorEntry(value); + Long divideBy = e.getKey(); + String suffix = e.getValue(); + + long truncated = value / (divideBy / 10); //the number part of the output times 10 + boolean hasDecimal = truncated < 100 && (truncated / 10d) != (truncated / 10); + return hasDecimal ? (truncated / 10d) + suffix : (truncated / 10) + suffix; + } +} -- cgit v1.2.3 From 2f7f5cb5d495b297fa7fd091860510a6c7aa7485 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Thu, 6 Oct 2022 01:10:30 +0600 Subject: new constants check it out --- core/src/com/ilotterytea/maxoning/MaxonConstants.java | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'core/src/com') diff --git a/core/src/com/ilotterytea/maxoning/MaxonConstants.java b/core/src/com/ilotterytea/maxoning/MaxonConstants.java index 9790f80..04bc932 100644 --- a/core/src/com/ilotterytea/maxoning/MaxonConstants.java +++ b/core/src/com/ilotterytea/maxoning/MaxonConstants.java @@ -5,6 +5,7 @@ import com.badlogic.gdx.files.FileHandle; import com.ilotterytea.maxoning.utils.OsUtils; import java.text.DecimalFormat; +import java.text.SimpleDateFormat; public class MaxonConstants { public static final String GAME_NAME = "Maxon Petting Simulator"; @@ -20,4 +21,8 @@ public class MaxonConstants { public static final FileHandle FILE_RU_RU = Gdx.files.internal("i18n/ru_ru.json"); public static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("###,###.##"); + @SuppressWarnings("SimpleDateFormat") + public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd/M/yyyy hh:mm:ss"); + public static final long startTime = System.currentTimeMillis(); + } -- cgit v1.2.3 From 3c355445d59a195a69b6465c1bdca1cb84032865 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Thu, 6 Oct 2022 01:12:51 +0600 Subject: prototype of the new menu screen appearance --- .../ilotterytea/maxoning/screens/MenuScreen.java | 359 +++++++++------------ 1 file changed, 158 insertions(+), 201 deletions(-) (limited to 'core/src/com') diff --git a/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java b/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java index 663a97c..135d0e9 100644 --- a/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java +++ b/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java @@ -2,6 +2,7 @@ package com.ilotterytea.maxoning.screens; import com.badlogic.gdx.*; import com.badlogic.gdx.audio.Music; +import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.graphics.*; import com.badlogic.gdx.graphics.g2d.Sprite; import com.badlogic.gdx.graphics.g2d.TextureAtlas; @@ -14,34 +15,42 @@ import com.badlogic.gdx.scenes.scene2d.ui.*; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.badlogic.gdx.utils.Align; import com.badlogic.gdx.utils.viewport.FillViewport; +import com.ilotterytea.maxoning.MaxonConstants; import com.ilotterytea.maxoning.MaxonGame; -import com.ilotterytea.maxoning.inputprocessors.CrossProcessor; +import com.ilotterytea.maxoning.player.MaxonPlayer; import com.ilotterytea.maxoning.ui.*; +import com.ilotterytea.maxoning.utils.math.Math; import java.io.IOException; +import java.io.ObjectInputStream; import java.util.ArrayList; +import java.util.Calendar; -public class MenuScreen implements Screen, InputProcessor { +public class MenuScreen implements Screen { final MaxonGame game; final Stage stage; final Skin skin, widgetSkin; - Image brandLogo, blackBg; - Label startLabel, infoLabel; + Image brandLogo, blackBg, menuBg; - TextButton singlePlayerButton, optionsButton, quitButton; final Music menuMusic; - Table menuTable, optionsTable; + Table menuTable, savegameTable; // Atlases: TextureAtlas environmentAtlas, brandAtlas; private ArrayList> bgMenuTiles; + private ArrayList leafTiles, delLeafTiles; - private boolean anyKeyPressed = false, brandActionsSet = false; + private final boolean isAutumn = + // Autumn. + ((Calendar.getInstance().get(Calendar.MONTH) + 1 > 8) && (Calendar.getInstance().get(Calendar.MONTH) + 1 < 12)) || + // Spring. + ((Calendar.getInstance().get(Calendar.MONTH) + 1 < 6) && (Calendar.getInstance().get(Calendar.MONTH) + 1 > 2)); + private final boolean isSummer = (Calendar.getInstance().get(Calendar.MONTH) + 1 > 5 && Calendar.getInstance().get(Calendar.MONTH) + 1 < 9); public MenuScreen(final MaxonGame game) { this.game = game; @@ -69,48 +78,27 @@ public class MenuScreen implements Screen, InputProcessor { stage.addActor(blackBg); - this.startLabel = new Label(game.locale.TranslatableText("menu.pressStart"), skin, "press"); - this.infoLabel = new DebugLabel(skin); + // Save game table: + savegameTable = new Table(); + loadSavegamesToTable(savegameTable); - // Menu Buttons: - menuTable = new Table(); - - singlePlayerButton = new TextButton(game.locale.TranslatableText("menu.playGame"), widgetSkin, "default"); - optionsButton = new TextButton(game.locale.TranslatableText("menu.options"), widgetSkin, "default"); - quitButton = new TextButton(game.locale.TranslatableText("menu.quit"), widgetSkin, "default"); + // Quick buttons: + Table quickTable = new Table(); + quickTable.align(Align.right); - singlePlayerButton.addListener(new ClickListener() { - @Override - public void clicked(InputEvent event, float x, float y) { - try { - game.setScreen(new GameScreen(game)); - } catch (IOException | ClassNotFoundException e) { - throw new RuntimeException(e); - } - dispose(); - } - }); - - // Options: + // Options button: + TextButton optionsButton = new TextButton("Options", widgetSkin, "default"); optionsButton.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { - menuTable.clearActions(); - menuTable.addAction(Actions.moveTo(-Gdx.graphics.getWidth(), menuTable.getY(), 0.75f, Interpolation.sine)); - - optionsTable.clearActions(); - optionsTable.addAction(Actions.moveTo(0, optionsTable.getY(), 0.75f, Interpolation.sine)); - - blackBg.clearActions(); - blackBg.addAction(Actions.alpha(0.5f)); - - brandLogo.addAction( - Actions.moveTo(brandLogo.getX(), brandLogo.getY() + 512f, 0.5f, Interpolation.sine) - ); + super.clicked(event, x, y); } }); - // Exit the game when "quit button" is pressed: + quickTable.add(optionsButton).height(48f).minWidth(90f).pad(4f); + + // Quit button: + TextButton quitButton = new TextButton("Quit", widgetSkin, "default"); quitButton.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { @@ -118,104 +106,71 @@ public class MenuScreen implements Screen, InputProcessor { } }); - // Set the width and position for menu table: - menuTable.setPosition(0, Gdx.graphics.getHeight()); - menuTable.setWidth(Gdx.graphics.getWidth()); - menuTable.align(Align.center); + quickTable.add(quitButton).height(48f).minWidth(90f).pad(4f); - menuTable.add(singlePlayerButton).width(512f).height(81f).padBottom(10f).row(); - menuTable.add(optionsButton).width(512f).height(81f).padBottom(91f).row(); - menuTable.add(quitButton).width(512f).height(81f).row(); + // Menu table: + menuTable = new Table(); + menuTable.setPosition(0, 0); + menuTable.setSize(stage.getWidth(), stage.getHeight()); + menuTable.align(Align.center); - blackBg.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); - blackBg.addAction(Actions.alpha(0.25f)); + Label menuTitle = new Label("Please select a save slot", skin, "default"); + menuTitle.setAlignment(Align.left); - // Options table: - optionsTable = new OptionsTable(game, skin, widgetSkin, menuMusic, menuTable, blackBg, brandLogo); + menuTable.add(menuTitle).width(512f).row(); + menuTable.add(savegameTable).width(512f).maxWidth(640f).row(); + menuTable.add(quickTable).width(512f); - stage.addActor(blackBg); - stage.addActor(infoLabel); - stage.addActor(brandLogo); - stage.addActor(startLabel); stage.addActor(menuTable); - stage.addActor(optionsTable); - - menuTable.addAction(Actions.sequence(Actions.alpha(0f), Actions.moveTo(0f, -Gdx.graphics.getHeight() - Gdx.graphics.getHeight(), 0f))); - optionsTable.addAction(Actions.moveTo(Gdx.graphics.getWidth(), 0, 0f)); - - Gdx.input.setInputProcessor(new InputMultiplexer(this, new CrossProcessor(), stage)); - - // Setting the music: - if (game.prefs.getBoolean("music", true)) { - menuMusic.setLooping(true); - menuMusic.setVolume((game.prefs.getBoolean("music", true)) ? 1f : 0f); - menuMusic.play(); - } - - // Generate background tiles: - bgMenuTiles = new ArrayList<>(); - - genNewBgTiles((int) stage.getWidth(), (int) stage.getHeight()); - } - - @Override public void show() { - brandLogo.setScale(100f); + // // Logo: + brandLogo = new Image(brandAtlas.findRegion("brand")); brandLogo.setPosition( - (Gdx.graphics.getWidth() / 2.0f) - (brandLogo.getWidth() / 2.0f), - (Gdx.graphics.getHeight() / 2.0f) - (brandLogo.getHeight() / 2.0f) + (stage.getWidth() / 2f) - (brandLogo.getWidth() / 2f), + stage.getHeight() - brandLogo.getHeight() * 1.5f ); brandLogo.setOrigin( - brandLogo.getWidth() / 2.0f, - brandLogo.getHeight() / 2.0f + brandLogo.getWidth() / 2f, + brandLogo.getHeight() / 2f ); brandLogo.addAction( - Actions.sequence( - Actions.alpha(0), - Actions.parallel( - Actions.fadeIn(1f), - Actions.scaleTo(1f, 1f, 1f, Interpolation.pow2InInverse) - ), - Actions.repeat( - RepeatAction.FOREVER, - Actions.sequence( - Actions.parallel( - Actions.rotateTo(-10, 10f, Interpolation.sine), - Actions.scaleTo(0.85f, 0.85f, 10f, Interpolation.sine) - ), - Actions.parallel( - Actions.rotateTo(10, 10f, Interpolation.sine), - Actions.scaleTo(1.25f, 1.25f, 10f, Interpolation.sine) - ) - ) - )) - ); - - startLabel.setPosition( - (Gdx.graphics.getWidth() / 2.0f) - (startLabel.getWidth() / 2.0f), - 32 - ); - - startLabel.addAction( Actions.repeat( RepeatAction.FOREVER, Actions.sequence( - Actions.alpha(0f), - Actions.fadeIn(1f), - Actions.delay(5f), - Actions.fadeOut(1f) + Actions.parallel( + Actions.rotateTo(-5f, 5f, Interpolation.smoother), + Actions.scaleTo(0.9f, 0.9f, 5f, Interpolation.smoother) + ), + Actions.parallel( + Actions.rotateTo(5f, 5f, Interpolation.smoother), + Actions.scaleTo(1.1f, 1.1f, 5f, Interpolation.smoother) + ) ) ) ); - infoLabel.setPosition(8, (Gdx.graphics.getHeight() - infoLabel.getHeight() - 8)); + stage.addActor(brandLogo); - // Start to render: - render(Gdx.graphics.getDeltaTime()); + // Debug label: + DebugLabel debug = new DebugLabel(skin); + debug.setPosition(4, stage.getHeight() - debug.getHeight() - 4); + stage.addActor(debug); + + Gdx.input.setInputProcessor(new InputMultiplexer(stage)); + + // Generate background tiles: + bgMenuTiles = new ArrayList<>(); + genNewBgTiles((int) stage.getWidth(), (int) stage.getHeight()); + leafTiles = new ArrayList<>(); + delLeafTiles = new ArrayList<>(); + } + @Override public void show() { + // Start to render: + render(Gdx.graphics.getDeltaTime()); } @Override @@ -223,46 +178,32 @@ public class MenuScreen implements Screen, InputProcessor { Gdx.gl.glClearColor(0, 0, 0, 1f); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); - if (anyKeyPressed && !brandActionsSet) { - startLabel.clearActions(); - startLabel.addAction(Actions.fadeOut(0.5f)); - - brandLogo.clearActions(); - brandLogo.addAction( - Actions.sequence( - Actions.parallel( - Actions.alpha(1f), - Actions.rotateTo(0f, 2f), - Actions.scaleTo(1f, 1f, 2f), - Actions.moveTo( - (Gdx.graphics.getWidth() / 2f) - (brandLogo.getWidth() / 2f), - (Gdx.graphics.getHeight() - brandLogo.getHeight()) - 81, - 2f, - Interpolation.sine - ) - ), - Actions.repeat(RepeatAction.FOREVER, - Actions.sequence( - Actions.parallel( - Actions.rotateTo(-5f, 5f, Interpolation.smoother), - Actions.scaleTo(0.9f, 0.9f, 5f, Interpolation.smoother) - ), - Actions.parallel( - Actions.rotateTo(5f, 5f, Interpolation.smoother), - Actions.scaleTo(1.1f, 1.1f, 5f, Interpolation.smoother) - ) - ))) - ); - - menuTable.clearActions(); - menuTable.addAction( - Actions.parallel( - Actions.fadeIn(1.5f), - Actions.moveTo(0, (Gdx.graphics.getHeight() / 2f) - (menuTable.getHeight() / 2f) - 64f, 2.5f, Interpolation.smoother) - ) - ); + // Generate a new leaf: + if (!isSummer) { + LeafParticle _leaf = new LeafParticle( + (isAutumn) ? environmentAtlas.findRegion("leaf") : environmentAtlas.findRegion("snowflake"), + (float) java.lang.Math.floor(java.lang.Math.random() * Gdx.graphics.getWidth()), + Gdx.graphics.getHeight(), + (float) Math.getRandomNumber(-257, 256) + 1, + (float) Math.getRandomNumber(-257, 256) + 1, + (float) Math.getRandomNumber(5, 15)); + + _leaf.setScale(5f); + + if (isAutumn) { + switch (Math.getRandomNumber(0, 3)) { + case 0: _leaf.setColor(Color.CORAL); break; + case 1: _leaf.setColor(Color.YELLOW); break; + default: _leaf.setColor(Color.RED); break; + } + } else { + switch (Math.getRandomNumber(0, 1)) { + case 0: _leaf.setColor(Color.WHITE); break; + case 1: _leaf.setColor(Color.SKY); + } + } - brandActionsSet = true; + leafTiles.add(_leaf); } game.batch.begin(); @@ -274,6 +215,10 @@ public class MenuScreen implements Screen, InputProcessor { } } + for (LeafParticle spr : leafTiles) { + spr.draw(game.batch); + } + game.batch.end(); for (ArrayList array : bgMenuTiles) { @@ -295,6 +240,17 @@ public class MenuScreen implements Screen, InputProcessor { } } + if (!isSummer) { + for (LeafParticle spr : leafTiles) { + if (spr.getX() > Gdx.graphics.getWidth() || spr.getY() > Gdx.graphics.getHeight()) { + delLeafTiles.add(spr); + } + } + + for (LeafParticle spr : delLeafTiles) { leafTiles.remove(spr); } + delLeafTiles.clear(); + } + stage.draw(); stage.act(delta); } @@ -308,6 +264,53 @@ public class MenuScreen implements Screen, InputProcessor { stage.getViewport().update(width, height, true); } + private void loadSavegamesToTable(Table table) { + FileHandle folder = Gdx.files.external(MaxonConstants.GAME_SAVEGAME_FOLDER); + + try { + for (FileHandle fh : folder.list()) { + final MaxonPlayer sav = (MaxonPlayer) new ObjectInputStream(fh.read()).readObject(); + SaveGameWidget widget = new SaveGameWidget( + skin, widgetSkin, sav + ); + widget.addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + try { + game.setScreen(new GameScreen(game, sav)); + } catch (IOException | ClassNotFoundException e) { + throw new RuntimeException(e); + } + dispose(); + } + }); + table.add(widget).width(512f).padBottom(8f).row(); + } + } catch (IOException | ClassNotFoundException e) { + e.printStackTrace(); + } + + for (int i = 0; i < 3 - folder.list().length; i++) { + final MaxonPlayer sav = new MaxonPlayer(); + SaveGameWidget widget = new SaveGameWidget( + skin, widgetSkin, null + ); + final int finalI = i; + widget.addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + try { + game.setScreen(new GameScreen(game, sav)); + } catch (IOException | ClassNotFoundException e) { + throw new RuntimeException(e); + } + dispose(); + } + }); + table.add(widget).width(512f).padBottom(8f).row(); + } + } + private void genNewBgTiles(int width, int height) { bgMenuTiles.clear(); @@ -337,50 +340,4 @@ public class MenuScreen implements Screen, InputProcessor { stage.clear(); skin.dispose(); } - - @Override - public boolean keyDown(int keycode) { - if (Gdx.input.isKeyPressed(Input.Keys.ANY_KEY)) { - anyKeyPressed = true; - } - 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) { - if (!anyKeyPressed) { - anyKeyPressed = true; - } - 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; - } } -- cgit v1.2.3 From c9bb9b34d005a9f396e4963c6f077d3a92a272fe Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Thu, 6 Oct 2022 01:15:12 +0600 Subject: garbage cuz game has more than 1 savegame slot --- core/src/com/ilotterytea/maxoning/MaxonGame.java | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'core/src/com') diff --git a/core/src/com/ilotterytea/maxoning/MaxonGame.java b/core/src/com/ilotterytea/maxoning/MaxonGame.java index 6f26b12..0ad6a8d 100644 --- a/core/src/com/ilotterytea/maxoning/MaxonGame.java +++ b/core/src/com/ilotterytea/maxoning/MaxonGame.java @@ -6,10 +6,8 @@ import com.badlogic.gdx.Preferences; import com.badlogic.gdx.assets.AssetManager; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; -import com.ilotterytea.maxoning.player.MaxonPlayer; import com.ilotterytea.maxoning.screens.SplashScreen; import com.ilotterytea.maxoning.utils.I18N; -import com.ilotterytea.maxoning.utils.serialization.GameDataSystem; import java.io.IOException; @@ -36,14 +34,6 @@ public class MaxonGame extends Game { prefs = Gdx.app.getPreferences("Maxoning"); locale = new I18N(Gdx.files.internal("i18n/" + prefs.getString("lang", "en_us") + ".json")); - if (!GameDataSystem.exists()) { - try { - GameDataSystem.SaveData(new MaxonPlayer()); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - prefs.putInteger("width", Gdx.graphics.getWidth()); prefs.putInteger("height", Gdx.graphics.getHeight()); prefs.flush(); -- cgit v1.2.3 From 9e17ac7008985c7c52c36dda7abacbf5cb21d2bc Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Thu, 6 Oct 2022 01:15:27 +0600 Subject: asd --- core/src/com/ilotterytea/maxoning/ui/PurchaseItem.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core/src/com') diff --git a/core/src/com/ilotterytea/maxoning/ui/PurchaseItem.java b/core/src/com/ilotterytea/maxoning/ui/PurchaseItem.java index c530950..c3778dc 100644 --- a/core/src/com/ilotterytea/maxoning/ui/PurchaseItem.java +++ b/core/src/com/ilotterytea/maxoning/ui/PurchaseItem.java @@ -12,7 +12,7 @@ public class PurchaseItem extends Stack { CharSequence desc, float price ) { - super(new Image(widgetSkin, "button")); + super(new Image(widgetSkin, "up")); Table summary = new Table(); summary.setHeight(super.getHeight()); -- cgit v1.2.3 From 6bd5bef619929d9903a44febdf5357f107365dad Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Thu, 6 Oct 2022 01:18:27 +0600 Subject: MaxonPlayer is required in GameScreen parameters --- core/src/com/ilotterytea/maxoning/screens/GameScreen.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'core/src/com') diff --git a/core/src/com/ilotterytea/maxoning/screens/GameScreen.java b/core/src/com/ilotterytea/maxoning/screens/GameScreen.java index bb55484..f04cec0 100644 --- a/core/src/com/ilotterytea/maxoning/screens/GameScreen.java +++ b/core/src/com/ilotterytea/maxoning/screens/GameScreen.java @@ -53,11 +53,10 @@ public class GameScreen implements Screen, InputProcessor { ArrayList> bgTiles; - public GameScreen(MaxonGame game) throws IOException, ClassNotFoundException { + public GameScreen(MaxonGame game, MaxonPlayer sav) throws IOException, ClassNotFoundException { this.game = game; - player = new MaxonPlayer(); - player.load(GameDataSystem.LoadData()); + player = sav; // Initializing the stage and skin: stage = new Stage(new FillViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight())); -- cgit v1.2.3 From 5bf74a321af0337fa8a2e0b0342b80f8a11299e5 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Thu, 6 Oct 2022 01:18:58 +0600 Subject: these styles no longer exists --- core/src/com/ilotterytea/maxoning/screens/GameScreen.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'core/src/com') diff --git a/core/src/com/ilotterytea/maxoning/screens/GameScreen.java b/core/src/com/ilotterytea/maxoning/screens/GameScreen.java index f04cec0..b3d5fdc 100644 --- a/core/src/com/ilotterytea/maxoning/screens/GameScreen.java +++ b/core/src/com/ilotterytea/maxoning/screens/GameScreen.java @@ -79,7 +79,7 @@ public class GameScreen implements Screen, InputProcessor { stage.addActor(blackBg); // Setting the background for inventory: - inventoryBg = new Image(widgetSkin, "button_disabled"); + inventoryBg = new Image(widgetSkin, "down"); inventoryBg.setSize((Gdx.graphics.getWidth() / 2.0f) - 512f, (Gdx.graphics.getHeight() / 2.0f) - 8f); inventoryBg.setPosition(8, 4); stage.addActor(inventoryBg); @@ -114,7 +114,7 @@ public class GameScreen implements Screen, InputProcessor { stage.addActor(inventoryTable); // Setting the background for pet shop: - shopBg = new Image(widgetSkin, "button_disabled"); + shopBg = new Image(widgetSkin, "down"); shopBg.setSize((Gdx.graphics.getWidth() / 2.0f) - 512f, (Gdx.graphics.getHeight() / 2.0f) - 8f); shopBg.setPosition(8, inventoryBg.getY() + inventoryBg.getHeight() + 8f); stage.addActor(shopBg); @@ -174,7 +174,7 @@ public class GameScreen implements Screen, InputProcessor { stage.addActor(petScroll); // Background for points label: - pointsBg = new Image(widgetSkin, "button_disabled"); + pointsBg = new Image(widgetSkin, "down"); pointsBg.setSize((Gdx.graphics.getWidth() - (shopBg.getX() + shopBg.getWidth()) - 8f), 64f); pointsBg.setPosition(shopBg.getX() + shopBg.getWidth() + 4f, Gdx.graphics.getHeight() - pointsBg.getHeight() - 4f); -- cgit v1.2.3 From 8a0e38c2cc63729ada215dccc72b8c526dd3ed2a Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Thu, 6 Oct 2022 01:23:16 +0600 Subject: new debug look letsgo --- core/src/com/ilotterytea/maxoning/ui/DebugLabel.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'core/src/com') diff --git a/core/src/com/ilotterytea/maxoning/ui/DebugLabel.java b/core/src/com/ilotterytea/maxoning/ui/DebugLabel.java index 9300962..5335450 100644 --- a/core/src/com/ilotterytea/maxoning/ui/DebugLabel.java +++ b/core/src/com/ilotterytea/maxoning/ui/DebugLabel.java @@ -1,18 +1,19 @@ package com.ilotterytea.maxoning.ui; import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.scenes.scene2d.ui.Label; import com.badlogic.gdx.scenes.scene2d.ui.Skin; -import com.ilotterytea.maxoning.MaxonConstants; public class DebugLabel extends Label { - private static final String str_placeholder = "%s\n%s fps"; + private static final String str_placeholder = "%s fps"; public DebugLabel(Skin skin) { - super(String.format(str_placeholder, MaxonConstants.GAME_VERSION, Gdx.graphics.getFramesPerSecond()), skin); + super(String.format(str_placeholder, Gdx.graphics.getFramesPerSecond()), skin, "debug"); + super.setColor(Color.LIME); } @Override public void act(float delta) { - super.setText(String.format(str_placeholder, MaxonConstants.GAME_VERSION, Gdx.graphics.getFramesPerSecond())); + super.setText(String.format(str_placeholder, Gdx.graphics.getFramesPerSecond())); } } -- cgit v1.2.3 From e8ab2aff11aa1da59968c9f06f96194e2f5e501e Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Thu, 6 Oct 2022 17:17:46 +0600 Subject: new game data system that based on json --- .../utils/serialization/GameDataSystem.java | 98 ++++++++++++++++++---- 1 file changed, 81 insertions(+), 17 deletions(-) (limited to 'core/src/com') diff --git a/core/src/com/ilotterytea/maxoning/utils/serialization/GameDataSystem.java b/core/src/com/ilotterytea/maxoning/utils/serialization/GameDataSystem.java index a10d98a..3e64c45 100644 --- a/core/src/com/ilotterytea/maxoning/utils/serialization/GameDataSystem.java +++ b/core/src/com/ilotterytea/maxoning/utils/serialization/GameDataSystem.java @@ -1,35 +1,99 @@ package com.ilotterytea.maxoning.utils.serialization; +import com.badlogic.gdx.utils.Null; +import com.google.gson.Gson; import com.ilotterytea.maxoning.MaxonConstants; -import com.ilotterytea.maxoning.player.MaxonPlayer; +import com.ilotterytea.maxoning.player.MaxonSavegame; +import org.jetbrains.annotations.NotNull; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.*; +import java.util.ArrayList; +/** + * External game data system control. + * @author NotDankEnough + * @since Alpha 1.0 + */ public class GameDataSystem { private static final File dir = new File(MaxonConstants.GAME_SAVEGAME_FOLDER); - private static final File file = new File(dir.getPath() + "/savegame.sav"); + private static final Gson gson = new Gson(); + private static final Logger log = LoggerFactory.getLogger(GameDataSystem.class.getSimpleName()); - public static boolean exists() { return file.exists(); } + /** + * Get all savefiles from savegame directory (/.Maxoning/savegames/) + * @return Array of MaxonSavegames + * @see MaxonSavegame + */ + public static ArrayList getSavegames() { + ArrayList saves = new ArrayList<>(); + File[] files = dir.listFiles(); - public static void SaveData(MaxonPlayer player) throws IOException { - if (!dir.exists()) { - dir.mkdirs(); + assert files != null; + for (File file : files) { + try { + + FileInputStream fis = new FileInputStream(file); + ObjectInputStream ois = new ObjectInputStream(fis); + + MaxonSavegame sav = gson.fromJson(ois.readUTF(), MaxonSavegame.class); + saves.add(sav); + + ois.close(); + fis.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } } - FileOutputStream fo = new FileOutputStream(file); - ObjectOutputStream out = new ObjectOutputStream(fo); - out.writeObject(player); - out.close(); + return saves; + } + + /** + * Convert MaxonSavegame class to JSON string and write in UTF-8 encoding (I'm sorry, encryption enjoyers). + * @param savegame Save game object. + * @param file_name File name. + * @see MaxonSavegame + */ + public static void save(@NotNull MaxonSavegame savegame, @NotNull String file_name) { + try { + log.info("Saving the game..."); + FileOutputStream fos = new FileOutputStream(String.format("%s/%s", dir.getAbsolutePath(), file_name)); + ObjectOutputStream oos = new ObjectOutputStream(fos); + + oos.writeUTF(gson.toJson(savegame)); + oos.close(); + log.info(String.format("Success! Savegame located at %s/%s", dir.getAbsolutePath(), file_name)); + } catch (IOException e) { + throw new RuntimeException(e); + } } - public static MaxonPlayer LoadData() throws IOException, ClassNotFoundException { - FileInputStream fi = new FileInputStream(file); - ObjectInputStream oi = new ObjectInputStream(fi); + /** + * Reading a JSON string from the file and convert to MaxonSavegame class. + * @param file_name File name. If null - it will get the first file by last modified time. + * @return Filled MaxonSavegame class + * @see MaxonSavegame + */ + public static MaxonSavegame load(@Null String file_name) { + MaxonSavegame sav = new MaxonSavegame(); + + if (new File(dir.getAbsolutePath() + "/" + file_name).exists()) { + try { + log.info(String.format("Trying to get the savegame at %s/%s...", dir.getAbsolutePath(), file_name)); + FileInputStream fis = new FileInputStream(String.format("%s/%s", dir.getAbsolutePath(), file_name)); + ObjectInputStream oos = new ObjectInputStream(fis); - MaxonPlayer pl = (MaxonPlayer) oi.readObject(); + sav = gson.fromJson(oos.readUTF(), MaxonSavegame.class); + oos.close(); + + log.info(String.format("Successfully loaded the savegame from %s/%s!", dir.getAbsolutePath(), file_name)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } - oi.close(); - fi.close(); - return pl; + return sav; } } -- cgit v1.2.3 From f706eab45127213e8a26e0a732cc5467784d01f6 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Thu, 6 Oct 2022 17:21:58 +0600 Subject: set game screen after loading assets (only for android) --- core/src/com/ilotterytea/maxoning/screens/SplashScreen.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'core/src/com') diff --git a/core/src/com/ilotterytea/maxoning/screens/SplashScreen.java b/core/src/com/ilotterytea/maxoning/screens/SplashScreen.java index 31a1023..2817948 100644 --- a/core/src/com/ilotterytea/maxoning/screens/SplashScreen.java +++ b/core/src/com/ilotterytea/maxoning/screens/SplashScreen.java @@ -14,8 +14,11 @@ import com.badlogic.gdx.utils.Timer; import com.badlogic.gdx.utils.viewport.FillViewport; import com.ilotterytea.maxoning.MaxonGame; import com.ilotterytea.maxoning.utils.AssetLoading; +import com.ilotterytea.maxoning.utils.OsUtils; import com.ilotterytea.maxoning.utils.math.Math; +import com.ilotterytea.maxoning.utils.serialization.GameDataSystem; +import java.io.IOException; import java.util.ArrayList; public class SplashScreen implements Screen { @@ -97,7 +100,15 @@ public class SplashScreen implements Screen { private void update() { if (game.assetManager.update()) { AssetLoading.registerItems(game.assetManager, game.locale); - game.setScreen(new MenuScreen(game)); + if (OsUtils.isAndroid || OsUtils.isIos) { + try { + game.setScreen(new GameScreen(game, GameDataSystem.load("latest.sav"))); + } catch (IOException | ClassNotFoundException e) { + throw new RuntimeException(e); + } + } else { + game.setScreen(new MenuScreen(game)); + } dispose(); } } -- cgit v1.2.3 From 0c7f6536eae679a2f11720a9ca6d0e36d8ff9df0 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Thu, 6 Oct 2022 17:45:58 +0600 Subject: ΠΏΠΎΠ΄Π³ΠΎΠ½ ΠΊ Π½ΠΎΠ²ΠΎΠΌΡƒ Ρ„ΠΎΡ€ΠΌΠ°Ρ‚Ρƒ сохранСний MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ilotterytea/maxoning/player/MaxonSavegame.java | 40 ++++++++++++++++ .../ilotterytea/maxoning/screens/GameScreen.java | 28 ++++++------ .../ilotterytea/maxoning/screens/MenuScreen.java | 53 ++++++++++------------ .../ilotterytea/maxoning/screens/SplashScreen.java | 2 +- .../ilotterytea/maxoning/ui/SaveGameWidget.java | 30 ++++++------ 5 files changed, 96 insertions(+), 57 deletions(-) create mode 100644 core/src/com/ilotterytea/maxoning/player/MaxonSavegame.java (limited to 'core/src/com') diff --git a/core/src/com/ilotterytea/maxoning/player/MaxonSavegame.java b/core/src/com/ilotterytea/maxoning/player/MaxonSavegame.java new file mode 100644 index 0000000..301840b --- /dev/null +++ b/core/src/com/ilotterytea/maxoning/player/MaxonSavegame.java @@ -0,0 +1,40 @@ +package com.ilotterytea.maxoning.player; + +import java.io.Serializable; +import java.util.ArrayList; + +/** + * Save-game data class. + * @author NotDankEnough + * @since Alpha 1.2 (Oct 02, 2022) + */ +public class MaxonSavegame implements Serializable { + /** Earned Squish Points. */ + public int points; + /** Multiplier. */ + public short multiplier; + + /** Home inventory. */ + public ArrayList inv; + /** Outside Inventory. */ + public ArrayList outInv; + + /** Seed. */ + public long seed; + + /** Player name. */ + public String name; + /** Pet name. */ + public String petName; + /** Pet ID. */ + public byte petId; + + /** Elapsed time from game start. */ + public long elapsedTime; + + /** Last timestamp when save game was used. */ + public long lastTimestamp; + + /** Location. */ + public short roomId; +} \ No newline at end of file diff --git a/core/src/com/ilotterytea/maxoning/screens/GameScreen.java b/core/src/com/ilotterytea/maxoning/screens/GameScreen.java index b3d5fdc..e0d2624 100644 --- a/core/src/com/ilotterytea/maxoning/screens/GameScreen.java +++ b/core/src/com/ilotterytea/maxoning/screens/GameScreen.java @@ -20,7 +20,7 @@ import com.ilotterytea.maxoning.anim.SpriteUtils; import com.ilotterytea.maxoning.inputprocessors.CrossProcessor; import com.ilotterytea.maxoning.player.MaxonItem; import com.ilotterytea.maxoning.player.MaxonItemRegister; -import com.ilotterytea.maxoning.player.MaxonPlayer; +import com.ilotterytea.maxoning.player.MaxonSavegame; import com.ilotterytea.maxoning.ui.*; import com.ilotterytea.maxoning.utils.serialization.GameDataSystem; import com.rafaskoberg.gdx.typinglabel.TypingLabel; @@ -32,8 +32,9 @@ import java.util.Map; public class GameScreen implements Screen, InputProcessor { final MaxonGame game; + final int slotId; - MaxonPlayer player; + MaxonSavegame player; Stage stage; Skin skin, widgetSkin; @@ -53,8 +54,9 @@ public class GameScreen implements Screen, InputProcessor { ArrayList> bgTiles; - public GameScreen(MaxonGame game, MaxonPlayer sav) throws IOException, ClassNotFoundException { + public GameScreen(MaxonGame game, MaxonSavegame sav, int slotId) throws IOException, ClassNotFoundException { this.game = game; + this.slotId = slotId; player = sav; @@ -68,7 +70,7 @@ public class GameScreen implements Screen, InputProcessor { items = new ArrayList<>(); - for (int id : player.purchasedItems) { + for (int id : player.inv) { items.add(MaxonItemRegister.get(id)); } @@ -98,7 +100,7 @@ public class GameScreen implements Screen, InputProcessor { invItems = new HashMap<>(); - for (Integer id : player.purchasedItems) { + for (Integer id : player.inv) { if (invItems.containsKey(id)) { invItems.put(id, invItems.get(id) + 1); } else { @@ -141,13 +143,13 @@ public class GameScreen implements Screen, InputProcessor { if (player.points > item.price) { player.points -= item.price; player.multiplier += item.multiplier; - player.purchasedItems.add(item.id); + player.inv.add(item.id); items.add(item); invItems.clear(); inventoryTable.clear(); - for (Integer id : player.purchasedItems) { + for (Integer id : player.inv) { if (invItems.containsKey(id)) { invItems.put(id, invItems.get(id) + 1); } else { @@ -246,7 +248,7 @@ public class GameScreen implements Screen, InputProcessor { player.points += multiplier; - final TypingLabel label = new TypingLabel(game.locale.FormattedText("game.newPoint", MaxonConstants.DECIMAL_FORMAT.format(1 * player.multiplier)), skin, "default"); + final TypingLabel label = new TypingLabel(game.locale.FormattedText("game.newPoint", MaxonConstants.DECIMAL_FORMAT.format(player.multiplier)), skin, "default"); label.setPosition( mainTable.getX() + actor.getActorX(), @@ -383,11 +385,7 @@ public class GameScreen implements Screen, InputProcessor { @Override public boolean keyDown(int keycode) { if (Gdx.input.isKeyPressed(Input.Keys.ESCAPE)) { - try { - GameDataSystem.SaveData(player); - } catch (IOException e) { - throw new RuntimeException(e); - } + GameDataSystem.save(player, String.format("%s.sav", (slotId >= 0) ? slotId : "latest")); game.setScreen(new MenuScreen(game)); dispose(); @@ -404,9 +402,9 @@ public class GameScreen implements Screen, InputProcessor { cat.nextFrame(); maxon.setDrawable(cat.getDrawable()); - player.points += 1 * player.multiplier; + player.points += player.multiplier; - final TypingLabel label = new TypingLabel(game.locale.FormattedText("game.newPoint", MaxonConstants.DECIMAL_FORMAT.format(1 * player.multiplier)), skin, "default"); + final TypingLabel label = new TypingLabel(game.locale.FormattedText("game.newPoint", MaxonConstants.DECIMAL_FORMAT.format(player.multiplier)), skin, "default"); label.setPosition( mainTable.getX() + actor.getActorX(), diff --git a/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java b/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java index 135d0e9..e8dc864 100644 --- a/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java +++ b/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java @@ -2,7 +2,6 @@ package com.ilotterytea.maxoning.screens; import com.badlogic.gdx.*; import com.badlogic.gdx.audio.Music; -import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.graphics.*; import com.badlogic.gdx.graphics.g2d.Sprite; import com.badlogic.gdx.graphics.g2d.TextureAtlas; @@ -15,11 +14,11 @@ import com.badlogic.gdx.scenes.scene2d.ui.*; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.badlogic.gdx.utils.Align; import com.badlogic.gdx.utils.viewport.FillViewport; -import com.ilotterytea.maxoning.MaxonConstants; import com.ilotterytea.maxoning.MaxonGame; -import com.ilotterytea.maxoning.player.MaxonPlayer; +import com.ilotterytea.maxoning.player.MaxonSavegame; import com.ilotterytea.maxoning.ui.*; import com.ilotterytea.maxoning.utils.math.Math; +import com.ilotterytea.maxoning.utils.serialization.GameDataSystem; import java.io.IOException; import java.io.ObjectInputStream; @@ -265,33 +264,31 @@ public class MenuScreen implements Screen { } private void loadSavegamesToTable(Table table) { - FileHandle folder = Gdx.files.external(MaxonConstants.GAME_SAVEGAME_FOLDER); - - try { - for (FileHandle fh : folder.list()) { - final MaxonPlayer sav = (MaxonPlayer) new ObjectInputStream(fh.read()).readObject(); - SaveGameWidget widget = new SaveGameWidget( - skin, widgetSkin, sav - ); - widget.addListener(new ClickListener() { - @Override - public void clicked(InputEvent event, float x, float y) { - try { - game.setScreen(new GameScreen(game, sav)); - } catch (IOException | ClassNotFoundException e) { - throw new RuntimeException(e); - } - dispose(); + ArrayList saves = GameDataSystem.getSavegames(); + + // Load existing files: + for (int i = 0; i < saves.size(); i++) { + final MaxonSavegame sav = saves.get(i); + SaveGameWidget widget = new SaveGameWidget( + skin, widgetSkin, sav + ); + final int finalI = i; + widget.addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + try { + game.setScreen(new GameScreen(game, sav, finalI)); + } catch (IOException | ClassNotFoundException e) { + throw new RuntimeException(e); } - }); - table.add(widget).width(512f).padBottom(8f).row(); - } - } catch (IOException | ClassNotFoundException e) { - e.printStackTrace(); + dispose(); + } + }); + table.add(widget).width(512f).padBottom(8f).row(); } - for (int i = 0; i < 3 - folder.list().length; i++) { - final MaxonPlayer sav = new MaxonPlayer(); + for (int i = 0; i < 3 - saves.size(); i++) { + final MaxonSavegame sav = new MaxonSavegame(); SaveGameWidget widget = new SaveGameWidget( skin, widgetSkin, null ); @@ -300,7 +297,7 @@ public class MenuScreen implements Screen { @Override public void clicked(InputEvent event, float x, float y) { try { - game.setScreen(new GameScreen(game, sav)); + game.setScreen(new GameScreen(game, sav, finalI)); } catch (IOException | ClassNotFoundException e) { throw new RuntimeException(e); } diff --git a/core/src/com/ilotterytea/maxoning/screens/SplashScreen.java b/core/src/com/ilotterytea/maxoning/screens/SplashScreen.java index 2817948..ccae6b1 100644 --- a/core/src/com/ilotterytea/maxoning/screens/SplashScreen.java +++ b/core/src/com/ilotterytea/maxoning/screens/SplashScreen.java @@ -102,7 +102,7 @@ public class SplashScreen implements Screen { AssetLoading.registerItems(game.assetManager, game.locale); if (OsUtils.isAndroid || OsUtils.isIos) { try { - game.setScreen(new GameScreen(game, GameDataSystem.load("latest.sav"))); + game.setScreen(new GameScreen(game, GameDataSystem.load("latest.sav"), -1)); } catch (IOException | ClassNotFoundException e) { throw new RuntimeException(e); } diff --git a/core/src/com/ilotterytea/maxoning/ui/SaveGameWidget.java b/core/src/com/ilotterytea/maxoning/ui/SaveGameWidget.java index cd6fa72..aa9fa85 100644 --- a/core/src/com/ilotterytea/maxoning/ui/SaveGameWidget.java +++ b/core/src/com/ilotterytea/maxoning/ui/SaveGameWidget.java @@ -3,15 +3,18 @@ package com.ilotterytea.maxoning.ui; import com.badlogic.gdx.scenes.scene2d.ui.*; import com.badlogic.gdx.utils.Align; -import com.ilotterytea.maxoning.player.MaxonPlayer; +import com.badlogic.gdx.utils.Null; +import com.ilotterytea.maxoning.player.MaxonSavegame; import com.ilotterytea.maxoning.utils.formatters.NumberFormatter; +import java.util.Date; + public class SaveGameWidget extends Button { public SaveGameWidget( Skin skin, Skin widgetSkin, - MaxonPlayer sav + @Null MaxonSavegame sav ) { // Setting the stack: super(widgetSkin, "slot"); @@ -20,14 +23,15 @@ public class SaveGameWidget extends Button { // // Info row: Table infoTable = new Table(); - // Top left label: - Label topleftLabel = new Label(String.format("%s Squish Points", (sav != null) ? NumberFormatter.format((long) sav.points) : "---"), skin); + // Top left label (name): + Label topleftLabel = new Label((sav != null) ? sav.name : "[EMPTY]", skin); topleftLabel.setAlignment(Align.left); infoTable.add(topleftLabel).width(256f); - // Top right label: + // Top right label (elapsed time): + Date date = new Date((sav != null) ? sav.elapsedTime : 0); Label toprightLabel = new Label( - String.format("%s purchased items", (sav != null) ? sav.purchasedItems.size() : "---"), + String.format("%s:%s", date.getHours(), date.getMinutes()), skin ); toprightLabel.setAlignment(Align.right); @@ -36,28 +40,28 @@ public class SaveGameWidget extends Button { // // Description row: Table descTable = new Table(); - // Bottom left label: + // Bottom left label (purchased items): Label bottomleftLabel = new Label( String.format( - "x%s", - (sav != null) ? NumberFormatter.format((long) sav.multiplier) : "?" + "%s purchased items", + (sav != null) ? sav.inv.size() : "?" ), skin ); bottomleftLabel.setAlignment(Align.left); descTable.add(bottomleftLabel).width(256f); - /* NOT IN USE. Bottom right label: + // Bottom right label (points/multiplier): Label pointsLabel = new Label( String.format( "%s$/x%s", - NumberFormatter.format(points), - NumberFormatter.format(multiplier) + (sav != null) ? NumberFormatter.format(sav.points) : "---", + (sav != null) ? NumberFormatter.format(sav.multiplier) : "0" ), skin ); pointsLabel.setAlignment(Align.right); - descTable.add(pointsLabel).width(256f);*/ + descTable.add(pointsLabel).width(256f); // Adding the tables to main table: Table summaryTable = new Table(); -- cgit v1.2.3 From f64565f74e1a9ee9c510c5f2e49c49d860472445 Mon Sep 17 00:00:00 2001 From: GreDDySS <97845769+GreDDySS@users.noreply.github.com> Date: Tue, 11 Oct 2022 14:04:53 +0800 Subject: add new format --- core/src/com/ilotterytea/maxoning/MaxonConstants.java | 1 + 1 file changed, 1 insertion(+) (limited to 'core/src/com') diff --git a/core/src/com/ilotterytea/maxoning/MaxonConstants.java b/core/src/com/ilotterytea/maxoning/MaxonConstants.java index 04bc932..42f2892 100644 --- a/core/src/com/ilotterytea/maxoning/MaxonConstants.java +++ b/core/src/com/ilotterytea/maxoning/MaxonConstants.java @@ -21,6 +21,7 @@ public class MaxonConstants { public static final FileHandle FILE_RU_RU = Gdx.files.internal("i18n/ru_ru.json"); public static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("###,###.##"); + public static final DecimalFormat DECIMAL_FORMAT2 = new DecimalFormat("###,###"); @SuppressWarnings("SimpleDateFormat") public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd/M/yyyy hh:mm:ss"); public static final long startTime = System.currentTimeMillis(); -- cgit v1.2.3 From 72f0873b112a27ae01508af9ffc911261b3a564d Mon Sep 17 00:00:00 2001 From: GreDDySS <97845769+GreDDySS@users.noreply.github.com> Date: Tue, 11 Oct 2022 14:07:05 +0800 Subject: ΠŸΡ€ΠΈΠΌΠ΅Π½ΠΈΠ» Π½ΠΎΠ²Ρ‹ΠΉ Ρ„ΠΎΡ€ΠΌΠ°Ρ‚ для Ρ†Π΅Π½Ρ‹ Π² ΠΌΠ°Π³Π°Π·ΠΈΠ½Π΅ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/src/com/ilotterytea/maxoning/screens/GameScreen.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core/src/com') diff --git a/core/src/com/ilotterytea/maxoning/screens/GameScreen.java b/core/src/com/ilotterytea/maxoning/screens/GameScreen.java index b3d5fdc..a3a551b 100644 --- a/core/src/com/ilotterytea/maxoning/screens/GameScreen.java +++ b/core/src/com/ilotterytea/maxoning/screens/GameScreen.java @@ -132,7 +132,7 @@ public class GameScreen implements Screen, InputProcessor { // Adding the pet items in pet table: for (final MaxonItem item : MaxonItemRegister.getItems()) { PurchaseItem purchaseItem = new PurchaseItem( - skin, widgetSkin, item.icon, item.name, item.desc, item.price + skin, widgetSkin, item.icon, item.name, item.desc, MaxonConstants.DECIMAL_FORMAT2.format(item.price) ); purchaseItem.addListener(new ClickListener() { -- cgit v1.2.3 From 40b947902a1aff04404d5338227eefdca5c30325 Mon Sep 17 00:00:00 2001 From: GreDDySS <97845769+GreDDySS@users.noreply.github.com> Date: Tue, 11 Oct 2022 14:10:03 +0800 Subject: ΠŸΠΎΠ΄ΠΊΠΎΡ€Ρ€Π΅ΠΊΡ‚ΠΈΡ€ΠΎΠ²Π°Π» Ρ‡ΡƒΡ‚ΠΎΠΊ, Ρ‡Ρ‚ΠΎΠ± Ρ€Π°Π±ΠΎΡ‚Π°Π» Π½ΠΎΠ²Ρ‹ΠΉ Ρ„ΠΎΡ€ΠΌΠ°Ρ‚ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/src/com/ilotterytea/maxoning/ui/PurchaseItem.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'core/src/com') diff --git a/core/src/com/ilotterytea/maxoning/ui/PurchaseItem.java b/core/src/com/ilotterytea/maxoning/ui/PurchaseItem.java index c3778dc..367dfb9 100644 --- a/core/src/com/ilotterytea/maxoning/ui/PurchaseItem.java +++ b/core/src/com/ilotterytea/maxoning/ui/PurchaseItem.java @@ -10,14 +10,14 @@ public class PurchaseItem extends Stack { AnimatedImage icon, CharSequence name, CharSequence desc, - float price + String price ) { super(new Image(widgetSkin, "up")); Table summary = new Table(); summary.setHeight(super.getHeight()); - Label title = new Label(String.format("%s\n(%s)", name, price), skin, "purchaseitem_title"); + Label title = new Label(String.format("%s\n(%s)", name, string), skin, "purchaseitem_title"); summary.add(title).fillX().row(); -- cgit v1.2.3 From 768d4000bf4cc4389d4c984a70c55777384ba29a Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Sat, 15 Oct 2022 17:16:28 +0200 Subject: update the elapsed time and last timestamp --- core/src/com/ilotterytea/maxoning/screens/GameScreen.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'core/src/com') diff --git a/core/src/com/ilotterytea/maxoning/screens/GameScreen.java b/core/src/com/ilotterytea/maxoning/screens/GameScreen.java index e0d2624..f2e5716 100644 --- a/core/src/com/ilotterytea/maxoning/screens/GameScreen.java +++ b/core/src/com/ilotterytea/maxoning/screens/GameScreen.java @@ -33,6 +33,7 @@ import java.util.Map; public class GameScreen implements Screen, InputProcessor { final MaxonGame game; final int slotId; + final long playTimestamp; MaxonSavegame player; @@ -57,6 +58,7 @@ public class GameScreen implements Screen, InputProcessor { public GameScreen(MaxonGame game, MaxonSavegame sav, int slotId) throws IOException, ClassNotFoundException { this.game = game; this.slotId = slotId; + this.playTimestamp = System.currentTimeMillis(); player = sav; @@ -385,7 +387,9 @@ public class GameScreen implements Screen, InputProcessor { @Override public boolean keyDown(int keycode) { if (Gdx.input.isKeyPressed(Input.Keys.ESCAPE)) { - GameDataSystem.save(player, String.format("%s.sav", (slotId >= 0) ? slotId : "latest")); + player.lastTimestamp = System.currentTimeMillis(); + player.elapsedTime = System.currentTimeMillis() - playTimestamp; + GameDataSystem.save(player, String.format("0%s.maxon", (slotId >= 0) ? slotId : "latest")); game.setScreen(new MenuScreen(game)); dispose(); -- cgit v1.2.3 From 67dbc1e33ed6552532f35e78b27b8905cedd4ee8 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Sat, 15 Oct 2022 17:22:40 +0200 Subject: Ρ‚Π°Π±Π»ΠΈΡ†Π° сСйвов ΠΊΠΎΡ‚ΠΎΡ€ΡƒΡŽ я Π΄Π΅Π»Π°Π» 7 Π΄Π½Π΅ΠΉ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ilotterytea/maxoning/screens/MenuScreen.java | 90 ++++++++++++---------- 1 file changed, 51 insertions(+), 39 deletions(-) (limited to 'core/src/com') diff --git a/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java b/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java index e8dc864..c796d22 100644 --- a/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java +++ b/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java @@ -14,14 +14,15 @@ import com.badlogic.gdx.scenes.scene2d.ui.*; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.badlogic.gdx.utils.Align; import com.badlogic.gdx.utils.viewport.FillViewport; +import com.ilotterytea.maxoning.MaxonConstants; import com.ilotterytea.maxoning.MaxonGame; import com.ilotterytea.maxoning.player.MaxonSavegame; import com.ilotterytea.maxoning.ui.*; import com.ilotterytea.maxoning.utils.math.Math; import com.ilotterytea.maxoning.utils.serialization.GameDataSystem; +import java.io.File; import java.io.IOException; -import java.io.ObjectInputStream; import java.util.ArrayList; import java.util.Calendar; @@ -264,47 +265,58 @@ public class MenuScreen implements Screen { } private void loadSavegamesToTable(Table table) { - ArrayList saves = GameDataSystem.getSavegames(); - - // Load existing files: - for (int i = 0; i < saves.size(); i++) { - final MaxonSavegame sav = saves.get(i); - SaveGameWidget widget = new SaveGameWidget( - skin, widgetSkin, sav - ); - final int finalI = i; - widget.addListener(new ClickListener() { - @Override - public void clicked(InputEvent event, float x, float y) { - try { - game.setScreen(new GameScreen(game, sav, finalI)); - } catch (IOException | ClassNotFoundException e) { - throw new RuntimeException(e); + for (int i = 0; i < 3; i++) { + if (new File(MaxonConstants.GAME_SAVEGAME_FOLDER + String.format("/0%s.maxon", i)).exists()) { + final MaxonSavegame sav = GameDataSystem.load("0" + i + ".maxon"); + SaveGameWidget widget = new SaveGameWidget( + skin, widgetSkin, sav + ); + final int finalI = i; + widget.addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + try { + game.setScreen(new GameScreen(game, sav, finalI)); + } catch (IOException | ClassNotFoundException e) { + throw new RuntimeException(e); + } + dispose(); } - dispose(); - } - }); - table.add(widget).width(512f).padBottom(8f).row(); - } + }); + table.add(widget).width(512f).padBottom(8f).row(); + } else { - for (int i = 0; i < 3 - saves.size(); i++) { - final MaxonSavegame sav = new MaxonSavegame(); - SaveGameWidget widget = new SaveGameWidget( - skin, widgetSkin, null - ); - final int finalI = i; - widget.addListener(new ClickListener() { - @Override - public void clicked(InputEvent event, float x, float y) { - try { - game.setScreen(new GameScreen(game, sav, finalI)); - } catch (IOException | ClassNotFoundException e) { - throw new RuntimeException(e); + final MaxonSavegame sav = new MaxonSavegame(); + final SaveGameWidget widget = new SaveGameWidget( + skin, widgetSkin, null + ); + final int finalI = i; + widget.addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + sav.petId = 0; + sav.inv = new ArrayList<>(); + sav.multiplier = 5; + sav.points = 0; + sav.roomId = 0; + sav.seed = System.currentTimeMillis(); + sav.name = "SAVE " + (finalI + 1); + sav.elapsedTime = 0; + sav.lastTimestamp = System.currentTimeMillis(); + sav.outInv = new ArrayList<>(); + + GameDataSystem.save(sav, "0" + finalI + ".maxon"); + + try { + game.setScreen(new GameScreen(game, sav, finalI)); + } catch (IOException | ClassNotFoundException e) { + throw new RuntimeException(e); + } + dispose(); } - dispose(); - } - }); - table.add(widget).width(512f).padBottom(8f).row(); + }); + table.add(widget).width(512f).padBottom(8f).row(); + } } } -- cgit v1.2.3 From a68e6371c345293cc60f8e74fda38fca7fbdfdf9 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Sat, 15 Oct 2022 17:30:07 +0200 Subject: Π²ΠΈΠ΄ΠΆΠ΅Ρ‚ сСрый Ссли сСйв пустой MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/src/com/ilotterytea/maxoning/ui/SaveGameWidget.java | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'core/src/com') diff --git a/core/src/com/ilotterytea/maxoning/ui/SaveGameWidget.java b/core/src/com/ilotterytea/maxoning/ui/SaveGameWidget.java index aa9fa85..d0175b5 100644 --- a/core/src/com/ilotterytea/maxoning/ui/SaveGameWidget.java +++ b/core/src/com/ilotterytea/maxoning/ui/SaveGameWidget.java @@ -1,6 +1,7 @@ package com.ilotterytea.maxoning.ui; +import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.scenes.scene2d.ui.*; import com.badlogic.gdx.utils.Align; import com.badlogic.gdx.utils.Null; @@ -68,6 +69,13 @@ public class SaveGameWidget extends Button { summaryTable.add(infoTable).pad(5f).row(); summaryTable.add(descTable).pad(5f).row(); + if (sav == null) { + topleftLabel.setColor(Color.DARK_GRAY); + toprightLabel.setColor(Color.DARK_GRAY); + bottomleftLabel.setColor(Color.DARK_GRAY); + pointsLabel.setColor(Color.DARK_GRAY); + } + super.add(summaryTable); } } -- cgit v1.2.3 From 806267277e552abdfd30aa6342a15464f0c2025a Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Sat, 15 Oct 2022 18:15:08 +0200 Subject: ΠΏΡ€ΠΈΠ±Π°Π²ΠΈΡ‚ΡŒ ΠΈΠΌΠ΅ΡŽΡ‰ΠΈΠ΅ΡΡ врСмя ΠΊ Ρ€Π΅Π·ΡƒΠ»ΡŒΡ‚Π°Ρ‚Ρƒ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/src/com/ilotterytea/maxoning/screens/GameScreen.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core/src/com') diff --git a/core/src/com/ilotterytea/maxoning/screens/GameScreen.java b/core/src/com/ilotterytea/maxoning/screens/GameScreen.java index f2e5716..873ce4e 100644 --- a/core/src/com/ilotterytea/maxoning/screens/GameScreen.java +++ b/core/src/com/ilotterytea/maxoning/screens/GameScreen.java @@ -388,7 +388,7 @@ public class GameScreen implements Screen, InputProcessor { public boolean keyDown(int keycode) { if (Gdx.input.isKeyPressed(Input.Keys.ESCAPE)) { player.lastTimestamp = System.currentTimeMillis(); - player.elapsedTime = System.currentTimeMillis() - playTimestamp; + player.elapsedTime = (System.currentTimeMillis() - playTimestamp) + player.elapsedTime; GameDataSystem.save(player, String.format("0%s.maxon", (slotId >= 0) ? slotId : "latest")); game.setScreen(new MenuScreen(game)); -- cgit v1.2.3 From e548d4b78d89bb752b38d107b2bb7d9e0302acbf Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Sat, 15 Oct 2022 18:17:49 +0200 Subject: Π½Π΅Π½ΡƒΠΆΠ½Ρ‹ΠΉ ΠΈΠΌΠΏΠΎΡ€Ρ‚ иоСксСпшн MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/src/com/ilotterytea/maxoning/MaxonGame.java | 2 -- 1 file changed, 2 deletions(-) (limited to 'core/src/com') diff --git a/core/src/com/ilotterytea/maxoning/MaxonGame.java b/core/src/com/ilotterytea/maxoning/MaxonGame.java index 0ad6a8d..f361d20 100644 --- a/core/src/com/ilotterytea/maxoning/MaxonGame.java +++ b/core/src/com/ilotterytea/maxoning/MaxonGame.java @@ -9,8 +9,6 @@ import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.ilotterytea.maxoning.screens.SplashScreen; import com.ilotterytea.maxoning.utils.I18N; -import java.io.IOException; - public class MaxonGame extends Game { public SpriteBatch batch; public ShapeRenderer shapeRenderer; -- cgit v1.2.3 From 09ad70d85a80779764268d37df533e446ecd37e6 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Sat, 15 Oct 2022 18:33:12 +0200 Subject: custom dank time formatter --- .../com/ilotterytea/maxoning/ui/SaveGameWidget.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'core/src/com') diff --git a/core/src/com/ilotterytea/maxoning/ui/SaveGameWidget.java b/core/src/com/ilotterytea/maxoning/ui/SaveGameWidget.java index d0175b5..2bb4a81 100644 --- a/core/src/com/ilotterytea/maxoning/ui/SaveGameWidget.java +++ b/core/src/com/ilotterytea/maxoning/ui/SaveGameWidget.java @@ -8,9 +8,6 @@ import com.badlogic.gdx.utils.Null; import com.ilotterytea.maxoning.player.MaxonSavegame; import com.ilotterytea.maxoning.utils.formatters.NumberFormatter; -import java.util.Date; - - public class SaveGameWidget extends Button { public SaveGameWidget( Skin skin, @@ -30,9 +27,21 @@ public class SaveGameWidget extends Button { infoTable.add(topleftLabel).width(256f); // Top right label (elapsed time): - Date date = new Date((sav != null) ? sav.elapsedTime : 0); + String time = "--:--"; + + if (sav != null) { + long h = sav.elapsedTime / 1000 / 60 / 60; + long m = sav.elapsedTime / 1000 / 60; + + time = String.format( + "%s:%s", + ((h < 10) ? "0" : "") + h, + ((m < 10) ? "0" : "") + m + ); + } + Label toprightLabel = new Label( - String.format("%s:%s", date.getHours(), date.getMinutes()), + time, skin ); toprightLabel.setAlignment(Align.right); -- cgit v1.2.3 From e2b205209ce7a747f2b41700204da67a6441f9e7 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Sat, 15 Oct 2022 18:46:07 +0200 Subject: Π˜ΡΠΏΡ€Π°Π²Π»Π΅Π½ΠΎ использованиС Π½Π΅ΡΡƒΡ‰Π΅ΡΡ‚Π²ΡƒΡŽΡ‰Π΅ΠΉ ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½ΠΎΠΉ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/src/com/ilotterytea/maxoning/ui/PurchaseItem.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core/src/com') diff --git a/core/src/com/ilotterytea/maxoning/ui/PurchaseItem.java b/core/src/com/ilotterytea/maxoning/ui/PurchaseItem.java index 367dfb9..b8c44f9 100644 --- a/core/src/com/ilotterytea/maxoning/ui/PurchaseItem.java +++ b/core/src/com/ilotterytea/maxoning/ui/PurchaseItem.java @@ -17,7 +17,7 @@ public class PurchaseItem extends Stack { Table summary = new Table(); summary.setHeight(super.getHeight()); - Label title = new Label(String.format("%s\n(%s)", name, string), skin, "purchaseitem_title"); + Label title = new Label(String.format("%s\n(%s)", name, price), skin, "purchaseitem_title"); summary.add(title).fillX().row(); -- cgit v1.2.3