mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
integrating TextraLabel into adventure ui
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package forge.adventure.character;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.*;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
@@ -217,12 +218,19 @@ public class CharacterSprite extends MapActor {
|
||||
@Override
|
||||
public void draw(Batch batch, float parentAlpha) {
|
||||
if (currentAnimation == null || hidden)
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
super.draw(batch,parentAlpha);
|
||||
beforeDraw(batch,parentAlpha);
|
||||
TextureRegion currentFrame = currentAnimation.getKeyFrame(timer, true);
|
||||
setHeight(currentFrame.getRegionHeight());
|
||||
setWidth(currentFrame.getRegionWidth());
|
||||
Color oldColor=batch.getColor().cpy();
|
||||
batch.setColor(getColor());
|
||||
batch.draw(currentFrame, getX(), getY());
|
||||
batch.setColor(oldColor);
|
||||
super.draw(batch,parentAlpha);
|
||||
//batch.draw(getDebugTexture(),getX(),getY());
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import forge.adventure.util.Config;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
/**
|
||||
* Map Actor base class for Actors on the map
|
||||
@@ -18,6 +19,12 @@ import forge.adventure.util.Config;
|
||||
public class MapActor extends Actor {
|
||||
|
||||
|
||||
private boolean removeIfEffectsAreFinished;
|
||||
|
||||
public void removeAfterEffects() {
|
||||
removeIfEffectsAreFinished=true;
|
||||
}
|
||||
|
||||
class CurrentEffect
|
||||
{
|
||||
public CurrentEffect(String path,ParticleEffect effect,Vector2 offset,boolean overlay)
|
||||
@@ -78,7 +85,7 @@ public class MapActor extends Actor {
|
||||
}
|
||||
public void playEffect(String path)
|
||||
{
|
||||
playEffect(path,0,false,Vector2.Zero);
|
||||
playEffect(path,0,true,Vector2.Zero);
|
||||
}
|
||||
public MapActor(int objectId)
|
||||
{
|
||||
@@ -91,7 +98,9 @@ public class MapActor extends Actor {
|
||||
private Texture getDebugTexture() {
|
||||
if (debugTexture == null) {
|
||||
Pixmap pixmap = new Pixmap((int) getWidth(), (int) getHeight(), Pixmap.Format.RGBA8888);
|
||||
pixmap.setColor(1.0f,0,0,0.5f);
|
||||
//pixmap.setColor(1.0f,0,0,0.5f);
|
||||
pixmap.setColor(MyRandom.getRandom().nextFloat(),MyRandom.getRandom().nextFloat(),MyRandom.getRandom().nextFloat(),0.5f);
|
||||
|
||||
pixmap.fillRectangle((int)(boundingRect.x - getX()), (int)(getHeight()- boundingRect.getHeight()) + (int)(boundingRect.y - getY()), (int)boundingRect.getWidth(), (int)boundingRect.getHeight());
|
||||
debugTexture = new Texture(pixmap);
|
||||
pixmap.dispose();
|
||||
@@ -115,7 +124,9 @@ public class MapActor extends Actor {
|
||||
public void draw(Batch batch, float alpha) {
|
||||
|
||||
if(boundDebug)
|
||||
{
|
||||
batch.draw(getDebugTexture(),getX(),getY());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -153,6 +164,9 @@ public class MapActor extends Actor {
|
||||
effect.effect.dispose();
|
||||
}
|
||||
}
|
||||
if(effects.size==0&&removeIfEffectsAreFinished&&getParent()!=null)
|
||||
getParent().removeActor(this);
|
||||
|
||||
}
|
||||
@Override
|
||||
protected void positionChanged() {
|
||||
|
||||
@@ -7,6 +7,8 @@ import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.Group;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.*;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.github.tommyettinger.textra.TextraButton;
|
||||
import com.github.tommyettinger.textra.TextraLabel;
|
||||
import forge.Forge;
|
||||
import forge.adventure.character.EnemySprite;
|
||||
import forge.adventure.data.ArenaData;
|
||||
@@ -27,7 +29,7 @@ public class ArenaScene extends UIScene implements IAfterMatch {
|
||||
private static ArenaScene object;
|
||||
private final float gridSize;
|
||||
private ArenaData arenaData;
|
||||
private TextButton startButton;
|
||||
private TextraButton startButton;
|
||||
|
||||
public static ArenaScene instance() {
|
||||
if(object==null)
|
||||
@@ -35,10 +37,10 @@ public class ArenaScene extends UIScene implements IAfterMatch {
|
||||
return object;
|
||||
}
|
||||
|
||||
private TextButton doneButton;
|
||||
private TextraButton doneButton;
|
||||
Dialog startDialog;
|
||||
Dialog areYouSureDialog;
|
||||
private Label goldLabel;
|
||||
private TextraLabel goldLabel;
|
||||
|
||||
private Group arenaPlane;
|
||||
private Random rand=new Random();
|
||||
@@ -89,7 +91,7 @@ public class ArenaScene extends UIScene implements IAfterMatch {
|
||||
|
||||
startButton=ui.findActor("start");
|
||||
|
||||
startDialog = new Dialog(Forge.getLocalizer().getMessage("lblStart"), Controls.GetSkin())
|
||||
startDialog = new Dialog(Forge.getLocalizer().getMessage("lblStart"), Controls.getSkin())
|
||||
{
|
||||
protected void result(Object object)
|
||||
{
|
||||
@@ -106,7 +108,7 @@ public class ArenaScene extends UIScene implements IAfterMatch {
|
||||
startDialog.getColor().a = 0;
|
||||
|
||||
|
||||
areYouSureDialog= new Dialog(Forge.getLocalizer().getMessage("lblConcedeTitle"), Controls.GetSkin())
|
||||
areYouSureDialog= new Dialog(Forge.getLocalizer().getMessage("lblConcedeTitle"), Controls.getSkin())
|
||||
{
|
||||
protected void result(Object object)
|
||||
{
|
||||
@@ -304,7 +306,7 @@ public class ArenaScene extends UIScene implements IAfterMatch {
|
||||
player=fighters.get(fighters.size-1);
|
||||
|
||||
|
||||
goldLabel.setText(data.entryFee +" $");
|
||||
goldLabel.setText(data.entryFee +" [+Gold]");
|
||||
goldLabel.setVisible(true);
|
||||
|
||||
startButton.setDisabled(data.entryFee>Current.player().getGold());
|
||||
|
||||
@@ -18,7 +18,7 @@ public class DeckEditScene extends ForgeScene {
|
||||
|
||||
private static DeckEditScene object;
|
||||
|
||||
public static DeckEditScene instance() {
|
||||
public static DeckEditScene getInstance() {
|
||||
if(object==null)
|
||||
object=new DeckEditScene();
|
||||
return object;
|
||||
|
||||
@@ -7,29 +7,38 @@ import com.badlogic.gdx.scenes.scene2d.ui.*;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.badlogic.gdx.utils.IntMap;
|
||||
import com.github.tommyettinger.textra.TextraButton;
|
||||
import com.github.tommyettinger.textra.TextraLabel;
|
||||
import forge.Forge;
|
||||
import forge.adventure.player.AdventurePlayer;
|
||||
import forge.adventure.util.Controls;
|
||||
import forge.adventure.util.Current;
|
||||
|
||||
public class DeckSelectScene extends UIScene {
|
||||
private final IntMap<TextButton> buttons = new IntMap<>();
|
||||
private final IntMap<TextraButton> buttons = new IntMap<>();
|
||||
Color defColor;
|
||||
Dialog dialog;
|
||||
TextField textInput;
|
||||
Table layout;
|
||||
Label header;
|
||||
TextButton back, edit, rename, dialogRenameBtn, dialogAbortBtn;
|
||||
TextraLabel header;
|
||||
TextraButton back, edit, rename, dialogRenameBtn, dialogAbortBtn;
|
||||
int currentSlot = 0;
|
||||
ScrollPane scrollPane;
|
||||
|
||||
private static DeckSelectScene object;
|
||||
|
||||
public static DeckSelectScene instance() {
|
||||
if(object==null)
|
||||
object=new DeckSelectScene();
|
||||
return object;
|
||||
}
|
||||
public DeckSelectScene() {
|
||||
super(Forge.isLandscapeMode() ? "ui/deck_selector.json" : "ui/deck_selector_portrait.json");
|
||||
|
||||
layout = new Table();
|
||||
stage.addActor(layout);
|
||||
|
||||
header = Controls.newLabel(Forge.getLocalizer().getMessage("lblSelectYourDeck"));
|
||||
header = Controls.newTextraLabel(Forge.getLocalizer().getMessage("lblSelectYourDeck"));
|
||||
layout.add(header).colspan(2).align(Align.center).pad(2, 5, 2, 5);
|
||||
layout.row();
|
||||
for (int i = 0; i < AdventurePlayer.NUMBER_OF_DECKS; i++)
|
||||
@@ -50,11 +59,8 @@ public class DeckSelectScene extends UIScene {
|
||||
dialog.hide();
|
||||
|
||||
back = ui.findActor("return");
|
||||
back.getLabel().setText(Forge.getLocalizer().getMessage("lblBack"));
|
||||
edit = ui.findActor("edit");
|
||||
edit.getLabel().setText(Forge.getLocalizer().getMessage("lblEdit"));
|
||||
rename = ui.findActor("rename");
|
||||
rename.getLabel().setText(Forge.getLocalizer().getMessage("lblRename"));
|
||||
ui.onButtonPress("return", () -> DeckSelectScene.this.back());
|
||||
ui.onButtonPress("edit", () -> DeckSelectScene.this.edit());
|
||||
ui.onButtonPress("rename", () -> {
|
||||
@@ -68,8 +74,8 @@ public class DeckSelectScene extends UIScene {
|
||||
scrollPane.setActor(layout);
|
||||
}
|
||||
|
||||
private TextButton addDeckSlot(String name, int i) {
|
||||
TextButton button = Controls.newTextButton("-");
|
||||
private TextraButton addDeckSlot(String name, int i) {
|
||||
TextraButton button = Controls.newTextButton("-");
|
||||
button.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
@@ -96,11 +102,11 @@ public class DeckSelectScene extends UIScene {
|
||||
public boolean select(int slot) {
|
||||
currentSlot = slot;
|
||||
|
||||
for (IntMap.Entry<TextButton> butt : new IntMap.Entries<TextButton>(buttons)) {
|
||||
for (IntMap.Entry<TextraButton> butt : new IntMap.Entries<TextraButton>(buttons)) {
|
||||
butt.value.setColor(defColor);
|
||||
}
|
||||
if (buttons.containsKey(slot)) {
|
||||
TextButton button = buttons.get(slot);
|
||||
TextraButton button = buttons.get(slot);
|
||||
button.setColor(Color.RED);
|
||||
}
|
||||
Current.player().setSelectedDeckSlot(slot);
|
||||
@@ -136,47 +142,7 @@ public class DeckSelectScene extends UIScene {
|
||||
super.enter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resLoaded() {
|
||||
super.resLoaded();
|
||||
layout = new Table();
|
||||
stage.addActor(layout);
|
||||
|
||||
header = Controls.newLabel(Forge.getLocalizer().getMessage("lblSelectYourDeck"));
|
||||
layout.add(header).colspan(2).align(Align.center).pad(2, 5, 2, 5);
|
||||
layout.row();
|
||||
for (int i = 0; i < AdventurePlayer.NUMBER_OF_DECKS; i++)
|
||||
addDeckSlot(Forge.getLocalizer().getMessage("lblDeck")+": " + (i + 1), i);
|
||||
|
||||
dialog = Controls.newDialog(Forge.getLocalizer().getMessage("lblSave"));
|
||||
textInput = Controls.newTextField("");
|
||||
dialog.getButtonTable().add(Controls.newLabel(Forge.getLocalizer().getMessage("lblNameYourSaveFile"))).colspan(2);
|
||||
dialog.getButtonTable().row();
|
||||
dialog.getButtonTable().add(Controls.newLabel(Forge.getLocalizer().getMessage("lblName")+": ")).align(Align.left);
|
||||
dialog.getButtonTable().add(textInput).fillX().expandX();
|
||||
dialog.getButtonTable().row();
|
||||
dialog.getButtonTable().add(Controls.newTextButton(Forge.getLocalizer().getMessage("lblRename"), () -> DeckSelectScene.this.rename())).align(Align.left);
|
||||
dialog.getButtonTable().add(Controls.newTextButton(Forge.getLocalizer().getMessage("lblAbort"), () -> dialog.hide())).align(Align.left);
|
||||
|
||||
back = ui.findActor("return");
|
||||
back.getLabel().setText(Forge.getLocalizer().getMessage("lblBack"));
|
||||
edit = ui.findActor("edit");
|
||||
edit.getLabel().setText(Forge.getLocalizer().getMessage("lblEdit"));
|
||||
rename = ui.findActor("rename");
|
||||
rename.getLabel().setText(Forge.getLocalizer().getMessage("lblRename"));
|
||||
ui.onButtonPress("return", () -> DeckSelectScene.this.back());
|
||||
ui.onButtonPress("edit", () -> DeckSelectScene.this.edit());
|
||||
ui.onButtonPress("rename", () -> {
|
||||
textInput.setText(Current.player().getSelectedDeck().getName());
|
||||
dialog.show(stage);
|
||||
stage.setKeyboardFocus(textInput);
|
||||
});
|
||||
defColor = ui.findActor("return").getColor();
|
||||
|
||||
ScrollPane scrollPane = ui.findActor("deckSlots");
|
||||
scrollPane.setActor(layout);
|
||||
|
||||
}
|
||||
|
||||
private void rename() {
|
||||
dialog.hide();
|
||||
@@ -186,6 +152,6 @@ public class DeckSelectScene extends UIScene {
|
||||
}
|
||||
|
||||
private void edit() {
|
||||
Forge.switchScene(SceneType.DeckEditScene.instance);
|
||||
Forge.switchScene(DeckEditScene.getInstance());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,13 +3,16 @@ package forge.adventure.scene;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.InputProcessor;
|
||||
import com.badlogic.gdx.graphics.GL20;
|
||||
import forge.Forge;
|
||||
import forge.adventure.stage.GameHUD;
|
||||
import forge.adventure.stage.GameStage;
|
||||
import forge.adventure.stage.IAfterMatch;
|
||||
import forge.adventure.stage.MapStage;
|
||||
|
||||
/**
|
||||
* Hud base scene
|
||||
*/
|
||||
public abstract class HudScene extends Scene implements InputProcessor, IAfterMatch {
|
||||
public abstract class HudScene extends Scene implements InputProcessor, IAfterMatch {
|
||||
|
||||
GameHUD hud;
|
||||
GameStage stage;
|
||||
|
||||
@@ -2,8 +2,7 @@ package forge.adventure.scene;
|
||||
|
||||
import com.badlogic.gdx.Input;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.github.tommyettinger.textra.TextraButton;
|
||||
import forge.Forge;
|
||||
import forge.adventure.stage.GameHUD;
|
||||
import forge.adventure.util.Current;
|
||||
@@ -20,38 +19,19 @@ public class InnScene extends UIScene {
|
||||
return object;
|
||||
}
|
||||
|
||||
TextButton tempHitPointCost, sell, leave;
|
||||
Label tempHitPoints;
|
||||
TextraButton tempHitPointCost, sell, leave;
|
||||
Image healIcon, sellIcon, leaveIcon;
|
||||
|
||||
private InnScene() {
|
||||
|
||||
super(Forge.isLandscapeMode() ? "ui/inn.json" : "ui/inn_portrait.json");
|
||||
ui.onButtonPress("done", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
InnScene.this.done();
|
||||
}
|
||||
});
|
||||
ui.onButtonPress("tempHitPointCost", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
InnScene.this.potionOfFalseLife();
|
||||
}
|
||||
});
|
||||
ui.onButtonPress("sell", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
InnScene.this.sell();
|
||||
}
|
||||
});
|
||||
tempHitPointCost = ui.findActor("tempHitPointCost");
|
||||
ui.onButtonPress("done", InnScene.this::done);
|
||||
ui.onButtonPress("tempHitPointCost", InnScene.this::potionOfFalseLife);
|
||||
ui.onButtonPress("sell", InnScene.this::sell);
|
||||
leave = ui.findActor("done");
|
||||
leave.getLabel().setText(Forge.getLocalizer().getMessage("lblLeave"));
|
||||
sell = ui.findActor("sell");
|
||||
sell.getLabel().setText(Forge.getLocalizer().getMessage("lblSell"));
|
||||
|
||||
tempHitPoints = ui.findActor("tempHitPoints");
|
||||
tempHitPoints.setText(Forge.getLocalizer().getMessageorUseDefault("lblTempHitPoints", "Temporary Hit Points"));
|
||||
|
||||
leaveIcon = ui.findActor("leaveIcon");
|
||||
healIcon = ui.findActor("healIcon");
|
||||
@@ -89,9 +69,8 @@ public class InnScene extends UIScene {
|
||||
boolean purchaseable = Current.player().getMaxLife() == Current.player().getLife() &&
|
||||
tempHealthCost <= Current.player().getGold();
|
||||
|
||||
tempHitPointCost = ui.findActor("tempHitPointCost");
|
||||
tempHitPointCost.setDisabled(!purchaseable);
|
||||
tempHitPointCost.getLabel().setText("$" + tempHealthCost);
|
||||
tempHitPointCost.setText( tempHealthCost+"[+Gold]");
|
||||
clearActorObjects();
|
||||
addActorObject(tempHitPointCost);
|
||||
addActorObject(sell);
|
||||
|
||||
@@ -8,6 +8,8 @@ import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Timer;
|
||||
import com.github.tommyettinger.textra.TextraButton;
|
||||
import com.github.tommyettinger.textra.TextraLabel;
|
||||
import forge.Forge;
|
||||
import forge.adventure.data.ItemData;
|
||||
import forge.adventure.stage.ConsoleCommandInterpreter;
|
||||
@@ -22,10 +24,10 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class InventoryScene extends UIScene {
|
||||
TextButton leave;
|
||||
TextraButton leave;
|
||||
Button equipButton;
|
||||
TextButton useButton;
|
||||
Label itemDescription;
|
||||
TextraButton useButton;
|
||||
TextraLabel itemDescription;
|
||||
Dialog confirm;
|
||||
Dialog useDialog;
|
||||
private Table inventory;
|
||||
@@ -51,7 +53,6 @@ public class InventoryScene extends UIScene {
|
||||
deleteButton = ui.findActor("delete");
|
||||
itemDescription = ui.findActor("item_description");
|
||||
itemDescription.setAlignment(Align.topLeft);
|
||||
leave.getLabel().setText(Forge.getLocalizer().getMessage("lblBack"));
|
||||
|
||||
inventoryButtons=new Array<>();
|
||||
equipmentSlots=new HashMap<>();
|
||||
@@ -102,7 +103,7 @@ public class InventoryScene extends UIScene {
|
||||
});
|
||||
}
|
||||
}
|
||||
inventory = new Table(Controls.GetSkin());
|
||||
inventory = new Table(Controls.getSkin());
|
||||
ScrollPane scrollPane = ui.findActor("inventory");
|
||||
scrollPane.setScrollingDisabled(true,false);
|
||||
scrollPane.setActor(inventory);
|
||||
@@ -110,7 +111,7 @@ public class InventoryScene extends UIScene {
|
||||
columns-=1;
|
||||
if(columns<=0)columns=1;
|
||||
scrollPane.setActor(inventory);
|
||||
confirm = new Dialog("\n "+Forge.getLocalizer().getMessage("lblDelete"), Controls.GetSkin())
|
||||
confirm = new Dialog("", Controls.getSkin())
|
||||
{
|
||||
protected void result(Object object)
|
||||
{
|
||||
@@ -119,6 +120,7 @@ public class InventoryScene extends UIScene {
|
||||
confirm.hide();
|
||||
};
|
||||
};
|
||||
confirm.text( Controls.newLabel(Forge.getLocalizer().getMessage("lblDelete")));
|
||||
|
||||
confirm.button(Forge.getLocalizer().getMessage("lblYes"), true);
|
||||
confirm.button(Forge.getLocalizer().getMessage("lblNo"), false);
|
||||
@@ -130,7 +132,7 @@ public class InventoryScene extends UIScene {
|
||||
confirm.getColor().a = 0;
|
||||
|
||||
|
||||
useDialog = new Dialog("\n "+Forge.getLocalizer().getMessage("lblDelete"), Controls.GetSkin())
|
||||
useDialog = new Dialog("", Controls.getSkin())
|
||||
{
|
||||
protected void result(Object object)
|
||||
{
|
||||
@@ -221,10 +223,10 @@ public class InventoryScene extends UIScene {
|
||||
boolean isInPoi = MapStage.getInstance().isInMap();
|
||||
useButton.setDisabled(!(isInPoi&&data.usableInPoi||!isInPoi&&data.usableOnWorldMap));
|
||||
if(data.manaNeeded==0)
|
||||
useButton.setText("Use Item");
|
||||
useButton.setText("Use");
|
||||
else
|
||||
useButton.setText("Use Item ("+data.manaNeeded+" mana)");
|
||||
|
||||
useButton.setText("Use "+data.manaNeeded+"[+Mana]");
|
||||
useButton.layout();
|
||||
if(Current.player().getMana()<data.manaNeeded)
|
||||
useButton.setDisabled(true);
|
||||
|
||||
@@ -235,9 +237,9 @@ public class InventoryScene extends UIScene {
|
||||
else
|
||||
{
|
||||
equipButton.setDisabled(false);
|
||||
if(equipButton instanceof TextButton)
|
||||
if(equipButton instanceof TextraButton)
|
||||
{
|
||||
TextButton button=(TextButton) equipButton;
|
||||
TextraButton button=(TextraButton) equipButton;
|
||||
String item=Current.player().itemInSlot(data.equipmentSlot);
|
||||
if(item!=null&&item.equals(data.name))
|
||||
{
|
||||
@@ -247,6 +249,7 @@ public class InventoryScene extends UIScene {
|
||||
{
|
||||
button.setText("Equip");
|
||||
}
|
||||
button.layout();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,7 +334,7 @@ public class InventoryScene extends UIScene {
|
||||
|
||||
public Button createInventorySlot() {
|
||||
|
||||
ImageButton button=new ImageButton(Controls.GetSkin(),"item_frame");
|
||||
ImageButton button=new ImageButton(Controls.getSkin(),"item_frame");
|
||||
return button;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,10 +5,13 @@ import com.badlogic.gdx.Input;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.*;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextField;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.github.tommyettinger.textra.TextraButton;
|
||||
import com.github.tommyettinger.textra.TextraLabel;
|
||||
import forge.Forge;
|
||||
import forge.adventure.data.DifficultyData;
|
||||
import forge.adventure.data.HeroListData;
|
||||
@@ -41,7 +44,7 @@ public class NewGameScene extends UIScene {
|
||||
private Selector mode;
|
||||
private Selector difficulty;
|
||||
private Array<String> stringList, random, custom;
|
||||
private Label colorLabel;
|
||||
private TextraLabel colorLabel;
|
||||
private int selected = -1;
|
||||
|
||||
private NewGameScene() {
|
||||
@@ -64,7 +67,7 @@ public class NewGameScene extends UIScene {
|
||||
gender = ui.findActor("gender");
|
||||
mode = ui.findActor("mode");
|
||||
colorLabel = ui.findActor("colorIdL");
|
||||
String colorIdLabel = colorLabel.getText().toString();
|
||||
String colorIdLabel = colorLabel.storedText;
|
||||
custom = new Array<>();
|
||||
for (DeckProxy deckProxy : DeckProxy.getAllCustomStarterDecks())
|
||||
custom.add(deckProxy.getName());
|
||||
@@ -314,7 +317,7 @@ public class NewGameScene extends UIScene {
|
||||
performTouch(selectedKey);
|
||||
} else {
|
||||
if (selectedActor != null) {
|
||||
if (selectedActor instanceof TextButton)
|
||||
if (selectedActor instanceof TextraButton)
|
||||
performTouch(selectedActor);
|
||||
else if (selectedActor instanceof TextField && !kbVisible) {
|
||||
lastInputField = selectedActor;
|
||||
|
||||
@@ -3,9 +3,13 @@ package forge.adventure.scene;
|
||||
import com.badlogic.gdx.Input;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.*;
|
||||
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.utils.TextureRegionDrawable;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.github.tommyettinger.textra.TextraButton;
|
||||
import com.github.tommyettinger.textra.TextraLabel;
|
||||
import forge.Forge;
|
||||
import forge.adventure.character.EnemySprite;
|
||||
import forge.adventure.data.EnemyData;
|
||||
@@ -26,32 +30,27 @@ import java.util.Map;
|
||||
public class PlayerStatisticScene extends UIScene {
|
||||
Image avatar, avatarBorder, lifeIcon, goldIcon;
|
||||
Image colorFrame;
|
||||
Label money, life;
|
||||
Label wins, totalWins;
|
||||
Label loss, totalLoss;
|
||||
Label winloss, lossWinRatio;
|
||||
Label playerName;
|
||||
TextButton back;
|
||||
private Table enemiesGroup;
|
||||
Label blessingScroll;
|
||||
TextraLabel money, life;
|
||||
TextraLabel wins, totalWins;
|
||||
TextraLabel loss, totalLoss;
|
||||
TextraLabel winloss, lossWinRatio;
|
||||
TextraLabel playerName;
|
||||
TextraButton back;
|
||||
private final Table enemiesGroup;
|
||||
TextraLabel blessingScroll;
|
||||
ScrollPane scrollPane, blessing;
|
||||
|
||||
private PlayerStatisticScene() {
|
||||
super(Forge.isLandscapeMode() ? "ui/statistic.json" : "ui/statistic_portrait.json");
|
||||
|
||||
|
||||
enemiesGroup = new Table(Controls.GetSkin());
|
||||
enemiesGroup = new Table(Controls.getSkin());
|
||||
enemiesGroup.row();
|
||||
blessingScroll = Controls.newLabel("");
|
||||
blessingScroll.setStyle(new Label.LabelStyle(Controls.getBitmapFont("default"), Color.BLACK));
|
||||
blessingScroll = Controls.newTextraLabel("");
|
||||
blessingScroll.setColor(Color.BLACK);
|
||||
blessingScroll.setAlignment(Align.topLeft);
|
||||
blessingScroll.setWrap(true);
|
||||
ui.onButtonPress("return", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlayerStatisticScene.this.back();
|
||||
}
|
||||
});
|
||||
ui.onButtonPress("return", PlayerStatisticScene.this::back);
|
||||
|
||||
avatar = ui.findActor("avatar");
|
||||
avatarBorder = ui.findActor("avatarBorder");
|
||||
@@ -62,16 +61,12 @@ public class PlayerStatisticScene extends UIScene {
|
||||
goldIcon = ui.findActor("goldIcon");
|
||||
wins = ui.findActor("wins");
|
||||
colorFrame = ui.findActor("colorFrame");
|
||||
wins.setText(Forge.getLocalizer().getMessage("lblWinProper")+":");
|
||||
totalWins = ui.findActor("totalWins");
|
||||
loss = ui.findActor("loss");
|
||||
loss.setText(Forge.getLocalizer().getMessage("lblLossProper")+":");
|
||||
totalLoss = ui.findActor("totalLoss");
|
||||
winloss = ui.findActor("winloss");
|
||||
winloss.setText(Forge.getLocalizer().getMessage("lblWinProper")+"/"+Forge.getLocalizer().getMessage("lblLossProper"));
|
||||
lossWinRatio = ui.findActor("lossWinRatio");
|
||||
back = ui.findActor("return");
|
||||
back.getLabel().setText(Forge.getLocalizer().getMessage("lblBack"));
|
||||
ScrollPane scrollPane = ui.findActor("enemies");
|
||||
scrollPane.setActor(enemiesGroup);
|
||||
ScrollPane blessing = ui.findActor("blessingInfo");
|
||||
@@ -157,10 +152,10 @@ public class PlayerStatisticScene extends UIScene {
|
||||
WorldSave.getCurrentSave().getPlayer().onGoldChange(() -> money.setText(String.valueOf(AdventurePlayer.current().getGold())));
|
||||
}
|
||||
if (totalWins != null) {
|
||||
totalWins.setText(Current.player().getStatistic().totalWins());
|
||||
totalWins.setText(String.valueOf(Current.player().getStatistic().totalWins()));
|
||||
}
|
||||
if (totalLoss != null) {
|
||||
totalLoss.setText(Current.player().getStatistic().totalLoss());
|
||||
totalLoss.setText(String.valueOf(Current.player().getStatistic().totalLoss()));
|
||||
}
|
||||
if (lossWinRatio != null) {
|
||||
lossWinRatio.setText(Float.toString(Current.player().getStatistic().winLossRatio()));
|
||||
@@ -194,42 +189,6 @@ public class PlayerStatisticScene extends UIScene {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resLoaded() {
|
||||
super.resLoaded();
|
||||
enemiesGroup = new Table(Controls.GetSkin());
|
||||
enemiesGroup.row();
|
||||
blessingScroll = Controls.newLabel("");
|
||||
blessingScroll.setStyle(new Label.LabelStyle(Controls.getBitmapFont("default"), 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");
|
||||
life = ui.findActor("lifePoints");
|
||||
money = ui.findActor("money");
|
||||
lifeIcon = ui.findActor("lifeIcon");
|
||||
goldIcon = ui.findActor("goldIcon");
|
||||
wins = ui.findActor("wins");
|
||||
colorFrame = ui.findActor("colorFrame");
|
||||
wins.setText(Forge.getLocalizer().getMessage("lblWinProper")+":");
|
||||
totalWins = ui.findActor("totalWins");
|
||||
loss = ui.findActor("loss");
|
||||
loss.setText(Forge.getLocalizer().getMessage("lblLossProper")+":");
|
||||
totalLoss = ui.findActor("totalLoss");
|
||||
winloss = ui.findActor("winloss");
|
||||
winloss.setText(Forge.getLocalizer().getMessage("lblWinProper")+"/"+Forge.getLocalizer().getMessage("lblLossProper"));
|
||||
lossWinRatio = ui.findActor("lossWinRatio");
|
||||
back = ui.findActor("return");
|
||||
back.getLabel().setText(Forge.getLocalizer().getMessage("lblBack"));
|
||||
scrollPane = ui.findActor("enemies");
|
||||
scrollPane.setActor(enemiesGroup);
|
||||
blessing = ui.findActor("blessingInfo");
|
||||
blessing.setActor(blessingScroll);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create() {
|
||||
|
||||
@@ -4,10 +4,11 @@ import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Input;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Timer;
|
||||
import com.github.tommyettinger.textra.TextraButton;
|
||||
import com.github.tommyettinger.textra.TextraLabel;
|
||||
import forge.Forge;
|
||||
import forge.adventure.character.ShopActor;
|
||||
import forge.adventure.player.AdventurePlayer;
|
||||
@@ -23,8 +24,8 @@ import forge.sound.SoundSystem;
|
||||
* Displays the rewards of a fight or a treasure
|
||||
*/
|
||||
public class RewardScene extends UIScene {
|
||||
private TextButton doneButton;
|
||||
private Label goldLabel;
|
||||
private TextraButton doneButton;
|
||||
private TextraLabel goldLabel;
|
||||
|
||||
private static RewardScene object;
|
||||
|
||||
@@ -272,7 +273,7 @@ public class RewardScene extends UIScene {
|
||||
switch (type) {
|
||||
case Shop:
|
||||
doneButton.setText(Forge.getLocalizer().getMessage("lblLeave"));
|
||||
goldLabel.setText("Gold:"+Current.player().getGold());
|
||||
goldLabel.setText(Current.player().getGold()+"[+Gold]");
|
||||
break;
|
||||
case Loot:
|
||||
goldLabel.setText("");
|
||||
@@ -360,7 +361,7 @@ public class RewardScene extends UIScene {
|
||||
if (currentRow != ((i + 1) / numberOfColumns))
|
||||
yOff += doneButton.getHeight();
|
||||
|
||||
TextButton buyCardButton = new BuyButton(shopActor.getObjectId(), i, shopActor.isUnlimited()?null:shopActor.getMapStage().getChanges(), actor, doneButton);
|
||||
TextraButton buyCardButton = new BuyButton(shopActor.getObjectId(), i, shopActor.isUnlimited()?null:shopActor.getMapStage().getChanges(), actor, doneButton);
|
||||
generated.add(buyCardButton);
|
||||
if (!skipCard) {
|
||||
stage.addActor(buyCardButton);
|
||||
@@ -386,7 +387,7 @@ public class RewardScene extends UIScene {
|
||||
}
|
||||
}
|
||||
|
||||
private class BuyButton extends TextButton {
|
||||
private class BuyButton extends TextraButton {
|
||||
private final int objectID;
|
||||
private final int index;
|
||||
private final PointOfInterestChanges changes;
|
||||
@@ -397,7 +398,7 @@ public class RewardScene extends UIScene {
|
||||
setDisabled(WorldSave.getCurrentSave().getPlayer().getGold() < price);
|
||||
}
|
||||
|
||||
public BuyButton(int id, int i, PointOfInterestChanges ch, RewardActor actor, TextButton style) {
|
||||
public BuyButton(int id, int i, PointOfInterestChanges ch, RewardActor actor, TextraButton style) {
|
||||
super("", style.getStyle());
|
||||
this.objectID = id;
|
||||
this.index = i;
|
||||
|
||||
@@ -12,6 +12,8 @@ import com.badlogic.gdx.utils.Align;
|
||||
import com.badlogic.gdx.utils.GdxRuntimeException;
|
||||
import com.badlogic.gdx.utils.IntMap;
|
||||
import com.badlogic.gdx.utils.Scaling;
|
||||
import com.github.tommyettinger.textra.TextraButton;
|
||||
import com.github.tommyettinger.textra.TextraLabel;
|
||||
import forge.Forge;
|
||||
import forge.adventure.data.DifficultyData;
|
||||
import forge.adventure.util.Config;
|
||||
@@ -32,19 +34,19 @@ import java.util.zip.InflaterInputStream;
|
||||
* Scene to load and save the game.
|
||||
*/
|
||||
public class SaveLoadScene extends UIScene {
|
||||
private final IntMap<TextButton> buttons = new IntMap<>();
|
||||
private final IntMap<TextraButton> buttons = new IntMap<>();
|
||||
IntMap<WorldSaveHeader> previews = new IntMap<>();
|
||||
Color defColor;
|
||||
Table layout;
|
||||
Modes mode;
|
||||
Dialog dialog;
|
||||
TextField textInput;
|
||||
Label header;
|
||||
TextraLabel header;
|
||||
int currentSlot = -3, lastSelectedSlot = 0;
|
||||
Image previewImage;
|
||||
Label previewDate;
|
||||
TextraLabel previewDate;
|
||||
Image previewBorder;
|
||||
TextButton saveLoadButton, back, quickSave, autoSave, dialogSaveBtn, dialogAbortBtn;
|
||||
TextraButton saveLoadButton, back, quickSave, autoSave, dialogSaveBtn, dialogAbortBtn;
|
||||
Actor lastHighlightedSave;
|
||||
SelectBox difficulty;
|
||||
ScrollPane scrollPane;
|
||||
@@ -73,14 +75,17 @@ public class SaveLoadScene extends UIScene {
|
||||
dialog.getButtonTable().add(Controls.newLabel(Forge.getLocalizer().getMessage("lblName") + ": ")).align(Align.left).pad(2, 15, 2, 2);
|
||||
dialog.getButtonTable().add(textInput).fillX().expandX().padRight(15);
|
||||
dialog.getButtonTable().row();
|
||||
dialog.getButtonTable().add(Controls.newTextButton(Forge.getLocalizer().getMessage("lblSave"), () -> SaveLoadScene.this.save())).align(Align.left).padLeft(15);
|
||||
dialog.getButtonTable().add(Controls.newTextButton(Forge.getLocalizer().getMessage("lblAbort"), () -> SaveLoadScene.this.saveAbort())).align(Align.right).padRight(15);
|
||||
dialogSaveBtn = Controls.newTextButton(Forge.getLocalizer().getMessage("lblSave"), () -> SaveLoadScene.this.save());
|
||||
dialog.getButtonTable().add(dialogSaveBtn).align(Align.left).padLeft(15);
|
||||
dialogAbortBtn = Controls.newTextButton(Forge.getLocalizer().getMessage("lblAbort"), () -> SaveLoadScene.this.saveAbort());
|
||||
dialog.getButtonTable().add(dialogAbortBtn).align(Align.right).padRight(15);
|
||||
|
||||
//makes dialog hidden immediately when you open saveload scene..
|
||||
dialog.getColor().a = 0;
|
||||
dialog.hide();
|
||||
previewImage = ui.findActor("preview");
|
||||
previewDate = ui.findActor("saveDate");
|
||||
header = Controls.newLabel(Forge.getLocalizer().getMessage("lblSave"));
|
||||
header = Controls.newTextraLabel(Forge.getLocalizer().getMessage("lblSave"));
|
||||
header.setAlignment(Align.center);
|
||||
layout.add(header).pad(2).colspan(4).align(Align.center).expandX();
|
||||
layout.row();
|
||||
@@ -90,15 +95,14 @@ public class SaveLoadScene extends UIScene {
|
||||
addSaveSlot(Forge.getLocalizer().getMessage("lblSlot") + ": " + i, i);
|
||||
|
||||
saveLoadButton = ui.findActor("save");
|
||||
saveLoadButton.getLabel().setText(Forge.getLocalizer().getMessage("lblSave"));
|
||||
saveLoadButton.setText(Forge.getLocalizer().getMessage("lblSave"));
|
||||
ui.onButtonPress("save", () -> SaveLoadScene.this.loadSave());
|
||||
back = ui.findActor("return");
|
||||
back.getLabel().setText(Forge.getLocalizer().getMessage("lblBack"));
|
||||
ui.onButtonPress("return", () -> SaveLoadScene.this.back());
|
||||
|
||||
defColor = saveLoadButton.getColor();
|
||||
|
||||
ScrollPane scrollPane = ui.findActor("saveSlots");
|
||||
scrollPane = ui.findActor("saveSlots");
|
||||
scrollPane.setActor(layout);
|
||||
ui.addActor(difficulty);
|
||||
difficulty.setSelectedIndex(1);
|
||||
@@ -123,9 +127,9 @@ public class SaveLoadScene extends UIScene {
|
||||
}
|
||||
|
||||
|
||||
private TextButton addSaveSlot(String name, int i) {
|
||||
private TextraButton addSaveSlot(String name, int i) {
|
||||
layout.add(Controls.newLabel(name)).align(Align.left).pad(2, 5, 2, 10);
|
||||
TextButton button = Controls.newTextButton("...");
|
||||
TextraButton button = Controls.newTextButton("...");
|
||||
button.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
@@ -137,7 +141,7 @@ public class SaveLoadScene extends UIScene {
|
||||
}
|
||||
}
|
||||
});
|
||||
layout.add(button).align(Align.left).expandX();
|
||||
layout.add(button).fill(true,false).expand(true,false).align(Align.left).expandX();
|
||||
buttons.put(i, button);
|
||||
layout.row();
|
||||
return button;
|
||||
@@ -171,11 +175,11 @@ public class SaveLoadScene extends UIScene {
|
||||
if (previewDate != null)
|
||||
previewDate.setVisible(false);
|
||||
}
|
||||
for (IntMap.Entry<TextButton> butt : new IntMap.Entries<TextButton>(buttons)) {
|
||||
for (IntMap.Entry<TextraButton> butt : new IntMap.Entries<TextraButton>(buttons)) {
|
||||
butt.value.setColor(defColor);
|
||||
}
|
||||
if (buttons.containsKey(slot)) {
|
||||
TextButton button = buttons.get(slot);
|
||||
TextraButton button = buttons.get(slot);
|
||||
button.setColor(Color.RED);
|
||||
selectActor(button, false);
|
||||
}
|
||||
@@ -448,8 +452,8 @@ public class SaveLoadScene extends UIScene {
|
||||
else
|
||||
select(-3);
|
||||
updateFiles();
|
||||
autoSave.getLabel().setText(Forge.getLocalizer().getMessage("lblAutoSave"));
|
||||
quickSave.getLabel().setText(Forge.getLocalizer().getMessage("lblQuickSave"));
|
||||
autoSave.setText(Forge.getLocalizer().getMessage("lblAutoSave"));
|
||||
quickSave.setText(Forge.getLocalizer().getMessage("lblQuickSave"));
|
||||
if (mode == Modes.NewGamePlus) {
|
||||
if (difficulty != null) {
|
||||
difficulty.setVisible(true);
|
||||
@@ -485,70 +489,4 @@ public class SaveLoadScene extends UIScene {
|
||||
super.enter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resLoaded() {
|
||||
super.resLoaded();
|
||||
layout = new Table();
|
||||
stage.addActor(layout);
|
||||
dialog = Controls.newDialog(Forge.getLocalizer().getMessage("lblSave"));
|
||||
textInput = Controls.newTextField("");
|
||||
int c = 0;
|
||||
String[] diffList = new String[Config.instance().getConfigData().difficulties.length];
|
||||
for (DifficultyData diff : Config.instance().getConfigData().difficulties) {
|
||||
diffList[c] = diff.name;
|
||||
c++;
|
||||
}
|
||||
;
|
||||
|
||||
difficulty = Controls.newComboBox(diffList, null, o -> {
|
||||
//DifficultyData difficulty1 = Config.instance().getConfigData().difficulties[difficulty.getSelectedIndex()];
|
||||
return null;
|
||||
});
|
||||
dialog.getButtonTable().add(Controls.newLabel(Forge.getLocalizer().getMessage("lblNameYourSaveFile"))).colspan(2).pad(2, 15, 2, 15);
|
||||
dialog.getButtonTable().row();
|
||||
dialog.getButtonTable().add(Controls.newLabel(Forge.getLocalizer().getMessage("lblName") + ": ")).align(Align.left).pad(2, 15, 2, 2);
|
||||
dialog.getButtonTable().add(textInput).fillX().expandX().padRight(15);
|
||||
dialog.getButtonTable().row();
|
||||
dialogSaveBtn = Controls.newTextButton(Forge.getLocalizer().getMessage("lblSave"), () -> SaveLoadScene.this.save());
|
||||
dialog.getButtonTable().add(dialogSaveBtn).align(Align.left).padLeft(15);
|
||||
dialogAbortBtn = Controls.newTextButton(Forge.getLocalizer().getMessage("lblAbort"), () -> SaveLoadScene.this.saveAbort());
|
||||
dialog.getButtonTable().add(dialogAbortBtn).align(Align.right).padRight(15);
|
||||
|
||||
//makes dialog hidden immediately when you open saveload scene..
|
||||
dialog.getColor().a = 0;
|
||||
dialog.hide();
|
||||
previewImage = ui.findActor("preview");
|
||||
previewDate = ui.findActor("saveDate");
|
||||
header = Controls.newLabel(Forge.getLocalizer().getMessage("lblSave"));
|
||||
header.setAlignment(Align.center);
|
||||
layout.add(header).pad(2).colspan(4).align(Align.center).expandX();
|
||||
layout.row();
|
||||
autoSave = addSaveSlot(Forge.getLocalizer().getMessage("lblAutoSave"), WorldSave.AUTO_SAVE_SLOT);
|
||||
quickSave = addSaveSlot(Forge.getLocalizer().getMessage("lblQuickSave"), WorldSave.QUICK_SAVE_SLOT);
|
||||
for (int i = 1; i < 11; i++)
|
||||
addSaveSlot(Forge.getLocalizer().getMessage("lblSlot") + ": " + i, i);
|
||||
|
||||
saveLoadButton = ui.findActor("save");
|
||||
saveLoadButton.getLabel().setText(Forge.getLocalizer().getMessage("lblSave"));
|
||||
ui.onButtonPress("save", () -> SaveLoadScene.this.loadSave());
|
||||
back = ui.findActor("return");
|
||||
back.getLabel().setText(Forge.getLocalizer().getMessage("lblBack"));
|
||||
ui.onButtonPress("return", () -> SaveLoadScene.this.back());
|
||||
|
||||
defColor = saveLoadButton.getColor();
|
||||
|
||||
scrollPane = ui.findActor("saveSlots");
|
||||
scrollPane.setActor(layout);
|
||||
ui.addActor(difficulty);
|
||||
difficulty.setSelectedIndex(1);
|
||||
difficulty.setAlignment(Align.center);
|
||||
difficulty.getStyle().fontColor = Color.GOLD;
|
||||
if (Forge.isLandscapeMode()) {
|
||||
difficulty.setX(280);
|
||||
difficulty.setY(220);
|
||||
} else {
|
||||
difficulty.setX(190);
|
||||
difficulty.setY(336);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package forge.adventure.scene;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Input;
|
||||
import com.badlogic.gdx.graphics.GL20;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.*;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.github.tommyettinger.textra.TextraButton;
|
||||
import com.github.tommyettinger.textra.TextraLabel;
|
||||
import forge.Forge;
|
||||
import forge.adventure.util.Config;
|
||||
import forge.adventure.util.Controls;
|
||||
@@ -24,123 +24,12 @@ public class SettingsScene extends UIScene {
|
||||
Stage stage;
|
||||
Texture Background;
|
||||
private Table settingGroup;
|
||||
TextButton back;
|
||||
TextraButton backButton;
|
||||
ScrollPane scrollPane;
|
||||
|
||||
private SettingsScene() {
|
||||
super(Forge.isLandscapeMode() ? "ui/settings.json" : "ui/settings_portrait.json");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
if (stage != null)
|
||||
stage.dispose();
|
||||
}
|
||||
|
||||
public void renderAct(float delta) {
|
||||
Gdx.gl.glClearColor(1, 0, 1, 1);
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
stage.getBatch().begin();
|
||||
stage.getBatch().disableBlending();
|
||||
stage.getBatch().draw(Background, 0, 0, getIntendedWidth(), getIntendedHeight());
|
||||
stage.getBatch().enableBlending();
|
||||
stage.getBatch().end();
|
||||
stage.act(delta);
|
||||
stage.draw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keycode) {
|
||||
if (keycode == Input.Keys.ESCAPE || keycode == Input.Keys.BACK) {
|
||||
back();
|
||||
}
|
||||
if (keycode == Input.Keys.BUTTON_B)
|
||||
performTouch(back);
|
||||
else if (keycode == Input.Keys.BUTTON_L1) {
|
||||
scrollPane.fling(1f, 0, -300);
|
||||
} else if (keycode == Input.Keys.BUTTON_R1) {
|
||||
scrollPane.fling(1f, 0, +300);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean back() {
|
||||
Forge.switchToLast();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void addInputField(String name, ForgePreferences.FPref pref) {
|
||||
TextField box = Controls.newTextField("");
|
||||
box.setText(Preference.getPref(pref));
|
||||
box.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
Preference.setPref(pref, ((TextField) actor).getText());
|
||||
Preference.save();
|
||||
}
|
||||
});
|
||||
|
||||
addLabel(name);
|
||||
settingGroup.add(box).align(Align.right);
|
||||
}
|
||||
|
||||
private void addCheckBox(String name, ForgePreferences.FPref pref) {
|
||||
CheckBox box = Controls.newCheckBox("");
|
||||
box.setChecked(Preference.getPrefBoolean(pref));
|
||||
box.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
Preference.setPref(pref, ((CheckBox) actor).isChecked());
|
||||
Preference.save();
|
||||
}
|
||||
});
|
||||
|
||||
addLabel(name);
|
||||
settingGroup.add(box).align(Align.right);
|
||||
}
|
||||
|
||||
private void addSettingSlider(String name, ForgePreferences.FPref pref, int min, int max) {
|
||||
Slider slide = Controls.newSlider(min, max, 1, false);
|
||||
slide.setValue(Preference.getPrefInt(pref));
|
||||
slide.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
Preference.setPref(pref, String.valueOf((int) ((Slider) actor).getValue()));
|
||||
Preference.save();
|
||||
}
|
||||
});
|
||||
addLabel(name);
|
||||
settingGroup.add(slide).align(Align.right);
|
||||
}
|
||||
|
||||
private void addSettingField(String name, boolean value, ChangeListener change) {
|
||||
CheckBox box = Controls.newCheckBox("");
|
||||
box.setChecked(value);
|
||||
box.addListener(change);
|
||||
addLabel(name);
|
||||
settingGroup.add(box).align(Align.right);
|
||||
}
|
||||
|
||||
private void addSettingField(String name, int value, ChangeListener change) {
|
||||
TextField text = Controls.newTextField(String.valueOf(value));
|
||||
text.setTextFieldFilter((textField, c) -> Character.isDigit(c));
|
||||
text.addListener(change);
|
||||
addLabel(name);
|
||||
settingGroup.add(text).align(Align.right);
|
||||
}
|
||||
|
||||
void addLabel(String name) {
|
||||
Label label = Controls.newLabel(name);
|
||||
label.setWrap(true);
|
||||
settingGroup.row().space(5);
|
||||
int w = Forge.isLandscapeMode() ? 160 : 80;
|
||||
settingGroup.add(label).align(Align.left).pad(2, 2, 2, 5).width(w).expand();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resLoaded() {
|
||||
super.resLoaded();
|
||||
settingGroup = new Table();
|
||||
if (Preference == null) {
|
||||
Preference = new ForgePreferences();
|
||||
@@ -271,47 +160,27 @@ public class SettingsScene extends UIScene {
|
||||
|
||||
|
||||
settingGroup.row();
|
||||
back = ui.findActor("return");
|
||||
back.getLabel().setText(Forge.getLocalizer().getMessage("lblBack"));
|
||||
backButton = ui.findActor("return");
|
||||
ui.onButtonPress("return", SettingsScene.this::back);
|
||||
|
||||
ScrollPane scrollPane = ui.findActor("settings");
|
||||
scrollPane.setActor(settingGroup);
|
||||
}
|
||||
|
||||
private static SettingsScene object;
|
||||
|
||||
public static SettingsScene instance() {
|
||||
if(object==null)
|
||||
object=new SettingsScene();
|
||||
return object;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
if (stage != null)
|
||||
stage.dispose();
|
||||
}
|
||||
|
||||
public void renderAct(float delta) {
|
||||
Gdx.gl.glClearColor(1, 0, 1, 1);
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
stage.getBatch().begin();
|
||||
stage.getBatch().disableBlending();
|
||||
stage.getBatch().draw(Background, 0, 0, getIntendedWidth(), getIntendedHeight());
|
||||
stage.getBatch().enableBlending();
|
||||
stage.getBatch().end();
|
||||
stage.act(delta);
|
||||
stage.draw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keycode) {
|
||||
if (keycode == Input.Keys.ESCAPE || keycode == Input.Keys.BACK) {
|
||||
back();
|
||||
}
|
||||
if (keycode == Input.Keys.BUTTON_B)
|
||||
performTouch(backButton);
|
||||
else if (keycode == Input.Keys.BUTTON_L1) {
|
||||
scrollPane.fling(1f, 0, -300);
|
||||
} else if (keycode == Input.Keys.BUTTON_R1) {
|
||||
scrollPane.fling(1f, 0, +300);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -381,13 +250,31 @@ public class SettingsScene extends UIScene {
|
||||
}
|
||||
|
||||
void addLabel(String name) {
|
||||
Label label = Controls.newLabel(name);
|
||||
TextraLabel label = Controls.newTextraLabel(name);
|
||||
label.setWrap(true);
|
||||
settingGroup.row().space(5);
|
||||
int w = Forge.isLandscapeMode() ? 160 : 80;
|
||||
settingGroup.add(label).align(Align.left).pad(2, 2, 2, 5).width(w).expand();
|
||||
}
|
||||
|
||||
|
||||
private static SettingsScene object;
|
||||
|
||||
public static SettingsScene instance() {
|
||||
if(object==null)
|
||||
object=new SettingsScene();
|
||||
return object;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
if (stage != null)
|
||||
stage.dispose();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void create() {
|
||||
|
||||
|
||||
@@ -3,12 +3,12 @@ package forge.adventure.scene;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||
import com.github.tommyettinger.textra.TextraButton;
|
||||
import com.github.tommyettinger.textra.TextraLabel;
|
||||
import forge.Forge;
|
||||
import forge.StaticData;
|
||||
import forge.adventure.data.RewardData;
|
||||
@@ -38,15 +38,15 @@ public class SpellSmithScene extends UIScene {
|
||||
}
|
||||
|
||||
private List<PaperCard> cardPool = new ArrayList<>();
|
||||
private Label goldLabel;
|
||||
private TextButton pullButton;
|
||||
private TextraLabel goldLabel;
|
||||
private TextraButton pullButton;
|
||||
private ScrollPane rewardDummy;
|
||||
private RewardActor rewardActor;
|
||||
SelectBox<CardEdition> editionList;
|
||||
//Button containers.
|
||||
final private HashMap<String, TextButton> rarityButtons = new HashMap<>();
|
||||
final private HashMap<String, TextButton> costButtons = new HashMap<>();
|
||||
final private HashMap<String, TextButton> colorButtons = new HashMap<>();
|
||||
final private HashMap<String, TextraButton> rarityButtons = new HashMap<>();
|
||||
final private HashMap<String, TextraButton> costButtons = new HashMap<>();
|
||||
final private HashMap<String, TextraButton> colorButtons = new HashMap<>();
|
||||
//Filter variables.
|
||||
private String edition = "";
|
||||
private String rarity = "";
|
||||
@@ -91,7 +91,7 @@ public class SpellSmithScene extends UIScene {
|
||||
pullButton.setDisabled(true);
|
||||
goldLabel.setText("Gold: "+ Current.player().getGold());
|
||||
for(String i : new String[]{"BBlack", "BBlue", "BGreen", "BRed", "BWhite", "BColorless"} ){
|
||||
TextButton button = ui.findActor(i);
|
||||
TextraButton button = ui.findActor(i);
|
||||
if(button != null){
|
||||
colorButtons.put(i, button);
|
||||
button.addListener(new ClickListener() {
|
||||
@@ -104,7 +104,7 @@ public class SpellSmithScene extends UIScene {
|
||||
}
|
||||
}
|
||||
for(String i : new String[]{"BCommon", "BUncommon", "BRare", "BMythic"} ){
|
||||
TextButton button = ui.findActor(i);
|
||||
TextraButton button = ui.findActor(i);
|
||||
if(button != null) {
|
||||
rarityButtons.put(i, button);
|
||||
button.addListener(new ClickListener() {
|
||||
@@ -117,7 +117,7 @@ public class SpellSmithScene extends UIScene {
|
||||
}
|
||||
}
|
||||
for(String i : new String[]{"B02", "B35", "B68", "B9X"} ){
|
||||
TextButton button = ui.findActor(i);
|
||||
TextraButton button = ui.findActor(i);
|
||||
if(button != null) {
|
||||
costButtons.put(i, button);
|
||||
button.addListener(new ClickListener() {
|
||||
@@ -148,7 +148,7 @@ public class SpellSmithScene extends UIScene {
|
||||
}
|
||||
|
||||
private boolean selectRarity(String what){
|
||||
for(Map.Entry<String, TextButton> B : rarityButtons.entrySet())
|
||||
for(Map.Entry<String, TextraButton> B : rarityButtons.entrySet())
|
||||
B.getValue().setColor(Color.WHITE);
|
||||
switch(what){
|
||||
case "BCommon":
|
||||
@@ -170,11 +170,11 @@ public class SpellSmithScene extends UIScene {
|
||||
}
|
||||
|
||||
private void selectColor(String what){
|
||||
TextButton B = colorButtons.get(what);
|
||||
TextraButton B = colorButtons.get(what);
|
||||
switch(what){
|
||||
case "BColorless":
|
||||
if(B.getColor().equals(Color.RED)) B.setColor(Color.WHITE); else {
|
||||
for (Map.Entry<String, TextButton> BT : colorButtons.entrySet())
|
||||
for (Map.Entry<String, TextraButton> BT : colorButtons.entrySet())
|
||||
BT.getValue().setColor(Color.WHITE);
|
||||
B.setColor(Color.RED);
|
||||
}
|
||||
@@ -191,7 +191,7 @@ public class SpellSmithScene extends UIScene {
|
||||
}
|
||||
|
||||
private boolean selectCost(String what){
|
||||
for(Map.Entry<String, TextButton> B : costButtons.entrySet())
|
||||
for(Map.Entry<String, TextraButton> B : costButtons.entrySet())
|
||||
B.getValue().setColor(Color.WHITE);
|
||||
switch(what){
|
||||
case "B02":
|
||||
@@ -218,11 +218,11 @@ public class SpellSmithScene extends UIScene {
|
||||
cost_low = -1; cost_high = 9999;
|
||||
rarity = "";
|
||||
currentPrice = (int)basePrice;
|
||||
goldLabel.setText("Gold: "+ Current.player().getGold());
|
||||
goldLabel.setText(Current.player().getGold()+"[+Gold]");
|
||||
|
||||
for(Map.Entry<String, TextButton> B : colorButtons.entrySet()) B.getValue().setColor(Color.WHITE);
|
||||
for(Map.Entry<String, TextButton> B : costButtons.entrySet()) B.getValue().setColor(Color.WHITE);
|
||||
for(Map.Entry<String, TextButton> B : rarityButtons.entrySet()) B.getValue().setColor(Color.WHITE);
|
||||
for(Map.Entry<String, TextraButton> B : colorButtons.entrySet()) B.getValue().setColor(Color.WHITE);
|
||||
for(Map.Entry<String, TextraButton> B : costButtons.entrySet()) B.getValue().setColor(Color.WHITE);
|
||||
for(Map.Entry<String, TextraButton> B : rarityButtons.entrySet()) B.getValue().setColor(Color.WHITE);
|
||||
editionList.setColor(Color.WHITE);
|
||||
filterResults();
|
||||
super.enter();
|
||||
@@ -231,10 +231,10 @@ public class SpellSmithScene extends UIScene {
|
||||
|
||||
public void filterResults() {
|
||||
Iterable<PaperCard> P = RewardData.getAllCards();
|
||||
goldLabel.setText("Gold: "+ Current.player().getGold());
|
||||
goldLabel.setText( Current.player().getGold()+"[+Gold]");
|
||||
float totalCost = basePrice * Current.player().goldModifier();
|
||||
final List<String> colorFilter = new ArrayList<>();
|
||||
for(Map.Entry<String, TextButton> B : colorButtons.entrySet())
|
||||
for(Map.Entry<String, TextraButton> B : colorButtons.entrySet())
|
||||
switch (B.getKey()){
|
||||
case "BColorless":
|
||||
if(B.getValue().getColor().equals(Color.RED)) colorFilter.add("Colorless");
|
||||
|
||||
@@ -3,8 +3,8 @@ package forge.adventure.scene;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Input;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Dialog;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.github.tommyettinger.textra.TextraButton;
|
||||
import forge.Forge;
|
||||
import forge.adventure.stage.GameHUD;
|
||||
import forge.adventure.stage.GameStage;
|
||||
@@ -20,8 +20,10 @@ import forge.screens.TransitionScreen;
|
||||
*/
|
||||
public class StartScene extends UIScene {
|
||||
|
||||
TextButton saveButton, resumeButton, continueButton, newGameButton, newGameButtonPlus, loadButton, settingsButton, exitButton, switchButton;
|
||||
private static StartScene object;
|
||||
TextraButton saveButton, resumeButton, continueButton, newGameButton, newGameButtonPlus, loadButton, settingsButton, exitButton, switchButton, dialogOk, dialogCancel, dialogButtonSelected;
|
||||
Dialog dialog;
|
||||
private int selected = -1;
|
||||
|
||||
public StartScene() {
|
||||
super(Forge.isLandscapeMode() ? "ui/start_menu.json" : "ui/start_menu_portrait.json");
|
||||
@@ -36,23 +38,13 @@ public class StartScene extends UIScene {
|
||||
ui.onButtonPress("Switch", () -> Forge.switchToClassic());
|
||||
|
||||
newGameButton = ui.findActor("Start");
|
||||
newGameButton.getLabel().setText(Forge.getLocalizer().getMessage("lblNewGame"));
|
||||
newGameButtonPlus = ui.findActor("Start+");
|
||||
newGameButtonPlus.getLabel().setText(Forge.getLocalizer().getMessage("lblNewGame") + "+");
|
||||
loadButton = ui.findActor("Load");
|
||||
loadButton.getLabel().setText(Forge.getLocalizer().getMessage("lblLoad"));
|
||||
saveButton = ui.findActor("Save");
|
||||
saveButton.getLabel().setText(Forge.getLocalizer().getMessage("lblSave"));
|
||||
resumeButton = ui.findActor("Resume");
|
||||
resumeButton.getLabel().setText(Forge.getLocalizer().getMessage("lblResume"));
|
||||
continueButton = ui.findActor("Continue");
|
||||
continueButton.getLabel().setText(Forge.getLocalizer().getMessage("lblContinue"));
|
||||
settingsButton = ui.findActor("Settings");
|
||||
settingsButton.getLabel().setText(Forge.getLocalizer().getMessage("lblSettings"));
|
||||
exitButton = ui.findActor("Exit");
|
||||
exitButton.getLabel().setText(Forge.getLocalizer().getMessage("lblExit"));
|
||||
switchButton = ui.findActor("Switch");
|
||||
switchButton.getLabel().setText(Forge.getLocalizer().getMessage("lblClassic"));
|
||||
|
||||
saveButton.setVisible(false);
|
||||
resumeButton.setVisible(false);
|
||||
@@ -67,6 +59,12 @@ public class StartScene extends UIScene {
|
||||
dialog.getColor().a = 0;
|
||||
}
|
||||
|
||||
public static StartScene instance() {
|
||||
if(object==null)
|
||||
object=new StartScene();
|
||||
return object;
|
||||
}
|
||||
|
||||
public boolean NewGame() {
|
||||
Forge.switchScene(NewGameScene.instance());
|
||||
return true;
|
||||
|
||||
@@ -9,18 +9,14 @@ import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Dialog;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextField;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.*;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.badlogic.gdx.utils.ObjectMap;
|
||||
import com.badlogic.gdx.utils.Scaling;
|
||||
import com.badlogic.gdx.utils.Timer;
|
||||
import com.badlogic.gdx.utils.viewport.ScalingViewport;
|
||||
import com.github.tommyettinger.textra.TextraButton;
|
||||
import forge.Forge;
|
||||
import forge.adventure.util.Config;
|
||||
import forge.adventure.util.Controls;
|
||||
@@ -37,7 +33,7 @@ public class UIScene extends Scene {
|
||||
String uiFile;
|
||||
private Dialog keyboardDialog;
|
||||
private Label kbLabel;
|
||||
private TextButton keyA, keyB, keyC, keyD, keyE, keyF, keyG, keyH, keyI, keyJ, keyK, keyL, keyM, keyN, keyO, keyP,
|
||||
private TextraButton keyA, keyB, keyC, keyD, keyE, keyF, keyG, keyH, keyI, keyJ, keyK, keyL, keyM, keyN, keyO, keyP,
|
||||
keyQ, keyR, keyS, keyT, keyU, keyV, keyW, keyX, keyY, keyZ, key1, key2, key3, key4, key5, key6, key7, key8,
|
||||
key9, key0, keyDot, keyComma, keyShift, keyBackspace, keySpace, keyOK;
|
||||
public Actor lastInputField;
|
||||
@@ -246,33 +242,33 @@ public class UIScene extends Scene {
|
||||
}
|
||||
private void shiftKey() {
|
||||
lowercaseKey = !lowercaseKey;
|
||||
keyShift.getLabel().setColor(lowercaseKey ? Color.WHITE : Color.CYAN);
|
||||
keyA.getLabel().setText(lowercaseKey ? "a" : "A");
|
||||
keyB.getLabel().setText(lowercaseKey ? "b" : "B");
|
||||
keyC.getLabel().setText(lowercaseKey ? "c" : "C");
|
||||
keyD.getLabel().setText(lowercaseKey ? "d" : "D");
|
||||
keyE.getLabel().setText(lowercaseKey ? "e" : "E");
|
||||
keyF.getLabel().setText(lowercaseKey ? "f" : "F");
|
||||
keyG.getLabel().setText(lowercaseKey ? "g" : "G");
|
||||
keyH.getLabel().setText(lowercaseKey ? "h" : "H");
|
||||
keyI.getLabel().setText(lowercaseKey ? "i" : "I");
|
||||
keyJ.getLabel().setText(lowercaseKey ? "j" : "J");
|
||||
keyK.getLabel().setText(lowercaseKey ? "k" : "K");
|
||||
keyL.getLabel().setText(lowercaseKey ? "l" : "L");
|
||||
keyM.getLabel().setText(lowercaseKey ? "m" : "M");
|
||||
keyN.getLabel().setText(lowercaseKey ? "n" : "N");
|
||||
keyO.getLabel().setText(lowercaseKey ? "o" : "O");
|
||||
keyP.getLabel().setText(lowercaseKey ? "p" : "P");
|
||||
keyQ.getLabel().setText(lowercaseKey ? "q" : "Q");
|
||||
keyR.getLabel().setText(lowercaseKey ? "r" : "R");
|
||||
keyS.getLabel().setText(lowercaseKey ? "s" : "S");
|
||||
keyT.getLabel().setText(lowercaseKey ? "t" : "T");
|
||||
keyU.getLabel().setText(lowercaseKey ? "u" : "U");
|
||||
keyV.getLabel().setText(lowercaseKey ? "v" : "V");
|
||||
keyW.getLabel().setText(lowercaseKey ? "w" : "W");
|
||||
keyX.getLabel().setText(lowercaseKey ? "x" : "X");
|
||||
keyY.getLabel().setText(lowercaseKey ? "y" : "Y");
|
||||
keyZ.getLabel().setText(lowercaseKey ? "z" : "Z");
|
||||
keyShift.setColor(lowercaseKey ? Color.WHITE : Color.CYAN);
|
||||
keyA.setText(lowercaseKey ? "a" : "A");
|
||||
keyB.setText(lowercaseKey ? "b" : "B");
|
||||
keyC.setText(lowercaseKey ? "c" : "C");
|
||||
keyD.setText(lowercaseKey ? "d" : "D");
|
||||
keyE.setText(lowercaseKey ? "e" : "E");
|
||||
keyF.setText(lowercaseKey ? "f" : "F");
|
||||
keyG.setText(lowercaseKey ? "g" : "G");
|
||||
keyH.setText(lowercaseKey ? "h" : "H");
|
||||
keyI.setText(lowercaseKey ? "i" : "I");
|
||||
keyJ.setText(lowercaseKey ? "j" : "J");
|
||||
keyK.setText(lowercaseKey ? "k" : "K");
|
||||
keyL.setText(lowercaseKey ? "l" : "L");
|
||||
keyM.setText(lowercaseKey ? "m" : "M");
|
||||
keyN.setText(lowercaseKey ? "n" : "N");
|
||||
keyO.setText(lowercaseKey ? "o" : "O");
|
||||
keyP.setText(lowercaseKey ? "p" : "P");
|
||||
keyQ.setText(lowercaseKey ? "q" : "Q");
|
||||
keyR.setText(lowercaseKey ? "r" : "R");
|
||||
keyS.setText(lowercaseKey ? "s" : "S");
|
||||
keyT.setText(lowercaseKey ? "t" : "T");
|
||||
keyU.setText(lowercaseKey ? "u" : "U");
|
||||
keyV.setText(lowercaseKey ? "v" : "V");
|
||||
keyW.setText(lowercaseKey ? "w" : "W");
|
||||
keyX.setText(lowercaseKey ? "x" : "X");
|
||||
keyY.setText(lowercaseKey ? "y" : "Y");
|
||||
keyZ.setText(lowercaseKey ? "z" : "Z");
|
||||
}
|
||||
public void setSelectedKey(int keyCode) {
|
||||
switch(keyCode) {
|
||||
@@ -632,7 +628,7 @@ public class UIScene extends Scene {
|
||||
if (actor instanceof TextButton)
|
||||
((TextButton) actor).fire(eventExit);
|
||||
else if (actor instanceof Selector)
|
||||
((Selector) actor).getLabel().fire(eventExit);
|
||||
((Selector) actor).fire(eventExit);
|
||||
else if (actor instanceof TextField) {
|
||||
if (stage.getKeyboardFocus() == actor)
|
||||
stage.setKeyboardFocus(null);
|
||||
@@ -668,8 +664,8 @@ public class UIScene extends Scene {
|
||||
if (kbVisible) {
|
||||
if (selectedKey != null) {
|
||||
selectedKey.fire(eventExit);
|
||||
if (selectedKey instanceof TextButton)
|
||||
if (!(((TextButton) selectedKey) == keyOK || ((TextButton) selectedKey) == keySpace))
|
||||
if (selectedKey instanceof TextraButton)
|
||||
if (!(selectedKey == keyOK || selectedKey == keySpace))
|
||||
lastSelectedKey = selectedKey;
|
||||
}
|
||||
selectedKey = actor;
|
||||
@@ -685,10 +681,10 @@ public class UIScene extends Scene {
|
||||
return;
|
||||
Actor a = actorObjectMap.get(key);
|
||||
if (a != null) {
|
||||
if (a instanceof TextButton)
|
||||
((TextButton) a).fire(eventEnter);
|
||||
if (a instanceof TextraButton)
|
||||
a.fire(eventEnter);
|
||||
else if (a instanceof Selector)
|
||||
((Selector) a).getLabel().fire(eventEnter);
|
||||
((Selector) a).fire(eventEnter);
|
||||
else if (a instanceof TextField) {
|
||||
stage.setKeyboardFocus(a);
|
||||
} else if (a instanceof ImageButton) {
|
||||
|
||||
@@ -26,7 +26,7 @@ public class Console extends Window {
|
||||
private Console console;
|
||||
|
||||
public InputLine(Console console) {
|
||||
super("", Controls.GetSkin());
|
||||
super("", Controls.getSkin());
|
||||
this.console = console;
|
||||
writeEnters=true;
|
||||
}
|
||||
@@ -77,8 +77,8 @@ public class Console extends Window {
|
||||
}
|
||||
|
||||
public Console() {
|
||||
super("", Controls.GetSkin());
|
||||
content = new Table(Controls.GetSkin());
|
||||
super("", Controls.getSkin());
|
||||
content = new Table(Controls.getSkin());
|
||||
input = new InputLine(this);
|
||||
scroll = new ScrollPane(content,new ScrollPane.ScrollPaneStyle());
|
||||
|
||||
|
||||
@@ -2,6 +2,9 @@ package forge.adventure.stage;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Input;
|
||||
import com.badlogic.gdx.controllers.Controller;
|
||||
import com.badlogic.gdx.controllers.ControllerListener;
|
||||
import com.badlogic.gdx.controllers.Controllers;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.Pixmap;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
@@ -10,17 +13,19 @@ import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.*;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Touchpad;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.badlogic.gdx.utils.Scaling;
|
||||
import com.badlogic.gdx.utils.Timer;
|
||||
import com.badlogic.gdx.utils.viewport.ScalingViewport;
|
||||
import com.github.tommyettinger.textra.TextraButton;
|
||||
import com.github.tommyettinger.textra.TextraLabel;
|
||||
import forge.Forge;
|
||||
import forge.adventure.player.AdventurePlayer;
|
||||
import forge.adventure.scene.Scene;
|
||||
import forge.adventure.scene.SceneType;
|
||||
import forge.adventure.scene.*;
|
||||
import forge.adventure.util.Config;
|
||||
import forge.adventure.util.Controls;
|
||||
import forge.adventure.util.Current;
|
||||
@@ -33,17 +38,19 @@ import forge.gui.GuiBase;
|
||||
/**
|
||||
* Stage to handle everything rendered in the HUD
|
||||
*/
|
||||
public class GameHUD extends Stage {
|
||||
public class GameHUD extends Stage implements ControllerListener {
|
||||
|
||||
static public GameHUD instance;
|
||||
private final GameStage gameStage;
|
||||
private final Image avatar;
|
||||
private final Image miniMapPlayer;
|
||||
private final Label lifePoints;
|
||||
private final Label money;
|
||||
private final Label mana;
|
||||
private final TextraLabel lifePoints;
|
||||
private final TextraLabel money;
|
||||
private final TextraLabel mana;
|
||||
private final Image miniMap, gamehud, mapborder, avatarborder, blank;
|
||||
private TextButton deckActor, menuActor, statsActor, inventoryActor;
|
||||
private final InputEvent eventTouchDown;
|
||||
private final InputEvent eventTouchUp;
|
||||
private TextraButton deckActor, menuActor, statsActor, inventoryActor;
|
||||
private UIActor ui;
|
||||
private Touchpad touchpad;
|
||||
private Console console;
|
||||
@@ -66,19 +73,15 @@ public class GameHUD extends Stage {
|
||||
|
||||
avatarborder = ui.findActor("avatarborder");
|
||||
deckActor = ui.findActor("deck");
|
||||
deckActor.getLabel().setText(Forge.getLocalizer().getMessage("lblDeck"));
|
||||
menuActor = ui.findActor("menu");
|
||||
referenceX = menuActor.getX();
|
||||
menuActor.getLabel().setText(Forge.getLocalizer().getMessage("lblMenu"));
|
||||
statsActor = ui.findActor("statistic");
|
||||
statsActor.getLabel().setText(Forge.getLocalizer().getMessage("lblStatus"));
|
||||
inventoryActor = ui.findActor("inventory");
|
||||
inventoryActor.getLabel().setText(Forge.getLocalizer().getMessage("lblItem"));
|
||||
gamehud = ui.findActor("gamehud");
|
||||
|
||||
miniMapPlayer = new Image(new Texture(Config.instance().getFile("ui/minimap_player.png")));
|
||||
//create touchpad
|
||||
touchpad = new Touchpad(10, Controls.GetSkin());
|
||||
touchpad = new Touchpad(10, Controls.getSkin());
|
||||
touchpad.setBounds(15, 15, TOUCHPAD_SCALE, TOUCHPAD_SCALE);
|
||||
touchpad.addListener(new ChangeListener() {
|
||||
@Override
|
||||
@@ -257,9 +260,9 @@ public class GameHUD extends Stage {
|
||||
avatar.setDrawable(new TextureRegionDrawable(Current.player().avatar()));
|
||||
Deck deck = AdventurePlayer.current().getSelectedDeck();
|
||||
if (deck == null || deck.isEmpty() || deck.getMain().toFlatList().size() < 30) {
|
||||
deckActor.getLabel().setColor(Color.RED);
|
||||
deckActor.setColor(Color.RED);
|
||||
} else {
|
||||
deckActor.getLabel().setColor(menuActor.getLabel().getColor());
|
||||
deckActor.setColor(menuActor.getColor());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ public abstract class GameStage extends Stage {
|
||||
return;
|
||||
foregroundSprites.removeActor(player);
|
||||
player = null;
|
||||
GameStage.this.GetPlayer();
|
||||
GameStage.this.getPlayerSprite();
|
||||
}
|
||||
});
|
||||
camera = (OrthographicCamera) getCamera();
|
||||
|
||||
@@ -2,9 +2,10 @@ package forge.adventure.stage;
|
||||
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Input;
|
||||
import com.badlogic.gdx.controllers.Controllers;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.maps.MapLayer;
|
||||
import com.badlogic.gdx.maps.MapObject;
|
||||
@@ -15,17 +16,16 @@ import com.badlogic.gdx.maps.tiled.TiledMapTileLayer;
|
||||
import com.badlogic.gdx.maps.tiled.objects.TiledMapTileMapObject;
|
||||
import com.badlogic.gdx.math.Rectangle;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.Group;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Dialog;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Scaling;
|
||||
import com.badlogic.gdx.utils.*;
|
||||
import com.github.tommyettinger.textra.TextraButton;
|
||||
import com.github.tommyettinger.textra.TextraLabel;
|
||||
import com.github.tommyettinger.textra.TypingAdapter;
|
||||
import com.github.tommyettinger.textra.TypingLabel;
|
||||
import forge.Forge;
|
||||
@@ -35,7 +35,6 @@ import forge.adventure.pointofintrest.PointOfInterestChanges;
|
||||
import forge.adventure.scene.*;
|
||||
import forge.adventure.util.*;
|
||||
import forge.adventure.world.WorldSave;
|
||||
import forge.card.ColorSet;
|
||||
import forge.deck.Deck;
|
||||
import forge.deck.DeckProxy;
|
||||
import forge.gui.FThreads;
|
||||
@@ -43,20 +42,18 @@ import forge.screens.TransitionScreen;
|
||||
import forge.sound.SoundEffectType;
|
||||
import forge.sound.SoundSystem;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static forge.adventure.util.Paths.MANA_ATLAS;
|
||||
|
||||
/**
|
||||
* Stage to handle tiled maps for points of interests
|
||||
*/
|
||||
public class MapStage extends GameStage {
|
||||
public static MapStage instance;
|
||||
Array<MapActor> actors = new Array<>();
|
||||
final Array<MapActor> actors = new Array<>();
|
||||
|
||||
TiledMap map;
|
||||
Array<Rectangle>[][] collision;
|
||||
Array<Rectangle> collisionRect=new Array<>();
|
||||
private float tileHeight;
|
||||
private float tileWidth;
|
||||
private float width;
|
||||
@@ -70,9 +67,9 @@ public class MapStage extends GameStage {
|
||||
private final Vector2 oldPosition3 = new Vector2();
|
||||
private final Vector2 oldPosition4 = new Vector2();
|
||||
private boolean isLoadingMatch = false;
|
||||
private HashMap<String, Byte> mapFlags = new HashMap<>(); //Stores local map flags. These aren't available outside this map.
|
||||
//private HashMap<String, Byte> mapFlags = new HashMap<>(); //Stores local map flags. These aren't available outside this map.
|
||||
|
||||
private Dialog dialog;
|
||||
private final Dialog dialog;
|
||||
private Stage dialogStage;
|
||||
private boolean dialogOnlyInput;
|
||||
|
||||
@@ -80,10 +77,11 @@ public class MapStage extends GameStage {
|
||||
//These maps are defined as embedded properties within the Tiled maps.
|
||||
private EffectData effect; //"Dungeon Effect": Character Effect applied to all adversaries within the map.
|
||||
private boolean preventEscape = false; //Prevents player from escaping the dungeon by any means that aren't an exit.
|
||||
private ObjectMap<Integer, TextButton> dialogButtonMap;
|
||||
private ObjectMap<Integer, TextraButton> dialogButtonMap;
|
||||
private int selected = 0;
|
||||
public InputEvent eventEnter, eventExit, eventTouchDown, eventTouchUp;
|
||||
TextButton selectedKey;
|
||||
TextraButton selectedKey;
|
||||
private boolean foundPlayerSpawn=false;
|
||||
|
||||
|
||||
public boolean getDialogOnlyInput() {
|
||||
@@ -157,7 +155,7 @@ public class MapStage extends GameStage {
|
||||
|
||||
@Override
|
||||
public boolean isColliding(Rectangle adjustedBoundingRect) {
|
||||
for (Rectangle collision : currentCollidingRectangles) {
|
||||
for (Rectangle collision : collisionRect) {
|
||||
if (collision.overlaps(adjustedBoundingRect)) {
|
||||
return true;
|
||||
}
|
||||
@@ -165,24 +163,10 @@ public class MapStage extends GameStage {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Array<Rectangle> currentCollidingRectangles = new Array<>();
|
||||
|
||||
@Override
|
||||
public void prepareCollision(Vector2 pos, Vector2 direction, Rectangle boundingRect) {
|
||||
currentCollidingRectangles.clear();
|
||||
int x1 = (int) (Math.min(boundingRect.x, boundingRect.x + direction.x) / tileWidth);
|
||||
int y1 = (int) (Math.min(boundingRect.y, boundingRect.y + direction.y) / tileHeight);
|
||||
int x2 = (int) (Math.min(boundingRect.x + boundingRect.width, boundingRect.x + boundingRect.width + direction.x) / tileWidth);
|
||||
int y2 = (int) (Math.min(boundingRect.y + boundingRect.height, boundingRect.y + boundingRect.height + direction.y) / tileHeight);
|
||||
|
||||
for (int x = x1; x <= x2; x++) {
|
||||
for (int y = y1; y <= y2; y++) {
|
||||
if (x < 0 || x >= width || y < 0 || y >= height) {
|
||||
continue;
|
||||
}
|
||||
currentCollidingRectangles.addAll(collision[x][y]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -194,18 +178,14 @@ public class MapStage extends GameStage {
|
||||
if (collisionGroup == null) {
|
||||
collisionGroup = new Group();
|
||||
|
||||
for (int x = 0; x < collision.length; x++) {
|
||||
for (int y = 0; y < collision[x].length; y++) {
|
||||
for (Rectangle rectangle : collision[x][y]) {
|
||||
MapActor collisionActor = new MapActor(0);
|
||||
collisionActor.setBoundDebug(true);
|
||||
collisionActor.setWidth(rectangle.width);
|
||||
collisionActor.setHeight(rectangle.height);
|
||||
collisionActor.setX(rectangle.x);
|
||||
collisionActor.setY(rectangle.y);
|
||||
collisionGroup.addActor(collisionActor);
|
||||
}
|
||||
}
|
||||
for (Rectangle rectangle : collisionRect) {
|
||||
MapActor collisionActor = new MapActor(0);
|
||||
collisionActor.setBoundDebug(true);
|
||||
collisionActor.setWidth(rectangle.width);
|
||||
collisionActor.setHeight(rectangle.height);
|
||||
collisionActor.setX(rectangle.x);
|
||||
collisionActor.setY(rectangle.y);
|
||||
collisionGroup.addActor(collisionActor);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -217,12 +197,12 @@ public class MapStage extends GameStage {
|
||||
|
||||
}
|
||||
|
||||
private void effectDialog(EffectData E) {
|
||||
private void effectDialog(EffectData effectData) {
|
||||
dialog.getButtonTable().clear();
|
||||
dialog.getContentTable().clear();
|
||||
TextButton ok = Controls.newTextButton("OK", this::hideDialog);
|
||||
TextraButton ok = Controls.newTextButton("OK", this::hideDialog);
|
||||
ok.setVisible(false);
|
||||
TypingLabel L = Controls.newTypingLabel("{GRADIENT=CYAN;WHITE;1;1}Strange magical energies flow within this place...{ENDGRADIENT}\nAll opponents get:\n" + E.getDescription());
|
||||
TypingLabel L = Controls.newTypingLabel("{GRADIENT=CYAN;WHITE;1;1}Strange magical energies flow within this place...{ENDGRADIENT}\nAll opponents get:\n" + effectData.getDescription());
|
||||
L.setWrap(true);
|
||||
L.setTypingListener(new TypingAdapter() {
|
||||
@Override
|
||||
@@ -247,7 +227,7 @@ public class MapStage extends GameStage {
|
||||
dialog.getContentTable().add(image).height(100);
|
||||
dialog.getContentTable().add().row();
|
||||
}
|
||||
Label L = Controls.newLabel(message);
|
||||
TextraLabel L = Controls.newTextraLabel(message);
|
||||
L.setWrap(true);
|
||||
dialog.getContentTable().add(L).width(250f);
|
||||
dialog.getButtonTable().add(Controls.newTextButton("OK", this::hideDialog)).width(250f);
|
||||
@@ -259,81 +239,14 @@ public class MapStage extends GameStage {
|
||||
public void showDeckAwardDialog(String message, Deck deck) {
|
||||
dialog.getContentTable().clear();
|
||||
dialog.getButtonTable().clear();
|
||||
if (deck != null) {
|
||||
TextureAtlas atlas = Config.instance().getAtlas(MANA_ATLAS);
|
||||
ColorSet deckColor = DeckProxy.getColorIdentity(deck);
|
||||
if (deckColor.isColorless()) {
|
||||
Image pixC = new Image(atlas.createSprite("pixC"));
|
||||
pixC.setScaling(Scaling.fit);
|
||||
dialog.getContentTable().add(pixC).height(20).width(20);
|
||||
dialog.getContentTable().add().row();
|
||||
} else if (deckColor.isMonoColor()) {
|
||||
Image pix = new Image(atlas.createSprite("pixC"));
|
||||
if (deckColor.hasWhite())
|
||||
pix = new Image(atlas.createSprite("pixW"));
|
||||
else if (deckColor.hasBlue())
|
||||
pix = new Image(atlas.createSprite("pixU"));
|
||||
else if (deckColor.hasBlack())
|
||||
pix = new Image(atlas.createSprite("pixB"));
|
||||
else if (deckColor.hasRed())
|
||||
pix = new Image(atlas.createSprite("pixR"));
|
||||
else if (deckColor.hasGreen())
|
||||
pix = new Image(atlas.createSprite("pixG"));
|
||||
pix.setScaling(Scaling.fit);
|
||||
dialog.getContentTable().add(pix).height(20).width(20);
|
||||
dialog.getContentTable().add().row();
|
||||
} else if (deckColor.isMulticolor()) {
|
||||
Group group = new Group();
|
||||
int mul = 0;
|
||||
if (deckColor.hasWhite()) {
|
||||
Image pix = new Image(atlas.createSprite("pixW"));
|
||||
pix.setScaling(Scaling.fit);
|
||||
pix.setSize(20, 20);
|
||||
pix.setPosition(0, 0);
|
||||
group.addActor(pix);
|
||||
mul++;
|
||||
}
|
||||
if (deckColor.hasBlue()) {
|
||||
Image pix = new Image(atlas.createSprite("pixU"));
|
||||
pix.setScaling(Scaling.fit);
|
||||
pix.setSize(20, 20);
|
||||
pix.setPosition(20 * mul, 0);
|
||||
mul++;
|
||||
group.addActor(pix);
|
||||
}
|
||||
if (deckColor.hasBlack()) {
|
||||
Image pix = new Image(atlas.createSprite("pixB"));
|
||||
pix.setScaling(Scaling.fit);
|
||||
pix.setSize(20, 20);
|
||||
pix.setPosition(20 * mul, 0);
|
||||
mul++;
|
||||
group.addActor(pix);
|
||||
}
|
||||
if (deckColor.hasRed()) {
|
||||
Image pix = new Image(atlas.createSprite("pixR"));
|
||||
pix.setScaling(Scaling.fit);
|
||||
pix.setSize(20, 20);
|
||||
pix.setPosition(20 * mul, 0);
|
||||
mul++;
|
||||
group.addActor(pix);
|
||||
}
|
||||
if (deckColor.hasGreen()) {
|
||||
Image pix = new Image(atlas.createSprite("pixG"));
|
||||
pix.setScaling(Scaling.fit);
|
||||
pix.setSize(20, 20);
|
||||
pix.setPosition(20 * mul, 0);
|
||||
mul++;
|
||||
group.addActor(pix);
|
||||
}
|
||||
group.setHeight(20);
|
||||
group.setWidth(20 * mul);
|
||||
dialog.getContentTable().add(group).align(Align.center);
|
||||
dialog.getContentTable().add().row();
|
||||
}
|
||||
}
|
||||
|
||||
dialog.getContentTable().add(Controls.newTypingLabel(Controls.colorIdToTypingString(DeckProxy.getColorIdentity(deck)))).align(Align.center);
|
||||
dialog.getContentTable().add().row();
|
||||
|
||||
TypingLabel L = Controls.newTypingLabel(message);
|
||||
L.setWrap(true);
|
||||
L.skipToTheEnd();
|
||||
|
||||
dialog.getContentTable().add(L).width(240);
|
||||
dialog.getButtonTable().add(Controls.newTextButton("OK", this::hideDialog)).width(240);
|
||||
dialog.setKeepWithinStage(true);
|
||||
@@ -351,13 +264,14 @@ public class MapStage extends GameStage {
|
||||
foregroundSprites.removeActor(actor);
|
||||
}
|
||||
|
||||
actors = new Array<>();
|
||||
actors.clear();
|
||||
collisionRect.clear();
|
||||
width = Float.parseFloat(map.getProperties().get("width").toString());
|
||||
height = Float.parseFloat(map.getProperties().get("height").toString());
|
||||
tileHeight = Float.parseFloat(map.getProperties().get("tileheight").toString());
|
||||
tileWidth = Float.parseFloat(map.getProperties().get("tilewidth").toString());
|
||||
setBounds(width * tileWidth, height * tileHeight);
|
||||
collision = new Array[(int) width][(int) height];
|
||||
//collision = new Array[(int) width][(int) height];
|
||||
|
||||
//Load dungeon effects.
|
||||
MapProperties MP = map.getProperties();
|
||||
@@ -385,23 +299,57 @@ public class MapStage extends GameStage {
|
||||
loadObjects(layer, sourceMap);
|
||||
}
|
||||
}
|
||||
|
||||
//reduce geometry in collision rectangles
|
||||
int oldSize;
|
||||
do {
|
||||
oldSize=collisionRect.size;
|
||||
for(int i=0;i<collisionRect.size;i++)
|
||||
{
|
||||
Rectangle r1= collisionRect.get(i);
|
||||
for(int j=i+1;j<collisionRect.size;j++)
|
||||
{
|
||||
Rectangle r2= collisionRect.get(j);
|
||||
if((Math.abs(r1.x-r2.x+r2.width)<1&&Math.abs(r1.y-r2.y)<1&&Math.abs(r1.height-r2.height)<1)//left edge is the same as right edge
|
||||
|
||||
||(Math.abs(r1.x+r1.width-r2.x)<1&&Math.abs(r1.y-r2.y)<1&&Math.abs(r1.height-r2.height)<1)//right edge is the same as left edge
|
||||
|
||||
||(Math.abs(r1.x - r2.x )<1&& Math.abs(r1.y+r1.height-r2.y)<1&&Math.abs(r1.width-r2.width)<1)//top edge is the same as bottom edge
|
||||
|
||||
||(Math.abs(r1.x - r2.x )<1&& Math.abs(r1.y-r2.y+r2.height)<1&&Math.abs(r1.width-r2.width)<1)//bottom edge is the same as left edge
|
||||
|
||||
||containsOrEquals(r1,r2)||containsOrEquals(r2,r1)
|
||||
)
|
||||
{
|
||||
r1.merge(r2);
|
||||
collisionRect.removeIndex(j);
|
||||
i--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}while (oldSize!=collisionRect.size);
|
||||
if (spriteLayer == null) System.err.print("Warning: No spriteLayer present in map.\n");
|
||||
|
||||
}
|
||||
|
||||
static public boolean containsOrEquals(Rectangle r1,Rectangle r2) {
|
||||
float xmi = r2.x;
|
||||
float xma = xmi + r2.width;
|
||||
float ymi = r2.y;
|
||||
float yma = ymi + r2.height;
|
||||
return xmi >= r1.x && xmi <= r1.x + r1.width && xma >= r1.x && xma <= r1.x + r1.width && ymi >= r1.y && ymi <= r1.y + r1.height && yma >= r1.y && yma <= r1.y + r1.height;
|
||||
}
|
||||
private void loadCollision(TiledMapTileLayer layer) {
|
||||
for (int x = 0; x < layer.getWidth(); x++) {
|
||||
for (int y = 0; y < layer.getHeight(); y++) {
|
||||
if (collision[x][y] == null)
|
||||
collision[x][y] = new Array<>();
|
||||
Array<Rectangle> map = collision[x][y];
|
||||
TiledMapTileLayer.Cell cell = layer.getCell(x, y);
|
||||
if (cell == null)
|
||||
continue;
|
||||
for (MapObject collision : cell.getTile().getObjects()) {
|
||||
if (collision instanceof RectangleMapObject) {
|
||||
Rectangle r = ((RectangleMapObject) collision).getRectangle();
|
||||
map.add(new Rectangle((Math.round(layer.getTileWidth() * x) + r.x), (Math.round(layer.getTileHeight() * y) + r.y), Math.round(r.width), Math.round(r.height)));
|
||||
collisionRect.add(new Rectangle((Math.round(layer.getTileWidth() * x) + r.x), (Math.round(layer.getTileHeight() * y) + r.y), Math.round(r.width), Math.round(r.height)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -409,13 +357,13 @@ public class MapStage extends GameStage {
|
||||
}
|
||||
|
||||
private boolean canSpawn(MapProperties prop) {
|
||||
DifficultyData DF = Current.player().getDifficulty();
|
||||
DifficultyData difficultyData = Current.player().getDifficulty();
|
||||
boolean spawnEasy = prop.get("spawn.Easy", Boolean.class);
|
||||
boolean spawnNorm = prop.get("spawn.Normal", Boolean.class);
|
||||
boolean spawnHard = prop.get("spawn.Hard", Boolean.class);
|
||||
if (DF.spawnRank == 2 && !spawnHard) return false;
|
||||
if (DF.spawnRank == 1 && !spawnNorm) return false;
|
||||
if (DF.spawnRank == 0 && !spawnEasy) return false;
|
||||
if (difficultyData.spawnRank == 2 && !spawnHard) return false;
|
||||
if (difficultyData.spawnRank == 1 && !spawnNorm) return false;
|
||||
if (difficultyData.spawnRank == 0 && !spawnEasy) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -423,8 +371,8 @@ public class MapStage extends GameStage {
|
||||
player.setMoveModifier(2);
|
||||
for (MapObject obj : layer.getObjects()) {
|
||||
MapProperties prop = obj.getProperties();
|
||||
if (prop.containsKey("type")) {
|
||||
String type = prop.get("type", String.class);
|
||||
String type = prop.get("type", String.class);
|
||||
if (type!=null) {
|
||||
int id = prop.get("id", int.class);
|
||||
if (changes.isObjectDeleted(id))
|
||||
continue;
|
||||
@@ -440,12 +388,12 @@ public class MapStage extends GameStage {
|
||||
String targetMap=prop.get("teleport").toString();
|
||||
boolean spawnPlayerThere=(targetMap==null||targetMap.isEmpty()&&sourceMap.isEmpty())||//if target is null and "from world"
|
||||
!sourceMap.isEmpty()&&targetMap.equals(sourceMap);
|
||||
|
||||
if(foundPlayerSpawn)
|
||||
spawnPlayerThere=false;
|
||||
if((prop.containsKey("spawn")&&prop.get("spawn").toString()=="true")&&spawnPlayerThere)
|
||||
if((prop.containsKey("spawn")&& prop.get("spawn").toString().equals("true"))&&spawnPlayerThere)
|
||||
{
|
||||
foundPlayerSpawn=true;
|
||||
spawnPlayerThere=true;
|
||||
}//set spawn to option with "spawn" over other entries
|
||||
EntryActor entry = new EntryActor(this, id, prop.get("teleport").toString(), x, y, w, h, prop.get("direction").toString(),spawnPlayerThere);
|
||||
addMapActor(obj, entry);
|
||||
@@ -467,33 +415,33 @@ public class MapStage extends GameStage {
|
||||
break;
|
||||
case "enemy":
|
||||
if (!canSpawn(prop)) break;
|
||||
Object E = prop.get("enemy");
|
||||
if (E != null && !E.toString().isEmpty()) {
|
||||
EnemyData EN = WorldData.getEnemy(E.toString());
|
||||
Object enemy = prop.get("enemy");
|
||||
if (enemy != null && !enemy.toString().isEmpty()) {
|
||||
EnemyData EN = WorldData.getEnemy(enemy.toString());
|
||||
if (EN == null) {
|
||||
System.err.printf("Enemy \"%s\" not found.", E.toString());
|
||||
System.err.printf("Enemy \"%s\" not found.", enemy);
|
||||
break;
|
||||
}
|
||||
EnemySprite mob = new EnemySprite(id, EN);
|
||||
Object D = prop.get("dialog"); //Check if the enemy has a dialogue attached to it.
|
||||
if (D != null && !D.toString().isEmpty()) {
|
||||
mob.dialog = new MapDialog(D.toString(), this, mob.getId());
|
||||
Object dialogObject = prop.get("dialog"); //Check if the enemy has a dialogue attached to it.
|
||||
if (dialogObject != null && !dialogObject.toString().isEmpty()) {
|
||||
mob.dialog = new MapDialog(dialogObject.toString(), this, mob.getId());
|
||||
}
|
||||
D = prop.get("defeatDialog"); //Check if the enemy has a defeat dialogue attached to it.
|
||||
if (D != null && !D.toString().isEmpty()) {
|
||||
mob.defeatDialog = new MapDialog(D.toString(), this, mob.getId());
|
||||
dialogObject = prop.get("defeatDialog"); //Check if the enemy has a defeat dialogue attached to it.
|
||||
if (dialogObject != null && !dialogObject.toString().isEmpty()) {
|
||||
mob.defeatDialog = new MapDialog(dialogObject.toString(), this, mob.getId());
|
||||
}
|
||||
D = prop.get("name"); //Check for name override.
|
||||
if (D != null && !D.toString().isEmpty()) {
|
||||
mob.nameOverride = D.toString();
|
||||
dialogObject = prop.get("name"); //Check for name override.
|
||||
if (dialogObject != null && !dialogObject.toString().isEmpty()) {
|
||||
mob.nameOverride = dialogObject.toString();
|
||||
}
|
||||
D = prop.get("effect"); //Check for special effects.
|
||||
if (D != null && !D.toString().isEmpty()) {
|
||||
mob.effect = JSONStringLoader.parse(EffectData.class, D.toString(), "");
|
||||
dialogObject = prop.get("effect"); //Check for special effects.
|
||||
if (dialogObject != null && !dialogObject.toString().isEmpty()) {
|
||||
mob.effect = JSONStringLoader.parse(EffectData.class, dialogObject.toString(), "");
|
||||
}
|
||||
D = prop.get("reward"); //Check for additional rewards.
|
||||
if (D != null && !D.toString().isEmpty()) {
|
||||
mob.rewards = JSONStringLoader.parse(RewardData[].class, D.toString(), "[]");
|
||||
dialogObject = prop.get("reward"); //Check for additional rewards.
|
||||
if (dialogObject != null && !dialogObject.toString().isEmpty()) {
|
||||
mob.rewards = JSONStringLoader.parse(RewardData[].class, dialogObject.toString(), "[]");
|
||||
}
|
||||
mob.hidden = hidden; //Evil.
|
||||
addMapActor(obj, mob);
|
||||
@@ -521,7 +469,7 @@ public class MapStage extends GameStage {
|
||||
}));
|
||||
break;
|
||||
case "exit":
|
||||
addMapActor(obj, new OnCollide(() -> MapStage.this.exit()));
|
||||
addMapActor(obj, new OnCollide(MapStage.this::exit));
|
||||
break;
|
||||
case "dialog":
|
||||
if (obj instanceof TiledMapTileMapObject) {
|
||||
@@ -593,7 +541,7 @@ public class MapStage extends GameStage {
|
||||
Current.player().win();
|
||||
player.setAnimation(CharacterSprite.AnimationTypes.Attack);
|
||||
currentMob.setAnimation(CharacterSprite.AnimationTypes.Death);
|
||||
startPause(0.3f, () -> MapStage.this.getReward());
|
||||
startPause(0.3f, MapStage.this::getReward);
|
||||
} else {
|
||||
player.setAnimation(CharacterSprite.AnimationTypes.Hit);
|
||||
currentMob.setAnimation(CharacterSprite.AnimationTypes.Attack);
|
||||
@@ -747,7 +695,7 @@ public class MapStage extends GameStage {
|
||||
else
|
||||
dialogButtonMap.clear();
|
||||
for (int i = 0; i < dialog.getButtonTable().getCells().size; i++) {
|
||||
dialogButtonMap.put(i, (TextButton) dialog.getButtonTable().getCells().get(i).getActor());
|
||||
dialogButtonMap.put(i, (TextraButton) dialog.getButtonTable().getCells().get(i).getActor());
|
||||
}
|
||||
dialog.show(dialogStage, Actions.show());
|
||||
dialog.setPosition((dialogStage.getWidth() - dialog.getWidth()) / 2, (dialogStage.getHeight() - dialog.getHeight()) / 2);
|
||||
@@ -812,7 +760,7 @@ public class MapStage extends GameStage {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void selectDialogButton(TextButton dialogButton, boolean press) {
|
||||
private void selectDialogButton(TextraButton dialogButton, boolean press) {
|
||||
if (dialogOnlyInput) {
|
||||
if (selectedKey != null)
|
||||
selectedKey.fire(eventExit);
|
||||
@@ -836,7 +784,7 @@ public class MapStage extends GameStage {
|
||||
}
|
||||
}, 0.10f);
|
||||
}
|
||||
private int getButtonIndexKey(TextButton dialogbutton) {
|
||||
private int getButtonIndexKey(TextraButton dialogbutton) {
|
||||
if (dialogButtonMap.isEmpty())
|
||||
return 0;
|
||||
Integer key = dialogButtonMap.findKey(dialogbutton, true);
|
||||
|
||||
@@ -2,6 +2,7 @@ package forge.adventure.stage;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.controllers.Controllers;
|
||||
import com.badlogic.gdx.math.GridPoint2;
|
||||
import com.badlogic.gdx.math.Rectangle;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
@@ -29,7 +30,10 @@ import forge.sound.SoundSystem;
|
||||
import forge.util.MyRandom;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
|
||||
/**
|
||||
@@ -145,7 +149,7 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
||||
}
|
||||
private void removeEnemy(EnemySprite currentMob) {
|
||||
|
||||
foregroundSprites.removeActor(currentMob);
|
||||
currentMob.removeAfterEffects();
|
||||
Iterator<Pair<Float, EnemySprite>> it = enemies.iterator();
|
||||
while (it.hasNext()) {
|
||||
Pair<Float, EnemySprite> pair = it.next();
|
||||
@@ -378,7 +382,7 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
||||
EnemySprite enemy=null;
|
||||
for (Pair<Float, EnemySprite> pair : enemies) {
|
||||
float dist= pair.getValue().pos().sub(player.pos()).len();
|
||||
if(shortestDist<dist)
|
||||
if(dist<shortestDist)
|
||||
{
|
||||
shortestDist=dist;
|
||||
enemy=pair.getValue();
|
||||
@@ -386,8 +390,9 @@ public class WorldStage extends GameStage implements SaveFileContent {
|
||||
}
|
||||
if(enemy!=null)
|
||||
{
|
||||
enemy.playEffect(Paths.EFFECT_KILL);
|
||||
removeEnemy(enemy);
|
||||
player.playEffect(Paths.EFFECT_KILL);
|
||||
player.playEffect(Paths.TRIGGER_KILL);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package forge.adventure.util;
|
||||
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||
import com.badlogic.gdx.math.Rectangle;
|
||||
@@ -11,8 +12,13 @@ import com.badlogic.gdx.scenes.scene2d.ui.*;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.badlogic.gdx.utils.Null;
|
||||
import com.github.tommyettinger.textra.Font;
|
||||
import com.github.tommyettinger.textra.TextraButton;
|
||||
import com.github.tommyettinger.textra.TextraLabel;
|
||||
import com.github.tommyettinger.textra.TypingLabel;
|
||||
import forge.Forge;
|
||||
import forge.card.ColorSet;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
@@ -20,8 +26,48 @@ import java.util.function.Function;
|
||||
* Class to create ui elements in the correct style
|
||||
*/
|
||||
public class Controls {
|
||||
static public TextButton newTextButton(String text) {
|
||||
return new TextButton(text, GetSkin());
|
||||
static class LabelFix extends TextraLabel
|
||||
{
|
||||
public LabelFix(String text)
|
||||
{
|
||||
super(text, getSkin(),getTextraFont());
|
||||
}
|
||||
@Override
|
||||
public void setText(@Null String text) {
|
||||
this.storedText = text;
|
||||
this.layout.setTargetWidth(this.getMaxWidth());
|
||||
this.getFont().markup(text, this.layout.clear());
|
||||
this.setWidth(this.layout.getWidth() + (this.style != null && this.style.background != null ? this.style.background.getLeftWidth() + this.style.background.getRightWidth() : 0.0F));
|
||||
layout();
|
||||
}
|
||||
}
|
||||
static class TextButtonFix extends TextraButton
|
||||
{
|
||||
public TextButtonFix(@Null String text)
|
||||
{
|
||||
super(text, Controls.getSkin(),Controls.getTextraFont()) ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStyle(Button.ButtonStyle style, boolean makeGridGlyphs) {
|
||||
super.setStyle(style,makeGridGlyphs);
|
||||
this.getTextraLabel().setFont( Controls.getTextraFont());
|
||||
|
||||
}
|
||||
@Override
|
||||
public void setText(@Null String text) {
|
||||
getTextraLabel().storedText = text;
|
||||
getTextraLabel().layout.setTargetWidth(getTextraLabel().getMaxWidth());
|
||||
getTextraLabel().getFont().markup(text, getTextraLabel().layout.clear());
|
||||
getTextraLabel().setWidth(getTextraLabel().layout.getWidth() + (getTextraLabel().style != null && getTextraLabel().style.background != null ? getTextraLabel().style.background.getLeftWidth() + getTextraLabel().style.background.getRightWidth() : 0.0F));
|
||||
layout();
|
||||
}
|
||||
}
|
||||
static public TextraButton newTextButton(String text) {
|
||||
TextraButton button= new TextButtonFix(text);
|
||||
// button.getTextraLabelCell().fill(true,false).expand(true,false);//keep it the same as TextButton
|
||||
button.getTextraLabel().setWrap(false);
|
||||
return button;
|
||||
}
|
||||
static public Rectangle getBoundingRect(Actor actor) {
|
||||
return new Rectangle(actor.getX(),actor.getY(),actor.getWidth(),actor.getHeight());
|
||||
@@ -33,7 +79,7 @@ public class Controls {
|
||||
}
|
||||
|
||||
static public SelectBox newComboBox(String[] text, String item, Function<Object, Void> func) {
|
||||
SelectBox ret = new SelectBox<String>(GetSkin());
|
||||
SelectBox ret = new SelectBox<String>(getSkin());
|
||||
ret.getStyle().listStyle.selection.setTopHeight(4);
|
||||
ret.setItems(text);
|
||||
ret.addListener(new ChangeListener() {
|
||||
@@ -54,7 +100,7 @@ public class Controls {
|
||||
}
|
||||
|
||||
static public SelectBox newComboBox(Float[] text, float item, Function<Object, Void> func) {
|
||||
SelectBox ret = new SelectBox<Float>(GetSkin());
|
||||
SelectBox ret = new SelectBox<Float>(getSkin());
|
||||
ret.getStyle().listStyle.selection.setTopHeight(4);
|
||||
ret.setItems(text);
|
||||
ret.addListener(new ChangeListener() {
|
||||
@@ -75,11 +121,11 @@ public class Controls {
|
||||
}
|
||||
|
||||
static public TextField newTextField(String text) {
|
||||
return new TextField(text, GetSkin());
|
||||
return new TextField(text, getSkin());
|
||||
}
|
||||
|
||||
static public TextField newTextField(String text, Function<String, Void> func) {
|
||||
TextField ret = new TextField(text, GetSkin());
|
||||
TextField ret = new TextField(text, getSkin());
|
||||
ret.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
@@ -94,8 +140,8 @@ public class Controls {
|
||||
return ret;
|
||||
}
|
||||
|
||||
static public TextButton newTextButton(String text, Runnable func) {
|
||||
TextButton ret = newTextButton(text);
|
||||
static public TextraButton newTextButton(String text, Runnable func) {
|
||||
TextraButton ret = newTextButton(text);
|
||||
ret.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
@@ -111,12 +157,12 @@ public class Controls {
|
||||
}
|
||||
|
||||
static public Slider newSlider(float min, float max, float step, boolean vertical) {
|
||||
Slider ret = new Slider(min, max, step, vertical, GetSkin());
|
||||
Slider ret = new Slider(min, max, step, vertical, getSkin());
|
||||
return ret;
|
||||
}
|
||||
|
||||
static public CheckBox newCheckBox(String text) {
|
||||
CheckBox ret = new CheckBox(text, GetSkin());
|
||||
CheckBox ret = new CheckBox(text, getSkin());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -124,15 +170,15 @@ public class Controls {
|
||||
switch (fontName) {
|
||||
case "blackbig":
|
||||
case "big":
|
||||
GetSkin().getFont("default").getData().setScale(2, 2);
|
||||
return GetSkin().getFont("default");
|
||||
getSkin().getFont("default").getData().setScale(2, 2);
|
||||
return getSkin().getFont("default");
|
||||
default:
|
||||
GetSkin().getFont("default").getData().setScale(1, 1);
|
||||
return GetSkin().getFont("default");
|
||||
getSkin().getFont("default").getData().setScale(1, 1);
|
||||
return getSkin().getFont("default");
|
||||
}
|
||||
}
|
||||
|
||||
static public Skin GetSkin() {
|
||||
static public Skin getSkin() {
|
||||
FileHandle skinFile = Config.instance().getFile(Paths.SKIN);
|
||||
if (!Forge.getAssets().manager().contains(skinFile.path(), Skin.class)) {
|
||||
Forge.getAssets().manager().load(skinFile.path(), Skin.class);
|
||||
@@ -140,32 +186,151 @@ public class Controls {
|
||||
FileHandle atlasFile = skinFile.sibling(skinFile.nameWithoutExtension() + ".atlas");
|
||||
Forge.getAssets().manager().load(atlasFile.path(), TextureAtlas.class);
|
||||
Forge.getAssets().manager().finishLoadingAsset(atlasFile.path());
|
||||
//font
|
||||
/*/font skin will load the LanaPixel.fnt now
|
||||
FileHandle pixelFont = Config.instance().getFile(Paths.SKIN).sibling("LanaPixel.fnt");
|
||||
Forge.getAssets().manager().load(pixelFont.path(), BitmapFont.class);
|
||||
Forge.getAssets().manager().finishLoadingAsset(pixelFont.path());
|
||||
Forge.getAssets().manager().get(skinFile.path(), Skin.class).add("default", Forge.getAssets().manager().get(pixelFont.path(), BitmapFont.class), BitmapFont.class);
|
||||
Forge.getAssets().manager().get(skinFile.path(), Skin.class).addRegions(Forge.getAssets().manager().get(atlasFile.path(), TextureAtlas.class));
|
||||
Forge.getAssets().manager().finishLoadingAsset(skinFile.path());
|
||||
*/
|
||||
|
||||
}
|
||||
return Forge.getAssets().manager().get(skinFile.path(), Skin.class);
|
||||
}
|
||||
|
||||
public static Label newLabel(String name) {
|
||||
Label ret = new Label(name, GetSkin());
|
||||
Label ret = new Label(name, getSkin());
|
||||
return ret;
|
||||
}
|
||||
static public Color colorFromString(String name)
|
||||
{
|
||||
String upperCase=name.toUpperCase();
|
||||
if(upperCase.startsWith("0X")||upperCase.startsWith("#"))
|
||||
{
|
||||
return new Color( Long.decode(upperCase).intValue());
|
||||
}
|
||||
if(upperCase.equals("WHITE"))
|
||||
return Color.WHITE;
|
||||
if(upperCase.equals("LIGHT_GRAY"))
|
||||
return Color.LIGHT_GRAY;
|
||||
if(upperCase.equals("GRAY"))
|
||||
return Color.GRAY;
|
||||
if(upperCase.equals("DARK_GRAY"))
|
||||
return Color.DARK_GRAY;
|
||||
if(upperCase.equals("BLACK"))
|
||||
return Color.BLACK;
|
||||
if(upperCase.equals("CLEAR"))
|
||||
return Color.CLEAR;
|
||||
if(upperCase.equals("BLUE"))
|
||||
return Color.BLUE;
|
||||
if(upperCase.equals("NAVY"))
|
||||
return Color.NAVY;
|
||||
if(upperCase.equals("ROYAL"))
|
||||
return Color.ROYAL;
|
||||
if(upperCase.equals("SLATE"))
|
||||
return Color.SLATE;
|
||||
if(upperCase.equals("SKY"))
|
||||
return Color.SKY;
|
||||
if(upperCase.equals("CYAN"))
|
||||
return Color.CYAN;
|
||||
if(upperCase.equals("TEAL"))
|
||||
return Color.TEAL;
|
||||
if(upperCase.equals("GREEN"))
|
||||
return Color.GREEN;
|
||||
if(upperCase.equals("CHARTREUSE"))
|
||||
return Color.CHARTREUSE;
|
||||
if(upperCase.equals("LIME"))
|
||||
return Color.LIME;
|
||||
if(upperCase.equals("FOREST"))
|
||||
return Color.FOREST;
|
||||
if(upperCase.equals("OLIVE"))
|
||||
return Color.OLIVE;
|
||||
if(upperCase.equals("YELLOW"))
|
||||
return Color.YELLOW;
|
||||
if(upperCase.equals("GOLD"))
|
||||
return Color.GOLD;
|
||||
if(upperCase.equals("GOLDENROD"))
|
||||
return Color.GOLDENROD;
|
||||
if(upperCase.equals("ORANGE"))
|
||||
return Color.ORANGE;
|
||||
if(upperCase.equals("TAN"))
|
||||
return Color.TAN;
|
||||
if(upperCase.equals("FIREBRICK"))
|
||||
return Color.FIREBRICK;
|
||||
if(upperCase.equals("RED"))
|
||||
return Color.RED;
|
||||
if(upperCase.equals("SCARLET"))
|
||||
return Color.SCARLET;
|
||||
if(upperCase.equals("CORAL"))
|
||||
return Color.CORAL;
|
||||
if(upperCase.equals("SALMON"))
|
||||
return Color.SALMON;
|
||||
if(upperCase.equals("PINK"))
|
||||
return Color.PINK;
|
||||
if(upperCase.equals("MAGENTA"))
|
||||
return Color.MAGENTA;
|
||||
if(upperCase.equals("PURPLE"))
|
||||
return Color.PURPLE;
|
||||
if(upperCase.equals("VIOLET"))
|
||||
return Color.VIOLET;
|
||||
if(upperCase.equals("PINK"))
|
||||
return Color.MAROON;
|
||||
return Color.BLACK;
|
||||
}
|
||||
|
||||
public static TextraLabel newTextraLabel(String name) {
|
||||
TextraLabel ret = new LabelFix(name);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static String colorIdToTypingString(ColorSet color)
|
||||
{
|
||||
String coloerId="";
|
||||
if(color.hasWhite())
|
||||
coloerId+="[+w]";
|
||||
if(color.hasBlue())
|
||||
coloerId+="[+u]";
|
||||
if(color.hasBlack())
|
||||
coloerId+="[+b]";
|
||||
if(color.hasRed())
|
||||
coloerId+="[+r]";
|
||||
if(color.hasGreen())
|
||||
coloerId+="[+g]";
|
||||
if(color.isColorless())
|
||||
coloerId+="[+c]";
|
||||
return coloerId;
|
||||
}
|
||||
public static TypingLabel newTypingLabel(String name) {
|
||||
TypingLabel ret = new TypingLabel(name, GetSkin());
|
||||
TypingLabel ret = new TypingLabel(name==null?"":name, getSkin(),getTextraFont());
|
||||
ret.setVariable("player_name",Current.player().getName());
|
||||
ret.setVariable("player_color_id",colorIdToTypingString(Current.player().getColorIdentity()));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
public static Dialog newDialog(String title) {
|
||||
Dialog ret = new Dialog(title, GetSkin());
|
||||
Dialog ret = new Dialog(title, getSkin());
|
||||
ret.setMovable(false);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static Font textraFont=null;
|
||||
static public Font getTextraFont()
|
||||
{
|
||||
if(textraFont==null)
|
||||
{
|
||||
textraFont=new Font(getSkin().getFont("default"));
|
||||
textraFont.addAtlas(Config.instance().getAtlas(Paths.ITEMS_ATLAS));
|
||||
textraFont.adjustLineHeight(0.8f);//not sure why this is needed maybe the font is bad
|
||||
}
|
||||
return textraFont;
|
||||
}
|
||||
static public Font getTextraFont(String name)
|
||||
{
|
||||
Font font=new Font(getSkin().getFont(name));
|
||||
font.addAtlas(Config.instance().getAtlas(Paths.ITEMS_ATLAS));
|
||||
return font;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package forge.adventure.util;
|
||||
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Dialog;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.github.tommyettinger.textra.TextraButton;
|
||||
import com.github.tommyettinger.textra.TypingLabel;
|
||||
import forge.Forge;
|
||||
import forge.adventure.character.EnemySprite;
|
||||
import forge.adventure.data.DialogData;
|
||||
@@ -54,7 +54,7 @@ public class MapDialog {
|
||||
String text; //Check for localized string (locname), otherwise print text.
|
||||
if(dialog.loctext != null && !dialog.loctext.isEmpty()) text = L.getMessage(dialog.loctext);
|
||||
else text = dialog.text;
|
||||
Label A = Controls.newLabel(text);
|
||||
TypingLabel A = Controls.newTypingLabel(text);
|
||||
A.setWrap(true);
|
||||
D.getContentTable().add(A).width(WIDTH); //Add() returns a Cell, which is what the width is being applied to.
|
||||
if(dialog.options != null) {
|
||||
@@ -63,8 +63,8 @@ public class MapDialog {
|
||||
String name; //Get localized label if present.
|
||||
if(option.locname != null && !option.locname.isEmpty()) name = L.getMessage(option.locname);
|
||||
else name = option.name;
|
||||
TextButton B = Controls.newTextButton(name,() -> loadDialog(option));
|
||||
B.getLabel().setWrap(true); //We want this to wrap in case it's a wordy choice.
|
||||
TextraButton B = Controls.newTextButton(name,() -> loadDialog(option));
|
||||
B.getTextraLabel().setWrap(true); //We want this to wrap in case it's a wordy choice.
|
||||
D.getButtonTable().add(B).width(WIDTH - 10); //The button table also returns a Cell when adding.
|
||||
//TODO: Reducing the space a tiny bit could help. But should be fine as long as there aren't more than 4-5 options.
|
||||
D.getButtonTable().row(); //Add a row. Tried to allow a few per row but it was a bit erratic.
|
||||
|
||||
@@ -14,14 +14,14 @@ public class Paths {
|
||||
public static final String SKIN_FONT = "skin/LanaPixel.ttf";
|
||||
public static final String ITEMS_EQUIP = "skin/equip.png";
|
||||
public static final String ITEMS_ATLAS = "sprites/items.atlas";
|
||||
public static final String MANA_ATLAS = "sprites/pixelmana.atlas";
|
||||
public static final String COLOR_FRAME_ATLAS = "ui/color_frames.atlas";
|
||||
public static final String ARENA_ATLAS = "ui/arena.atlas";
|
||||
public static final String MAP_MARKER = "sprites/map_marker.atlas";
|
||||
|
||||
|
||||
public static final String EFFECT_HEAL = "particle_effects/heal.p";
|
||||
public static final String EFFECT_KILL = "particle_effects/kill.p";
|
||||
public static final String EFFECT_KILL = "particle_effects/killed.p";
|
||||
public static final String TRIGGER_KILL = "particle_effects/kill.p";
|
||||
public static final String EFFECT_HIDE = "particle_effects/hide.p";
|
||||
public static final String EFFECT_SPRINT = "particle_effects/sprint.p";
|
||||
public static final String EFFECT_FLY = "particle_effects/fly.p";
|
||||
|
||||
@@ -17,13 +17,13 @@ import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Tooltip;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.badlogic.gdx.utils.Disposable;
|
||||
import com.github.tommyettinger.textra.TextraButton;
|
||||
import forge.Forge;
|
||||
import forge.Graphics;
|
||||
import forge.ImageKeys;
|
||||
@@ -680,7 +680,7 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
|
||||
Image tooltip_image;
|
||||
Table tooltip_actor;
|
||||
float height;
|
||||
TextButton switchButton;
|
||||
TextraButton switchButton;
|
||||
//Vector2 tmp = new Vector2();
|
||||
|
||||
public HoldTooltip(Image tooltip_image) {
|
||||
@@ -704,7 +704,7 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
|
||||
|
||||
@Override
|
||||
public boolean longPress(Actor actor, float x, float y) {
|
||||
TextButton done = actor.getStage().getRoot().findActor("done");
|
||||
TextraButton done = actor.getStage().getRoot().findActor("done");
|
||||
if (done != null && Reward.Type.Card.equals(reward.type)) {
|
||||
switchButton.setBounds(done.getX(), done.getY(), done.getWidth(), done.getHeight());
|
||||
if (reward.getCard().hasBackFace())
|
||||
|
||||
@@ -3,11 +3,11 @@ package forge.adventure.util;
|
||||
import com.badlogic.gdx.scenes.scene2d.Group;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Pools;
|
||||
import com.github.tommyettinger.textra.TextraButton;
|
||||
|
||||
/**
|
||||
* UI element to click through options, can be configured in an UiActor
|
||||
@@ -15,19 +15,19 @@ import com.badlogic.gdx.utils.Pools;
|
||||
public class Selector extends Group {
|
||||
private final ImageButton leftArrow;
|
||||
private final ImageButton rightArrow;
|
||||
private final TextButton label;
|
||||
private final TextraButton label;
|
||||
private int currentIndex = 0;
|
||||
private Array<String> textList;
|
||||
|
||||
|
||||
public Selector() {
|
||||
ImageButton.ImageButtonStyle leftArrowStyle = Controls.GetSkin().get("leftarrow", ImageButton.ImageButtonStyle.class);
|
||||
ImageButton.ImageButtonStyle leftArrowStyle = Controls.getSkin().get("leftarrow", ImageButton.ImageButtonStyle.class);
|
||||
leftArrow = new ImageButton(leftArrowStyle);
|
||||
|
||||
ImageButton.ImageButtonStyle rightArrowStyle = Controls.GetSkin().get("rightarrow", ImageButton.ImageButtonStyle.class);
|
||||
ImageButton.ImageButtonStyle rightArrowStyle = Controls.getSkin().get("rightarrow", ImageButton.ImageButtonStyle.class);
|
||||
rightArrow = new ImageButton(rightArrowStyle);
|
||||
|
||||
label = new TextButton("", Controls.GetSkin());
|
||||
label = Controls.newTextButton("");
|
||||
addActor(leftArrow);
|
||||
addActor(rightArrow);
|
||||
addActor(label);
|
||||
@@ -80,10 +80,12 @@ public class Selector extends Group {
|
||||
int oldIndex = currentIndex;
|
||||
this.currentIndex = currentIndex;
|
||||
label.setText(textList.get(currentIndex));
|
||||
label.layout();
|
||||
ChangeListener.ChangeEvent changeEvent = Pools.obtain(ChangeListener.ChangeEvent.class);
|
||||
if (fire(changeEvent)) {
|
||||
this.currentIndex = oldIndex;
|
||||
label.setText(textList.get(currentIndex));
|
||||
label.layout();
|
||||
}
|
||||
Pools.free(changeEvent);
|
||||
}
|
||||
@@ -91,7 +93,7 @@ public class Selector extends Group {
|
||||
public String getText() {
|
||||
return textList.get(currentIndex);
|
||||
}
|
||||
public TextButton getLabel() {
|
||||
public TextraButton getLabel() {
|
||||
return label;
|
||||
}
|
||||
public ImageButton getLeftArrow() {
|
||||
|
||||
@@ -196,6 +196,8 @@ public class TemplateTmxMapLoader extends TmxMapLoader {
|
||||
protected void loadObject(TiledMap map, MapObjects objects, XmlReader.Element element, float heightInPixels) {
|
||||
if (element.getName().equals("object")) {
|
||||
|
||||
if( element.hasAttribute("class")&& !element.hasAttribute("type"))
|
||||
element.setAttribute("type",element.getAttribute("class"));//set type to class value for Tiled 1.9 compatibility
|
||||
if (!element.hasAttribute("template")) {
|
||||
super.loadObject(map, objects, element, heightInPixels);
|
||||
return;
|
||||
|
||||
@@ -13,6 +13,8 @@ import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
||||
import com.badlogic.gdx.utils.Json;
|
||||
import com.badlogic.gdx.utils.ObjectMap;
|
||||
import com.badlogic.gdx.utils.OrderedMap;
|
||||
import com.github.tommyettinger.textra.TextraButton;
|
||||
import com.github.tommyettinger.textra.TextraLabel;
|
||||
import forge.Forge;
|
||||
import forge.adventure.data.UIData;
|
||||
|
||||
@@ -44,11 +46,11 @@ public class UIActor extends Group {
|
||||
readSelectorProperties((Selector) newActor, new OrderedMap.OrderedMapEntries<>(element));
|
||||
break;
|
||||
case "Label":
|
||||
newActor = new Label("", Controls.GetSkin());
|
||||
readLabelProperties((Label) newActor, new OrderedMap.OrderedMapEntries<>(element));
|
||||
newActor = Controls.newTextraLabel("");
|
||||
readLabelProperties((TextraLabel) newActor, new OrderedMap.OrderedMapEntries<>(element));
|
||||
break;
|
||||
case "Table":
|
||||
newActor = new Table(Controls.GetSkin());
|
||||
newActor = new Table(Controls.getSkin());
|
||||
readTableProperties((Table) newActor, new OrderedMap.OrderedMapEntries<>(element));
|
||||
break;
|
||||
case "Image":
|
||||
@@ -56,31 +58,31 @@ public class UIActor extends Group {
|
||||
readImageProperties((Image) newActor, new OrderedMap.OrderedMapEntries<>(element));
|
||||
break;
|
||||
case "ImageButton":
|
||||
newActor = new ImageButton(Controls.GetSkin());
|
||||
newActor = new ImageButton(Controls.getSkin());
|
||||
readImageButtonProperties((ImageButton) newActor, new OrderedMap.OrderedMapEntries<>(element));
|
||||
break;
|
||||
case "Window":
|
||||
newActor = new Window("", Controls.GetSkin());
|
||||
newActor = new Window("", Controls.getSkin());
|
||||
readWindowProperties((Window) newActor, new OrderedMap.OrderedMapEntries<>(element));
|
||||
break;
|
||||
case "TextButton":
|
||||
newActor = new TextButton("", Controls.GetSkin());
|
||||
readButtonProperties((TextButton) newActor, new OrderedMap.OrderedMapEntries<>(element));
|
||||
newActor = Controls.newTextButton("");
|
||||
readButtonProperties((TextraButton) newActor, new OrderedMap.OrderedMapEntries<>(element));
|
||||
break;
|
||||
case "TextField":
|
||||
newActor = new TextField("", Controls.GetSkin());
|
||||
newActor = new TextField("", Controls.getSkin());
|
||||
readTextFieldProperties((TextField) newActor, new OrderedMap.OrderedMapEntries<>(element));
|
||||
break;
|
||||
case "Scroll":
|
||||
newActor = new ScrollPane(null, Controls.GetSkin());
|
||||
newActor = new ScrollPane(null, Controls.getSkin());
|
||||
readScrollPaneProperties((ScrollPane) newActor, new OrderedMap.OrderedMapEntries<>(element));
|
||||
break;
|
||||
case "CheckBox":
|
||||
newActor = new CheckBox("", Controls.GetSkin());
|
||||
newActor = new CheckBox("", Controls.getSkin());
|
||||
readCheckBoxProperties((CheckBox) newActor, new OrderedMap.OrderedMapEntries<>(element));
|
||||
break;
|
||||
case "SelectBox":
|
||||
newActor = new SelectBox<>(Controls.GetSkin());
|
||||
newActor = new SelectBox<>(Controls.getSkin());
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Unexpected value: " + type);
|
||||
@@ -135,11 +137,11 @@ public class UIActor extends Group {
|
||||
}
|
||||
|
||||
private void readScrollPaneProperties(ScrollPane newActor, ObjectMap.Entries<String, String> entries) {
|
||||
newActor.setActor(new Label("", Controls.GetSkin()));
|
||||
newActor.setActor(Controls.newTextraLabel(""));
|
||||
for (ObjectMap.Entry property : entries) {
|
||||
switch (property.key.toString()) {
|
||||
case "style":
|
||||
newActor.setStyle(Controls.GetSkin().get(property.value.toString(), ScrollPane.ScrollPaneStyle.class));
|
||||
newActor.setStyle(Controls.getSkin().get(property.value.toString(), ScrollPane.ScrollPaneStyle.class));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -149,7 +151,7 @@ public class UIActor extends Group {
|
||||
for (ObjectMap.Entry property : entries) {
|
||||
switch (property.key.toString()) {
|
||||
case "style":
|
||||
newActor.setStyle(Controls.GetSkin().get(property.value.toString(), Window.WindowStyle.class));
|
||||
newActor.setStyle(Controls.getSkin().get(property.value.toString(), Window.WindowStyle.class));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -170,13 +172,13 @@ public class UIActor extends Group {
|
||||
}
|
||||
|
||||
public static String localize(String str) {
|
||||
Pattern regex=Pattern.compile("\\{[^\\}]*\\}");
|
||||
Pattern regex=Pattern.compile("tr\\([^\\)]*\\)");
|
||||
for(int i=0;i<100;i++)
|
||||
{
|
||||
Matcher matcher= regex.matcher(str);
|
||||
if(!matcher.find())
|
||||
return str;
|
||||
str=matcher.replaceAll(Forge.getLocalizer().getMessage(matcher.group().substring(1,matcher.group().length()-1)));
|
||||
str=matcher.replaceFirst(Forge.getLocalizer().getMessage(matcher.group().substring(3,matcher.group().length()-1)));
|
||||
}
|
||||
return str;
|
||||
}
|
||||
@@ -185,39 +187,34 @@ public class UIActor extends Group {
|
||||
for (ObjectMap.Entry property : entries) {
|
||||
switch (property.key.toString()) {
|
||||
case "style":
|
||||
newActor.setStyle(Controls.GetSkin().get(property.value.toString(), ImageButton.ImageButtonStyle.class));
|
||||
newActor.setStyle(Controls.getSkin().get(property.value.toString(), ImageButton.ImageButtonStyle.class));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void readLabelProperties(Label newActor, ObjectMap.Entries<String, String> entries) {
|
||||
Label.LabelStyle style = new Label.LabelStyle(newActor.getStyle());
|
||||
private void readLabelProperties(TextraLabel newActor, ObjectMap.Entries<String, String> entries) {
|
||||
for (ObjectMap.Entry property : entries) {
|
||||
switch (property.key.toString()) {
|
||||
case "text":
|
||||
newActor.setText(localize(property.value.toString()));
|
||||
break;
|
||||
case "font"://legacy
|
||||
style.font = Controls.getBitmapFont(property.value.toString());
|
||||
if (property.value.toString().contains("black"))
|
||||
style.fontColor = Color.BLACK;
|
||||
if (property.value.toString().contains("big"))
|
||||
newActor.setFontScale(2, 2);
|
||||
newActor.setStyle(style);
|
||||
break;
|
||||
case "fontSize":
|
||||
newActor.setFontScale((Float)property.value, (Float)property.value);
|
||||
break;
|
||||
case "font":
|
||||
case "fontName":
|
||||
style.font = Controls.getBitmapFont(property.value.toString());
|
||||
newActor.setStyle(style);
|
||||
if(!property.value.toString().equals("default"))
|
||||
newActor.setFont(Controls.getTextraFont(property.value.toString()));
|
||||
break;
|
||||
case "style":
|
||||
newActor.style=(Controls.getSkin().get(property.value.toString(), Label.LabelStyle.class));
|
||||
break;
|
||||
case "color":
|
||||
case "fontColor":
|
||||
newActor.setColor(new Color(Integer.decode(property.value.toString()) ));
|
||||
newActor.layout.setBaseColor(Controls.colorFromString(property.value.toString()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
newActor.setText(newActor.storedText);//necessary if color changes after text inserted
|
||||
newActor.layout();
|
||||
}
|
||||
|
||||
private void readTableProperties(Table newActor, ObjectMap.Entries<String, String> entries) {
|
||||
@@ -247,14 +244,18 @@ public class UIActor extends Group {
|
||||
}
|
||||
}
|
||||
|
||||
private void readButtonProperties(TextButton newActor, ObjectMap.Entries<String, String> entries) {
|
||||
private void readButtonProperties(TextraButton newActor, ObjectMap.Entries<String, String> entries) {
|
||||
for (ObjectMap.Entry property : entries) {
|
||||
switch (property.key.toString()) {
|
||||
case "text":
|
||||
newActor.setText(localize(property.value.toString()));
|
||||
break;
|
||||
case "style":
|
||||
newActor.setStyle(Controls.getSkin().get(property.value.toString(), TextButton.TextButtonStyle.class));
|
||||
break;
|
||||
}
|
||||
}
|
||||
newActor.layout();
|
||||
}
|
||||
|
||||
private void readImageProperties(Image newActor, ObjectMap.Entries<String, String> entries) {
|
||||
|
||||
Reference in New Issue
Block a user