mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
update itemSprite, update items
This commit is contained in:
@@ -2,14 +2,11 @@ package forge.adventure.data;
|
||||
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.graphics.g2d.Sprite;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Json;
|
||||
import forge.adventure.util.Config;
|
||||
import forge.adventure.util.Paths;
|
||||
|
||||
import static forge.adventure.util.Paths.ITEMS_ATLAS;
|
||||
|
||||
/**
|
||||
* Data class that will be used to read Json configuration files
|
||||
* ItemData
|
||||
@@ -49,16 +46,9 @@ public class ItemData {
|
||||
shardsNeeded = cpy.shardsNeeded;
|
||||
}
|
||||
|
||||
public Sprite sprite()
|
||||
{
|
||||
if(itemAtlas==null)
|
||||
{
|
||||
itemAtlas=Config.instance().getAtlas(ITEMS_ATLAS);
|
||||
}
|
||||
return itemAtlas.createSprite(iconName);
|
||||
public Sprite sprite() {
|
||||
return Config.instance().getItemSprite(iconName);
|
||||
}
|
||||
|
||||
private static TextureAtlas itemAtlas;
|
||||
private static Array<ItemData> itemList;
|
||||
public static Array<ItemData> getAllItems() {
|
||||
if (itemList == null) {
|
||||
|
||||
@@ -2,7 +2,6 @@ package forge.adventure.scene;
|
||||
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.Sprite;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.*;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
@@ -24,8 +23,6 @@ import forge.deck.Deck;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static forge.adventure.util.Paths.ITEMS_ATLAS;
|
||||
|
||||
public class InventoryScene extends UIScene {
|
||||
TextraButton leave;
|
||||
Button equipButton;
|
||||
@@ -350,8 +347,7 @@ public class InventoryScene extends UIScene {
|
||||
System.err.print("Can not add null / empty booster " + Current.player().getBoostersOwned().get(i) + "\n");
|
||||
continue;
|
||||
}
|
||||
TextureAtlas atlas = Config.instance().getAtlas(ITEMS_ATLAS);
|
||||
Sprite deckSprite = atlas.createSprite("Deck");
|
||||
Sprite deckSprite = Config.instance().getItemSprite("Deck");
|
||||
|
||||
Image img = new Image(deckSprite);
|
||||
img.setX((newActor.getWidth() - img.getWidth()) / 2);
|
||||
|
||||
@@ -518,9 +518,9 @@ public class RewardScene extends UIScene {
|
||||
if (Type.Shop != type)
|
||||
return;
|
||||
if (collectionPool != null && Reward.Type.Card.equals(reward.getType()))
|
||||
setText("[%75]" + price + " [+Gold]\n" + Forge.getLocalizer().getMessage("lblOwned") + ": " + collectionPool.count(reward.getCard()));
|
||||
setText("[%75][+GoldCoin] " + price + "\n" + Forge.getLocalizer().getMessage("lblOwned") + ": " + collectionPool.count(reward.getCard()));
|
||||
else if (Reward.Type.Item.equals(reward.getType()))
|
||||
setText("[%75]" + price + " [+Gold]\n" + Forge.getLocalizer().getMessage("lblOwned") + ": " + AdventurePlayer.current().countItem(reward.getItem().name));
|
||||
setText("[%75][+GoldCoin] " + price + "\n" + Forge.getLocalizer().getMessage("lblOwned") + ": " + AdventurePlayer.current().countItem(reward.getItem().name));
|
||||
}
|
||||
|
||||
public BuyButton(int id, int i, RewardActor actor, Reward reward, TextraButton style, float shopModifier) {
|
||||
@@ -536,7 +536,7 @@ public class RewardScene extends UIScene {
|
||||
price = CardUtil.getRewardPrice(actor.getReward());
|
||||
price *= Current.player().goldModifier();
|
||||
price *= shopModifier;
|
||||
setText(price + " [+Gold]");
|
||||
setText("[+GoldCoin] " + price);
|
||||
updateOwned();
|
||||
addListener(new ClickListener() {
|
||||
@Override
|
||||
|
||||
@@ -6,12 +6,11 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.github.tommyettinger.textra.TextraLabel;
|
||||
import forge.adventure.data.BiomeSpriteData;
|
||||
import forge.adventure.pointofintrest.PointOfInterest;
|
||||
import forge.adventure.pointofintrest.PointOfInterestChanges;
|
||||
import forge.adventure.scene.MapViewScene;
|
||||
import forge.adventure.util.Controls;
|
||||
import forge.adventure.util.Config;
|
||||
import forge.adventure.world.WorldSave;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
@@ -25,8 +24,8 @@ public class MapSprite extends Actor {
|
||||
static public int BackgroundLayer = -1;
|
||||
static public int SpriteLayer = 0;
|
||||
TextureRegion texture;
|
||||
TextraLabel searchPost = Controls.newTextraLabel("[%80][+SearchPost]");
|
||||
Sprite bookmark = Controls.getSprite("Star");
|
||||
Sprite bookmark = Config.instance().getItemSprite("Star");
|
||||
Sprite magnifier = Config.instance().getItemSprite("Magnifier");
|
||||
boolean isCaveDungeon, isOldorVisited, isBookmarked;
|
||||
public MapSprite(Vector2 pos, TextureRegion sprite, PointOfInterest point) {
|
||||
if (point != null) {
|
||||
@@ -87,9 +86,10 @@ public class MapSprite extends Actor {
|
||||
if (texture == null)
|
||||
return;
|
||||
batch.draw(texture, getX(), getY());
|
||||
if (isCaveDungeon && !isOldorVisited) {
|
||||
searchPost.setPosition(getX() - 7, getY() + 7);
|
||||
searchPost.draw(batch, parentAlpha);
|
||||
if (isCaveDungeon && !isOldorVisited && magnifier != null) {
|
||||
magnifier.setScale(0.7f, 0.7f);
|
||||
magnifier.setPosition(getX() - 7, getY() + 2);
|
||||
magnifier.draw(batch, parentAlpha);
|
||||
}
|
||||
if (isBookmarked && bookmark != null) {
|
||||
bookmark.setScale(0.7f, 0.7f);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package forge.adventure.util;
|
||||
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.graphics.g2d.Sprite;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Json;
|
||||
@@ -50,6 +51,7 @@ public class Config {
|
||||
private SettingData settingsData;
|
||||
private String Lang = "en-us";
|
||||
private final String plane;
|
||||
private ObjectMap<String, Sprite> itemSprites = new ObjectMap<>();
|
||||
|
||||
static public Config instance() {
|
||||
if (currentConfig == null)
|
||||
@@ -245,6 +247,15 @@ public class Config {
|
||||
return atlas;
|
||||
}
|
||||
|
||||
public Sprite getItemSprite(String itemName) {
|
||||
Sprite sprite = itemSprites.get(itemName);
|
||||
if (sprite == null) {
|
||||
sprite = getAtlas(forge.adventure.util.Paths.ITEMS_ATLAS).createSprite(itemName);
|
||||
if (sprite != null)
|
||||
itemSprites.put(itemName, sprite);
|
||||
}
|
||||
return sprite;
|
||||
}
|
||||
public SettingData getSettingData() {
|
||||
return settingsData;
|
||||
}
|
||||
|
||||
@@ -429,10 +429,6 @@ public class Controls {
|
||||
return Forge.getAssets().getTextraFont(name, getSkin().getFont(name), Config.instance().getAtlas(Paths.ITEMS_ATLAS));
|
||||
}
|
||||
|
||||
static public Sprite getSprite(String itemSprite) {
|
||||
return Config.instance().getAtlas(Paths.ITEMS_ATLAS).createSprite(itemSprite);
|
||||
}
|
||||
|
||||
static public class AccountingLabel extends TextraLabel {
|
||||
private TextraLabel label;
|
||||
private final TextraLabel placeholder;
|
||||
|
||||
@@ -50,8 +50,6 @@ import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static forge.adventure.util.Paths.ITEMS_ATLAS;
|
||||
|
||||
/**
|
||||
* Render the rewards as a card on the reward scene.
|
||||
*/
|
||||
@@ -296,8 +294,7 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
|
||||
break;
|
||||
}
|
||||
case Item: {
|
||||
TextureAtlas atlas = Config.instance().getAtlas(ITEMS_ATLAS);
|
||||
Sprite backSprite = atlas.createSprite("CardBack");
|
||||
Sprite backSprite = Config.instance().getItemSprite("CardBack");
|
||||
if (reward.getItem() == null) {
|
||||
needsToBeDisposed = true;
|
||||
processSprite(backSprite, null, null, 0, 0, false);
|
||||
@@ -311,8 +308,7 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
|
||||
break;
|
||||
}
|
||||
case CardPack: {
|
||||
TextureAtlas atlas = Config.instance().getAtlas(ITEMS_ATLAS);
|
||||
Sprite backSprite = atlas.createSprite("CardBack");
|
||||
Sprite backSprite = Config.instance().getItemSprite("CardBack");
|
||||
if (reward.getDeck() == null) {
|
||||
needsToBeDisposed = true;
|
||||
processSprite(backSprite, null, null, 0, 0, false);
|
||||
@@ -342,7 +338,7 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
|
||||
item = new Sprite(new TextureRegion(t));
|
||||
isBooster = true;
|
||||
} else {
|
||||
item = atlas.createSprite("Deck");
|
||||
item = Config.instance().getItemSprite("Deck");
|
||||
}
|
||||
|
||||
setItemTooltips(item, backSprite, isBooster);
|
||||
@@ -356,9 +352,8 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
|
||||
case Life:
|
||||
case Shards:
|
||||
case Gold: {
|
||||
TextureAtlas atlas = Config.instance().getAtlas(ITEMS_ATLAS);
|
||||
Sprite backSprite = atlas.createSprite("CardBack");
|
||||
Sprite item = atlas.createSprite(reward.type.toString());
|
||||
Sprite backSprite = Config.instance().getItemSprite("CardBack");
|
||||
Sprite item = Config.instance().getItemSprite(reward.type.toString());
|
||||
setItemTooltips(item, backSprite, false);
|
||||
boolean isShop = RewardScene.Type.Shop.equals(type);
|
||||
processSprite(backSprite, item, isShop ? null :
|
||||
|
||||
@@ -444,6 +444,12 @@ GreenLeaf
|
||||
GreenLeaf2
|
||||
xy: 112, 608
|
||||
size: 16, 16
|
||||
GoldCoin
|
||||
xy: 464, 63
|
||||
size: 16, 16
|
||||
Magnifier
|
||||
xy: 448, 63
|
||||
size: 16, 16
|
||||
Bookmark
|
||||
xy: 432, 63
|
||||
size: 16, 16
|
||||
@@ -465,6 +471,9 @@ GPS
|
||||
Star
|
||||
xy: 464, 16
|
||||
size: 16, 16
|
||||
TreasureChest
|
||||
xy: 464, 32
|
||||
size: 16, 16
|
||||
UnderworldCookbook
|
||||
xy: 304, 960
|
||||
size: 16, 16
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 274 KiB After Width: | Height: | Size: 275 KiB |
Reference in New Issue
Block a user