summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2024-06-10 02:30:27 +0500
committerilotterytea <iltsu@alright.party>2024-06-10 02:30:27 +0500
commit8af98ac84fdcef1295fbc82137d6b65a703d4388 (patch)
treeb058b75347da59e45c4d02e076f6fb6464ea67b7 /core
parentb7736a15442cee4c56ee8d0badeaf4201ed69a6d (diff)
feat: show tooltips for pets
Diffstat (limited to 'core')
-rw-r--r--core/src/kz/ilotterytea/maxon/pets/PetWidget.java23
1 files changed, 23 insertions, 0 deletions
diff --git a/core/src/kz/ilotterytea/maxon/pets/PetWidget.java b/core/src/kz/ilotterytea/maxon/pets/PetWidget.java
index 01a9dc0..41f25dc 100644
--- a/core/src/kz/ilotterytea/maxon/pets/PetWidget.java
+++ b/core/src/kz/ilotterytea/maxon/pets/PetWidget.java
@@ -6,11 +6,14 @@ 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.utils.formatters.NumberFormatter;
public class PetWidget extends Table {
private double price;
+ private final Skin skin;
private final Label priceLabel, nameLabel;
+ private TextTooltip priceTooltip, nameTooltip;
private final Pet pet;
private boolean isDisabled = false;
@@ -26,6 +29,7 @@ public class PetWidget extends Table {
super.setBackground("store_item");
super.align(Align.left | Align.center);
this.pet = pet;
+ this.skin = skin;
super.add(pet.getIcon()).size(64f).pad(6f);
@@ -43,11 +47,19 @@ public class PetWidget extends Table {
this.nameLabel = new Label(pet.getName(), skin, "store_item");
nameLabel.setAlignment(Align.left);
+ this.nameTooltip = new TextTooltip(pet.getDescription(), skin);
+ nameTooltip.setInstant(true);
+ nameLabel.addListener(nameTooltip);
+
Image priceIcon = new Image(atlas.findRegion("points"));
this.priceLabel = new Label(NumberFormatter.format((long) price), skin, "store_item_price");
priceLabel.setAlignment(Align.left);
+ priceTooltip = new TextTooltip(MaxonConstants.DECIMAL_FORMAT.format(pet.getPrice()), skin);
+ priceTooltip.setInstant(true);
+ priceLabel.addListener(priceTooltip);
+
summary.add(nameLabel).align(Align.left).grow().row();
Table priceTable = new Table();
@@ -79,8 +91,19 @@ public class PetWidget extends Table {
}
public void setPrice(double price) {
+ if (price == this.price) {
+ return;
+ }
+
this.price = price;
this.priceLabel.setText(NumberFormatter.format((long) price));
+
+ priceTooltip.hide();
+ this.priceTooltip = new TextTooltip(MaxonConstants.DECIMAL_FORMAT.format(price), skin);
+ priceTooltip.setInstant(true);
+
+ priceLabel.clearListeners();
+ priceLabel.addListener(priceTooltip);
}
public double getPrice() {