From 9eff5a2c5370262631d185ba43cea762a3b28dad Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Wed, 23 Nov 2022 21:57:31 +0600 Subject: Changed to a white background instead of the ugly rainbow shit. --- .../ilotterytea/maxoning/screens/SplashScreen.java | 50 +--------------------- 1 file changed, 1 insertion(+), 49 deletions(-) (limited to 'core/src') diff --git a/core/src/com/ilotterytea/maxoning/screens/SplashScreen.java b/core/src/com/ilotterytea/maxoning/screens/SplashScreen.java index ccae6b1..e8ea561 100644 --- a/core/src/com/ilotterytea/maxoning/screens/SplashScreen.java +++ b/core/src/com/ilotterytea/maxoning/screens/SplashScreen.java @@ -1,35 +1,28 @@ package com.ilotterytea.maxoning.screens; import com.badlogic.gdx.*; -import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.GL20; -import com.badlogic.gdx.graphics.g2d.Sprite; import com.badlogic.gdx.graphics.g2d.TextureAtlas; import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.ui.Image; import com.badlogic.gdx.scenes.scene2d.ui.Skin; import com.badlogic.gdx.scenes.scene2d.ui.Table; import com.badlogic.gdx.utils.Align; -import com.badlogic.gdx.utils.Timer; import com.badlogic.gdx.utils.viewport.FillViewport; import com.ilotterytea.maxoning.MaxonGame; import com.ilotterytea.maxoning.utils.AssetLoading; import com.ilotterytea.maxoning.utils.OsUtils; -import com.ilotterytea.maxoning.utils.math.Math; import com.ilotterytea.maxoning.utils.serialization.GameDataSystem; import java.io.IOException; -import java.util.ArrayList; public class SplashScreen implements Screen { - final MaxonGame game; final Stage stage; final Skin skin; TextureAtlas brandAtlas, envAtlas; - ArrayList contribList; Image dev, pub; public SplashScreen(MaxonGame game) { @@ -46,7 +39,6 @@ public class SplashScreen implements Screen { brandAtlas = new TextureAtlas(Gdx.files.internal("sprites/gui/ilotterytea.atlas")); envAtlas = new TextureAtlas(Gdx.files.internal("sprites/env/environment.atlas")); - contribList = new ArrayList<>(); pub = new Image(brandAtlas.findRegion("org")); logoTable.add(pub).size(pub.getWidth() * 5f, pub.getHeight() * 5f).pad(16f).row(); @@ -60,40 +52,6 @@ public class SplashScreen implements Screen { } @Override public void show() { - int size = 64; - for (int i = 0; i < stage.getHeight() / size; i++) { - for (int j = 0; j < stage.getWidth() / size; j++) { - Sprite spr = new Sprite(envAtlas.findRegion("tile")); - spr.setSize(size, size); - spr.setPosition(size * j, size * i); - switch (Math.getRandomNumber(0, 5)) { - case 0: spr.setColor(Color.SKY); break; - case 1: spr.setColor(Color.PURPLE); break; - case 2: spr.setColor(Color.PINK); break; - case 3: spr.setColor(Color.CHARTREUSE); break; - case 4: spr.setColor(Color.ORANGE); break; - } - spr.setAlpha(0.25f); - contribList.add(spr); - } - } - - Timer.schedule(new Timer.Task() { - @Override - public void run() { - for (Sprite spr : contribList) { - switch (Math.getRandomNumber(0, 5)) { - case 0: spr.setColor(Color.SKY); break; - case 1: spr.setColor(Color.PURPLE); break; - case 2: spr.setColor(Color.PINK); break; - case 3: spr.setColor(Color.CHARTREUSE); break; - case 4: spr.setColor(Color.ORANGE); break; - } - spr.setAlpha(0.25f); - } - } - }, 1f, 1f); - render(Gdx.graphics.getDeltaTime()); } @@ -115,15 +73,9 @@ public class SplashScreen implements Screen { @Override public void render(float delta) { - Gdx.gl.glClearColor(0, 0, 0, 1); + Gdx.gl.glClearColor(1, 1, 1, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); - game.batch.begin(); - for (Sprite spr : contribList) { - spr.draw(game.batch); - } - game.batch.end(); - stage.draw(); stage.act(delta); -- cgit v1.2.3 From fd669f8c4968fad37adf3341eef14619c50475c4 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Wed, 23 Nov 2022 22:03:46 +0600 Subject: Removed leaf particles. --- .../ilotterytea/maxoning/screens/MenuScreen.java | 56 ---------------------- 1 file changed, 56 deletions(-) (limited to 'core/src') diff --git a/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java b/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java index 02ce550..b6a5906 100644 --- a/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java +++ b/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java @@ -17,13 +17,11 @@ import com.ilotterytea.maxoning.MaxonConstants; import com.ilotterytea.maxoning.MaxonGame; import com.ilotterytea.maxoning.player.MaxonSavegame; import com.ilotterytea.maxoning.ui.*; -import com.ilotterytea.maxoning.utils.math.Math; import com.ilotterytea.maxoning.utils.serialization.GameDataSystem; import java.io.File; import java.io.IOException; import java.util.ArrayList; -import java.util.Calendar; public class MenuScreen implements Screen { @@ -42,14 +40,6 @@ public class MenuScreen implements Screen { TextureAtlas environmentAtlas, brandAtlas; private final MovingChessBackground bg; - private ArrayList leafTiles, delLeafTiles; - - private final boolean isAutumn = - // Autumn. - ((Calendar.getInstance().get(Calendar.MONTH) + 1 > 8) && (Calendar.getInstance().get(Calendar.MONTH) + 1 < 12)) || - // Spring. - ((Calendar.getInstance().get(Calendar.MONTH) + 1 < 6) && (Calendar.getInstance().get(Calendar.MONTH) + 1 > 2)); - private final boolean isSummer = (Calendar.getInstance().get(Calendar.MONTH) + 1 > 5 && Calendar.getInstance().get(Calendar.MONTH) + 1 < 9); public MenuScreen(final MaxonGame game) { this.game = game; @@ -168,9 +158,6 @@ public class MenuScreen implements Screen { widgetSkin.getDrawable("bgTile01"), widgetSkin.getDrawable("bgTile02") ); - - leafTiles = new ArrayList<>(); - delLeafTiles = new ArrayList<>(); } @Override public void show() { @@ -183,55 +170,12 @@ public class MenuScreen implements Screen { Gdx.gl.glClearColor(0, 0, 0, 1f); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); - // Generate a new leaf: - if (!isSummer) { - LeafParticle _leaf = new LeafParticle( - (isAutumn) ? environmentAtlas.findRegion("leaf") : environmentAtlas.findRegion("snowflake"), - (float) java.lang.Math.floor(java.lang.Math.random() * Gdx.graphics.getWidth()), - Gdx.graphics.getHeight(), - (float) Math.getRandomNumber(-257, 256) + 1, - (float) Math.getRandomNumber(-257, 256) + 1, - (float) Math.getRandomNumber(5, 15)); - - _leaf.setScale(5f); - - if (isAutumn) { - switch (Math.getRandomNumber(0, 3)) { - case 0: _leaf.setColor(Color.CORAL); break; - case 1: _leaf.setColor(Color.YELLOW); break; - default: _leaf.setColor(Color.RED); break; - } - } else { - switch (Math.getRandomNumber(0, 1)) { - case 0: _leaf.setColor(Color.WHITE); break; - case 1: _leaf.setColor(Color.SKY); - } - } - - leafTiles.add(_leaf); - } - game.batch.begin(); bg.draw(game.batch); - for (LeafParticle spr : leafTiles) { - spr.draw(game.batch); - } - game.batch.end(); - if (!isSummer) { - for (LeafParticle spr : leafTiles) { - if (spr.getX() > Gdx.graphics.getWidth() || spr.getY() > Gdx.graphics.getHeight()) { - delLeafTiles.add(spr); - } - } - - for (LeafParticle spr : delLeafTiles) { leafTiles.remove(spr); } - delLeafTiles.clear(); - } - stage.draw(); stage.act(delta); } -- cgit v1.2.3 From 283378f20bb1e8cd8e7b09ad479a961fddfd2e44 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Fri, 25 Nov 2022 18:20:33 +0600 Subject: New dank prototype of UI design again (WIP) --- assets/i18n/en_us.json | 15 +- assets/i18n/ru_ru.json | 15 +- assets/sprites/gui/widgeticons.skin | 10 + .../ilotterytea/maxoning/screens/MenuScreen.java | 388 +++++++++++++++++++-- .../ilotterytea/maxoning/utils/AssetLoading.java | 1 + 5 files changed, 389 insertions(+), 40 deletions(-) create mode 100644 assets/sprites/gui/widgeticons.skin (limited to 'core/src') diff --git a/assets/i18n/en_us.json b/assets/i18n/en_us.json index 0f5f4eb..001650a 100644 --- a/assets/i18n/en_us.json +++ b/assets/i18n/en_us.json @@ -1,18 +1,25 @@ { "splash.disclaimer": "This game contains an unbelievable dose of cheeky \"woolbags\". Please, it is not recommended for anyone to play. Any match in real life of the presented images of cats is pure coincidence! All cat images were generated by \"NUT-S\" neural network.", + "menu.last_savegame.found": "Savegame: %s - %s Squish Points (x%s/click) - %s purchased items.", + "menu.last_savegame.empty": "No savegame found.", "menu.pressStart": "PRESS START", "menu.playGame": "PLAY GAME", "menu.options": "OPTIONS", "menu.quit": "QUIT TO DESKTOP", "options.title": "Options", - "options.music": "Music: %s", - "options.sound": "Sound: %s", - "options.vsync": "V-Sync: %s", - "options.fullscreen": "Fullscreen: %s", + "options.music": "Music", + "options.sound": "Sound", + "options.vsync": "Vertical Sync", + "options.fullscreen": "Fullscreen", "options.language": "Language: %s (%s)", + "options.debug": "Show debug", + "options.reset": "Reset save data", "options.close": "Back to main title", + "options.general": "General", + "options.video": "Video", + "options.audio": "Audio", "game.petShop": "Pet Shop", "game.points": "%s Squish Points (x%s/click)", diff --git a/assets/i18n/ru_ru.json b/assets/i18n/ru_ru.json index 6ac2a69..b6b49b7 100644 --- a/assets/i18n/ru_ru.json +++ b/assets/i18n/ru_ru.json @@ -1,18 +1,25 @@ { "splash.disclaimer": "Эта игра содержит невероятную дозу щекастых \"шерстяных мешков\". Никому не рекомендуется не играть в эту игру. Любое сходство в реальной жизни с представленными изображениями котов - чистое совпадение! Все изображения котов были сгенерированы нейросетью \"NUT-S\".", + "menu.last_savegame.found": "Сохранение: %s - %s баллы жмякания (х%s/клик) - %s куплено предметов.", + "menu.last_savegame.empty": "Сохранение не найдено!", "menu.pressStart": "НАЖМИТЕ ЛЮБУЮ КНОПКУ", "menu.playGame": "НАЧАТЬ ИГРУ", "menu.options": "НАСТРОЙКИ...", "menu.quit": "ВЫЙТИ НА РАБОЧИЙ СТОЛ", "options.title": "Настройки", - "options.music": "Музыка: %s", - "options.sound": "Звук: %s", - "options.vsync": "V-Sync: %s", - "options.fullscreen": "Полноэкранный режим: %s", + "options.music": "Музыка", + "options.sound": "Звук", + "options.vsync": "Верт. синхронизация", + "options.fullscreen": "Полноэкранный режим", "options.language": "Язык: %s (%s)", + "options.debug": "Показать откладку", + "options.reset": "Сбросить сохранение", "options.close": "Вернуться на главный экран", + "options.general": "Основное", + "options.video": "Видео", + "options.audio": "Аудио", "game.petShop": "Магазин Щекастых", "game.points": "%s Баллы жмякания (x%s/клик)", diff --git a/assets/sprites/gui/widgeticons.skin b/assets/sprites/gui/widgeticons.skin new file mode 100644 index 0000000..5c0a57f --- /dev/null +++ b/assets/sprites/gui/widgeticons.skin @@ -0,0 +1,10 @@ +{ + com.badlogic.gdx.scenes.scene2d.ui.ImageButton$ImageButtonStyle: { + quit: { + up: exit + }, + options: { + up: options + } + } +} \ No newline at end of file diff --git a/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java b/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java index b6a5906..9855066 100644 --- a/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java +++ b/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java @@ -2,6 +2,7 @@ package com.ilotterytea.maxoning.screens; import com.badlogic.gdx.*; import com.badlogic.gdx.audio.Music; +import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.graphics.*; import com.badlogic.gdx.graphics.g2d.TextureAtlas; import com.badlogic.gdx.math.Interpolation; @@ -10,6 +11,9 @@ import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.actions.Actions; import com.badlogic.gdx.scenes.scene2d.actions.RepeatAction; import com.badlogic.gdx.scenes.scene2d.ui.*; +import com.badlogic.gdx.scenes.scene2d.ui.Image; +import com.badlogic.gdx.scenes.scene2d.ui.Label; +import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.badlogic.gdx.utils.Align; import com.badlogic.gdx.utils.viewport.FillViewport; @@ -17,27 +21,33 @@ import com.ilotterytea.maxoning.MaxonConstants; import com.ilotterytea.maxoning.MaxonGame; import com.ilotterytea.maxoning.player.MaxonSavegame; import com.ilotterytea.maxoning.ui.*; +import com.ilotterytea.maxoning.utils.I18N; import com.ilotterytea.maxoning.utils.serialization.GameDataSystem; +import java.awt.*; import java.io.File; import java.io.IOException; import java.util.ArrayList; +import java.util.Locale; public class MenuScreen implements Screen { final MaxonGame game; final Stage stage; - final Skin skin, widgetSkin; + final Skin skin, widgetSkin, iconSkin; - Image brandLogo, blackBg, menuBg; + Image brandLogo, blackBg; final Music menuMusic; - Table menuTable, savegameTable; + Table menuTable; + + TextButton startBtn; + Label savLabel; // Atlases: - TextureAtlas environmentAtlas, brandAtlas; + TextureAtlas environmentAtlas, brandAtlas, iconAtlas; private final MovingChessBackground bg; @@ -50,10 +60,14 @@ public class MenuScreen implements Screen { // Brand atlas: brandAtlas = game.assetManager.get("sprites/gui/brand.atlas", TextureAtlas.class); + // Icon atlas: + iconAtlas = game.assetManager.get("sprites/gui/widgeticons.atlas", TextureAtlas.class); + // Stage and skin: this.stage = new Stage(new FillViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight())); this.skin = new Skin(Gdx.files.internal("main.skin")); this.widgetSkin = new Skin(Gdx.files.internal("sprites/gui/widgets.skin")); + this.iconSkin = new Skin(Gdx.files.internal("sprites/gui/widgeticons.skin")); // Main Menu music: this.menuMusic = game.assetManager.get("mus/menu/mus_menu_loop.ogg", Music.class); @@ -67,56 +81,69 @@ public class MenuScreen implements Screen { stage.addActor(blackBg); - // Save game table: - savegameTable = new Table(); - loadSavegamesToTable(savegameTable); + // // Menu table: + float iconSize = 48f, iconPad = 6f; + menuTable = new Table(); + menuTable.setSize(stage.getWidth() / 2f, iconSize); + menuTable.setPosition(0, 0); + menuTable.pad(iconPad); + menuTable.align(Align.bottomLeft); - // Quick buttons: - Table quickTable = new Table(); - quickTable.align(Align.right); + // Quit button: + ImageButton quitBtn = new ImageButton(iconSkin, "quit"); - // Options button: - TextButton optionsButton = new TextButton("Options", widgetSkin, "default"); - optionsButton.addListener(new ClickListener() { + quitBtn.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { - super.clicked(event, x, y); + Gdx.app.exit(); } }); - quickTable.add(optionsButton).height(48f).minWidth(90f).pad(4f); + menuTable.add(quitBtn).size(iconSize).pad(iconPad); - // Quit button: - TextButton quitButton = new TextButton("Quit", widgetSkin, "default"); - quitButton.addListener(new ClickListener() { + // Options button: + ImageButton optBtn = new ImageButton(iconSkin, "options"); + + optBtn.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { - Gdx.app.exit(); + showOptions(); } }); - quickTable.add(quitButton).height(48f).minWidth(90f).pad(4f); + menuTable.add(optBtn).size(iconSize).pad(iconPad); - // Menu table: - menuTable = new Table(); - menuTable.setPosition(0, 0); - menuTable.setSize(stage.getWidth(), stage.getHeight()); - menuTable.align(Align.center); + stage.addActor(menuTable); - Label menuTitle = new Label("Please select a save slot", skin, "default"); - menuTitle.setAlignment(Align.left); + // // Press start: + startBtn = new TextButton(game.locale.TranslatableText("menu.pressStart"), skin); + startBtn.setPosition((stage.getWidth() / 2f) - (startBtn.getWidth() / 2f), 8f); - menuTable.add(menuTitle).width(512f).row(); - menuTable.add(savegameTable).width(512f).maxWidth(640f).row(); - menuTable.add(quickTable).width(512f); + startBtn.addAction( + Actions.repeat( + -1, + Actions.sequence( + Actions.fadeIn(1f), + Actions.delay(2f), + Actions.fadeOut(1f), + Actions.delay(2f) + ) + ) + ); - stage.addActor(menuTable); + stage.addActor(startBtn); + + // // Savegame: + savLabel = new Label("test", skin); + savLabel.setPosition((stage.getWidth() / 2f) - (savLabel.getWidth() / 2f), 8f + startBtn.getY() + startBtn.getHeight()); + + stage.addActor(savLabel); // // Logo: brandLogo = new Image(brandAtlas.findRegion("brand")); brandLogo.setPosition( (stage.getWidth() / 2f) - (brandLogo.getWidth() / 2f), - stage.getHeight() - brandLogo.getHeight() * 1.5f + (stage.getHeight() / 2f) - (brandLogo.getHeight() / 2f) ); brandLogo.setOrigin( @@ -187,6 +214,303 @@ public class MenuScreen implements Screen { stage.getViewport().update(width, height, true); } + private void showOptions() { + startBtn.addAction(Actions.moveTo(startBtn.getX(), -startBtn.getY() - startBtn.getHeight(), 1f, Interpolation.exp10Out)); + savLabel.addAction(Actions.moveTo(savLabel.getX(), -savLabel.getY() - savLabel.getHeight(), 1f, Interpolation.exp10Out)); + menuTable.addAction(Actions.moveTo(menuTable.getX(), -menuTable.getY() - menuTable.getHeight(), 1f, Interpolation.exp10Out)); + + brandLogo.clearActions(); + brandLogo.addAction( + Actions.sequence( + Actions.parallel( + Actions.moveTo( + (stage.getWidth() / 2f) - (brandLogo.getWidth() / 2f), + stage.getHeight() - brandLogo.getHeight() * 1.5f, + 1f, + Interpolation.fade + ), + Actions.rotateTo(0f, .25f, Interpolation.fade) + ), + 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) + ) + ) + ) + ) + ); + + // Main options window: + final Table mOptTable = new Table(); + mOptTable.setPosition(0, 0); + mOptTable.align(Align.center); + mOptTable.setSize(stage.getWidth(), stage.getHeight()); + stage.addActor(mOptTable); + + // Options title: + Label optTitle = new Label(game.locale.TranslatableText("options.title"), skin); + optTitle.setAlignment(Align.left); + mOptTable.add(optTitle).width(512f).row(); + + // Options table: + Table optTable = new Table(widgetSkin); + optTable.setBackground("plain_down"); + optTable.align(Align.topLeft); + + // Scroll panel for options: + ScrollPane optScroll = new ScrollPane(optTable); + optScroll.setScrollingDisabled(true, false); + mOptTable.add(optScroll).width(512f).height(384f).row(); + + // - - - General category - - -: + Label genLabel = new Label(game.locale.TranslatableText("options.general"), skin); + optTable.add(genLabel).expandX().row(); + + Table genCategory = new Table(); + optTable.add(genCategory).expandX().row(); + + // Show debug: + Label debLabel = new Label(game.locale.TranslatableText("options.debug"), skin); + debLabel.setAlignment(Align.left); + genCategory.add(debLabel).width(256f); + + final TextButton debButton = new TextButton((game.prefs.getBoolean("debug", false)) ? "ON" : "OFF", widgetSkin); + + debButton.addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + boolean value = game.prefs.getBoolean("debug", false); + + game.prefs.putBoolean("debug", !value); + game.prefs.flush(); + + value = !value; + + debButton.getLabel().setText((value) ? "ON" : "OFF"); + } + }); + + genCategory.add(debButton).width(256f).row(); + + // - - - Audio category - - -: + Label audioLabel = new Label(game.locale.TranslatableText("options.audio"), skin); + optTable.add(audioLabel).expandX().row(); + + Table audioCategory = new Table(); + optTable.add(audioCategory).expandX().row(); + + // Music: + Label musLabel = new Label(game.locale.TranslatableText("options.music"), skin); + musLabel.setAlignment(Align.left); + audioCategory.add(musLabel).width(256f); + + final TextButton musButton = new TextButton((game.prefs.getBoolean("music", true)) ? "ON" : "OFF", widgetSkin); + + musButton.addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + boolean value = game.prefs.getBoolean("music", true); + + game.prefs.putBoolean("music", !value); + game.prefs.flush(); + + value = !value; + + if (value) menuMusic.play(); + else menuMusic.pause(); + + musButton.getLabel().setText((value) ? "ON" : "OFF"); + } + }); + + audioCategory.add(musButton).width(256f).row(); + + // Sound: + Label sndLabel = new Label(game.locale.TranslatableText("options.sound"), skin); + sndLabel.setAlignment(Align.left); + audioCategory.add(sndLabel).width(256f); + + final TextButton sndButton = new TextButton((game.prefs.getBoolean("sfx", true)) ? "ON" : "OFF", widgetSkin); + + sndButton.addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + boolean value = game.prefs.getBoolean("sfx", true); + + game.prefs.putBoolean("sfx", !value); + game.prefs.flush(); + + value = !value; + + sndButton.getLabel().setText((value) ? "ON" : "OFF"); + } + }); + + audioCategory.add(sndButton).width(256f).row(); + + // - - - Video category - - -: + Label videoLabel = new Label(game.locale.TranslatableText("options.video"), skin); + optTable.add(videoLabel).expandX().row(); + + Table videoCategory = new Table(); + optTable.add(videoCategory).expandX().row(); + + // Vertical sync: + Label vscLabel = new Label(game.locale.TranslatableText("options.vsync"), skin); + vscLabel.setAlignment(Align.left); + videoCategory.add(vscLabel).width(256f); + + final TextButton vscButton = new TextButton((game.prefs.getBoolean("vsync", true)) ? "ON" : "OFF", widgetSkin); + + vscButton.addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + boolean value = game.prefs.getBoolean("vsync", true); + + game.prefs.putBoolean("vsync", !value); + game.prefs.flush(); + + value = !value; + + Gdx.graphics.setVSync(value); + + vscButton.getLabel().setText((value) ? "ON" : "OFF"); + } + }); + + videoCategory.add(vscButton).width(256f).row(); + + // Full screen: + Label fscLabel = new Label(game.locale.TranslatableText("options.fullscreen"), skin); + fscLabel.setAlignment(Align.left); + videoCategory.add(fscLabel).width(256f); + + final TextButton fscButton = new TextButton((game.prefs.getBoolean("fullscreen", true)) ? "ON" : "OFF", widgetSkin); + + fscButton.addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + boolean value = game.prefs.getBoolean("fullscreen", true); + + game.prefs.putBoolean("fullscreen", !value); + game.prefs.flush(); + + value = !value; + Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); + + if (value) Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode()); + else Gdx.graphics.setWindowedMode(dim.width, dim.height); + + fscButton.getLabel().setText((value) ? "ON" : "OFF"); + } + }); + + videoCategory.add(fscButton).width(256f).row(); + + // - - - Switch the language - - -: + String[] fh4Locale = game.locale.getFileHandle().nameWithoutExtension().split("_"); + Locale locale = new Locale(fh4Locale[0], fh4Locale[1]); + final TextButton langButton = new TextButton(game.locale.FormattedText("options.language", locale.getDisplayLanguage(), locale.getDisplayCountry()), widgetSkin); + + langButton.addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + int index = 0; + ArrayList fhArray = new ArrayList<>(); + fhArray.add(MaxonConstants.FILE_RU_RU); + fhArray.add(MaxonConstants.FILE_EN_US); + + if (fhArray.indexOf(game.locale.getFileHandle()) + 1 < fhArray.size()) { + index = fhArray.indexOf(game.locale.getFileHandle()) + 1; + } + + FileHandle fhNext = fhArray.get(index); + + game.locale = new I18N(fhNext); + game.prefs.putString("lang", fhNext.nameWithoutExtension()); + game.prefs.flush(); + + String[] fh4Locale = fhNext.nameWithoutExtension().split("_"); + Locale locale = new Locale(fh4Locale[0], fh4Locale[1]); + + langButton.setText(game.locale.FormattedText("options.language", locale.getDisplayLanguage(), locale.getDisplayCountry())); + game.setScreen(new SplashScreen(game)); + menuMusic.stop(); + } + }); + + optTable.add(langButton).width(512f).row(); + + // - - - Reset save data - - -: + TextButton resetButton = new TextButton(game.locale.TranslatableText("options.reset"), widgetSkin); + optTable.add(resetButton).width(512f).row(); + + // Game info: + Label infLabel = new Label(String.format("%s - %s", MaxonConstants.GAME_NAME, MaxonConstants.GAME_VERSION), skin); + infLabel.setAlignment(Align.center); + optTable.add(infLabel).maxWidth(512f).row(); + + // // Action buttons: + Table actTable = new Table(widgetSkin); + actTable.setBackground("plain_down"); + actTable.setWidth(512f); + actTable.align(Align.right); + mOptTable.add(actTable).width(512f).maxWidth(512f).pad(5f); + + TextButton closeBtn = new TextButton("Back to main menu", widgetSkin); + + closeBtn.addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + mOptTable.remove(); + + brandLogo.clearActions(); + brandLogo.addAction( + Actions.sequence( + Actions.parallel( + Actions.rotateTo(0f, 1f), + Actions.moveTo( + (stage.getWidth() / 2f) - (brandLogo.getWidth() / 2f), + (stage.getHeight() / 2f) - (brandLogo.getHeight() / 2f), + 1f, + Interpolation.fade + ) + ), + 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) + ) + ) + ) + ) + ); + + startBtn.addAction(Actions.moveTo(startBtn.getX(), 8f, 1f, Interpolation.smoother)); + savLabel.addAction(Actions.moveTo(savLabel.getX(), 16f + startBtn.getHeight(), 1f, Interpolation.smoother)); + menuTable.addAction(Actions.moveTo(menuTable.getX(), 0, 1f, Interpolation.smoother)); + } + }); + + actTable.add(closeBtn).pad(5f); + + TextButton saveBtn = new TextButton("Apply", widgetSkin); + actTable.add(saveBtn).pad(5f); + } + private void loadSavegamesToTable(Table table) { for (int i = 0; i < 3; i++) { if (new File(MaxonConstants.GAME_SAVEGAME_FOLDER + String.format("/0%s.maxon", i)).exists()) { diff --git a/core/src/com/ilotterytea/maxoning/utils/AssetLoading.java b/core/src/com/ilotterytea/maxoning/utils/AssetLoading.java index aba31fa..271163d 100644 --- a/core/src/com/ilotterytea/maxoning/utils/AssetLoading.java +++ b/core/src/com/ilotterytea/maxoning/utils/AssetLoading.java @@ -17,6 +17,7 @@ public class AssetLoading { am.load("sprites/gui/icons.atlas", TextureAtlas.class); am.load("sprites/gui/ilotterytea.atlas", TextureAtlas.class); am.load("sprites/gui/widgets.atlas", TextureAtlas.class); + am.load("sprites/gui/widgeticons.atlas", TextureAtlas.class); // Cat item textures: am.load("sprites/sheet/loadingCircle.png", Texture.class); -- cgit v1.2.3