adjusted style to work with android

fixed android touch
fixed save load issues between portrait mode
This commit is contained in:
Grimm
2022-04-15 06:03:50 +02:00
parent d335e47832
commit 113997443d
12 changed files with 78 additions and 172 deletions

View File

@@ -6,7 +6,7 @@
<packaging.type>jar</packaging.type>
<build.min.memory>-Xms1024m</build.min.memory>
<build.max.memory>-Xmx1536m</build.max.memory>
<alpha-version>1.6.50.414</alpha-version>
<alpha-version>1.6.49.001</alpha-version>
<sign.keystore>keystore</sign.keystore>
<sign.alias>alias</sign.alias>
<sign.storepass>storepass</sign.storepass>

View File

@@ -77,7 +77,6 @@ public class PointOfInterestMap implements SaveFileContent {
data.store("numberOfChunksY",numberOfChunksY);
data.store("tileSize",tileSize);
data.store("chunkSize",chunkSize);
data.store("numberOfChunksX",numberOfChunksX);
for (int x = 0; x < numberOfChunksX; x++) {
for (int y = 0; y < numberOfChunksY; y++) {

View File

@@ -4,19 +4,13 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.EventListener;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.ui.Touchpad;
import com.badlogic.gdx.scenes.scene2d.ui.Touchpad.TouchpadStyle;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.Scaling;
import com.badlogic.gdx.utils.viewport.ScalingViewport;
import forge.Forge;
@@ -24,6 +18,7 @@ import forge.adventure.player.AdventurePlayer;
import forge.adventure.scene.Scene;
import forge.adventure.scene.SceneType;
import forge.adventure.util.Config;
import forge.adventure.util.Controls;
import forge.adventure.util.Current;
import forge.adventure.util.UIActor;
import forge.adventure.world.WorldSave;
@@ -42,20 +37,11 @@ public class GameHUD extends Stage {
private final Image miniMapPlayer;
private final Label lifePoints;
private final Label money;
private Image miniMap, gamehud, mapborder, avatarborder, blank;
private final Image miniMap, gamehud, mapborder, avatarborder, blank;
private TextButton deckActor, menuActor, statsActor, inventoryActor;
private boolean deckPressed = false;
private boolean menuPressed = false;
private boolean statsPressed = false;
private boolean inventoryPressed = false;
private UIActor ui;
private Touchpad touchpad;
private TouchpadStyle touchpadStyle;
private Skin touchpadSkin;
private Drawable touchBackground;
private Drawable touchKnob;
float TOUCHPAD_SCALE = 70f;
float TOUCHPAD_KNOB_MIN_WIDTH = 40f;
private GameHUD(GameStage gameStage) {
super(new ScalingViewport(FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.UI_STRETCH)?Scaling.stretch:Scaling.fit, Scene.getIntendedWidth(), Scene.getIntendedHeight()), gameStage.getBatch());
@@ -80,19 +66,9 @@ public class GameHUD extends Stage {
miniMapPlayer = new Image(new Texture(Config.instance().getFile("ui/minimap_player.png")));
//create touchpad skin
touchpadSkin = new Skin();
touchpadSkin.add("touchBackground", new Texture(Config.instance().getFile("ui/touchBackground.png")));
touchpadSkin.add("touchKnob", new Texture(Config.instance().getFile("ui/touchKnob.png")));
//set touchpad skin background and knob
touchBackground = touchpadSkin.getDrawable("touchBackground");
touchKnob = touchpadSkin.getDrawable("touchKnob");
//set touchpad style
touchpadStyle = new TouchpadStyle(touchBackground, touchKnob);
//set touchpad knob size
touchpadStyle.knob.setMinWidth(TOUCHPAD_KNOB_MIN_WIDTH);
touchpadStyle.knob.setMinHeight(TOUCHPAD_KNOB_MIN_WIDTH);
//create touchpad
touchpad = new Touchpad(10, touchpadStyle);
touchpad = new Touchpad(10, Controls.GetSkin());
touchpad.setBounds(15, 15, TOUCHPAD_SCALE, TOUCHPAD_SCALE);
touchpad.addListener(new ChangeListener() {
@Override
@@ -156,15 +132,6 @@ public class GameHUD extends Stage {
touchpad.setVisible(false);
MapStage.getInstance().GetPlayer().setMovementDirection(Vector2.Zero);
WorldStage.getInstance().GetPlayer().setMovementDirection(Vector2.Zero);
//simulate button
checkButtonState(deckActor, pointer);
checkButtonState(menuActor, pointer);
checkButtonState(statsActor, pointer);
checkButtonState(inventoryActor, pointer);
deckPressed = false;
menuPressed = false;
statsPressed = false;
inventoryPressed = false;
return super.touchUp(screenX, screenY, pointer, button);
}
@@ -206,53 +173,6 @@ public class GameHUD extends Stage {
float x=(c.x-miniMap.getX())/miniMap.getWidth();
float y=(c.y-miniMap.getY())/miniMap.getHeight();
float deckX = deckActor.getX();
float deckY = deckActor.getY();
float deckR = deckActor.getRight();
float deckT = deckActor.getTop();
float deckOriginX = deckActor.getOriginX();
//deck button bounds
if (c.x>=deckX&&c.x<=deckR&&c.y>=deckY&&c.y<=deckT) {
if (pointer < 1)
deckPressed = true;
return true;
}
float inventoryX = inventoryActor.getX();
float inventoryY = inventoryActor.getY();
float inventoryR = inventoryActor.getRight();
float inventoryT = inventoryActor.getTop();
float inventoryOriginX = inventoryActor.getOriginX();
//inventory button bounds
if (c.x>=inventoryX&&c.x<=inventoryR&&c.y>=inventoryY&&c.y<=inventoryT) {
if (pointer < 1)
inventoryPressed = true;
return true;
}
float menuX = menuActor.getX();
float menuY = menuActor.getY();
float menuR = menuActor.getRight();
float menuT = menuActor.getTop();
float menuOriginX = menuActor.getOriginX();
//menu button bounds
if (c.x>=menuX&&c.x<=menuR&&c.y>=menuY&&c.y<=menuT) {
if (pointer < 1)
menuPressed = true;
return true;
}
float statsX = statsActor.getX();
float statsY = statsActor.getY();
float statsR = statsActor.getRight();
float statsT = statsActor.getTop();
float statsOriginX = statsActor.getOriginX();
//stats button bounds
if (c.x>=statsX&&c.x<=statsR&&c.y>=statsY&&c.y<=statsT) {
if (pointer < 1)
statsPressed = true;
return true;
}
float uiX = gamehud.getX();
float uiY = gamehud.getY();
@@ -284,38 +204,17 @@ public class GameHUD extends Stage {
//auto follow touchpad
if (GuiBase.isAndroid()) {
if (!(touch.x>=mMapX&&touch.x<=mMapR&&touch.y>=mMapY&&touch.y<=mMapT) // not inside map bounds
&& !(touch.x>=uiX&&touch.x<=uiRight&&touch.y>=uiY&&touch.y<=uiTop) //not inside gamehud bounds
&& (touch.x>=displayX&&touch.x<=displayR&&touch.y>=displayY&&touch.y<=displayT) //inside display bounds
&& pointer < 1) { //not more than 1 pointer
touchpad.setBounds(touch.x-TOUCHPAD_SCALE/2, touch.y-TOUCHPAD_SCALE/2, TOUCHPAD_SCALE, TOUCHPAD_SCALE);
touchpad.setVisible(true);
touchpad.setResetOnTouchUp(true);
&& !(touch.x>=uiX&&touch.x<=uiRight&&touch.y>=uiY&&touch.y<=uiTop) //not inside gamehud bounds
&& (touch.x>=displayX&&touch.x<=displayR&&touch.y>=displayY&&touch.y<=displayT) //inside display bounds
&& pointer < 1) { //not more than 1 pointer
touchpad.setBounds(touch.x-TOUCHPAD_SCALE/2, touch.y-TOUCHPAD_SCALE/2, TOUCHPAD_SCALE, TOUCHPAD_SCALE);
touchpad.setVisible(true);
touchpad.setResetOnTouchUp(true);
return super.touchDown(screenX, screenY, pointer, button);
}
}
return super.touchDown(screenX, screenY, pointer, button);
}
void checkButtonState(Actor actor, int pointer) {
Array<EventListener> listeners = actor.getListeners();
for(int i=0;i<listeners.size;i++)
{
if(listeners.get(i) instanceof ClickListener){
if (((ClickListener)listeners.get(i)).isVisualPressed()) {
((ClickListener)listeners.get(i)).setVisualPressed(false);
((ClickListener)listeners.get(i)).clicked(null, 0, 0);
}
}
}
}
void updateVisualState(Actor actor, boolean state) {
Array<EventListener> listeners = actor.getListeners();
for(int i=0;i<listeners.size;i++)
{
if(listeners.get(i) instanceof ClickListener){
((ClickListener)listeners.get(i)).setVisualPressed(state);
}
}
}
@Override
public void draw() {
@@ -326,10 +225,7 @@ public class GameHUD extends Stage {
int xPosMini = (int) (((float) xPos / (float) WorldSave.getCurrentSave().getWorld().getTileSize() / (float) WorldSave.getCurrentSave().getWorld().getWidthInTiles()) * miniMap.getWidth());
int yPosMini = (int) (((float) yPos / (float) WorldSave.getCurrentSave().getWorld().getTileSize() / (float) WorldSave.getCurrentSave().getWorld().getHeightInTiles()) * miniMap.getHeight());
miniMapPlayer.setPosition(miniMap.getX() + xPosMini - miniMapPlayer.getWidth()/2, miniMap.getY() + yPosMini - miniMapPlayer.getHeight()/2);
updateVisualState(statsActor, statsPressed);
updateVisualState(menuActor, menuPressed);
updateVisualState(deckActor, deckPressed);
updateVisualState(inventoryActor, inventoryPressed);
}
Texture miniMapTexture;

View File

@@ -227,8 +227,8 @@ public abstract class GameStage extends Stage {
camera.zoom += (amountY * 0.03);
if (camera.zoom < 0.3f)
camera.zoom = 0.3f;
if (camera.zoom > 1f)
camera.zoom = 1f;
if (camera.zoom > 1.5f)
camera.zoom = 1.5f;
return super.scrolled(amountX, amountY);
}

View File

@@ -185,7 +185,8 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
if(Forge.isLandscapeMode())
drawable.setMinSize((Scene.getIntendedHeight() / RewardScene.CARD_WIDTH_TO_HEIGHT) * 0.95f, Scene.getIntendedHeight() * 0.95f);
else
drawable.setMinSize(Scene.getIntendedWidth() * 0.95f, Scene.getIntendedWidth()* RewardScene.CARD_WIDTH_TO_HEIGHT * 0.95f); toolTipImage = new Image(drawable);
drawable.setMinSize(Scene.getIntendedWidth() * 0.95f, Scene.getIntendedWidth()* RewardScene.CARD_WIDTH_TO_HEIGHT * 0.95f);
toolTipImage = new Image(drawable);
tooltip = new Tooltip<Image>(toolTipImage);
holdTooltip = new HoldTooltip(new Image(drawable));
tooltip.setInstant(true);
@@ -444,15 +445,9 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
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);
if (!Forge.isLandscapeMode()) {
float h = height * 0.65f;
tooltip_actor.setX(480/2 - tooltip_actor.getWidth() /2);
tooltip_actor.setHeight(h);
tooltip_actor.setY(270/2 - h/2);
}
if (tooltip_actor.getX() + tooltip_actor.getWidth() > Scene.getIntendedWidth())
tooltip_actor.setX(Math.max(0,actor.getX() - tooltip_actor.getWidth()));
tooltip_actor.setY(Scene.getIntendedHeight() / 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);

View File

@@ -553,7 +553,7 @@ public class World implements Disposable, SaveFileContent {
}
public int getChunkSize() {
return Scene.getIntendedWidth() / data.tileSize;
return (Scene.getIntendedWidth()>Scene.getIntendedHeight()?Scene.getIntendedWidth():Scene.getIntendedHeight()) / data.tileSize;
}
public void dispose() {

View File

@@ -6,7 +6,7 @@ filter: Nearest, Nearest
repeat: none
BKey_3_14
rotate: false
xy: 51, 321
xy: 253, 371
size: 32, 16
split: 6, 6, 9, 6
pad: 0, 0, 0, 0
@@ -15,7 +15,7 @@ BKey_3_14
index: -1
BKey_3_9
rotate: false
xy: 1, 271
xy: 203, 321
size: 32, 16
split: 5, 5, 6, 7
pad: 0, 0, 0, 0
@@ -52,7 +52,7 @@ MiKrollFantasy(3)
index: -1
9patch4
rotate: false
xy: 51, 339
xy: 75, 137
size: 48, 48
split: 7, 7, 7, 7
pad: 0, 0, 0, 0
@@ -61,63 +61,63 @@ MiKrollFantasy(3)
index: -1
down
rotate: false
xy: 1, 168
xy: 97, 119
size: 16, 16
orig: 16, 16
offset: 0, 0
index: -1
down_down
rotate: false
xy: 1, 150
xy: 125, 147
size: 16, 16
orig: 16, 16
offset: 0, 0
index: -1
left
rotate: false
xy: 1, 132
xy: 147, 169
size: 16, 16
orig: 16, 16
offset: 0, 0
index: -1
left_down
rotate: false
xy: 1, 114
xy: 203, 281
size: 16, 16
orig: 16, 16
offset: 0, 0
index: -1
right
rotate: false
xy: 1, 96
xy: 275, 353
size: 16, 16
orig: 16, 16
offset: 0, 0
index: -1
right_down
rotate: false
xy: 1, 78
xy: 305, 371
size: 16, 16
orig: 16, 16
offset: 0, 0
index: -1
up
rotate: false
xy: 1, 60
xy: 1, 19
size: 16, 16
orig: 16, 16
offset: 0, 0
index: -1
up_down
rotate: false
xy: 1, 42
xy: 51, 72
size: 16, 16
orig: 16, 16
offset: 0, 0
index: -1
cursor
rotate: false
xy: 125, 384
xy: 25, 58
size: 4, 3
split: 1, 1, 1, 1
pad: 0, 0, 0, 0
@@ -126,28 +126,28 @@ cursor
index: -1
item_frame
rotate: false
xy: 51, 299
xy: 75, 115
size: 20, 20
orig: 20, 20
offset: 0, 0
index: -1
item_frame_hover
rotate: false
xy: 101, 359
xy: 125, 165
size: 20, 20
orig: 20, 20
offset: 0, 0
index: -1
item_frame_selected
rotate: false
xy: 1, 244
xy: 203, 299
size: 20, 20
orig: 20, 20
offset: 0, 0
index: -1
item_frame_selected_hover
rotate: false
xy: 1, 222
xy: 253, 349
size: 20, 20
orig: 20, 20
offset: 0, 0
@@ -161,7 +161,7 @@ select
index: -1
bar
rotate: false
xy: 101, 381
xy: 1, 55
size: 22, 6
split: 2, 2, 2, 2
pad: 0, 0, 0, 0
@@ -170,7 +170,7 @@ bar
index: -1
barcontent
rotate: false
xy: 1, 266
xy: 51, 108
size: 20, 3
split: 0, 0, 0, 0
orig: 20, 3
@@ -178,14 +178,14 @@ barcontent
index: -1
check
rotate: false
xy: 73, 311
xy: 115, 127
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
map
rotate: false
xy: 1, 289
xy: 1, 63
size: 48, 48
split: 17, 16, 13, 11
pad: 0, 0, 0, 0
@@ -194,7 +194,7 @@ map
index: -1
pressed
rotate: false
xy: 23, 253
xy: 253, 331
size: 14, 16
split: 4, 4, 6, 5
pad: 0, 0, 0, 0
@@ -203,7 +203,7 @@ pressed
index: -1
pressedMap
rotate: false
xy: 1, 204
xy: 1, 37
size: 16, 16
split: 6, 6, 4, 3
pad: 0, 0, 0, 0
@@ -212,7 +212,7 @@ pressedMap
index: -1
pressedround
rotate: false
xy: 23, 236
xy: 293, 354
size: 12, 15
split: 4, 4, 7, 5
pad: 0, 0, 0, 0
@@ -221,7 +221,7 @@ pressedround
index: -1
scroll
rotate: false
xy: 39, 254
xy: 1, 2
size: 6, 15
split: 2, 2, 3, 4
pad: 0, 0, 0, 0
@@ -230,7 +230,7 @@ scroll
index: -1
scroll2
rotate: false
xy: 85, 330
xy: 225, 312
size: 14, 7
split: 3, 3, 2, 3
pad: 0, 0, 0, 0
@@ -239,7 +239,7 @@ scroll2
index: -1
thinwindow
rotate: false
xy: 1, 186
xy: 51, 90
size: 16, 16
split: 2, 2, 2, 2
pad: 0, 0, 0, 0
@@ -248,14 +248,14 @@ thinwindow
index: -1
uncheck
rotate: false
xy: 101, 331
xy: 125, 137
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
unpressed
rotate: false
xy: 35, 271
xy: 237, 321
size: 14, 16
split: 4, 4, 4, 7
pad: 0, 0, 0, 0
@@ -264,7 +264,7 @@ unpressed
index: -1
unpressed-disable
rotate: false
xy: 1, 24
xy: 203, 263
size: 14, 16
split: 3, 3, 3, 6
pad: 0, 0, 0, 0
@@ -273,7 +273,7 @@ unpressed-disable
index: -1
unpressed-hover
rotate: false
xy: 51, 281
xy: 165, 169
size: 14, 16
split: 3, 3, 3, 6
pad: 0, 0, 0, 0
@@ -282,7 +282,7 @@ unpressed-hover
index: -1
unpressedMap
rotate: false
xy: 101, 341
xy: 287, 371
size: 16, 16
split: 6, 6, 3, 4
pad: 0, 0, 0, 0
@@ -291,7 +291,7 @@ unpressedMap
index: -1
unpressedround
rotate: false
xy: 1, 7
xy: 323, 372
size: 12, 15
split: 4, 4, 5, 7
pad: 0, 0, 0, 0
@@ -300,10 +300,24 @@ unpressedround
index: -1
windowMain
rotate: false
xy: 1, 339
xy: 203, 339
size: 48, 48
split: 6, 6, 6, 6
pad: 0, 0, 0, 0
orig: 48, 48
offset: 0, 0
index: -1
touchBackground
rotate: false
xy: 1, 187
size: 200, 200
orig: 200, 200
offset: 0, 0
index: -1
touchKnob
rotate: false
xy: 1, 113
size: 72, 72
orig: 72, 72
offset: 0, 0
index: -1

View File

@@ -19,6 +19,13 @@
"a": 1
}
},
"com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable": {
"touchKnob": {
"region": "touchKnob",
"minWidth": 40,
"minHeight": 40
}
},
"com.ray3k.tenpatch.TenPatchDrawable": {
"paper10Patch": {
"region": "map",
@@ -389,16 +396,11 @@
"cursor": "cursor",
"selection": "select"
}
},
"com.badlogic.gdx.scenes.scene2d.ui.TextTooltip$TextTooltipStyle": {
"default": {
"label": "default"
}
},
},
"com.badlogic.gdx.scenes.scene2d.ui.Touchpad$TouchpadStyle": {
"default": {
"background": "thinwindow",
"knob": "unpressed-hover"
"background": "touchBackground",
"knob": "touchKnob"
}
},
"com.badlogic.gdx.scenes.scene2d.ui.Tree$TreeStyle": {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

View File

@@ -184,7 +184,7 @@
"sprite":"AzoriusShop",
"rewards": [
{
"count":8,
"count":4,
"colors": ["white","blue"]
},
{