diff options
Diffstat (limited to 'core/src/com/ilotterytea/maxoning/ui')
5 files changed, 136 insertions, 22 deletions
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())); } } 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); + } +} 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..b8c44f9 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 + String price ) { - super(new Image(ninepatch)); + super(new Image(widgetSkin, "up")); Table summary = new Table(); summary.setHeight(super.getHeight()); 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..2bb4a81 --- /dev/null +++ b/core/src/com/ilotterytea/maxoning/ui/SaveGameWidget.java @@ -0,0 +1,90 @@ +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; +import com.ilotterytea.maxoning.player.MaxonSavegame; +import com.ilotterytea.maxoning.utils.formatters.NumberFormatter; + +public class SaveGameWidget extends Button { + public SaveGameWidget( + Skin skin, + Skin widgetSkin, + @Null MaxonSavegame sav + ) { + // Setting the stack: + super(widgetSkin, "slot"); + + // // // Save slot data: + // // Info row: + Table infoTable = new Table(); + + // 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 (elapsed time): + 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( + time, + skin + ); + toprightLabel.setAlignment(Align.right); + infoTable.add(toprightLabel).width(256f); + + // // Description row: + Table descTable = new Table(); + + // Bottom left label (purchased items): + Label bottomleftLabel = new Label( + String.format( + "%s purchased items", + (sav != null) ? sav.inv.size() : "?" + ), + skin + ); + bottomleftLabel.setAlignment(Align.left); + descTable.add(bottomleftLabel).width(256f); + + // Bottom right label (points/multiplier): + Label pointsLabel = new Label( + String.format( + "%s$/x%s", + (sav != null) ? NumberFormatter.format(sav.points) : "---", + (sav != null) ? NumberFormatter.format(sav.multiplier) : "0" + ), + 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(); + + 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); + } +} |
