Merge branch 'master' into 'master'

update touch controls for adventure rewards

See merge request core-developers/forge!6278
This commit is contained in:
Anthony Calosa
2022-02-22 06:54:58 +00:00
18 changed files with 653 additions and 608 deletions

View File

@@ -303,6 +303,8 @@ public class Forge implements ApplicationListener {
startContinuousRendering(); startContinuousRendering();
GuiBase.setIsAdventureMode(true); GuiBase.setIsAdventureMode(true);
isMobileAdventureMode = true; isMobileAdventureMode = true;
if (GuiBase.isAndroid()) //force it for adventure mode
altZoneTabs = true;
//pixl cursor for adventure //pixl cursor for adventure
setCursor(null, "0"); setCursor(null, "0");
try { try {

View File

@@ -3,6 +3,7 @@ package forge.adventure.scene;
import com.badlogic.gdx.Input; import com.badlogic.gdx.Input;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton; import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import forge.Forge; import forge.Forge;
import forge.adventure.stage.GameHUD;
import forge.adventure.util.Current; import forge.adventure.util.Current;
/** /**
@@ -18,6 +19,7 @@ public class InnScene extends UIScene {
public void done() public void done()
{ {
GameHUD.getInstance().getTouchpad().setVisible(false);
Forge.switchToLast(); Forge.switchToLast();
} }
public void heal() public void heal()

View File

@@ -11,6 +11,7 @@ import forge.Forge;
import forge.adventure.character.ShopActor; import forge.adventure.character.ShopActor;
import forge.adventure.player.AdventurePlayer; import forge.adventure.player.AdventurePlayer;
import forge.adventure.pointofintrest.PointOfInterestChanges; import forge.adventure.pointofintrest.PointOfInterestChanges;
import forge.adventure.stage.GameHUD;
import forge.adventure.util.CardUtil; import forge.adventure.util.CardUtil;
import forge.adventure.util.Current; import forge.adventure.util.Current;
import forge.adventure.util.Reward; import forge.adventure.util.Reward;
@@ -45,6 +46,7 @@ public class RewardScene extends UIScene {
float flipCountDown=1.0f; float flipCountDown=1.0f;
public boolean done() public boolean done()
{ {
GameHUD.getInstance().getTouchpad().setVisible(false);
if(doneClicked) if(doneClicked)
return true; return true;

View File

@@ -55,7 +55,8 @@ public class SaveLoadScene extends UIScene {
private TextButton addSaveSlot(String name, int i) { private TextButton addSaveSlot(String name, int i) {
layout.add(Controls.newLabel(name)); layout.add(Controls.newLabel(name)).colspan(1).align(Align.right).expandX();
layout.add(Controls.newLabel(" "));
TextButton button = Controls.newTextButton("..."); TextButton button = Controls.newTextButton("...");
button.addListener(new ClickListener() { button.addListener(new ClickListener() {
@Override @Override
@@ -68,7 +69,7 @@ public class SaveLoadScene extends UIScene {
} }
} }
}); });
layout.add(button).expandX(); layout.add(button).colspan(2).align(Align.left).expandX();
buttons.put(i, button); buttons.put(i, button);
layout.row(); layout.row();
return button; return button;
@@ -223,7 +224,7 @@ public class SaveLoadScene extends UIScene {
previewImage = ui.findActor("preview"); previewImage = ui.findActor("preview");
header = Controls.newLabel("Save"); header = Controls.newLabel("Save");
header.setHeight(header.getHeight() * 2); header.setHeight(header.getHeight() * 2);
layout.add(header).colspan(2).align(Align.center); layout.add(header).colspan(3).align(Align.center).expand();
layout.row(); layout.row();
autoSave=addSaveSlot("Auto save", WorldSave.AUTO_SAVE_SLOT); autoSave=addSaveSlot("Auto save", WorldSave.AUTO_SAVE_SLOT);
quickSave=addSaveSlot("Quick save", WorldSave.QUICK_SAVE_SLOT); quickSave=addSaveSlot("Quick save", WorldSave.QUICK_SAVE_SLOT);

View File

@@ -229,8 +229,11 @@ public class SettingsScene extends UIScene {
addCheckBox(localizer.getMessage("cbImageFetcher"), ForgePreferences.FPref.UI_ENABLE_ONLINE_IMAGE_FETCHER); addCheckBox(localizer.getMessage("cbImageFetcher"), ForgePreferences.FPref.UI_ENABLE_ONLINE_IMAGE_FETCHER);
addCheckBox(localizer.getMessage("lblBattlefieldTextureFiltering"), ForgePreferences.FPref.UI_LIBGDX_TEXTURE_FILTERING); if (!GuiBase.isAndroid()) {
addCheckBox(localizer.getMessage("lblAltZoneTabs"), ForgePreferences.FPref.UI_ALT_PLAYERZONETABS); addCheckBox(localizer.getMessage("lblBattlefieldTextureFiltering"), ForgePreferences.FPref.UI_LIBGDX_TEXTURE_FILTERING);
addCheckBox(localizer.getMessage("lblAltZoneTabs"), ForgePreferences.FPref.UI_ALT_PLAYERZONETABS);
}
addCheckBox(localizer.getMessage("lblAnimatedCardTapUntap"), ForgePreferences.FPref.UI_ANIMATED_CARD_TAPUNTAP); addCheckBox(localizer.getMessage("lblAnimatedCardTapUntap"), ForgePreferences.FPref.UI_ANIMATED_CARD_TAPUNTAP);
if (!GuiBase.isAndroid()) { if (!GuiBase.isAndroid()) {
addCheckBox(localizer.getMessage("lblBorderMaskOption"), ForgePreferences.FPref.UI_ENABLE_BORDER_MASKING); addCheckBox(localizer.getMessage("lblBorderMaskOption"), ForgePreferences.FPref.UI_ENABLE_BORDER_MASKING);

View File

@@ -1,5 +1,6 @@
package forge.adventure.scene; package forge.adventure.scene;
import forge.adventure.stage.GameHUD;
import forge.screens.FScreen; import forge.screens.FScreen;
/** /**
@@ -22,6 +23,7 @@ public class ShopScene extends ForgeScene {
@Override @Override
public void enter() { public void enter() {
GameHUD.getInstance().getTouchpad().setVisible(false);
getScreen(); getScreen();
screen.refresh(); screen.refresh();
super.enter(); super.enter();

View File

@@ -139,6 +139,10 @@ public class GameHUD extends Stage {
return instance == null ? instance = new GameHUD(WorldStage.getInstance()) : instance; return instance == null ? instance = new GameHUD(WorldStage.getInstance()) : instance;
} }
public Touchpad getTouchpad() {
return touchpad;
}
@Override @Override
public boolean touchUp(int screenX, int screenY, int pointer, int button) { public boolean touchUp(int screenX, int screenY, int pointer, int button) {
touchpad.setVisible(false); touchpad.setVisible(false);

View File

@@ -12,9 +12,12 @@ import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.ui.Image; import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.Tooltip; 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.ClickListener;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.utils.Disposable; import com.badlogic.gdx.utils.Disposable;
import forge.Forge; import forge.Forge;
import forge.adventure.scene.RewardScene; import forge.adventure.scene.RewardScene;
@@ -26,28 +29,27 @@ import forge.util.ImageFetcher;
/** /**
* Render the rewards as a card on the reward scene. * Render the rewards as a card on the reward scene.
*
*/ */
public class RewardActor extends Actor implements Disposable, ImageFetcher.Callback { public class RewardActor extends Actor implements Disposable, ImageFetcher.Callback {
Tooltip<Image> tooltip; Tooltip<Image> tooltip;
HoldTooltip holdTooltip;
Reward reward; Reward reward;
static TextureRegion backTexture; static TextureRegion backTexture;
Texture image; Texture image;
boolean needsToBeDisposed; boolean needsToBeDisposed;
float flipProcess=0; float flipProcess = 0;
boolean clicked=false; boolean clicked = false;
boolean flipOnClick; boolean flipOnClick;
private boolean hover; private boolean hover;
static final ImageFetcher fetcher = GuiBase.getInterface().getImageFetcher(); static final ImageFetcher fetcher = GuiBase.getInterface().getImageFetcher();
Image toolTipImage; Image toolTipImage;
@Override @Override
public void dispose() { public void dispose() {
if (needsToBeDisposed)
if(needsToBeDisposed)
image.dispose(); image.dispose();
} }
public Reward getReward() { public Reward getReward() {
@@ -56,53 +58,43 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
@Override @Override
public void onImageFetched() { public void onImageFetched() {
setCardImage(ImageCache.getImage(reward.getCard().getImageKey(false),false)); setCardImage(ImageCache.getImage(reward.getCard().getImageKey(false), false));
} }
public RewardActor(Reward reward,boolean flippable) public RewardActor(Reward reward, boolean flippable) {
{ this.flipOnClick = flippable;
this.reward = reward;
this.flipOnClick=flippable; if (backTexture == null) {
this.reward=reward; backTexture = FSkin.getSleeves().get(0);
if(backTexture==null)
{
backTexture= FSkin.getSleeves().get(0);
} }
switch (reward.type) switch (reward.type) {
{ case Card: {
case Card: if (ImageCache.imageKeyFileExists(reward.getCard().getImageKey(false))) {
if(ImageCache.imageKeyFileExists(reward.getCard().getImageKey(false))) setCardImage(ImageCache.getImage(reward.getCard().getImageKey(false), false));
{ } else {
setCardImage( ImageCache.getImage(reward.getCard().getImageKey(false),false));
}
else
{
if (!ImageCache.imageKeyFileExists(reward.getCard().getImageKey(false))) { if (!ImageCache.imageKeyFileExists(reward.getCard().getImageKey(false))) {
fetcher.fetchImage(reward.getCard().getImageKey(false), this); fetcher.fetchImage(reward.getCard().getImageKey(false), this);
} }
} }
break; break;
case Gold: }
{ case Gold: {
TextureAtlas atlas = Config.instance().getAtlas("sprites/items.atlas");
Sprite backSprite = atlas.createSprite("CardBack");
Pixmap drawingMap = new Pixmap((int) backSprite.getWidth(), (int) backSprite.getHeight(), Pixmap.Format.RGBA8888);
TextureAtlas atlas= Config.instance().getAtlas("sprites/items.atlas"); DrawOnPixmap.draw(drawingMap, backSprite);
Sprite backSprite=atlas.createSprite("CardBack"); Sprite gold = atlas.createSprite("Gold");
Pixmap drawingMap=new Pixmap((int)backSprite.getWidth(),(int)backSprite.getHeight(), Pixmap.Format.RGBA8888); DrawOnPixmap.draw(drawingMap, (int) ((backSprite.getWidth() / 2f) - gold.getWidth() / 2f), (int) ((backSprite.getHeight() / 4f) * 1f), gold);
DrawOnPixmap.drawText(drawingMap, String.valueOf(reward.getCount()), 0, (int) ((backSprite.getHeight() / 4f) * 2f), backSprite.getWidth());
DrawOnPixmap.draw(drawingMap,backSprite);
Sprite gold=atlas.createSprite("Gold");
DrawOnPixmap.draw(drawingMap,(int)((backSprite.getWidth()/2f)-gold.getWidth()/2f),(int)((backSprite.getHeight()/4f)*1f),gold);
DrawOnPixmap.drawText(drawingMap,String.valueOf(reward.getCount()),0,(int)((backSprite.getHeight()/4f)*2f),backSprite.getWidth());
image=new Texture(drawingMap); image=new Texture(drawingMap);
drawingMap.dispose(); drawingMap.dispose();
needsToBeDisposed=true; needsToBeDisposed = true;
break; break;
} }
case Life: case Life: {
{
TextureAtlas atlas = Config.instance().getAtlas("sprites/items.atlas"); TextureAtlas atlas = Config.instance().getAtlas("sprites/items.atlas");
Sprite backSprite = atlas.createSprite("CardBack"); Sprite backSprite = atlas.createSprite("CardBack");
Pixmap drawingMap = new Pixmap((int) backSprite.getWidth(), (int) backSprite.getHeight(), Pixmap.Format.RGBA8888); Pixmap drawingMap = new Pixmap((int) backSprite.getWidth(), (int) backSprite.getHeight(), Pixmap.Format.RGBA8888);
@@ -119,33 +111,40 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
} }
} }
addListener(new ClickListener() { addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
if(flipOnClick)
flip();
}
@Override @Override
public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor){ public void clicked(InputEvent event, float x, float y) {
hover=true; if (flipOnClick)
flip();
} }
@Override @Override
public void exit(InputEvent event, float x, float y, int pointer, Actor fromActor){ public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) {
hover=false; hover = true;
} }
});
@Override
public void exit(InputEvent event, float x, float y, int pointer, Actor fromActor) {
hover = false;
}
});
} }
private void setCardImage(Texture img) { private void setCardImage(Texture img) {
image=img; image = img;
if(Forge.isTextureFilteringEnabled()) if (Forge.isTextureFilteringEnabled())
image.setFilter(Texture.TextureFilter.MipMapLinearLinear,Texture.TextureFilter.Linear); image.setFilter(Texture.TextureFilter.MipMapLinearLinear, Texture.TextureFilter.Linear);
TextureRegionDrawable drawable=new TextureRegionDrawable(new TextureRegion(image)); TextureRegionDrawable drawable = new TextureRegionDrawable(ImageCache.croppedBorderImage(image));
drawable.setMinSize((Scene.GetIntendedHeight()/ RewardScene.CARD_WIDTH_TO_HEIGHT)*0.95f,Scene.GetIntendedHeight()*0.95f); drawable.setMinSize((Scene.GetIntendedHeight() / RewardScene.CARD_WIDTH_TO_HEIGHT) * 0.95f, Scene.GetIntendedHeight() * 0.95f);
toolTipImage=new Image(drawable); toolTipImage = new Image(drawable);
tooltip=new Tooltip<Image>(toolTipImage); tooltip = new Tooltip<Image>(toolTipImage);
holdTooltip = new HoldTooltip(new Image(drawable));
tooltip.setInstant(true); tooltip.setInstant(true);
if(frontSideUp()) if (frontSideUp()) {
addListener(tooltip); if (GuiBase.isAndroid())
addListener(holdTooltip);
else
addListener(tooltip);
}
} }
private boolean frontSideUp() { private boolean frontSideUp() {
@@ -153,79 +152,77 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
} }
public boolean isFlipped() { public boolean isFlipped() {
return (clicked && flipProcess >= 1);
return (clicked&&flipProcess>=1);
} }
public void flip() { public void flip() {
if (clicked)
if(clicked)
return; return;
clicked=true; clicked = true;
flipProcess=0; flipProcess = 0;
} }
@Override
public void act(float delta)
{
super.act(delta);
if(clicked)
{
if(flipProcess<1)
flipProcess+=delta;
else
flipProcess=1;
if(tooltip!=null&&frontSideUp()&&!getListeners().contains(tooltip,true)) @Override
addListener(tooltip); public void act(float delta) {
super.act(delta);
if (clicked) {
if (flipProcess < 1)
flipProcess += delta;
else
flipProcess = 1;
if (GuiBase.isAndroid()) {
if (holdTooltip != null && frontSideUp() && !getListeners().contains(holdTooltip, true)) {
addListener(holdTooltip);
}
} else {
if (tooltip != null && frontSideUp() && !getListeners().contains(tooltip, true)) {
addListener(tooltip);
}
}
// flipProcess=(float)Gdx.input.getX()/ (float)Gdx.graphics.getWidth(); // flipProcess=(float)Gdx.input.getX()/ (float)Gdx.graphics.getWidth();
} }
} }
@Override
public void draw (Batch batch, float parentAlpha) {
@Override
public void draw(Batch batch, float parentAlpha) {
applyTransform(batch, computeTransform(batch.getTransformMatrix().cpy())); applyTransform(batch, computeTransform(batch.getTransformMatrix().cpy()));
oldProjectionTransform.set(batch.getProjectionMatrix()); oldProjectionTransform.set(batch.getProjectionMatrix());
applyProjectionMatrix(batch); applyProjectionMatrix(batch);
if(hover) if (hover)
batch.setColor(0.5f,0.5f,0.5f,1); batch.setColor(0.5f, 0.5f, 0.5f, 1);
if(!frontSideUp()) if (!frontSideUp()) {
{ batch.draw(backTexture, -getWidth() / 2, -getHeight() / 2, getWidth(), getHeight());
batch.draw(backTexture,-getWidth()/2,-getHeight()/2,getWidth(),getHeight()); } else {
}
else
{
drawFrontSide(batch); drawFrontSide(batch);
} }
batch.setColor(1,1,1,1); batch.setColor(1, 1, 1, 1);
resetTransform(batch); resetTransform(batch);
batch.setProjectionMatrix(oldProjectionTransform); batch.setProjectionMatrix(oldProjectionTransform);
} }
private void drawFrontSide(Batch batch) { private void drawFrontSide(Batch batch) {
float width; float width;
float x; float x;
if(flipOnClick) if (flipOnClick) {
{ width = -getWidth();
width=-getWidth(); x = -getWidth() / 2 + getWidth();
x=-getWidth()/2+getWidth(); } else {
} width = getWidth();
else x = -getWidth() / 2;
{
width=getWidth();
x=-getWidth()/2;
} }
if (image != null) if (image != null) {
batch.draw(image,x,-getHeight()/2,width,getHeight()); batch.draw(ImageCache.croppedBorderImage(image), x, -getHeight() / 2, width, getHeight());
}
else else
batch.draw(ImageCache.defaultImage,x,-getHeight()/2,width,getHeight()); batch.draw(ImageCache.defaultImage, x, -getHeight() / 2, width, getHeight());
switch (reward.getType()) switch (reward.getType()) {
{
case Card: case Card:
break; break;
@@ -237,23 +234,22 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
} }
private void applyProjectionMatrix(Batch batch) { private void applyProjectionMatrix(Batch batch) {
final Vector3 direction = new Vector3(0, 0, -1); final Vector3 direction = new Vector3(0, 0, -1);
final Vector3 up = new Vector3(0, 1, 0); final Vector3 up = new Vector3(0, 1, 0);
//final Vector3 position = new Vector3( getX()+getWidth()/2 , getY()+getHeight()/2, 0); //final Vector3 position = new Vector3( getX()+getWidth()/2 , getY()+getHeight()/2, 0);
final Vector3 position = new Vector3( Scene.GetIntendedWidth() /2f , Scene.GetIntendedHeight()/2f, 0); final Vector3 position = new Vector3(Scene.GetIntendedWidth() / 2f, Scene.GetIntendedHeight() / 2f, 0);
float fov=67; float fov = 67;
Matrix4 projection=new Matrix4(); Matrix4 projection = new Matrix4();
Matrix4 view=new Matrix4(); Matrix4 view = new Matrix4();
float hy= Scene.GetIntendedHeight()/2f; float hy = Scene.GetIntendedHeight() / 2f;
float a= (float) ((hy)/Math.sin(MathUtils.degreesToRadians*(fov/2f))); float a = (float) ((hy) / Math.sin(MathUtils.degreesToRadians * (fov / 2f)));
float height= (float) Math.sqrt((a*a)-(hy*hy)); float height = (float) Math.sqrt((a * a) - (hy * hy));
position.z=height*1f; position.z = height * 1f;
float far=height*2f; float far = height * 2f;
float near=height*0.8f; float near = height * 0.8f;
float aspect = (float)Scene.GetIntendedWidth() / (float)Scene.GetIntendedHeight(); float aspect = (float) Scene.GetIntendedWidth() / (float) Scene.GetIntendedHeight();
projection.setToProjection(Math.abs(near), Math.abs(far), fov, aspect); projection.setToProjection(Math.abs(near), Math.abs(far), fov, aspect);
view.setToLookAt(position, position.cpy().add(direction), up); view.setToLookAt(position, position.cpy().add(direction), up);
Matrix4.mul(projection.val, view.val); Matrix4.mul(projection.val, view.val);
@@ -262,39 +258,69 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
} }
private final Matrix4 computedTransform = new Matrix4(); private final Matrix4 computedTransform = new Matrix4();
private final Matrix4 oldTransform = new Matrix4(); private final Matrix4 oldTransform = new Matrix4();
private final Matrix4 oldProjectionTransform = new Matrix4(); private final Matrix4 oldProjectionTransform = new Matrix4();
protected void applyTransform (Batch batch, Matrix4 transform) protected void applyTransform(Batch batch, Matrix4 transform) {
{
oldTransform.set(batch.getTransformMatrix()); oldTransform.set(batch.getTransformMatrix());
batch.setTransformMatrix(transform); batch.setTransformMatrix(transform);
} }
/** Restores the batch transform to what it was before {@link #applyTransform(Batch, Matrix4)}. Note this causes the batch to /**
* be flushed. */ * Restores the batch transform to what it was before {@link #applyTransform(Batch, Matrix4)}. Note this causes the batch to
protected void resetTransform (Batch batch) { * be flushed.
*/
protected void resetTransform(Batch batch) {
batch.setTransformMatrix(oldTransform); batch.setTransformMatrix(oldTransform);
} }
protected Matrix4 computeTransform (Matrix4 worldTransform) {
protected Matrix4 computeTransform(Matrix4 worldTransform) {
float[] val=worldTransform.getValues(); float[] val = worldTransform.getValues();
//val[Matrix4.M32]=0.0002f; //val[Matrix4.M32]=0.0002f;
worldTransform.set(val); worldTransform.set(val);
float originX = this.getOriginX(), originY = this.getOriginY(); float originX = this.getOriginX(), originY = this.getOriginY();
worldTransform.translate(getX()+getWidth()/2 , getY()+getHeight()/2,0); worldTransform.translate(getX() + getWidth() / 2, getY() + getHeight() / 2, 0);
if(clicked) if (clicked) {
{ worldTransform.rotate(0, 1, 0, 180 * flipProcess);
worldTransform.rotate(0,1,0,180*flipProcess);
} }
computedTransform.set(worldTransform); computedTransform.set(worldTransform);
return computedTransform; return computedTransform;
} }
class HoldTooltip extends ActorGestureListener {
Image tooltip_image;
Table tooltip_actor;
//Vector2 tmp = new Vector2();
public HoldTooltip(Image tooltip_image) {
this.tooltip_image = tooltip_image;
tooltip_actor = new Table();
tooltip_actor.add(this.tooltip_image);
tooltip_actor.align(Align.center);
tooltip_actor.setSize(this.tooltip_image.getPrefWidth(), this.tooltip_image.getPrefHeight());
getGestureDetector().setLongPressSeconds(0.1f);
}
@Override
public boolean longPress(Actor actor, float x, float y) {
//Vector2 point = actor.localToStageCoordinates(tmp.set(x, y));
tooltip_actor.setX(actor.getRight());
if (tooltip_actor.getX() + tooltip_actor.getWidth() > 480)
tooltip_actor.setX(actor.getX() - tooltip_actor.getWidth());
tooltip_actor.setY(270 / 2 - tooltip_actor.getHeight() / 2);
//tooltip_actor.setX(480/2 - tooltip_actor.getWidth()/2); //480 hud width
//tooltip_actor.setY(270/2-tooltip_actor.getHeight()/2); //270 hud height
actor.getStage().addActor(tooltip_actor);
return super.longPress(actor, x, y);
}
@Override
public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
tooltip_actor.remove();
super.touchUp(event, x, y, pointer, button);
}
}
} }

View File

@@ -9,6 +9,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
import com.badlogic.gdx.scenes.scene2d.ui.Label; import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane; import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton; import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.ui.TextField; import com.badlogic.gdx.scenes.scene2d.ui.TextField;
import com.badlogic.gdx.scenes.scene2d.ui.Window; import com.badlogic.gdx.scenes.scene2d.ui.Window;
@@ -50,6 +51,10 @@ public class UIActor extends Group {
newActor = new Label("", Controls.GetSkin()); newActor = new Label("", Controls.GetSkin());
readLabelProperties((Label) newActor, new OrderedMap.OrderedMapEntries<>(element)); readLabelProperties((Label) newActor, new OrderedMap.OrderedMapEntries<>(element));
break; break;
case "Table":
newActor = new Table(Controls.GetSkin());
readTableProperties((Table) newActor, new OrderedMap.OrderedMapEntries<>(element));
break;
case "Image": case "Image":
newActor = new Image(); newActor = new Image();
readImageProperties((Image) newActor, new OrderedMap.OrderedMapEntries<>(element)); readImageProperties((Image) newActor, new OrderedMap.OrderedMapEntries<>(element));
@@ -161,6 +166,16 @@ public class UIActor extends Group {
} }
} }
private void readTableProperties(Table newActor, ObjectMap.Entries<String, String> entries) {
for (ObjectMap.Entry property : entries) {
switch (property.key.toString()) {
case "font":
newActor.getSkin().get(Label.LabelStyle.class).font = Controls.GetSkin().getFont(property.value.toString());
break;
}
}
}
private void readSelectorProperties(Selector newActor, ObjectMap.Entries<String, String> entries) { private void readSelectorProperties(Selector newActor, ObjectMap.Entries<String, String> entries) {
} }

