Skip to content

Commit

Permalink
Changed switch to portrait to be when extra padding appears in Y dire…
Browse files Browse the repository at this point in the history
…ction, i.e. AGI screen exactly fits window width.
  • Loading branch information
lanceewing committed Mar 22, 2024
1 parent 8041126 commit 7c42ee1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
6 changes: 4 additions & 2 deletions core/src/main/java/com/agifans/agile/GameScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,10 @@ private void draw(float delta) {
// The keyboard is always render in portrait mode, as there is space for it,
// but in landscape mode, it needs to be enabled via the keyboard icon.
if (keyboardType.isRendered() || viewportManager.isPortrait()) {
batch.setColor(c.r, c.g, c.b, keyboardType.getOpacity());
batch.draw(keyboardType.getTexture(), 0, keyboardType.getRenderOffset());
if (keyboardType.getTexture() != null) {
batch.setColor(c.r, c.g, c.b, keyboardType.getOpacity());
batch.draw(keyboardType.getTexture(), 0, keyboardType.getRenderOffset());
}
}

batch.setColor(c.r, c.g, c.b, 0.5f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ public boolean touchDragged(int screenX, int screenY, int pointer) {
* @param height The new screen height.
*/
public void resize(int width, int height) {
if (height > width) {
if (height > (width / 1.32f)) {
// Change to portrait if it is not already a portrait keyboard.
if (!keyboardType.isPortrait()) {
keyboardType = KeyboardType.PORTRAIT_LOWER_CASE;
Expand Down
3 changes: 1 addition & 2 deletions core/src/main/java/com/agifans/agile/ui/ViewportManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ public static ViewportManager getInstance() {
* @param height The new screen height.
*/
public void update(int width, int height) {
// TODO: This should ideally switch to portrait as soon as gap appears in Y direction.
portrait = (height > width);
portrait = (height > (width / 1.32f));
getCurrentViewport().update(width, height, true);
}

Expand Down

0 comments on commit 7c42ee1

Please sign in to comment.