diff options
| author | ilotterytea <iltsu@alright.party> | 2024-06-09 23:12:36 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2024-06-09 23:12:36 +0500 |
| commit | 8924b8dadd904f13179303552a8ec7c99002366e (patch) | |
| tree | 7402968a6e194043f668ea03eff4643476d8b53e /core/src/kz/ilotterytea/maxon | |
| parent | f72a9ac8929890887391faec6c2c2150ab682f84 (diff) | |
feat: mobile support for MenuScreen
Diffstat (limited to 'core/src/kz/ilotterytea/maxon')
| -rw-r--r-- | core/src/kz/ilotterytea/maxon/screens/MenuScreen.java | 135 | ||||
| -rw-r--r-- | core/src/kz/ilotterytea/maxon/ui/SavegameWidget.java | 13 |
2 files changed, 94 insertions, 54 deletions
diff --git a/core/src/kz/ilotterytea/maxon/screens/MenuScreen.java b/core/src/kz/ilotterytea/maxon/screens/MenuScreen.java index 50c9d05..5a58530 100644 --- a/core/src/kz/ilotterytea/maxon/screens/MenuScreen.java +++ b/core/src/kz/ilotterytea/maxon/screens/MenuScreen.java @@ -24,6 +24,7 @@ import kz.ilotterytea.maxon.MaxonGame; import kz.ilotterytea.maxon.player.Savegame; import kz.ilotterytea.maxon.ui.*; import kz.ilotterytea.maxon.utils.I18N; +import kz.ilotterytea.maxon.utils.OsUtils; import net.mgsx.gltf.scene3d.attributes.PBRCubemapAttribute; import net.mgsx.gltf.scene3d.attributes.PBRTextureAttribute; import net.mgsx.gltf.scene3d.lights.DirectionalShadowLight; @@ -87,23 +88,40 @@ public class MenuScreen implements Screen { logo.getHeight() / 2f ); - logo.addAction( - Actions.repeat( - RepeatAction.FOREVER, - Actions.sequence( - Actions.parallel( - Actions.rotateTo(-5f, 5f, Interpolation.smoother), - Actions.scaleTo(0.9f, 0.9f, 5f, Interpolation.smoother) - ), - Actions.parallel( - Actions.rotateTo(5f, 5f, Interpolation.smoother), - Actions.scaleTo(1.1f, 1.1f, 5f, Interpolation.smoother) - ) - ) - ) - ); - - brandTable.add(logo); + if (OsUtils.isMobile) { + logo.addAction( + Actions.repeat( + RepeatAction.FOREVER, + Actions.sequence( + Actions.scaleTo(0.9f, 0.9f, 5f, Interpolation.smoother), + Actions.scaleTo(1.0f, 1.0f, 5f, Interpolation.smoother) + ) + ) + ); + + float stageWidth = this.stage.getWidth() - 10f; + float difference = stageWidth / logo.getWidth(); + + brandTable.add(logo).size(stageWidth, logo.getHeight() * difference); + } else { + logo.addAction( + Actions.repeat( + RepeatAction.FOREVER, + Actions.sequence( + Actions.parallel( + Actions.rotateTo(-5f, 5f, Interpolation.smoother), + Actions.scaleTo(0.9f, 0.9f, 5f, Interpolation.smoother) + ), + Actions.parallel( + Actions.rotateTo(5f, 5f, Interpolation.smoother), + Actions.scaleTo(1.1f, 1.1f, 5f, Interpolation.smoother) + ) + ) + ) + ); + + brandTable.add(logo); + } // - - - Menu control (quit, options, etc.) - - - Table controlTable = new Table(skin); @@ -128,7 +146,11 @@ public class MenuScreen implements Screen { // Right part of menu control Table rightGameControlTable = new Table(); - rightGameControlTable.align(Align.right); + if (OsUtils.isMobile) { + rightGameControlTable.align(Align.center); + } else { + rightGameControlTable.align(Align.right); + } // - - - D E V E L O P E R S H O W C A S E - - - Image developerImage = new Image(); @@ -172,8 +194,6 @@ public class MenuScreen implements Screen { } }, 0, 5)); - rightGameControlTable.add(developerImage).padRight(16f); - // Localization String[] fh4Locale = game.locale.getFileHandle().nameWithoutExtension().split("_"); String localeButtonStyleName = "locale_" + fh4Locale[0]; @@ -204,9 +224,6 @@ public class MenuScreen implements Screen { } }); - - rightGameControlTable.add(localeButton).padRight(16f); - // Music button String musicButtonStyleName; @@ -239,49 +256,63 @@ public class MenuScreen implements Screen { musicButton.setStyle(style); } }); - rightGameControlTable.add(musicButton).padRight(16f); - // Resolution button - String resolutionButtonStyleName; + if (!OsUtils.isMobile) { + rightGameControlTable.add(developerImage).padRight(16f); + rightGameControlTable.add(localeButton).padRight(16f); + rightGameControlTable.add(musicButton).padRight(16f); - if (game.prefs.getBoolean("fullscreen")) { - resolutionButtonStyleName = "windowed"; - } else { - resolutionButtonStyleName = "fullscreen"; - } + // Resolution button + String resolutionButtonStyleName; - ImageButton resolutionButton = new ImageButton(widgetSkin, resolutionButtonStyleName); - 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"; + } - Button.ButtonStyle style; + ImageButton resolutionButton = new ImageButton(widgetSkin, resolutionButtonStyleName); + resolutionButton.addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + super.clicked(event, x, y); - if (game.prefs.getBoolean("fullscreen")) { - style = widgetSkin.get("fullscreen", ImageButton.ImageButtonStyle.class); - Gdx.graphics.setWindowedMode(game.prefs.getInteger("width", 800), game.prefs.getInteger("height", 600)); - } else { - style = widgetSkin.get("windowed", ImageButton.ImageButtonStyle.class); - Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode()); - } + Button.ButtonStyle style; - game.prefs.putBoolean("fullscreen", !game.prefs.getBoolean("fullscreen")); - game.prefs.flush(); + if (game.prefs.getBoolean("fullscreen")) { + style = widgetSkin.get("fullscreen", ImageButton.ImageButtonStyle.class); + Gdx.graphics.setWindowedMode(game.prefs.getInteger("width", 800), game.prefs.getInteger("height", 600)); + } else { + style = widgetSkin.get("windowed", ImageButton.ImageButtonStyle.class); + Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode()); + } - resolutionButton.setStyle(style); - } - }); - rightGameControlTable.add(resolutionButton); + game.prefs.putBoolean("fullscreen", !game.prefs.getBoolean("fullscreen")); + game.prefs.flush(); + + resolutionButton.setStyle(style); + } + }); + rightGameControlTable.add(resolutionButton); + + controlTable.add(leftGameControlTable).grow(); + } else { + rightGameControlTable.add(developerImage).expand(); + rightGameControlTable.add(localeButton).expand(); + rightGameControlTable.add(musicButton).expand(); + } - controlTable.add(leftGameControlTable).grow(); controlTable.add(rightGameControlTable).grow(); // - - - Savegame - - - Table savegameTable = new Table(); SavegameWidget info = new SavegameWidget(this.game, uiSkin, stage, savegame); - savegameTable.add(info).minSize(640f, 240f); + if (OsUtils.isMobile) { + savegameTable.add(info).growX().minHeight(240f).pad(16f); + } else { + savegameTable.add(info).minSize(640f, 240f); + } // Adding tables into the main UI table menuTable.add(brandTable).grow().row(); diff --git a/core/src/kz/ilotterytea/maxon/ui/SavegameWidget.java b/core/src/kz/ilotterytea/maxon/ui/SavegameWidget.java index 9f7c653..3a5667f 100644 --- a/core/src/kz/ilotterytea/maxon/ui/SavegameWidget.java +++ b/core/src/kz/ilotterytea/maxon/ui/SavegameWidget.java @@ -14,6 +14,7 @@ import kz.ilotterytea.maxon.MaxonGame; import kz.ilotterytea.maxon.player.Savegame; import kz.ilotterytea.maxon.screens.game.GameScreen; import kz.ilotterytea.maxon.screens.WelcomeScreen; +import kz.ilotterytea.maxon.utils.OsUtils; import kz.ilotterytea.maxon.utils.formatters.NumberFormatter; public class SavegameWidget extends Table implements Disposable { @@ -120,7 +121,6 @@ public class SavegameWidget extends Table implements Disposable { // - - - C O N T R O L - - - TextButton playButton = new TextButton(game.locale.TranslatableText("menu.continue"), skin); - controlTable.add(playButton).padRight(16f).growX(); playButton.addListener(new ClickListener() { @Override @@ -131,7 +131,6 @@ public class SavegameWidget extends Table implements Disposable { }); TextButton resetButton = new TextButton(game.locale.TranslatableText("menu.reset"), skin); - controlTable.add(resetButton); resetButton.addListener(new ClickListener() { @Override @@ -144,6 +143,16 @@ public class SavegameWidget extends Table implements Disposable { createEmpty(); } }); + + if (OsUtils.isMobile) { + header.pad(32f); + data.pad(32f); + controlTable.add(playButton).growX().minHeight(86f).padBottom(16f).row(); + controlTable.add(resetButton).growX(); + } else { + controlTable.add(playButton).padRight(16f).growX(); + controlTable.add(resetButton); + } } private void moveToNextScreen() { |
