mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-12 08:48:39 +00:00
Merge pull request #2753 from kevlahnota/newmaster2
update PlayerStatisticScene, update filters
This commit is contained in:
@@ -57,7 +57,7 @@
|
||||
<dependency>
|
||||
<groupId>com.github.tommyettinger</groupId>
|
||||
<artifactId>textratypist</artifactId>
|
||||
<version>0.8.1</version>
|
||||
<version>0.8.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.badlogicgames.gdx-controllers</groupId>
|
||||
|
||||
@@ -28,6 +28,7 @@ import forge.card.ColorSet;
|
||||
import forge.game.GameType;
|
||||
import forge.localinstance.achievements.Achievement;
|
||||
import forge.localinstance.achievements.AchievementCollection;
|
||||
import forge.localinstance.achievements.PlaneswalkerAchievements;
|
||||
import forge.model.FModel;
|
||||
import forge.player.GamePlayerUtil;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
@@ -35,9 +36,9 @@ import org.apache.commons.lang3.tuple.Pair;
|
||||
import java.util.Map;
|
||||
|
||||
public class PlayerStatisticScene extends UIScene {
|
||||
Image avatar, avatarBorder, lifeIcon, goldIcon;
|
||||
Image avatar, avatarBorder;
|
||||
Image colorFrame;
|
||||
TextraLabel money, life;
|
||||
TextraLabel money, life, shards;
|
||||
TextraLabel wins, totalWins;
|
||||
TextraLabel loss, totalLoss;
|
||||
TextraLabel winloss, lossWinRatio;
|
||||
@@ -48,7 +49,6 @@ public class PlayerStatisticScene extends UIScene {
|
||||
ScrollPane scroller;
|
||||
Table root;
|
||||
boolean toggle = false;
|
||||
AchievementCollection achievements;
|
||||
|
||||
private PlayerStatisticScene() {
|
||||
super(Forge.isLandscapeMode() ? "ui/statistic.json" : "ui/statistic_portrait.json");
|
||||
@@ -65,8 +65,7 @@ public class PlayerStatisticScene extends UIScene {
|
||||
playerName = ui.findActor("playerName");
|
||||
life = ui.findActor("lifePoints");
|
||||
money = ui.findActor("money");
|
||||
lifeIcon = ui.findActor("lifeIcon");
|
||||
goldIcon = ui.findActor("goldIcon");
|
||||
shards = ui.findActor("shards");
|
||||
wins = ui.findActor("wins");
|
||||
colorFrame = ui.findActor("colorFrame");
|
||||
totalWins = ui.findActor("totalWins");
|
||||
@@ -154,27 +153,8 @@ public class PlayerStatisticScene extends UIScene {
|
||||
@Override
|
||||
public void enter() {
|
||||
super.enter();
|
||||
achievements = FModel.getAchievements(GameType.Constructed);
|
||||
achievementContainer.clear();
|
||||
for (Achievement a : achievements) {
|
||||
GameType g = GameType.smartValueOf(a.getKey());
|
||||
if (g != null) //skip variants
|
||||
continue;
|
||||
TextureRegion textureRegion = new TextureRegion(((FBufferedImage) a.getImage()).getTexture());
|
||||
textureRegion.flip(true, true);
|
||||
Image image = new Image(textureRegion);
|
||||
float alpha = a.isActive() ? 1f : 0.25f;
|
||||
image.getColor().a = alpha;
|
||||
achievementContainer.add(image).height(50).width(40).center().pad(5);
|
||||
String value = "[%105]" + a.getDisplayName() + "[%98]";
|
||||
String subTitle = a.getSubTitle(true);
|
||||
if (subTitle != null)
|
||||
value += "\n" + subTitle;
|
||||
TextraLabel label = Controls.newTextraLabel(value);
|
||||
label.getColor().a = alpha;
|
||||
achievementContainer.add(label).left().pad(5);
|
||||
achievementContainer.row();
|
||||
}
|
||||
updateAchievements(PlaneswalkerAchievements.instance, true);
|
||||
updateAchievements(FModel.getAchievements(GameType.Constructed), false);
|
||||
scrollContainer.clear();
|
||||
|
||||
if (playerName != null) {
|
||||
@@ -184,10 +164,13 @@ public class PlayerStatisticScene extends UIScene {
|
||||
avatar.setDrawable(new TextureRegionDrawable(Current.player().avatar()));
|
||||
}
|
||||
if (life != null) {
|
||||
AdventurePlayer.current().onLifeChange(() -> life.setText(AdventurePlayer.current().getLife() + "/" + AdventurePlayer.current().getMaxLife()));
|
||||
AdventurePlayer.current().onLifeChange(() -> life.setText("[+Life] [BLACK]" + AdventurePlayer.current().getLife() + "/" + AdventurePlayer.current().getMaxLife()));
|
||||
}
|
||||
if (money != null) {
|
||||
WorldSave.getCurrentSave().getPlayer().onGoldChange(() -> money.setText(String.valueOf(AdventurePlayer.current().getGold())));
|
||||
WorldSave.getCurrentSave().getPlayer().onGoldChange(() -> money.setText("[+Gold] [BLACK]" + AdventurePlayer.current().getGold()));
|
||||
}
|
||||
if (shards != null) {
|
||||
WorldSave.getCurrentSave().getPlayer().onShardsChange(() -> shards.setText("[+Shards] [BLACK]" + AdventurePlayer.current().getShards()));
|
||||
}
|
||||
if (totalWins != null) {
|
||||
totalWins.setText(String.valueOf(Current.player().getStatistic().totalWins()));
|
||||
@@ -222,4 +205,31 @@ public class PlayerStatisticScene extends UIScene {
|
||||
}
|
||||
performTouch(scrollPaneOfActor(scrollContainer)); //can use mouse wheel if available to scroll
|
||||
}
|
||||
void updateAchievements(AchievementCollection achievementCollection, boolean isPW) {
|
||||
achievementContainer.clear();
|
||||
for (Achievement a : achievementCollection) {
|
||||
if (isPW) {
|
||||
if (!a.isActive()) //skip inactive
|
||||
continue;
|
||||
} else {
|
||||
GameType g = GameType.smartValueOf(a.getKey());
|
||||
if (g != null) //skip variants
|
||||
continue;
|
||||
}
|
||||
TextureRegion textureRegion = new TextureRegion(((FBufferedImage) a.getImage()).getTexture());
|
||||
textureRegion.flip(true, true);
|
||||
Image image = new Image(textureRegion);
|
||||
float alpha = a.isActive() ? 1f : 0.25f;
|
||||
image.getColor().a = alpha;
|
||||
achievementContainer.add(image).height(50).width(40).center().pad(5);
|
||||
String value = "[%105]" + a.getDisplayName() + "[%98]";
|
||||
String subTitle = a.getSubTitle(true);
|
||||
if (subTitle != null)
|
||||
value += "\n" + subTitle;
|
||||
TextraLabel label = Controls.newTextraLabel(value);
|
||||
label.getColor().a = alpha;
|
||||
achievementContainer.add(label).left().pad(5);
|
||||
achievementContainer.row();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,7 +289,9 @@ public class UIActor extends Group {
|
||||
for (ObjectMap.Entry property : entries) {
|
||||
switch (property.key.toString()) {
|
||||
case "image":
|
||||
Texture t = Forge.getAssets().getTexture(Config.instance().getFile(property.value.toString()));
|
||||
boolean is2D = property.value.toString().startsWith("ui") &&
|
||||
(property.value.toString().contains("minimap") || property.value.toString().contains("hud"));
|
||||
Texture t = Forge.getAssets().getTexture(Config.instance().getFile(property.value.toString()), is2D, false);
|
||||
TextureRegion tr = new TextureRegion(t);
|
||||
if (property.value.toString().contains("title_bg")) {
|
||||
ShaderProgram shaderNightDay = Forge.getGraphics().getShaderNightDay();
|
||||
|
||||
@@ -251,11 +251,16 @@ public class Assets implements Disposable {
|
||||
public Texture getTexture(FileHandle file) {
|
||||
return getTexture(file, true);
|
||||
}
|
||||
|
||||
public Texture getTexture(FileHandle file, boolean required) {
|
||||
return getTexture(file, false, required);
|
||||
}
|
||||
|
||||
public Texture getTexture(FileHandle file, boolean is2D, boolean required) {
|
||||
if (file == null || !file.exists()) {
|
||||
if (!required)
|
||||
return null;
|
||||
System.err.println("Failed to load: " + file +"!. Creating dummy texture.");
|
||||
System.err.println("Failed to load: " + file + "!. Creating dummy texture.");
|
||||
return getDummy();
|
||||
}
|
||||
//internal path can be inside apk or jar..
|
||||
@@ -269,15 +274,19 @@ public class Assets implements Disposable {
|
||||
}
|
||||
Texture t = manager().get(file.path(), Texture.class, false);
|
||||
if (t == null) {
|
||||
if (is2D)
|
||||
manager().load(file.path(), Texture.class, new TextureParameter());
|
||||
else
|
||||
manager().load(file.path(), Texture.class, getTextureFilter());
|
||||
manager().finishLoadingAsset(file.path());
|
||||
t = manager().get(file.path(), Texture.class);
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
public ParticleEffect getEffect(FileHandle file) {
|
||||
if (file == null || !file.exists() || !FileType.Absolute.equals(file.type())) {
|
||||
System.err.println("Failed to load: " + file +"!.");
|
||||
System.err.println("Failed to load: " + file + "!.");
|
||||
return null;
|
||||
}
|
||||
ParticleEffect effect = manager().get(file.path(), ParticleEffect.class, false);
|
||||
@@ -310,6 +319,7 @@ public class Assets implements Disposable {
|
||||
public void loadTexture(FileHandle file) {
|
||||
loadTexture(file, getTextureFilter());
|
||||
}
|
||||
|
||||
public void loadTexture(FileHandle file, TextureParameter parameter) {
|
||||
try {
|
||||
if (file == null || !file.exists())
|
||||
@@ -339,7 +349,7 @@ public class Assets implements Disposable {
|
||||
textrafonts = new ObjectMap<>();
|
||||
if (!textrafonts.containsKey("textrafont")) {
|
||||
Font font = new Font(bitmapFont, 0f, 2f, 0f, 0f);
|
||||
font.addAtlas(item_atlas, 0f, 4f, 0f);
|
||||
font.addAtlas(item_atlas, 0f, 6f, 0f);
|
||||
//problematic atlas since some buttons are small, and this is too big for some buttons, need a way to enable
|
||||
//this via property
|
||||
//font.addAtlas(pixelmana_atlas, -90f, 20f, 0f);
|
||||
@@ -354,7 +364,7 @@ public class Assets implements Disposable {
|
||||
textrafonts = new ObjectMap<>();
|
||||
if (!textrafonts.containsKey("keysfont")) {
|
||||
Font font = new Font(bitmapFont);
|
||||
font.addAtlas(keys_atlas, 0f, 4f, 0f);
|
||||
font.addAtlas(keys_atlas, 0f, 6f, 0f);
|
||||
font.integerPosition = false;
|
||||
textrafonts.put("keysfont", font);
|
||||
}
|
||||
@@ -366,7 +376,7 @@ public class Assets implements Disposable {
|
||||
textrafonts = new ObjectMap<>();
|
||||
if (!textrafonts.containsKey(name)) {
|
||||
Font font = new Font(bitmapFont);
|
||||
font.addAtlas(items_atlas, 0f, 4f, 0f);
|
||||
font.addAtlas(items_atlas, 0f, 6f, 0f);
|
||||
font.integerPosition = false;
|
||||
textrafonts.put(name, font);
|
||||
}
|
||||
@@ -375,7 +385,7 @@ public class Assets implements Disposable {
|
||||
|
||||
public Music getMusic(FileHandle file) {
|
||||
if (file == null || !file.exists() || !FileType.Absolute.equals(file.type())) {
|
||||
System.err.println("Failed to load: " + file +"!.");
|
||||
System.err.println("Failed to load: " + file + "!.");
|
||||
return null;
|
||||
}
|
||||
Music music = manager().get(file.path(), Music.class, false);
|
||||
@@ -389,7 +399,7 @@ public class Assets implements Disposable {
|
||||
|
||||
public Sound getSound(FileHandle file) {
|
||||
if (file == null || !file.exists() || !FileType.Absolute.equals(file.type())) {
|
||||
System.err.println("Failed to load: " + file +"!.");
|
||||
System.err.println("Failed to load: " + file + "!.");
|
||||
return null;
|
||||
}
|
||||
Sound sound = manager().get(file.path(), Sound.class, false);
|
||||
|
||||
@@ -34,7 +34,7 @@ public class FSkin {
|
||||
|
||||
public static Texture getLogo() {
|
||||
if (Forge.isMobileAdventureMode)
|
||||
return Forge.getAssets().getTexture(getDefaultSkinFile("adv_logo.png"));
|
||||
return Forge.getAssets().getTexture(getDefaultSkinFile("adv_logo.png"), true, false);
|
||||
return Forge.getAssets().getTexture(getSkinFile("hd_logo.png"), false);
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ public class FSkin {
|
||||
|
||||
//load theme logo while changing skins
|
||||
Forge.getAssets().loadTexture(getSkinFile("hd_logo.png"));
|
||||
Forge.getAssets().loadTexture(getDefaultSkinFile("adv_logo.png"));
|
||||
Forge.getAssets().loadTexture(getDefaultSkinFile("adv_logo.png"), new TextureLoader.TextureParameter());
|
||||
Forge.getAssets().loadTexture(getDefaultSkinFile("overlay_alpha.png"));
|
||||
Forge.getAssets().loadTexture(getDefaultSkinFile("splatter.png"));
|
||||
|
||||
@@ -157,14 +157,14 @@ public class FSkin {
|
||||
//override splashscreen startup
|
||||
if (Forge.selector.equals("Adventure")) {
|
||||
if (f3.exists()) {
|
||||
Texture advSplash = Forge.getAssets().getTexture(f3);
|
||||
Texture advSplash = Forge.getAssets().getTexture(f3, true, false);
|
||||
w = advSplash.getWidth();
|
||||
h = advSplash.getHeight();
|
||||
splashScreen.setSplashTexture(new TextureRegion(advSplash, 0, 0, w, h - 100));
|
||||
pxSplash = new Pixmap(f3);
|
||||
}
|
||||
if (f4.exists()) {
|
||||
Texture advBG = Forge.getAssets().getTexture(f4);
|
||||
Texture advBG = Forge.getAssets().getTexture(f4, true, false);
|
||||
advBG.setWrap(Texture.TextureWrap.Repeat, Texture.TextureWrap.Repeat);
|
||||
splashScreen.setSplashBGTexture(advBG);
|
||||
}
|
||||
|
||||
@@ -522,12 +522,13 @@ public enum FSkinImage implements FImage {
|
||||
|
||||
public void load(Pixmap preferredIcons) {
|
||||
String filename = sourceFile.getFilename();
|
||||
boolean is2D = sourceFile == SourceFile.ADVENTURE;
|
||||
FileHandle preferredFile = FSkin.getSkinFile(filename);
|
||||
Texture texture = Forge.getAssets().getTexture(preferredFile, false);
|
||||
Texture texture = Forge.getAssets().getTexture(preferredFile, is2D, false);
|
||||
if (texture == null) {
|
||||
if (preferredFile.exists()) {
|
||||
try {
|
||||
texture = Forge.getAssets().getTexture(preferredFile, false);
|
||||
texture = Forge.getAssets().getTexture(preferredFile, is2D, false);
|
||||
}
|
||||
catch (final Exception e) {
|
||||
System.err.println("Failed to load skin file: " + preferredFile);
|
||||
@@ -594,11 +595,11 @@ public enum FSkinImage implements FImage {
|
||||
|
||||
//use default file if can't use preferred file
|
||||
FileHandle defaultFile = FSkin.getDefaultSkinFile(filename);
|
||||
texture = Forge.getAssets().getTexture(defaultFile, false);
|
||||
texture = Forge.getAssets().getTexture(defaultFile, is2D, false);
|
||||
if (texture == null) {
|
||||
if (defaultFile.exists()) {
|
||||
try {
|
||||
texture = Forge.getAssets().getTexture(defaultFile, false);
|
||||
texture = Forge.getAssets().getTexture(defaultFile, is2D, false);
|
||||
}
|
||||
catch (final Exception e) {
|
||||
System.err.println("Failed to load skin file: " + defaultFile);
|
||||
|
||||
@@ -21,7 +21,7 @@ public class ClosingScreen extends FContainer {
|
||||
private boolean drawStatic = false;
|
||||
private FileHandle adv_logo = getSkinFile("adv_logo.png");
|
||||
private FileHandle existingLogo = adv_logo.exists() ? adv_logo : getDefaultSkinFile("adv_logo.png");
|
||||
private Texture logo = existingLogo.exists() && Forge.advStartup ? Forge.getAssets().getTexture(existingLogo) : FSkin.getLogo();
|
||||
private Texture logo = existingLogo.exists() && Forge.advStartup ? Forge.getAssets().getTexture(existingLogo, true, false) : FSkin.getLogo();
|
||||
|
||||
public ClosingScreen(boolean restart0) {
|
||||
bgAnimation = new BGAnimation();
|
||||
|
||||
@@ -56,6 +56,7 @@ public class AdventureScreen extends LaunchScreen {
|
||||
|
||||
@Override
|
||||
protected void startMatch() {
|
||||
Forge.isMobileAdventureMode = true; //set early for the transition logo
|
||||
Forge.switchToAdventure();
|
||||
}
|
||||
public static void preload() {
|
||||
|
||||
@@ -136,24 +136,6 @@
|
||||
"x": 315,
|
||||
"y": 224
|
||||
},
|
||||
{
|
||||
"type": "Image",
|
||||
"name": "lifeIcon",
|
||||
"image": "ui/life.png",
|
||||
"x": 392,
|
||||
"y": 40,
|
||||
"width": 16,
|
||||
"height": 16
|
||||
},
|
||||
{
|
||||
"type": "Image",
|
||||
"name": "goldIcon",
|
||||
"image": "ui/money.png",
|
||||
"x": 392,
|
||||
"y": 60,
|
||||
"width": 16,
|
||||
"height": 16
|
||||
},
|
||||
{
|
||||
"type": "Label",
|
||||
"name": "playerName",
|
||||
@@ -166,19 +148,25 @@
|
||||
{
|
||||
"type": "Label",
|
||||
"name": "lifePoints",
|
||||
"fontColor":"black",
|
||||
"width": 64,
|
||||
"height": 16,
|
||||
"x": 410,
|
||||
"x": 394,
|
||||
"y": 40
|
||||
},
|
||||
{
|
||||
"type": "Label",
|
||||
"name": "money",
|
||||
"fontColor":"black",
|
||||
"width": 64,
|
||||
"height": 16,
|
||||
"x": 410,
|
||||
"x": 394,
|
||||
"y": 80
|
||||
},
|
||||
{
|
||||
"type": "Label",
|
||||
"name": "shards",
|
||||
"width": 64,
|
||||
"height": 16,
|
||||
"x": 394,
|
||||
"y": 60
|
||||
},
|
||||
{
|
||||
|
||||
@@ -136,40 +136,28 @@
|
||||
"height": 24,
|
||||
"fontColor":"black"
|
||||
},
|
||||
{
|
||||
"type": "Image",
|
||||
"name": "lifeIcon",
|
||||
"image": "ui/life.png",
|
||||
"x": 98,
|
||||
"y": 22,
|
||||
"width": 16,
|
||||
"height": 16
|
||||
},
|
||||
{
|
||||
"type": "Image",
|
||||
"name": "goldIcon",
|
||||
"image": "ui/money.png",
|
||||
"x": 98,
|
||||
"y": 42,
|
||||
"width": 16,
|
||||
"height": 16
|
||||
},
|
||||
{
|
||||
"type": "Label",
|
||||
"name": "lifePoints",
|
||||
"fontColor":"black",
|
||||
"width": 64,
|
||||
"height": 16,
|
||||
"x": 118,
|
||||
"x": 98,
|
||||
"y": 22
|
||||
},
|
||||
{
|
||||
"type": "Label",
|
||||
"name": "money",
|
||||
"fontColor":"black",
|
||||
"width": 64,
|
||||
"height": 16,
|
||||
"x": 118,
|
||||
"x": 98,
|
||||
"y": 42
|
||||
},
|
||||
{
|
||||
"type": "Label",
|
||||
"name": "shards",
|
||||
"width": 64,
|
||||
"height": 16,
|
||||
"x": 170,
|
||||
"y": 42
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user