summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2024-05-28 23:07:48 +0500
committerilotterytea <iltsu@alright.party>2024-05-28 23:07:48 +0500
commitd1d599552a0253c2637cc270642564c2ec55b7db (patch)
tree042023ebb669f555ffc79e937026500211de2ce4
parent353377e482d0f887019797a01229b9032ea36dd2 (diff)
fix: incorrect shop ui position and size
-rw-r--r--core/src/com/ilotterytea/maxoning/screens/GameScreen.java7
-rw-r--r--core/src/com/ilotterytea/maxoning/screens/game/shop/ShopUI.java48
2 files changed, 26 insertions, 29 deletions
diff --git a/core/src/com/ilotterytea/maxoning/screens/GameScreen.java b/core/src/com/ilotterytea/maxoning/screens/GameScreen.java
index f514ae3..1573600 100644
--- a/core/src/com/ilotterytea/maxoning/screens/GameScreen.java
+++ b/core/src/com/ilotterytea/maxoning/screens/GameScreen.java
@@ -72,6 +72,8 @@ public class GameScreen implements Screen, InputProcessor {
MovingChessBackground bg;
Playlist playlist;
+ private ShopUI shopUI;
+
private SceneManager sceneManager;
private PerspectiveCamera camera;
@@ -291,6 +293,7 @@ public class GameScreen implements Screen, InputProcessor {
public void resize(int width, int height) {
this.stage.getViewport().update(width, height, true);
sceneManager.updateViewport(width, height);
+ this.shopUI.update();
}
private void showShop() {
@@ -534,12 +537,12 @@ 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);
- ShopUI shopUI = new ShopUI(this.stage, this.skin, this.mainAtlas);
+ this.shopUI = new ShopUI(this.stage, this.skin, this.mainAtlas);
- shopUI.createSavegameUI(this.player);
shopUI.createShopTitleUI();
shopUI.createShopControlUI();
shopUI.createShopListUI(this.player);
+ shopUI.createSavegameUI(this.player);
}
@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 a691045..fa52c01 100644
--- a/core/src/com/ilotterytea/maxoning/screens/game/shop/ShopUI.java
+++ b/core/src/com/ilotterytea/maxoning/screens/game/shop/ShopUI.java
@@ -16,7 +16,7 @@ import com.ilotterytea.maxoning.utils.math.Math;
import java.util.ArrayList;
public class ShopUI {
- private final Stage stage;
+ private final Table table, mainTable;
private final Skin skin;
private final TextureAtlas atlas;
private final ArrayList<MaxonItem> items;
@@ -25,20 +25,26 @@ public class ShopUI {
private ShopMultiplier multiplier;
public ShopUI(Stage stage, Skin skin, TextureAtlas atlas) {
- this.stage = stage;
this.skin = skin;
this.atlas = atlas;
this.mode = ShopMode.BUY;
this.multiplier = ShopMultiplier.X1;
this.items = MaxonItemRegister.getItems();
+
+ this.table = new Table(skin);
+ this.table.setBackground("board");
+
+ this.mainTable = new Table(this.skin);
+ mainTable.setFillParent(true);
+ mainTable.align(Align.center | Align.left);
+
+ mainTable.add(this.table).growY().width(Math.percentFromValue(25f, Gdx.graphics.getWidth()));
+ stage.addActor(mainTable);
}
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.align(Align.center | Align.left);
table.pad(10f);
@@ -64,32 +70,24 @@ public class ShopUI {
table.add(multiplierTable);
- this.stage.addActor(table);
+ this.table.add(table).grow();
}
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.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);
+ this.table.add(table).grow().row();
}
public void createShopControlUI() {
Table table = new Table(this.skin);
- table.setBackground("board");
- table.setWidth(Math.percentFromValue(25f, Gdx.graphics.getWidth()));
- table.setHeight(Math.percentFromValue(10f, Gdx.graphics.getHeight()));
- table.setY(Gdx.graphics.getHeight() - table.getHeight() - Math.percentFromValue(5f, Gdx.graphics.getHeight()));
table.align(Align.center);
table.pad(10f);
@@ -143,18 +141,12 @@ public class ShopUI {
table.add(multiplierTable).grow();
- this.stage.addActor(table);
+ this.table.add(table).grow().row();
}
public void createShopListUI(final MaxonSavegame player) {
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 (final MaxonItem item : this.items) {
int amount = (int) player.inv.stream().filter(c -> c == item.id).count();
@@ -162,19 +154,21 @@ public class ShopUI {
item.price = (float) price;
PurchaseItem purchaseItem = new PurchaseItem(this.skin, item);
- table.add(purchaseItem).width(table.getWidth()).padBottom(5f).row();
+ table.add(purchaseItem).growX().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);
+ this.table.add(scrollPaneTable).grow().row();
+ }
+
+ public void update() {
+ this.mainTable.clear();
+ this.mainTable.add(this.table).growY().width(Math.percentFromValue(30f, Gdx.graphics.getWidth()));
}
}