Skip to content

Commit

Permalink
Implemented full screen toggle, activated by new icon.
Browse files Browse the repository at this point in the history
  • Loading branch information
lanceewing committed Mar 6, 2024
1 parent 1cc728d commit e20809e
Showing 1 changed file with 28 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.agifans.agile.GameScreen;
import com.badlogic.gdx.Application.ApplicationType;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.Graphics;
import com.badlogic.gdx.InputAdapter;
import com.badlogic.gdx.math.Vector2;

Expand Down Expand Up @@ -67,6 +67,16 @@ class TouchInfo {
*/
private int agiMouseButton;

/**
* The width of the screen/window before full screen mode was activated.
*/
private int screenWidthBeforeFullScreen;

/**
* The height of the screen/width before ful screen mode was activated.
*/
private int screenHeightBeforeFullScreen;

/**
* Constructor for GameScreenInputProcessor.
*
Expand Down Expand Up @@ -222,6 +232,7 @@ public boolean touchUp(int screenX, int screenY, int pointer, int button) {
boolean keyboardClicked = false;
boolean joystickClicked = false;
boolean backArrowClicked = false;
boolean fullScreenClicked = false;

if (viewportManager.isPortrait()) {
// Portrait.
Expand Down Expand Up @@ -255,13 +266,14 @@ public boolean touchUp(int screenX, int screenY, int pointer, int button) {
if (touchXY.y > (screenTop - 140)) {
if (touchXY.x < 140) {
joystickClicked = true;

} else if (touchXY.x > (viewportManager.getWidth() - 150)) {
keyboardClicked = true;
fullScreenClicked = true;
}
} else if (touchXY.y < 140) {
if (touchXY.x > (viewportManager.getWidth() - 150)) {
backArrowClicked = true;
} else if (touchXY.x < 140) {
keyboardClicked = true;
}
}
}
Expand All @@ -278,6 +290,19 @@ public boolean touchUp(int screenX, int screenY, int pointer, int button) {
if (joystickClicked) {
keyboardType = KeyboardType.JOYSTICK;
}

if (fullScreenClicked) {
Boolean fullScreen = Gdx.graphics.isFullscreen();
if (fullScreen == true) {
Gdx.graphics.setWindowedMode(screenWidthBeforeFullScreen, screenHeightBeforeFullScreen);
}
else {
Graphics.DisplayMode currentMode = Gdx.graphics.getDisplayMode();
screenWidthBeforeFullScreen = Gdx.graphics.getWidth();
screenHeightBeforeFullScreen = Gdx.graphics.getHeight();
Gdx.graphics.setFullscreenMode(currentMode);
}
}

if (backArrowClicked) {
dialogHandler.confirm("Are you sure you want to quit the game?",
Expand Down

0 comments on commit e20809e

Please sign in to comment.