summaryrefslogtreecommitdiff
path: root/core/src/kz/ilotterytea/maxon/ui
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2024-06-01 23:35:01 +0500
committerilotterytea <iltsu@alright.party>2024-06-01 23:35:01 +0500
commit6b8982910d1b0ca259d8e3a3de1072fe673b4217 (patch)
tree2c63466f50b6e3c6284b1f7a39178cedf2d8918a /core/src/kz/ilotterytea/maxon/ui
parentfbb43bc134d4704706c9333ba97d585db75ceb41 (diff)
upd: shop ui style
Diffstat (limited to 'core/src/kz/ilotterytea/maxon/ui')
-rw-r--r--core/src/kz/ilotterytea/maxon/ui/PurchaseItem.java55
1 files changed, 38 insertions, 17 deletions
diff --git a/core/src/kz/ilotterytea/maxon/ui/PurchaseItem.java b/core/src/kz/ilotterytea/maxon/ui/PurchaseItem.java
index 5ef7ab6..e9c69ef 100644
--- a/core/src/kz/ilotterytea/maxon/ui/PurchaseItem.java
+++ b/core/src/kz/ilotterytea/maxon/ui/PurchaseItem.java
@@ -1,60 +1,79 @@
package kz.ilotterytea.maxon.ui;
+import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.ui.*;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.utils.Align;
-import kz.ilotterytea.maxon.MaxonConstants;
import kz.ilotterytea.maxon.player.MaxonItem;
+import kz.ilotterytea.maxon.utils.formatters.NumberFormatter;
public class PurchaseItem extends Table {
private double price;
- private final Label priceLabel;
+ private final Label priceLabel, nameLabel;
private final MaxonItem item;
private boolean isDisabled = false;
+ private final Label.LabelStyle idleStyle, hoverStyle, disabledStyle, availablePriceStyle, disabledPriceStyle;
+
public PurchaseItem(
Skin skin,
- MaxonItem item
+ MaxonItem item,
+ TextureAtlas atlas
) {
super(skin);
- super.setBackground("shop_item");
+ super.setBackground("store_item");
super.align(Align.left | Align.center);
super.add(item.icon).size(64f).pad(6f);
+ this.idleStyle = skin.get("store_item", Label.LabelStyle.class);
+ this.hoverStyle = skin.get("store_item_hover", Label.LabelStyle.class);
+ this.disabledStyle = skin.get("store_item_disabled", Label.LabelStyle.class);
+ this.availablePriceStyle = skin.get("store_item_price", Label.LabelStyle.class);
+ this.disabledPriceStyle = skin.get("store_item_price_disabled", Label.LabelStyle.class);
+
this.price = item.price;
this.item = item;
- Table summary = new Table();
- summary.align(Align.topLeft);
+ Table summary = new Table(skin);
+ summary.align(Align.left);
+
+ this.nameLabel = new Label(item.name, skin, "store_item");
+ nameLabel.setAlignment(Align.left);
+
+ Image priceIcon = new Image(atlas.findRegion("points"));
- Label name = new Label(item.name, skin, "item_title");
- name.setAlignment(Align.left);
+ this.priceLabel = new Label(NumberFormatter.format((long) price), skin, "store_item_price");
+ priceLabel.setAlignment(Align.left);
- this.priceLabel = new Label(String.format("%s SQP (%s/click)", MaxonConstants.DECIMAL_FORMAT.format(price), MaxonConstants.DECIMAL_FORMAT.format(item.multiplier)), skin, "item_price");
- this.priceLabel.setAlignment(Align.left);
+ summary.add(nameLabel).align(Align.left).grow().row();
- summary.add(name).align(Align.left).row();
- summary.add(this.priceLabel).grow();
+ Table priceTable = new Table();
+ priceTable.align(Align.left);
+ priceTable.add(priceIcon).size(16f, 16f).padRight(5f);
+ priceTable.add(priceLabel).grow();
+ summary.add(priceTable).grow();
- super.add(summary).grow();
+ super.add(summary).align(Align.left).grow();
super.addListener(new ClickListener() {
@Override
public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) {
super.enter(event, x, y, pointer, fromActor);
if (!isDisabled) {
- PurchaseItem.super.setBackground("shop_item_hover");
+ nameLabel.setStyle(hoverStyle);
+ PurchaseItem.super.setBackground("store_item_hover");
}
}
@Override
public void exit(InputEvent event, float x, float y, int pointer, Actor toActor) {
super.exit(event, x, y, pointer, toActor);
if (!isDisabled) {
- PurchaseItem.super.setBackground("shop_item");
+ nameLabel.setStyle(idleStyle);
+ PurchaseItem.super.setBackground("store_item");
}
}
});
@@ -62,7 +81,7 @@ public class PurchaseItem extends Table {
public void setPrice(double price) {
this.price = price;
- this.priceLabel.setText(String.format("%s SQP (%s/click)", MaxonConstants.DECIMAL_FORMAT.format(price), MaxonConstants.DECIMAL_FORMAT.format(item.multiplier)));
+ this.priceLabel.setText(NumberFormatter.format((long) price));
}
public double getPrice() {
@@ -76,7 +95,9 @@ public class PurchaseItem extends Table {
public void setDisabled(boolean disabled) {
isDisabled = disabled;
- super.setBackground(isDisabled ? "bg" : "shop_item");
+ priceLabel.setStyle(isDisabled ? disabledPriceStyle : availablePriceStyle);
+ nameLabel.setStyle(isDisabled ? disabledStyle : idleStyle);
+ super.setBackground(isDisabled ? "store_item_disabled" : "store_item");
}
public MaxonItem getItem() {