Merge pull request #2753 from kevlahnota/newmaster2

update PlayerStatisticScene, update filters
This commit is contained in:
Anthony Calosa
2023-03-26 03:00:37 +08:00
committed by GitHub
10 changed files with 91 additions and 91 deletions

View File

@@ -57,7 +57,7 @@
<dependency> <dependency>
<groupId>com.github.tommyettinger</groupId> <groupId>com.github.tommyettinger</groupId>
<artifactId>textratypist</artifactId> <artifactId>textratypist</artifactId>
<version>0.8.1</version> <version>0.8.2</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.badlogicgames.gdx-controllers</groupId> <groupId>com.badlogicgames.gdx-controllers</groupId>

View File

@@ -28,6 +28,7 @@ import forge.card.ColorSet;
import forge.game.GameType; import forge.game.GameType;
import forge.localinstance.achievements.Achievement; import forge.localinstance.achievements.Achievement;
import forge.localinstance.achievements.AchievementCollection; import forge.localinstance.achievements.AchievementCollection;
import forge.localinstance.achievements.PlaneswalkerAchievements;
import forge.model.FModel; import forge.model.FModel;
import forge.player.GamePlayerUtil; import forge.player.GamePlayerUtil;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
@@ -35,9 +36,9 @@ import org.apache.commons.lang3.tuple.Pair;
import java.util.Map; import java.util.Map;
public class PlayerStatisticScene extends UIScene { public class PlayerStatisticScene extends UIScene {
Image avatar, avatarBorder, lifeIcon, goldIcon; Image avatar, avatarBorder;
Image colorFrame; Image colorFrame;
TextraLabel money, life; TextraLabel money, life, shards;
TextraLabel wins, totalWins; TextraLabel wins, totalWins;
TextraLabel loss, totalLoss; TextraLabel loss, totalLoss;
TextraLabel winloss, lossWinRatio; TextraLabel winloss, lossWinRatio;
@@ -48,7 +49,6 @@ public class PlayerStatisticScene extends UIScene {
ScrollPane scroller; ScrollPane scroller;
Table root; Table root;
boolean toggle = false; boolean toggle = false;
AchievementCollection achievements;
private PlayerStatisticScene() { private PlayerStatisticScene() {
super(Forge.isLandscapeMode() ? "ui/statistic.json" : "ui/statistic_portrait.json"); super(Forge.isLandscapeMode() ? "ui/statistic.json" : "ui/statistic_portrait.json");
@@ -65,8 +65,7 @@ public class PlayerStatisticScene extends UIScene {
playerName = ui.findActor("playerName"); playerName = ui.findActor("playerName");
life = ui.findActor("lifePoints"); life = ui.findActor("lifePoints");
money = ui.findActor("money"); money = ui.findActor("money");
lifeIcon = ui.findActor("lifeIcon"); shards = ui.findActor("shards");
goldIcon = ui.findActor("goldIcon");
wins = ui.findActor("wins"); wins = ui.findActor("wins");
colorFrame = ui.findActor("colorFrame"); colorFrame = ui.findActor("colorFrame");
totalWins = ui.findActor("totalWins"); totalWins = ui.findActor("totalWins");
@@ -154,27 +153,8 @@ public class PlayerStatisticScene extends UIScene {
@Override @Override
public void enter() { public void enter() {
super.enter(); super.enter();
achievements = FModel.getAchievements(GameType.Constructed); updateAchievements(PlaneswalkerAchievements.instance, true);
achievementContainer.clear(); updateAchievements(FModel.getAchievements(GameType.Constructed), false);
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();
}
scrollContainer.clear(); scrollContainer.clear();
if (playerName != null) { if (playerName != null) {
@@ -184,10 +164,13 @@ public class PlayerStatisticScene extends UIScene {
avatar.setDrawable(new TextureRegionDrawable(Current.player().avatar())); avatar.setDrawable(new TextureRegionDrawable(Current.player().avatar()));
} }
if (life != null) { 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) { 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) { if (totalWins != null) {
totalWins.setText(String.valueOf(Current.player().getStatistic().totalWins())); 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 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();
}
}
} }

View File

@@ -289,7 +289,9 @@ public class UIActor extends Group {
for (ObjectMap.Entry property : entries) { for (ObjectMap.Entry property : entries) {
switch (property.key.toString()) { switch (property.key.toString()) {
case "image": 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); TextureRegion tr = new TextureRegion(t);
if (property.value.toString().contains("title_bg")) { if (property.value.toString().contains("title_bg")) {
ShaderProgram shaderNightDay = Forge.getGraphics().getShaderNightDay(); ShaderProgram shaderNightDay = Forge.getGraphics().getShaderNightDay();

View File

@@ -251,11 +251,16 @@ public class Assets implements Disposable {
public Texture getTexture(FileHandle file) { public Texture getTexture(FileHandle file) {
return getTexture(file, true); return getTexture(file, true);
} }
public Texture getTexture(FileHandle file, boolean required) { 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 (file == null || !file.exists()) {
if (!required) if (!required)
return null; return null;
System.err.println("Failed to load: " + file +"!. Creating dummy texture."); System.err.println("Failed to load: " + file + "!. Creating dummy texture.");
return getDummy(); return getDummy();
} }
//internal path can be inside apk or jar.. //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); Texture t = manager().get(file.path(), Texture.class, false);
if (t == null) { if (t == null) {
manager().load(file.path(), Texture.class, getTextureFilter()); if (is2D)
manager().load(file.path(), Texture.class, new TextureParameter());
else
manager().load(file.path(), Texture.class, getTextureFilter());
manager().finishLoadingAsset(file.path()); manager().finishLoadingAsset(file.path());
t = manager().get(file.path(), Texture.class); t = manager().get(file.path(), Texture.class);
} }
return t; return t;
} }
public ParticleEffect getEffect(FileHandle file) { public ParticleEffect getEffect(FileHandle file) {
if (file == null || !file.exists() || !FileType.Absolute.equals(file.type())) { 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; return null;
} }
ParticleEffect effect = manager().get(file.path(), ParticleEffect.class, false); ParticleEffect effect = manager().get(file.path(), ParticleEffect.class, false);
@@ -310,6 +319,7 @@ public class Assets implements Disposable {
public void loadTexture(FileHandle file) { public void loadTexture(FileHandle file) {
loadTexture(file, getTextureFilter()); loadTexture(file, getTextureFilter());
} }
public void loadTexture(FileHandle file, TextureParameter parameter) { public void loadTexture(FileHandle file, TextureParameter parameter) {
try { try {
if (file == null || !file.exists()) if (file == null || !file.exists())
@@ -339,7 +349,7 @@ public class Assets implements Disposable {
textrafonts = new ObjectMap<>(); textrafonts = new ObjectMap<>();
if (!textrafonts.containsKey("textrafont")) { if (!textrafonts.containsKey("textrafont")) {
Font font = new Font(bitmapFont, 0f, 2f, 0f, 0f); 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 //problematic atlas since some buttons are small, and this is too big for some buttons, need a way to enable
//this via property //this via property
//font.addAtlas(pixelmana_atlas, -90f, 20f, 0f); //font.addAtlas(pixelmana_atlas, -90f, 20f, 0f);
@@ -354,7 +364,7 @@ public class Assets implements Disposable {
textrafonts = new ObjectMap<>(); textrafonts = new ObjectMap<>();
if (!textrafonts.containsKey("keysfont")) { if (!textrafonts.containsKey("keysfont")) {
Font font = new Font(bitmapFont); Font font = new Font(bitmapFont);
font.addAtlas(keys_atlas, 0f, 4f, 0f); font.addAtlas(keys_atlas, 0f, 6f, 0f);
font.integerPosition = false; font.integerPosition = false;
textrafonts.put("keysfont", font); textrafonts.put("keysfont", font);
} }
@@ -366,7 +376,7 @@ public class Assets implements Disposable {
textrafonts = new ObjectMap<>(); textrafonts = new ObjectMap<>();
if (!textrafonts.containsKey(name)) { if (!textrafonts.containsKey(name)) {
Font font = new Font(bitmapFont); Font font = new Font(bitmapFont);
font.addAtlas(items_atlas, 0f, 4f, 0f); font.addAtlas(items_atlas, 0f, 6f, 0f);
font.integerPosition = false; font.integerPosition = false;
textrafonts.put(name, font); textrafonts.put(name, font);
} }
@@ -375,7 +385,7 @@ public class Assets implements Disposable {
public Music getMusic(FileHandle file) { public Music getMusic(FileHandle file) {
if (file == null || !file.exists() || !FileType.Absolute.equals(file.type())) { 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; return null;
} }
Music music = manager().get(file.path(), Music.class, false); Music music = manager().get(file.path(), Music.class, false);
@@ -389,7 +399,7 @@ public class Assets implements Disposable {
public Sound getSound(FileHandle file) { public Sound getSound(FileHandle file) {
if (file == null || !file.exists() || !FileType.Absolute.equals(file.type())) { 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; return null;
} }
Sound sound = manager().get(file.path(), Sound.class, false); Sound sound = manager().get(file.path(), Sound.class, false);

View File

@@ -34,7 +34,7 @@ public class FSkin {
public static Texture getLogo() { public static Texture getLogo() {
if (Forge.isMobileAdventureMode) 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); return Forge.getAssets().getTexture(getSkinFile("hd_logo.png"), false);
} }
@@ -113,7 +113,7 @@ public class FSkin {
//load theme logo while changing skins //load theme logo while changing skins
Forge.getAssets().loadTexture(getSkinFile("hd_logo.png")); 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("overlay_alpha.png"));
Forge.getAssets().loadTexture(getDefaultSkinFile("splatter.png")); Forge.getAssets().loadTexture(getDefaultSkinFile("splatter.png"));
@@ -157,14 +157,14 @@ public class FSkin {
//override splashscreen startup //override splashscreen startup
if (Forge.selector.equals("Adventure")) { if (Forge.selector.equals("Adventure")) {
if (f3.exists()) { if (f3.exists()) {
Texture advSplash = Forge.getAssets().getTexture(f3); Texture advSplash = Forge.getAssets().getTexture(f3, true, false);
w = advSplash.getWidth(); w = advSplash.getWidth();
h = advSplash.getHeight(); h = advSplash.getHeight();
splashScreen.setSplashTexture(new TextureRegion(advSplash, 0, 0, w, h - 100)); splashScreen.setSplashTexture(new TextureRegion(advSplash, 0, 0, w, h - 100));
pxSplash = new Pixmap(f3); pxSplash = new Pixmap(f3);
} }
if (f4.exists()) { 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); advBG.setWrap(Texture.TextureWrap.Repeat, Texture.TextureWrap.Repeat);
splashScreen.setSplashBGTexture(advBG); splashScreen.setSplashBGTexture(advBG);
} }

View File

@@ -522,12 +522,13 @@ public enum FSkinImage implements FImage {
public void load(Pixmap preferredIcons) { public void load(Pixmap preferredIcons) {
String filename = sourceFile.getFilename(); String filename = sourceFile.getFilename();
boolean is2D = sourceFile == SourceFile.ADVENTURE;
FileHandle preferredFile = FSkin.getSkinFile(filename); FileHandle preferredFile = FSkin.getSkinFile(filename);
Texture texture = Forge.getAssets().getTexture(preferredFile, false); Texture texture = Forge.getAssets().getTexture(preferredFile, is2D, false);
if (texture == null) { if (texture == null) {
if (preferredFile.exists()) { if (preferredFile.exists()) {
try { try {
texture = Forge.getAssets().getTexture(preferredFile, false); texture = Forge.getAssets().getTexture(preferredFile, is2D, false);
} }
catch (final Exception e) { catch (final Exception e) {
System.err.println("Failed to load skin file: " + preferredFile); 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 //use default file if can't use preferred file
FileHandle defaultFile = FSkin.getDefaultSkinFile(filename); FileHandle defaultFile = FSkin.getDefaultSkinFile(filename);
texture = Forge.getAssets().getTexture(defaultFile, false); texture = Forge.getAssets().getTexture(defaultFile, is2D, false);
if (texture == null) { if (texture == null) {
if (defaultFile.exists()) { if (defaultFile.exists()) {
try { try {
texture = Forge.getAssets().getTexture(defaultFile, false); texture = Forge.getAssets().getTexture(defaultFile, is2D, false);
} }
catch (final Exception e) { catch (final Exception e) {
System.err.println("Failed to load skin file: " + defaultFile); System.err.println("Failed to load skin file: " + defaultFile);

View File

@@ -21,7 +21,7 @@ public class ClosingScreen extends FContainer {
private boolean drawStatic = false; private boolean drawStatic = false;
private FileHandle adv_logo = getSkinFile("adv_logo.png"); private FileHandle adv_logo = getSkinFile("adv_logo.png");
private FileHandle existingLogo = adv_logo.exists() ? adv_logo : getDefaultSkinFile("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) { public ClosingScreen(boolean restart0) {
bgAnimation = new BGAnimation(); bgAnimation = new BGAnimation();

View File

@@ -56,6 +56,7 @@ public class AdventureScreen extends LaunchScreen {
@Override @Override
protected void startMatch() { protected void startMatch() {
Forge.isMobileAdventureMode = true; //set early for the transition logo
Forge.switchToAdventure(); Forge.switchToAdventure();
} }
public static void preload() { public static void preload() {

View File

@@ -136,24 +136,6 @@
"x": 315, "x": 315,
"y": 224 "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", "type": "Label",
"name": "playerName", "name": "playerName",
@@ -166,19 +148,25 @@
{ {
"type": "Label", "type": "Label",
"name": "lifePoints", "name": "lifePoints",
"fontColor":"black",
"width": 64, "width": 64,
"height": 16, "height": 16,
"x": 410, "x": 394,
"y": 40 "y": 40
}, },
{ {
"type": "Label", "type": "Label",
"name": "money", "name": "money",
"fontColor":"black",
"width": 64, "width": 64,
"height": 16, "height": 16,
"x": 410, "x": 394,
"y": 80
},
{
"type": "Label",
"name": "shards",
"width": 64,
"height": 16,
"x": 394,
"y": 60 "y": 60
}, },
{ {

View File

@@ -136,40 +136,28 @@
"height": 24, "height": 24,
"fontColor":"black" "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", "type": "Label",
"name": "lifePoints", "name": "lifePoints",
"fontColor":"black",
"width": 64, "width": 64,
"height": 16, "height": 16,
"x": 118, "x": 98,
"y": 22 "y": 22
}, },
{ {
"type": "Label", "type": "Label",
"name": "money", "name": "money",
"fontColor":"black",
"width": 64, "width": 64,
"height": 16, "height": 16,
"x": 118, "x": 98,
"y": 42
},
{
"type": "Label",
"name": "shards",
"width": 64,
"height": 16,
"x": 170,
"y": 42 "y": 42
}, },
{ {