diff options
| author | ilotterytea <iltsu@alright.party> | 2024-04-28 13:21:50 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2024-04-28 13:21:50 +0500 |
| commit | b751f59e4297c6f4a94bfa544fda975d4e2a176a (patch) | |
| tree | 920112c85c61ef095e1b066cccbc3713206a5761 /core | |
| parent | 01cbb6d0cfd0d58c5144bf746ec2a7ddd3beb6c3 (diff) | |
upd: moved shop ui stuff to the dedicated class
Diffstat (limited to 'core')
| -rw-r--r-- | core/src/com/ilotterytea/maxoning/screens/GameScreen.java | 57 | ||||
| -rw-r--r-- | core/src/com/ilotterytea/maxoning/screens/game/shop/ShopUI.java | 76 |
2 files changed, 80 insertions, 53 deletions
diff --git a/core/src/com/ilotterytea/maxoning/screens/GameScreen.java b/core/src/com/ilotterytea/maxoning/screens/GameScreen.java index 047aff5..77aea43 100644 --- a/core/src/com/ilotterytea/maxoning/screens/GameScreen.java +++ b/core/src/com/ilotterytea/maxoning/screens/GameScreen.java @@ -26,6 +26,7 @@ import com.ilotterytea.maxoning.player.DecalPlayer; import com.ilotterytea.maxoning.player.MaxonItem; import com.ilotterytea.maxoning.player.MaxonItemRegister; import com.ilotterytea.maxoning.player.MaxonSavegame; +import com.ilotterytea.maxoning.screens.game.shop.ShopUI; import com.ilotterytea.maxoning.ui.*; import com.ilotterytea.maxoning.utils.math.Math; import com.ilotterytea.maxoning.utils.serialization.GameDataSystem; @@ -533,60 +534,10 @@ public class GameScreen implements Screen, InputProcessor { this.skin = this.game.assetManager.get("MainSpritesheet.skin", Skin.class); this.mainAtlas = this.game.assetManager.get("MainSpritesheet.atlas", TextureAtlas.class); - createSavegameUI(); - createShopTitleUI(); - } - - private void createSavegameUI() { - Table table = new Table(this.skin); - table.setBackground("board"); - - table.setWidth(Math.percentFromValue(25f, Gdx.graphics.getWidth())); - table.setHeight(Math.percentFromValue(15f, Gdx.graphics.getHeight())); - table.setX(Gdx.graphics.getWidth() - table.getWidth()); - table.align(Align.center | Align.left); - table.pad(10f); - - // Setting up the points - Table pointsTable = new Table(); - - Image pointsImage = new Image(this.mainAtlas.findRegion("points")); - Label pointsLabel = new Label(String.valueOf(this.player.points), this.skin); - - pointsTable.add(pointsImage); - pointsTable.add(pointsLabel).padLeft(15f); - - table.add(pointsTable).padBottom(10f).row(); - - // Setting up the multiplier - Table multiplierTable = new Table(); - - Image multiplierImage = new Image(this.mainAtlas.findRegion("multiplier")); - Label multiplierLabel = new Label(String.format("%s/s", this.player.multiplier), this.skin); - - multiplierTable.add(multiplierImage); - multiplierTable.add(multiplierLabel).padLeft(15f); - - table.add(multiplierTable); - - this.stage.addActor(table); - } - - private void createShopTitleUI() { - Table table = new Table(this.skin); - table.setBackground("board"); - - table.setWidth(Math.percentFromValue(25f, Gdx.graphics.getWidth())); - table.setHeight(Math.percentFromValue(5f, Gdx.graphics.getHeight())); - table.setX(Gdx.graphics.getWidth() - table.getWidth()); - table.setY(Gdx.graphics.getHeight() - table.getHeight()); - table.align(Align.center); - table.pad(10f); - - Label label = new Label("Store", skin); - table.add(label); + ShopUI shopUI = new ShopUI(this.stage, this.skin, this.mainAtlas); - this.stage.addActor(table); + shopUI.createSavegameUI(this.player); + shopUI.createShopTitleUI(); } @Override diff --git a/core/src/com/ilotterytea/maxoning/screens/game/shop/ShopUI.java b/core/src/com/ilotterytea/maxoning/screens/game/shop/ShopUI.java new file mode 100644 index 0000000..943d634 --- /dev/null +++ b/core/src/com/ilotterytea/maxoning/screens/game/shop/ShopUI.java @@ -0,0 +1,76 @@ +package com.ilotterytea.maxoning.screens.game.shop; + +import com.badlogic.gdx.Gdx; +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.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.ilotterytea.maxoning.player.MaxonSavegame; +import com.ilotterytea.maxoning.utils.math.Math; + +public class ShopUI { + private final Stage stage; + private final Skin skin; + private final TextureAtlas atlas; + + public ShopUI(Stage stage, Skin skin, TextureAtlas atlas) { + this.stage = stage; + this.skin = skin; + this.atlas = atlas; + } + + public void createSavegameUI(final MaxonSavegame player) { + Table table = new Table(this.skin); + table.setBackground("board"); + + table.setWidth(Math.percentFromValue(25f, Gdx.graphics.getWidth())); + table.setHeight(Math.percentFromValue(15f, Gdx.graphics.getHeight())); + table.setX(Gdx.graphics.getWidth() - table.getWidth()); + table.align(Align.center | Align.left); + table.pad(10f); + + // Setting up the points + Table pointsTable = new Table(); + + Image pointsImage = new Image(this.atlas.findRegion("points")); + Label pointsLabel = new Label(String.valueOf(player.points), this.skin); + + pointsTable.add(pointsImage); + pointsTable.add(pointsLabel).padLeft(15f); + + table.add(pointsTable).padBottom(10f).row(); + + // Setting up the multiplier + Table multiplierTable = new Table(); + + Image multiplierImage = new Image(this.atlas.findRegion("multiplier")); + Label multiplierLabel = new Label(String.format("%s/s", player.multiplier), this.skin); + + multiplierTable.add(multiplierImage); + multiplierTable.add(multiplierLabel).padLeft(15f); + + table.add(multiplierTable); + + this.stage.addActor(table); + } + + public void createShopTitleUI() { + Table table = new Table(this.skin); + table.setBackground("board"); + + table.setWidth(Math.percentFromValue(25f, Gdx.graphics.getWidth())); + table.setHeight(Math.percentFromValue(5f, Gdx.graphics.getHeight())); + table.setX(Gdx.graphics.getWidth() - table.getWidth()); + table.setY(Gdx.graphics.getHeight() - table.getHeight()); + table.align(Align.center); + table.pad(10f); + + Label label = new Label("Store", skin); + table.add(label); + + this.stage.addActor(table); + } +} |
