diff options
| -rw-r--r-- | assets/sprites/gui/widgets.atlas | 4 | ||||
| -rw-r--r-- | assets/sprites/gui/widgets.skin | 4 | ||||
| -rw-r--r-- | core/src/kz/ilotterytea/maxon/screens/MenuScreen.java | 26 | ||||
| -rw-r--r-- | core/src/kz/ilotterytea/maxon/ui/ShakingImageButton.kt | 37 | ||||
| -rw-r--r-- | core/src/kz/ilotterytea/maxon/ui/game/QuickActionsTable.kt | 3 |
5 files changed, 56 insertions, 18 deletions
diff --git a/assets/sprites/gui/widgets.atlas b/assets/sprites/gui/widgets.atlas index dfa7c46..026b16b 100644 --- a/assets/sprites/gui/widgets.atlas +++ b/assets/sprites/gui/widgets.atlas @@ -9,9 +9,9 @@ music_off bounds:2,134,87,64 music_on bounds:2,68,79,64 -russia +locale_ru bounds:91,134,64,64 -usa +locale_en bounds:2,2,64,64 windowed bounds:157,134,64,64 diff --git a/assets/sprites/gui/widgets.skin b/assets/sprites/gui/widgets.skin index e074867..a5a5f10 100644 --- a/assets/sprites/gui/widgets.skin +++ b/assets/sprites/gui/widgets.skin @@ -5,7 +5,7 @@ windowed: { up: windowed }, music_off: { up: music_off }, music_on: { up: music_on }, - locale_en: { up: usa }, - locale_ru: { up: russia } + locale_en: { up: locale_en }, + locale_ru: { up: locale_ru } } }
\ No newline at end of file diff --git a/core/src/kz/ilotterytea/maxon/screens/MenuScreen.java b/core/src/kz/ilotterytea/maxon/screens/MenuScreen.java index 11dcd5b..3158d67 100644 --- a/core/src/kz/ilotterytea/maxon/screens/MenuScreen.java +++ b/core/src/kz/ilotterytea/maxon/screens/MenuScreen.java @@ -135,7 +135,7 @@ public class MenuScreen implements Screen { Table leftGameControlTable = new Table(); leftGameControlTable.align(Align.left); - ImageButton quitButton = new ImageButton(widgetSkin, "quit"); + ShakingImageButton quitButton = new ShakingImageButton(widgetSkin, "exit"); quitButton.addListener(new ClickListener() { @Override @@ -158,7 +158,7 @@ public class MenuScreen implements Screen { // - - - D E V E L O P E R S H O W C A S E - - - final int[] developerIndex = {0}; - Image developerImage = new Image(friendsSkin.getDrawable(MaxonConstants.GAME_DEVELOPERS[developerIndex[0]][0])); + ShakingImageButton developerImage = new ShakingImageButton(friendsSkin, MaxonConstants.GAME_DEVELOPERS[developerIndex[0]][0]); developerImage.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { @@ -210,7 +210,7 @@ public class MenuScreen implements Screen { // Localization String[] fh4Locale = game.locale.getFileHandle().nameWithoutExtension().split("_"); String localeButtonStyleName = "locale_" + fh4Locale[0]; - ImageButton localeButton = new ImageButton(widgetSkin, localeButtonStyleName); + ShakingImageButton localeButton = new ShakingImageButton(widgetSkin, localeButtonStyleName); localeButton.addListener(new ClickListener() { @Override @@ -248,26 +248,26 @@ public class MenuScreen implements Screen { musicButtonStyleName = "music_off"; } - ImageButton musicButton = new ImageButton(widgetSkin, musicButtonStyleName); + ShakingImageButton musicButton = new ShakingImageButton(widgetSkin, musicButtonStyleName); musicButton.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { super.clicked(event, x, y); - Button.ButtonStyle style; + String style; if (game.prefs.getBoolean("music")) { - style = widgetSkin.get("music_off", ImageButton.ImageButtonStyle.class); + style = "music_off"; menuMusic.pause(); } else { - style = widgetSkin.get("music_on", ImageButton.ImageButtonStyle.class); + style = "music_on"; menuMusic.play(); } game.prefs.putBoolean("music", !game.prefs.getBoolean("music")); game.prefs.flush(); - musicButton.setStyle(style); + musicButton.setDrawable(widgetSkin, style); clickSound.play(); } }); @@ -286,26 +286,26 @@ public class MenuScreen implements Screen { resolutionButtonStyleName = "fullscreen"; } - ImageButton resolutionButton = new ImageButton(widgetSkin, resolutionButtonStyleName); + ShakingImageButton resolutionButton = new ShakingImageButton(widgetSkin, resolutionButtonStyleName); resolutionButton.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { super.clicked(event, x, y); - Button.ButtonStyle style; + String style; if (game.prefs.getBoolean("fullscreen")) { - style = widgetSkin.get("fullscreen", ImageButton.ImageButtonStyle.class); + style = "fullscreen"; Gdx.graphics.setWindowedMode(game.prefs.getInteger("width", 800), game.prefs.getInteger("height", 600)); } else { - style = widgetSkin.get("windowed", ImageButton.ImageButtonStyle.class); + style = "windowed"; Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode()); } game.prefs.putBoolean("fullscreen", !game.prefs.getBoolean("fullscreen")); game.prefs.flush(); - resolutionButton.setStyle(style); + resolutionButton.setDrawable(widgetSkin, style); clickSound.play(); } }); diff --git a/core/src/kz/ilotterytea/maxon/ui/ShakingImageButton.kt b/core/src/kz/ilotterytea/maxon/ui/ShakingImageButton.kt new file mode 100644 index 0000000..eb8c51c --- /dev/null +++ b/core/src/kz/ilotterytea/maxon/ui/ShakingImageButton.kt @@ -0,0 +1,37 @@ +package kz.ilotterytea.maxon.ui + +import com.badlogic.gdx.scenes.scene2d.Actor +import com.badlogic.gdx.scenes.scene2d.InputEvent +import com.badlogic.gdx.scenes.scene2d.actions.Actions +import com.badlogic.gdx.scenes.scene2d.actions.RepeatAction +import com.badlogic.gdx.scenes.scene2d.ui.Image +import com.badlogic.gdx.scenes.scene2d.ui.Skin +import com.badlogic.gdx.scenes.scene2d.utils.ClickListener + +class ShakingImageButton(skin: Skin, style: String) : Image(skin.getRegion(style)) { + init { + setOrigin(width / 2f, height / 2f) + + addListener(object : ClickListener() { + override fun enter(event: InputEvent?, x: Float, y: Float, pointer: Int, fromActor: Actor?) { + super.enter(event, x, y, pointer, fromActor) + + addAction( + Actions.repeat( + RepeatAction.FOREVER, + Actions.sequence( + Actions.rotateTo(-2f, 0.1f), + Actions.rotateTo(2f, 0.1f) + ) + ) + ) + } + + override fun exit(event: InputEvent?, x: Float, y: Float, pointer: Int, toActor: Actor?) { + super.exit(event, x, y, pointer, toActor) + clearActions() + addAction(Actions.rotateTo(0f, 0.1f)) + } + }) + } +}
\ No newline at end of file diff --git a/core/src/kz/ilotterytea/maxon/ui/game/QuickActionsTable.kt b/core/src/kz/ilotterytea/maxon/ui/game/QuickActionsTable.kt index b5df026..c2c1667 100644 --- a/core/src/kz/ilotterytea/maxon/ui/game/QuickActionsTable.kt +++ b/core/src/kz/ilotterytea/maxon/ui/game/QuickActionsTable.kt @@ -12,11 +12,12 @@ import com.badlogic.gdx.utils.Align import kz.ilotterytea.maxon.MaxonGame import kz.ilotterytea.maxon.player.Savegame import kz.ilotterytea.maxon.screens.MenuScreen +import kz.ilotterytea.maxon.ui.ShakingImageButton class QuickActionsTable(skin: Skin) : Table() { init { val game = MaxonGame.getInstance() - val quitButton = ImageButton(skin, "quit") + val quitButton = ShakingImageButton(skin, "exit") val clickSound = game.assetManager.get("sfx/ui/click.ogg", Sound::class.java) |
