diff options
| author | ilotterytea <iltsu@alright.party> | 2024-11-06 22:05:21 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2024-11-06 22:05:21 +0500 |
| commit | 0df1f3ebcb74cc6f26fccd5a2f7a23db5dcc767b (patch) | |
| tree | bc27694fec0e9877f5e89b96bdf3c6384f23bd19 /core/src/kz/ilotterytea/maxon/screens | |
| parent | 196f6376be6caada1efeda9869f8fbfa9bd12fff (diff) | |
feat: zoom button (mobile only)
Diffstat (limited to 'core/src/kz/ilotterytea/maxon/screens')
| -rw-r--r-- | core/src/kz/ilotterytea/maxon/screens/MenuScreen.java | 74 |
1 files changed, 44 insertions, 30 deletions
diff --git a/core/src/kz/ilotterytea/maxon/screens/MenuScreen.java b/core/src/kz/ilotterytea/maxon/screens/MenuScreen.java index 2e1fe1f..054ca4e 100644 --- a/core/src/kz/ilotterytea/maxon/screens/MenuScreen.java +++ b/core/src/kz/ilotterytea/maxon/screens/MenuScreen.java @@ -23,6 +23,7 @@ import com.badlogic.gdx.utils.viewport.ScreenViewport; import kz.ilotterytea.javaextra.tuples.Triple; import kz.ilotterytea.maxon.MaxonConstants; import kz.ilotterytea.maxon.MaxonGame; +import kz.ilotterytea.maxon.constants.SettingsConstants; import kz.ilotterytea.maxon.localization.LineId; import kz.ilotterytea.maxon.localization.LocalizationManager; import kz.ilotterytea.maxon.player.Savegame; @@ -76,7 +77,7 @@ public class MenuScreen implements Screen { soundVolume = game.prefs.getInteger("sfx", 10) / 10f; // - - - - - - U I - - - - - - - float iconSize = OsUtils.isMobile ? 256f : 64f; + float iconSize = (OsUtils.isMobile ? 256f : 64f) * game.prefs.getFloat("guiScale", SettingsConstants.UI_DEFAULT_SCALE); Table menuTable = new Table(); menuTable.setFillParent(true); @@ -270,49 +271,62 @@ public class MenuScreen implements Screen { } }); - if (!OsUtils.isMobile) { - rightGameControlTable.add(localeButton).size(iconSize).padRight(16f); - rightGameControlTable.add(musicButton).size(iconSize).padRight(16f); - - // Resolution button - String resolutionButtonStyleName; + // Resolution button + String resolutionButtonStyleName; - if (game.prefs.getBoolean("fullscreen")) { - resolutionButtonStyleName = "windowed"; - } else { - resolutionButtonStyleName = "fullscreen"; - } - - ShakingImageButton resolutionButton = new ShakingImageButton(widgetSkin, resolutionButtonStyleName); - resolutionButton.setOrigin(iconSize / 2f, iconSize / 2f); - resolutionButton.addListener(new ClickListener() { - @Override - public void clicked(InputEvent event, float x, float y) { - super.clicked(event, x, y); + if (game.prefs.getBoolean("fullscreen")) { + resolutionButtonStyleName = "windowed"; + } else { + resolutionButtonStyleName = "fullscreen"; + } - String style; + ShakingImageButton resolutionButton = new ShakingImageButton(widgetSkin, resolutionButtonStyleName); + resolutionButton.setOrigin(iconSize / 2f, iconSize / 2f); + resolutionButton.addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + super.clicked(event, x, y); + if (OsUtils.isMobile) { + float scale = game.prefs.getFloat("guiScale", SettingsConstants.UI_DEFAULT_SCALE); - if (game.prefs.getBoolean("fullscreen")) { - style = "fullscreen"; - Gdx.graphics.setWindowedMode(game.prefs.getInteger("width", 800), game.prefs.getInteger("height", 600)); - } else { - style = "windowed"; - Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode()); + if (scale + 0.5f > SettingsConstants.UI_MAX_SCALE || scale <= 0) { + scale = 0; } - game.prefs.putBoolean("fullscreen", !game.prefs.getBoolean("fullscreen")); + game.prefs.putFloat("guiScale", scale + 0.5f); game.prefs.flush(); + game.setScreen(new SplashScreen()); + return; + } - resolutionButton.setDrawable(widgetSkin, style); - clickSound.play(soundVolume); + String style; + + if (game.prefs.getBoolean("fullscreen")) { + style = "fullscreen"; + Gdx.graphics.setWindowedMode(game.prefs.getInteger("width", 800), game.prefs.getInteger("height", 600)); + } else { + style = "windowed"; + Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode()); } - }); + + game.prefs.putBoolean("fullscreen", !game.prefs.getBoolean("fullscreen")); + game.prefs.flush(); + + resolutionButton.setDrawable(widgetSkin, style); + clickSound.play(soundVolume); + } + }); + + if (!OsUtils.isMobile) { + rightGameControlTable.add(localeButton).size(iconSize).padRight(16f); + rightGameControlTable.add(musicButton).size(iconSize).padRight(16f); rightGameControlTable.add(resolutionButton).size(iconSize); controlTable.add(leftGameControlTable).grow(); } else { rightGameControlTable.add(localeButton).size(iconSize).expand(); rightGameControlTable.add(musicButton).size(iconSize).expand(); + rightGameControlTable.add(resolutionButton).size(iconSize).expand(); } controlTable.add(rightGameControlTable).grow(); |
