From d9d19bf1fd95da5256179d22305dcffad6701e9c Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Sat, 19 Oct 2024 20:15:39 +0500 Subject: fix: windowed mode --- core/src/kz/ilotterytea/maxon/MaxonGame.java | 29 +++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/core/src/kz/ilotterytea/maxon/MaxonGame.java b/core/src/kz/ilotterytea/maxon/MaxonGame.java index c9ff8af..f457270 100644 --- a/core/src/kz/ilotterytea/maxon/MaxonGame.java +++ b/core/src/kz/ilotterytea/maxon/MaxonGame.java @@ -43,12 +43,31 @@ public class MaxonGame extends Game { prefs = Gdx.app.getPreferences(MaxonConstants.GAME_APP_PACKAGE); locale = new I18N(Gdx.files.internal("i18n/" + prefs.getString("lang", "en_us") + ".json")); - prefs.putInteger("width", Gdx.graphics.getWidth()); - prefs.putInteger("height", Gdx.graphics.getHeight()); - prefs.flush(); - Gdx.graphics.setVSync(prefs.getBoolean("vsync", true)); - if (prefs.getBoolean("fullscreen", false)) { Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode()); } + + if (prefs.getBoolean("fullscreen", false)) { + Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode()); + } else if ( + prefs.contains("width") || + prefs.contains("height") + ) { + int width = prefs.getInteger("width", 800); + + if (width < 800) { + width = 800; + prefs.putInteger("width", width); + } + + int height = prefs.getInteger("height", 600); + + if (height < 600) { + height = 600; + prefs.putInteger("height", height); + } + + prefs.flush(); + Gdx.graphics.setWindowedMode(width, height); + } assetManager = new AssetManager(); petManager = new PetManager(assetManager); -- cgit v1.2.3