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