View File

@@ -9,6 +9,7 @@ import forge.Graphics;
import forge.animation.ForgeAnimation; import forge.animation.ForgeAnimation;
import forge.assets.FSkin; import forge.assets.FSkin;
import forge.assets.FSkinImage; import forge.assets.FSkinImage;
import forge.assets.FSkinTexture;
import forge.gui.GuiBase; import forge.gui.GuiBase;
import forge.toolbox.FContainer; import forge.toolbox.FContainer;
@@ -34,7 +35,6 @@ public class TransitionScreen extends FContainer {
private class BGAnimation extends ForgeAnimation { private class BGAnimation extends ForgeAnimation {
float DURATION = 0.6f; float DURATION = 0.6f;
private float progress = 0; private float progress = 0;
Texture transition_bg = new Texture(GuiBase.isAndroid() ? Gdx.files.internal("fallback_skin").child("title_bg_lq.png") : Gdx.files.classpath("fallback_skin").child("title_bg_lq.png"));
public void drawBackground(Graphics g) { public void drawBackground(Graphics g) {
float percentage = progress / DURATION; float percentage = progress / DURATION;
@@ -46,9 +46,9 @@ public class TransitionScreen extends FContainer {
} }
if (isloading) { if (isloading) {
g.fillRect(Color.BLACK, 0, 0, Forge.getScreenWidth(), Forge.getScreenHeight()); g.fillRect(Color.BLACK, 0, 0, Forge.getScreenWidth(), Forge.getScreenHeight());
if (transition_bg != null) { if (FSkinTexture.BG_TEXTURE != null) {
g.setAlphaComposite(percentage); g.setAlphaComposite(percentage);
g.drawImage(transition_bg, 0, 0, Forge.getScreenWidth(), Forge.getScreenHeight()); g.drawImage(FSkinTexture.BG_TEXTURE, 0, 0, Forge.getScreenWidth(), Forge.getScreenHeight());
g.setAlphaComposite(oldAlpha); g.setAlphaComposite(oldAlpha);
} }
float xmod = Forge.getScreenHeight() > 2000 ? 1.5f : 1f; float xmod = Forge.getScreenHeight() > 2000 ? 1.5f : 1f;

View File

@@ -1,95 +1,93 @@
{ {
"width": 480, "width": 480,
"height": 270, "height": 270,
"yDown": true, "yDown": true,
"elements":[ "elements": [
{ {
"type" : "Image", "type": "Image",
"name" : "gamehud", "name": "gamehud",
"width": 64, "width": 64,
"height": 206, "height": 206,
"image":"ui/hud.png", "image": "ui/hud.png",
"x": 416, "x": 416,
"y": 64 "y": 64
} , },
{ {
"type" : "Image", "type": "Image",
"name" : "map" , "name": "map",
"width": 64, "width": 64,
"height": 64, "height": 64,
"x": 416, "x": 416,
"y": 0 "y": 0
} , },
{ {
"type" : "Image", "type": "Image",
"image" : "ui/minimap.png" , "image": "ui/minimap.png",
"width": 64, "width": 64,
"height": 64, "height": 64,
"x": 416, "x": 416,
"y": 0 "y": 0
} , },
{ {
"type" : "Image", "type": "Image",
"name" : "avatar" , "name": "avatar",
"width": 32, "width": 32,
"height": 32, "height": 32,
"x": 432, "x": 432,
"y": 80 "y": 80
} , },
{ {
"type" : "Image", "type": "Image",
"image" : "ui/avatarhud.png" , "image": "ui/avatarhud.png",
"width": 32, "width": 32,
"height": 32, "height": 32,
"x": 432, "x": 432,
"y": 80 "y": 80
} , },
{ {
"type" : "Label", "type": "Label",
"name" : "lifePoints" , "name": "lifePoints",
"font" : "default" , "font": "default",
"width": 64, "width": 64,
"height": 16, "height": 16,
"x": 448, "x": 448,
"y": 128 "y": 128
} , },
{ {
"type" : "Label", "type": "Label",
"name" : "money" , "name": "money",
"font" : "default" , "font": "default",
"width": 64, "width": 64,
"height": 16, "height": 16,
"x": 448, "x": 448,
"y": 144 "y": 144
} , },
{ {
"type" : "TextButton", "type": "TextButton",
"name" : "deck" , "name": "deck",
"text" : "Deck", "text": "Deck",
"width": 32, "width": 32,
"height": 24, "height": 24,
"x": 432, "x": 432,
"y": 176 "y": 176
} , },
{ {
"type" : "TextButton", "type": "TextButton",
"name" : "statistic" , "name": "statistic",
"text" : "Status", "text": "Status",
"width": 32, "width": 32,
"height": 24, "height": 24,
"x": 432, "x": 432,
"y": 204 "y": 204
} , },
{ {
"type" : "TextButton", "type": "TextButton",
"name" : "menu" , "name": "menu",
"text" : "Menu", "text": "Menu",
"width": 32, "width": 32,
"height": 24, "height": 24,
"x": 432, "x": 432,
"y": 232 "y": 232
} }
] ]
} }

View File

@@ -1,95 +1,93 @@
{ {
"width": 480, "width": 480,
"height": 270, "height": 270,
"yDown": true, "yDown": true,
"elements":[ "elements": [
{ {
"type" : "Image", "type": "Image",
"name" : "gamehud", "name": "gamehud",
"width": 64, "width": 64,
"height": 270, "height": 270,
"image":"ui/hud_mobile.png", "image": "ui/hud_mobile.png",
"x": 416, "x": 416,
"y": 0 "y": 0
} , },
{ {
"type" : "Image", "type": "Image",
"name" : "map" , "name": "map",
"width": 80, "width": 80,
"height": 80, "height": 80,
"x": 0, "x": 0,
"y": 0 "y": 0
} , },
{ {
"type" : "Image", "type": "Image",
"image" : "ui/minimap.png" , "image": "ui/minimap.png",
"width": 80, "width": 80,
"height": 80, "height": 80,
"x": 0, "x": 0,
"y": 0 "y": 0
} , },
{ {
"type" : "Image", "type": "Image",
"name" : "avatar" , "name": "avatar",
"width": 46, "width": 46,
"height": 46, "height": 46,
"x": 425, "x": 425,
"y": 10 "y": 10
} , },
{ {
"type" : "Image", "type": "Image",
"image" : "ui/avatarhud.png" , "image": "ui/avatarhud.png",
"width": 46, "width": 46,
"height": 46, "height": 46,
"x": 425, "x": 425,
"y": 10 "y": 10
} , },
{ {
"type" : "Label", "type": "Label",
"name" : "lifePoints" , "name": "lifePoints",
"font" : "default" , "font": "default",
"width": 64, "width": 64,
"height": 16, "height": 16,
"x": 442, "x": 442,
"y": 64 "y": 64
} , },
{ {
"type" : "Label", "type": "Label",
"name" : "money" , "name": "money",
"font" : "default" , "font": "default",
"width": 64, "width": 64,
"height": 16, "height": 16,
"x": 442, "x": 442,
"y": 82 "y": 82
} , },
{ {
"type" : "TextButton", "type": "TextButton",
"name" : "deck" , "name": "deck",
"text" : "Deck", "text": "Deck",
"width": 40, "width": 40,
"height": 44, "height": 44,
"x": 428, "x": 428,
"y": 106 "y": 106
} , },
{ {
"type" : "TextButton", "type": "TextButton",
"name" : "statistic" , "name": "statistic",
"text" : "Status", "text": "Status",
"width": 40, "width": 40,
"height": 44, "height": 44,
"x": 428, "x": 428,
"y": 162 "y": 162
} , },
{ {
"type" : "TextButton", "type": "TextButton",
"name" : "menu" , "name": "menu",
"text" : "Menu", "text": "Menu",
"width": 40, "width": 40,
"height": 44, "height": 44,
"x": 428, "x": 428,
"y": 216 "y": 216
} }
] ]
} }

View File

@@ -1,44 +1,40 @@
{ {
"width": 480, "width": 480,
"height": 270, "height": 270,
"yDown": true, "yDown": true,
"elements":[ "elements": [
{ {
"type" : "Image", "type": "Image",
"name":"lastScreen", "name": "lastScreen",
"width": 480, "width": 480,
"height": 270 "height": 270
},
{
"type": "TextButton",
"name": "heal",
"text": "Heal",
"width": 48,
"height": 16,
"x": 420,
"y": 10
},
{
"type": "TextButton",
"name": "sell",
"text": "Sell cards",
"width": 48,
"height": 16,
"x": 420,
"y": 34
},
{
"type": "TextButton",
"name": "done",
"text": "Leave",
"width": 48,
"height": 16,
"x": 420,
"y": 58
} }
, ]
{
"type" : "TextButton",
"name" : "heal" ,
"text" : "Heal" ,
"width": 48,
"height": 16,
"x": 420,
"y": 10
} ,
{
"type" : "TextButton",
"name" : "sell" ,
"text" : "Sell cards" ,
"width": 48,
"height": 16,
"x": 420,
"y": 34
} ,
{
"type" : "TextButton",
"name" : "done" ,
"text" : "Leave" ,
"width": 48,
"height": 16,
"x": 420,
"y": 58
}
]
} }

View File

@@ -1,33 +1,29 @@
{ {
"width": 480, "width": 480,
"height": 270, "height": 270,
"yDown": true, "yDown": true,
"elements":[ "elements": [
{ {
"type" : "Image", "type": "Image",
"name":"lastScreen", "name": "lastScreen",
"width": 480, "width": 480,
"height": 270 "height": 270
} },
,
{ {
"name": "cards", "name": "cards",
"x": 5, "x": 5,
"y": 5 , "y": 5,
"width": 405, "width": 405,
"height": 265 "height": 265
} , },
{ {
"type" : "TextButton", "type": "TextButton",
"name" : "done" , "name": "done",
"text" : "Take all" , "text": "Take all",
"width": 48, "width": 48,
"height": 16, "height": 16,
"x": 420, "x": 420,
"y": 10 "y": 10
} }
] ]
} }

View File

@@ -1,166 +1,162 @@
{ {
"width": 480, "width": 480,
"height": 270, "height": 270,
"yDown": true, "yDown": true,
"elements":[ "elements": [
{ {
"type" : "Image", "type": "Image",
"image":"ui/title_bg.png", "image": "ui/title_bg.png",
"width": 480, "width": 480,
"height": 270 "height": 270
} },
,
{ {
"type" : "Scroll", "type": "Scroll",
"style":"paper", "style": "paper",
"x": 10, "x": 10,
"y": 10, "y": 10,
"width": 256, "width": 256,
"height": 236 "height": 236
},
{
"type": "Label",
"text": "Create a Character",
"width": 128,
"height": 32,
"font": "blackbig",
"x": 16,
"y": 16
},
{
"type": "Label",
"text": "Avatar:",
"width": 128,
"height": 32,
"x": 16,
"y": 64
},
{
"type": "Label",
"text": "Name:",
"width": 128,
"height": 32,
"x": 16,
"y": 96
},
{
"type": "Label",
"text": "Race:",
"width": 128,
"height": 32,
"x": 16,
"y": 128
},
{
"type": "Label",
"text": "Gender:",
"width": 128,
"height": 32,
"x": 16,
"y": 160
},
{
"type": "Label",
"text": "Difficulty:",
"width": 128,
"height": 32,
"x": 16,
"y": 192
},
{
"type": "Label",
"text": "Deck:",
"width": 128,
"height": 32,
"x": 16,
"y": 224
},
{
"type": "ImageButton",
"name": "leftAvatar",
"style": "leftarrow",
"width": 16,
"height": 16,
"x": 96,
"y": 64
},
{
"type": "Image",
"name": "avatarPreview",
"width": 48,
"height": 48,
"x": 128,
"y": 48
},
{
"type": "ImageButton",
"name": "rightAvatar",
"style": "rightarrow",
"width": 16,
"height": 16,
"x": 192,
"y": 64
},
{
"type": "TextField",
"name": "nameField",
"width": 112,
"height": 16,
"x": 96,
"y": 96
},
{
"type": "Selector",
"name": "race",
"width": 112,
"height": 16,
"x": 96,
"y": 128
},
{
"type": "Selector",
"name": "gender",
"width": 112,
"height": 16,
"x": 96,
"y": 160
},
{
"type": "Selector",
"name": "difficulty",
"width": 112,
"height": 16,
"x": 96,
"y": 192
},
{
"type": "Selector",
"name": "deck",
"width": 112,
"height": 16,
"x": 96,
"y": 224
},
{
"type": "TextButton",
"name": "back",
"text": "Back",
"width": 38,
"height": 16,
"x": 352,
"y": 240
},
{
"type": "TextButton",
"name": "start",
"text": "Start",
"width": 38,
"height": 16,
"x": 416,
"y": 240
} }
, ]
{
"type" : "Label",
"text" : "Create a Character",
"width": 128,
"height": 32,
"font":"blackbig",
"x": 16,
"y": 16
} ,
{
"type" : "Label",
"text" : "Avatar:" ,
"width": 128,
"height": 32,
"x": 16,
"y": 64
} ,
{
"type" : "Label",
"text" : "Name:" ,
"width": 128,
"height": 32,
"x": 16,
"y": 96
} ,
{
"type" : "Label",
"text" : "Race:" ,
"width": 128,
"height": 32,
"x": 16,
"y": 128
} ,
{
"type" : "Label",
"text" : "Gender:" ,
"width": 128,
"height": 32,
"x": 16,
"y": 160
} ,
{
"type" : "Label",
"text" : "Difficulty:" ,
"width": 128,
"height": 32,
"x": 16,
"y": 192
} ,
{
"type" : "Label",
"text" : "Deck:" ,
"width": 128,
"height": 32,
"x": 16,
"y": 224
} ,
{
"type" : "ImageButton",
"name" : "leftAvatar" ,
"style" : "leftarrow" ,
"width": 16,
"height": 16,
"x": 96,
"y": 64
} ,
{
"type" : "Image",
"name" : "avatarPreview" ,
"width": 48,
"height": 48,
"x": 128,
"y": 48
} ,
{
"type" : "ImageButton",
"name" : "rightAvatar" ,
"style" : "rightarrow" ,
"width": 16,
"height": 16,
"x": 192,
"y": 64
} ,
{
"type" : "TextField",
"name" : "nameField" ,
"width": 112,
"height": 16,
"x": 96,
"y": 96
} ,
{
"type" : "Selector",
"name" : "race" ,
"width": 112,
"height": 16,
"x": 96,
"y": 128
} ,
{
"type" : "Selector",
"name" : "gender" ,
"width": 112,
"height": 16,
"x": 96,
"y": 160
} ,
{
"type" : "Selector",
"name" : "difficulty" ,
"width": 112,
"height": 16,
"x": 96,
"y": 192
} ,
{
"type" : "Selector",
"name" : "deck" ,
"width": 112,
"height": 16,
"x": 96,
"y": 224
} ,
{
"type" : "TextButton",
"name" : "back" ,
"text" : "Back" ,
"width": 38,
"height": 16,
"x": 352,
"y": 240
} ,
{
"type" : "TextButton",
"name" : "start" ,
"text" : "Start" ,
"width": 38,
"height": 16,
"x": 416,
"y": 240
}
]
} }

View File

@@ -1,51 +1,51 @@
{ {
"width": 480, "width": 480,
"height": 270, "height": 270,
"yDown": true, "yDown": true,
"elements":[ "elements": [
{ {
"type" : "Image", "type": "Image",
"image":"ui/title_bg.png", "image": "ui/title_bg.png",
"width": 480, "width": 480,
"height": 270 "height": 270
} , },
{ {
"type" : "Image", "type": "Image",
"name": "preview", "name": "preview",
"x": 364, "x": 364,
"y": 10 , "y": 10,
"width": 96, "width": 96,
"height": 54 "height": 54
} , },
{ {
"type" : "Scroll", "type": "Scroll",
"name": "saveSlots", "name": "saveSlots",
"x": 10, "x": 10,
"y": 10 , "y": 10,
"width": 344, "width": 344,
"height": 235 "height": 235
} , },
{ {
"type" : "TextButton", "type": "TextButton",
"name" : "return" , "name": "return",
"text" : "Back" , "text": "Back",
"width": 48, "width": 48,
"height": 16, "height": 16,
"x": 15, "x": 15,
"y": 250 "y": 250
} , },
{ {
"type" : "TextButton", "type": "TextButton",
"name" : "save" , "name": "save",
"text" : "saveLoad" , "text": "saveLoad",
"width": 48, "width": 48,
"height": 16, "height": 16,
"x": 115, "x": 115,
"y": 250 "y": 250
},
{
"type": "Table",
"font": "default"
} }
] ]
} }

View File

@@ -1,33 +1,30 @@
{ {
"width": 480, "width": 480,
"height": 270, "height": 270,
"yDown": true, "yDown": true,
"elements":[ "elements": [
{ {
"type" : "Image", "type": "Image",
"image":"ui/title_bg.png", "image": "ui/title_bg.png",
"width": 480, "width": 480,
"height": 270 "height": 270
} , },
{ {
"type" : "Scroll", "type": "Scroll",
"name": "settings", "name": "settings",
"x": 10, "x": 10,
"y": 10 , "y": 10,
"width": 450, "width": 450,
"height": 235 "height": 235
} , },
{ {
"type" : "TextButton", "type": "TextButton",
"name" : "return" , "name": "return",
"text" : "Back" , "text": "Back",
"width": 48, "width": 48,
"height": 16, "height": 16,
"x": 15, "x": 15,
"y": 250 "y": 250
} }
] ]
} }

View File

@@ -2,96 +2,103 @@
"width": 480, "width": 480,
"height": 270, "height": 270,
"yDown": true, "yDown": true,
"elements":[ "elements": [
{ {
"type" : "Image", "type": "Image",
"image":"ui/title_bg.png", "image": "ui/title_bg.png",
"width": 480, "width": 480,
"height": 270 "height": 270
} , },
{ {
"type" : "Scroll", "type": "Scroll",
"name": "enemies", "name": "enemies",
"x": 206, "x": 206,
"y": 10 , "y": 10,
"width": 256, "width": 256,
"height": 235 "height": 235
} , },
{ {
"type" : "Image", "type": "Image",
"name": "avatar", "name": "avatar",
"x": 10, "x": 10,
"y": 10 , "y": 10,
"width": 64, "width": 64,
"height": 64 "height": 64
} , },
{ {
"type" : "Label", "type": "Label",
"name": "totalWins", "name": "totalWins",
"x": 90, "x": 90,
"y": 84 , "y": 84,
"width": 80, "width": 80,
"height": 24 "height": 24,
} , "font": "default"
},
{ {
"type" : "Label", "type": "Label",
"text": "Win:", "text": "Win:",
"x": 10, "x": 10,
"y": 84 , "y": 84,
"width": 80, "width": 80,
"height": 24 "height": 24,
} , "font": "default"
},
{ {
"type" : "Label", "type": "Label",
"name": "totalLoss", "name": "totalLoss",
"x": 90, "x": 90,
"y": 104 , "y": 104,
"width": 80, "width": 80,
"height": 24 "height": 24,
} , "font": "default"
},
{ {
"type" : "Label", "type": "Label",
"text": "Loss:", "text": "Loss:",
"x": 10, "x": 10,
"y": 104 , "y": 104,
"width": 80, "width": 80,
"height": 24 "height": 24,
} , "font": "default"
},
{ {
"type" : "Label", "type": "Label",
"name": "lossWinRatio", "name": "lossWinRatio",
"x": 90, "x": 90,
"y": 124 , "y": 124,
"width": 80, "width": 80,
"height": 24 "height": 24,
} , "font": "default"
},
{ {
"type" : "Label", "type": "Label",
"text": "Win Loss Ratio:", "text": "Win Loss Ratio:",
"x": 10, "x": 10,
"y": 124 , "y": 124,
"width": 80, "width": 80,
"height": 24 "height": 24,
} , "font": "default"
},
{ {
"type" : "Image", "type": "Image",
"image" : "ui/avatarhud.png" , "image": "ui/avatarhud.png",
"x": 10, "x": 10,
"y": 10 , "y": 10,
"width": 64, "width": 64,
"height": 64 "height": 64
} , },
{ {
"type" : "TextButton", "type": "TextButton",
"name" : "return" , "name": "return",
"text" : "Back" , "text": "Back",
"width": 48, "width": 48,
"height": 16, "height": 16,
"x": 15, "x": 15,
"y": 250 "y": 250
},
{
"type": "Table",
"font": "default"
} }
] ]
} }