diff options
| author | ilotterytea <iltsu@alright.party> | 2024-04-28 14:10:14 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2024-04-28 14:10:14 +0500 |
| commit | fedb6bb73e4e6b365a8da41529259bb9bfb1ef81 (patch) | |
| tree | 7019c0e3aa9dd4de2b82ef0e2c8300c26cbe9244 /core | |
| parent | 17019f442934c0a7b9365445a8ab4d975eeb6eb5 (diff) | |
feat: shop list ui
Diffstat (limited to 'core')
| -rw-r--r-- | core/src/com/ilotterytea/maxoning/screens/GameScreen.java | 1 | ||||
| -rw-r--r-- | core/src/com/ilotterytea/maxoning/screens/game/shop/ShopUI.java | 38 |
2 files changed, 36 insertions, 3 deletions
diff --git a/core/src/com/ilotterytea/maxoning/screens/GameScreen.java b/core/src/com/ilotterytea/maxoning/screens/GameScreen.java index 5044b67..555e87e 100644 --- a/core/src/com/ilotterytea/maxoning/screens/GameScreen.java +++ b/core/src/com/ilotterytea/maxoning/screens/GameScreen.java @@ -539,6 +539,7 @@ public class GameScreen implements Screen, InputProcessor { shopUI.createSavegameUI(this.player); shopUI.createShopTitleUI(); shopUI.createShopControlUI(); + shopUI.createShopListUI(); } @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 index 8cdb2e8..2203ad9 100644 --- a/core/src/com/ilotterytea/maxoning/screens/game/shop/ShopUI.java +++ b/core/src/com/ilotterytea/maxoning/screens/game/shop/ShopUI.java @@ -7,13 +7,19 @@ import com.badlogic.gdx.scenes.scene2d.Stage; 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.player.MaxonItem; +import com.ilotterytea.maxoning.player.MaxonItemRegister; import com.ilotterytea.maxoning.player.MaxonSavegame; +import com.ilotterytea.maxoning.ui.PurchaseItem; import com.ilotterytea.maxoning.utils.math.Math; +import java.util.ArrayList; + public class ShopUI { private final Stage stage; private final Skin skin; private final TextureAtlas atlas; + private final ArrayList<MaxonItem> items; private ShopMode mode; private ShopMultiplier multiplier; @@ -24,6 +30,7 @@ public class ShopUI { this.atlas = atlas; this.mode = ShopMode.BUY; this.multiplier = ShopMultiplier.X1; + this.items = MaxonItemRegister.getItems(); } public void createSavegameUI(final MaxonSavegame player) { @@ -32,7 +39,6 @@ public class ShopUI { 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); @@ -67,7 +73,6 @@ public class ShopUI { 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); @@ -84,7 +89,6 @@ public class ShopUI { table.setWidth(Math.percentFromValue(25f, Gdx.graphics.getWidth())); table.setHeight(Math.percentFromValue(10f, Gdx.graphics.getHeight())); - table.setX(Gdx.graphics.getWidth() - table.getWidth()); table.setY(Gdx.graphics.getHeight() - table.getHeight() - Math.percentFromValue(5f, Gdx.graphics.getHeight())); table.align(Align.center); table.pad(10f); @@ -141,4 +145,32 @@ public class ShopUI { this.stage.addActor(table); } + + public void createShopListUI() { + Table table = new Table(); + + table.setWidth(Math.percentFromValue(25f, Gdx.graphics.getWidth())); + table.setHeight(Math.percentFromValue(70f, Gdx.graphics.getHeight())); + table.setY(Math.percentFromValue(15f, Gdx.graphics.getHeight())); + table.align(Align.center); + table.pad(10f); + + for (MaxonItem item : this.items) { + PurchaseItem purchaseItem = new PurchaseItem(this.skin, item); + + table.add(purchaseItem).width(table.getWidth()).padBottom(5f).row(); + } + + ScrollPane scrollPane = new ScrollPane(table); + scrollPane.setScrollingDisabled(true, false); + + Table scrollPaneTable = new Table(this.skin); + scrollPaneTable.setBackground("shop_list"); + scrollPaneTable.setPosition(table.getX(), table.getY()); + scrollPaneTable.setSize(table.getWidth(), table.getHeight()); + scrollPaneTable.pad(1f, 5f, 1f, 5f); + scrollPaneTable.add(scrollPane).grow(); + + this.stage.addActor(scrollPaneTable); + } } |
