Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.badlogic.gdx.graphics.Color;
- import com.badlogic.gdx.math.Vector2;
- import com.badlogic.gdx.scenes.scene2d.Group;
- import com.badlogic.gdx.scenes.scene2d.Touchable;
- import com.badlogic.gdx.scenes.scene2d.ui.Label;
- import com.badlogic.gdx.scenes.scene2d.ui.Table;
- import com.badlogic.gdx.utils.Align;
- import com.badlogic.gdx.utils.Array;
- import com.erow.growpet.common.LabelStyles;
- import com.erow.growpet.ext.DarkGroup;
- import com.erow.growpet.ext.DarkImage;
- import com.erow.growpet.ext.DarkStage;
- /**
- * Created by user on 23.01.17.
- */
- public class ShopViewItem extends Group {
- public DarkImage holder;
- public DarkImage icon;
- public Label name;
- public Label upgrade;
- public Label gives;
- public Group freeGrp;
- public DarkImage freeHolder;
- public DarkImage freeImage;
- public Group priceGrp;
- public DarkImage priceHolder;
- public DarkImage priceImage;
- public Label price;
- public Group superPriceGrp;
- public DarkImage superPriceHolder;
- public DarkImage superPriceImage;
- public Label superPrice;
- private String UPGRADE_TEXT = "UPGRADE ";
- private String GIVES_TEXT = "GIVES ";
- Array<DarkImage> stars = new Array<DarkImage>();
- public ShopViewItem(
- String iconName,
- String nameValue,
- String upgradeValue,
- String givesValue,
- String priceValue,
- String superPriceValue) {
- holder = new DarkImage("shopitemback");
- icon = new DarkImage(iconName);
- name = new Label(nameValue, LabelStyles.shopName30);
- upgrade = new Label(UPGRADE_TEXT + upgradeValue, LabelStyles.shopCountGives25);
- gives = new Label(GIVES_TEXT + givesValue, LabelStyles.shopCountGives25);
- freeHolder = new DarkImage("pan_freet");
- freeImage = new DarkImage("shopitemfree");
- priceHolder = new DarkImage("pan_forheart");
- priceImage = new DarkImage("shopitemprice");
- price = new Label(priceValue, LabelStyles.whiteFont30);
- superPriceHolder = new DarkImage("pan_fortopaz");
- superPriceImage = new DarkImage("shopitemsuperprice");
- superPrice = new Label(superPriceValue, LabelStyles.whiteFont30);
- for(int i = 0; i < 5; i++)
- stars.add(new DarkImage("star"));
- //--------------------
- setSize(holder.getWidth(), holder.getHeight() + priceImage.getHeight()/2 + 20);
- holder.setPosition(0, priceImage.getHeight()/2 + 20);
- price.setTouchable(Touchable.disabled);
- superPrice.setTouchable(Touchable.disabled);
- price.setAlignment(Align.right);
- superPrice.setAlignment(Align.right);
- priceImage.setOrigin(Align.center);
- superPriceImage.setOrigin(Align.center);
- icon.setPosition(95, holder.getY(Align.center) + 13, Align.center);
- name.setPosition(icon.getX(Align.right) + 50, holder.getY(Align.top) - 23, Align.topLeft);
- upgrade.setPosition(name.getX(), name.getY() + 5, Align.topLeft);
- gives.setPosition(name.getX(), upgrade.getY() + 5, Align.topLeft);
- priceImage.setPosition(holder.getX(Align.right), holder.getY(), Align.right);
- superPriceImage.setPosition(priceImage.getX() - 20, holder.getY(), Align.right);
- price.setPosition(priceImage.getX(Align.right) - 30, priceImage.getY(Align.center), Align.right);
- superPrice.setPosition(superPriceImage.getX(Align.right) - 30,superPriceImage.getY(Align.center), Align.right);
- freeImage.setPosition(superPriceImage.getX() - 30, superPriceImage.getY(Align.center), Align.right);
- priceHolder.setPosition(priceImage.getX(Align.center), priceImage.getY(Align.center), Align.center);
- superPriceHolder.setPosition(superPriceImage.getX(Align.center), superPriceImage.getY(Align.center), Align.center);
- freeHolder.setPosition(freeImage.getX(Align.center), freeImage.getY(Align.center), Align.center);
- DarkImage lastStar = stars.peek();
- lastStar.setPosition(holder.getX(Align.right) - 40, name.getY(Align.center), Align.right);
- Vector2 lastPos = new Vector2(lastStar.getX(Align.left), lastStar.getY(Align.center));
- for(int i = stars.size - 2; i >= 0; i--) {
- DarkImage star = stars.get(i);
- star.setPosition(lastPos.x, lastPos.y, Align.right);
- lastPos. x = star.getX(Align.left);
- }
- freeGrp = new Group();
- freeGrp.addActor(freeHolder);
- freeGrp.addActor(freeImage);
- priceGrp = new Group();
- priceGrp.addActor(priceHolder);
- priceGrp.addActor(priceImage);
- priceGrp.addActor(price);
- superPriceGrp = new Group();
- superPriceGrp.addActor(superPriceHolder);
- superPriceGrp.addActor(superPriceImage);
- superPriceGrp.addActor(superPrice);
- addActor(holder);
- addActor(icon);
- addActor(name);
- addActor(upgrade);
- addActor(gives);
- addActor(priceGrp);
- addActor(superPriceGrp);
- addActor(freeGrp);
- for(DarkImage star : stars) {
- addActor(star);
- star.setVisible(false);
- }
- }
- public void setUpgrade(String upgradeValue) {
- upgrade.setText(UPGRADE_TEXT + upgradeValue);
- }
- public void setGives(String givesValue) {
- gives.setText(GIVES_TEXT + givesValue);
- }
- public void setStars(boolean visible, int starsCount) {
- for(int i = 0; i < stars.size; i++) {
- DarkImage star = stars.get(i);
- boolean open = ((i + 1) <= starsCount);
- star.setColor(open ? Color.WHITE : Color.BLUE);
- star.setVisible(visible);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement