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