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 --- .../com/ilotterytea/maxoning/ui/OptionsTable.java | 22 ++++++++-------------- .../com/ilotterytea/maxoning/ui/PurchaseItem.java | 5 ++--- 2 files changed, 10 insertions(+), 17 deletions(-) (limited to 'core/src/com/ilotterytea/maxoning/ui') 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 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/ilotterytea/maxoning/ui') 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 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/ilotterytea/maxoning/ui') 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 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/ilotterytea/maxoning/ui') 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 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/ilotterytea/maxoning/ui') 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 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/ilotterytea/maxoning/ui') 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 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/ilotterytea/maxoning/ui') 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 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/ilotterytea/maxoning/ui') 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 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/ilotterytea/maxoning/ui') 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/ilotterytea/maxoning/ui') 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