mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
Merge pull request #2635 from kevlahnota/newmaster2
update PlayerStatisticScene
This commit is contained in:
@@ -5,6 +5,7 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Window;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.github.tommyettinger.textra.TextraButton;
|
||||
@@ -34,23 +35,18 @@ public class PlayerStatisticScene extends UIScene {
|
||||
TextraLabel winloss, lossWinRatio;
|
||||
TextraLabel playerName;
|
||||
TextraButton back;
|
||||
private final Table enemiesGroup;
|
||||
private final Table scrollContainer;
|
||||
TextraLabel blessingScroll;
|
||||
ScrollPane scrollPane, blessing;
|
||||
|
||||
|
||||
private PlayerStatisticScene() {
|
||||
super(Forge.isLandscapeMode() ? "ui/statistic.json" : "ui/statistic_portrait.json");
|
||||
|
||||
|
||||
enemiesGroup = new Table(Controls.getSkin());
|
||||
enemiesGroup.row();
|
||||
scrollContainer = new Table(Controls.getSkin());
|
||||
scrollContainer.row();
|
||||
blessingScroll = Controls.newTextraLabel("");
|
||||
blessingScroll.setColor(Color.BLACK);
|
||||
blessingScroll.setAlignment(Align.topLeft);
|
||||
blessingScroll.setWrap(true);
|
||||
ui.onButtonPress("return", PlayerStatisticScene.this::back);
|
||||
|
||||
avatar = ui.findActor("avatar");
|
||||
avatarBorder = ui.findActor("avatarBorder");
|
||||
playerName = ui.findActor("playerName");
|
||||
@@ -66,55 +62,53 @@ public class PlayerStatisticScene extends UIScene {
|
||||
winloss = ui.findActor("winloss");
|
||||
lossWinRatio = ui.findActor("lossWinRatio");
|
||||
back = ui.findActor("return");
|
||||
ScrollPane scrollPane = ui.findActor("enemies");
|
||||
scrollPane.setActor(enemiesGroup);
|
||||
Window window = ui.findActor("scrollWindow");
|
||||
Table root = ui.findActor("enemies");
|
||||
root.add(Forge.getLocalizer().getMessage("lblAvatar")).pad(3, 10, 3, 10).center();
|
||||
root.add(Forge.getLocalizer().getMessage("lblName")).fillX().pad(3, 10, 3, 60).center();
|
||||
root.add(Forge.getLocalizer().getMessage("lblWinProper") + "/" + Forge.getLocalizer().getMessage("lblLossProper")).pad(3, 5, 3, 10).center();
|
||||
root.row();
|
||||
ScrollPane scroller = new ScrollPane(scrollContainer);
|
||||
root.add(scroller).colspan(3);
|
||||
ScrollPane blessing = ui.findActor("blessingInfo");
|
||||
blessing.setActor(blessingScroll);
|
||||
window.add(root);
|
||||
}
|
||||
|
||||
private static PlayerStatisticScene object;
|
||||
|
||||
public static PlayerStatisticScene instance() {
|
||||
if(object==null)
|
||||
object=new PlayerStatisticScene();
|
||||
if (object == null)
|
||||
object = new PlayerStatisticScene();
|
||||
return object;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private TextureRegion getColorFrame(ColorSet color){
|
||||
String colorName= "color_";
|
||||
if(color.hasWhite())
|
||||
colorName+="w";
|
||||
if(color.hasBlue())
|
||||
colorName+="u";
|
||||
if(color.hasBlack())
|
||||
colorName+="b";
|
||||
if(color.hasRed())
|
||||
colorName+="r";
|
||||
if(color.hasGreen())
|
||||
colorName+="g";
|
||||
private TextureRegion getColorFrame(ColorSet color) {
|
||||
String colorName = "color_";
|
||||
if (color.hasWhite())
|
||||
colorName += "w";
|
||||
if (color.hasBlue())
|
||||
colorName += "u";
|
||||
if (color.hasBlack())
|
||||
colorName += "b";
|
||||
if (color.hasRed())
|
||||
colorName += "r";
|
||||
if (color.hasGreen())
|
||||
colorName += "g";
|
||||
return Config.instance().getAtlas(Paths.COLOR_FRAME_ATLAS).findRegion(colorName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
super.enter();
|
||||
enemiesGroup.clear();
|
||||
|
||||
enemiesGroup.add(Forge.getLocalizer().getMessage("lblAvatar")).align(Align.center).space(3, 10, 3, 10);
|
||||
enemiesGroup.add(Forge.getLocalizer().getMessage("lblName")).fillX().align(Align.center).fillX().space(3, 10, 3, 60);
|
||||
enemiesGroup.add(Forge.getLocalizer().getMessage("lblWinProper")).align(Align.center).space(3, 5, 3, 5);
|
||||
enemiesGroup.add("/").align(Align.center).space(3, 5, 3, 5);
|
||||
enemiesGroup.add(Forge.getLocalizer().getMessage("lblLossProper")).align(Align.center).space(3, 5, 3, 5);
|
||||
enemiesGroup.row().space(8);
|
||||
scrollContainer.clear();
|
||||
|
||||
if (playerName != null) {
|
||||
playerName.setText(GamePlayerUtil.getGuiPlayer().getName());
|
||||
@@ -137,11 +131,11 @@ public class PlayerStatisticScene extends UIScene {
|
||||
if (lossWinRatio != null) {
|
||||
lossWinRatio.setText(Float.toString(Current.player().getStatistic().winLossRatio()));
|
||||
}
|
||||
if(colorFrame != null){
|
||||
if (colorFrame != null) {
|
||||
colorFrame.setDrawable(new TextureRegionDrawable(getColorFrame(Current.player().getColorIdentity())));
|
||||
}
|
||||
if(blessingScroll != null){
|
||||
if(Current.player().getBlessing() != null) {
|
||||
if (blessingScroll != null) {
|
||||
if (Current.player().getBlessing() != null) {
|
||||
blessingScroll.setText(Current.player().getBlessing().getDescription());
|
||||
} else {
|
||||
blessingScroll.setText("No blessing.");
|
||||
@@ -155,14 +149,10 @@ public class PlayerStatisticScene extends UIScene {
|
||||
enemyImage.setDrawable(new TextureRegionDrawable(new EnemySprite(data).getAvatar()));
|
||||
enemyImage.setSize(8, 8);
|
||||
|
||||
enemiesGroup.add(enemyImage).align(Align.center).space(3, 10, 3, 10);
|
||||
enemiesGroup.add((data.name)).fillX().align(Align.center).fillX().space(3, 10, 3, 10);
|
||||
enemiesGroup.add((entry.getValue().getLeft().toString())).space(3, 2, 3, 2);
|
||||
enemiesGroup.add(("/")).align(Align.center).space(3, 2, 3, 2);
|
||||
enemiesGroup.add((entry.getValue().getRight().toString())).align(Align.center).space(3, 2, 3, 2);
|
||||
enemiesGroup.row().space(8);
|
||||
scrollContainer.add(enemyImage).pad(3, 10, 3, 10).center();
|
||||
scrollContainer.add((data.name)).fillX().pad(3, 10, 3, 40).center();
|
||||
scrollContainer.add(entry.getValue().getLeft().toString() + "/" + entry.getValue().getRight().toString()).pad(3, 5, 3, 10).center();
|
||||
scrollContainer.row();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,13 +19,21 @@
|
||||
"height": 200
|
||||
},
|
||||
{
|
||||
"type": "Scroll",
|
||||
"name": "enemies",
|
||||
"type": "Window",
|
||||
"name": "scrollWindow",
|
||||
"x": 15,
|
||||
"y": 18,
|
||||
"width": 256,
|
||||
"height": 235
|
||||
},
|
||||
{
|
||||
"type": "Table",
|
||||
"name": "enemies",
|
||||
"x": 15,
|
||||
"y": 22,
|
||||
"width": 256,
|
||||
"height": 220
|
||||
},
|
||||
{
|
||||
"type": "Image",
|
||||
"name": "avatar",
|
||||
|
||||
@@ -19,13 +19,21 @@
|
||||
"height": 98
|
||||
},
|
||||
{
|
||||
"type": "Scroll",
|
||||
"name": "enemies",
|
||||
"type": "Window",
|
||||
"name": "scrollWindow",
|
||||
"x": 4,
|
||||
"y": 106,
|
||||
"width": 262,
|
||||
"height": 327
|
||||
},
|
||||
{
|
||||
"type": "Table",
|
||||
"name": "enemies",
|
||||
"x": 4,
|
||||
"y": 110,
|
||||
"width": 262,
|
||||
"height": 318
|
||||
},
|
||||
{
|
||||
"type": "Image",
|
||||
"name": "avatar",
|
||||
|
||||
Reference in New Issue
Block a user