v0.9.4: fixed iOS text input errors

This commit is contained in:
Evan Debenham 2021-07-08 17:28:18 -04:00
parent 603f91d10f
commit 285dd374b3
3 changed files with 16 additions and 4 deletions

View File

@ -122,6 +122,7 @@ public class Game implements ApplicationListener {
Vertexbuffer.refreshAllBuffers(); Vertexbuffer.refreshAllBuffers();
} }
height -= bottomInset;
if (height != Game.height || width != Game.width) { if (height != Game.height || width != Game.width) {
Game.width = width; Game.width = width;

View File

@ -2,6 +2,7 @@ package com.watabou.noosa;
import com.badlogic.gdx.Files; import com.badlogic.gdx.Files;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.Stage;
@ -12,6 +13,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.TextField;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.badlogic.gdx.utils.Align; import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.utils.viewport.ScreenViewport; import com.badlogic.gdx.utils.viewport.ScreenViewport;
import com.badlogic.gdx.utils.viewport.Viewport;
import com.watabou.glscripts.Script; import com.watabou.glscripts.Script;
import com.watabou.glwrap.Blending; import com.watabou.glwrap.Blending;
import com.watabou.glwrap.Quad; import com.watabou.glwrap.Quad;
@ -36,7 +38,12 @@ public class TextInput extends Component {
this.bg = bg; this.bg = bg;
add(bg); add(bg);
stage = new Stage(new ScreenViewport()); //use a custom viewport here to ensure stage camera matches game camera
Viewport viewport = new Viewport() {};
viewport.setWorldSize(Game.width, Game.height);
viewport.setScreenBounds(0, Game.bottomInset, Game.width, Game.height);
viewport.setCamera(new OrthographicCamera());
stage = new Stage(viewport);
Game.inputHandler.addInputProcessor(stage); Game.inputHandler.addInputProcessor(stage);
container = new Container<TextField>(); container = new Container<TextField>();

View File

@ -33,8 +33,9 @@ public class IOSPlatformSupport extends PlatformSupport {
} }
if (!SPDSettings.fullscreen()) { if (!SPDSettings.fullscreen()) {
int insetChange = Gdx.graphics.getSafeInsetBottom() - Game.bottomInset;
Game.bottomInset = Gdx.graphics.getSafeInsetBottom(); Game.bottomInset = Gdx.graphics.getSafeInsetBottom();
Game.height -= Game.bottomInset; Game.height -= insetChange;
Game.dispHeight = Game.height; Game.dispHeight = Game.height;
} else { } else {
Game.height += Game.bottomInset; Game.height += Game.bottomInset;
@ -46,9 +47,12 @@ public class IOSPlatformSupport extends PlatformSupport {
@Override @Override
public void updateSystemUI() { public void updateSystemUI() {
int prevInset = Game.bottomInset;
updateDisplaySize(); updateDisplaySize();
if (prevInset != Game.bottomInset) {
ShatteredPixelDungeon.seamlessResetScene(); ShatteredPixelDungeon.seamlessResetScene();
} }
}
@Override @Override
public boolean connectedToUnmeteredNetwork() { public boolean connectedToUnmeteredNetwork() {