summaryrefslogtreecommitdiff
path: root/core/src/kz/ilotterytea/maxon/ui
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2024-11-10 20:45:32 +0500
committerilotterytea <iltsu@alright.party>2024-11-10 20:45:32 +0500
commit0a29485586012ae00548997c262ea16f3820a823 (patch)
treec1abed64ee34a53e8e119219a6278a03733b0754 /core/src/kz/ilotterytea/maxon/ui
parentc5493df746e8f3915d86d8ebe85346dc1690ee4f (diff)
upd: kotlin has been a disaster for maxon source code
Diffstat (limited to 'core/src/kz/ilotterytea/maxon/ui')
-rw-r--r--core/src/kz/ilotterytea/maxon/ui/ShakingImageButton.java42
-rw-r--r--core/src/kz/ilotterytea/maxon/ui/ShakingImageButton.kt37
-rw-r--r--core/src/kz/ilotterytea/maxon/ui/game/QuickActionsTable.java71
-rw-r--r--core/src/kz/ilotterytea/maxon/ui/game/QuickActionsTable.kt66
4 files changed, 113 insertions, 103 deletions
diff --git a/core/src/kz/ilotterytea/maxon/ui/ShakingImageButton.java b/core/src/kz/ilotterytea/maxon/ui/ShakingImageButton.java
new file mode 100644
index 0000000..2a28586
--- /dev/null
+++ b/core/src/kz/ilotterytea/maxon/ui/ShakingImageButton.java
@@ -0,0 +1,42 @@
+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;
+
+public class ShakingImageButton extends Image {
+ public ShakingImageButton(Skin skin, String style) {
+ super(skin.getRegion(style));
+
+ this.setOrigin(getWidth() / 2f, getHeight() / 2f);
+
+ this.addListener(new ClickListener() {
+ @Override
+ public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) {
+ 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
+ public void exit(InputEvent event, float x, float y, int pointer, Actor toActor) {
+ super.exit(event, x, y, pointer, toActor);
+
+ clearActions();
+ addAction(Actions.rotateTo(0f, 0.1f));
+ }
+ });
+ }
+}
diff --git a/core/src/kz/ilotterytea/maxon/ui/ShakingImageButton.kt b/core/src/kz/ilotterytea/maxon/ui/ShakingImageButton.kt
deleted file mode 100644
index eb8c51c..0000000
--- a/core/src/kz/ilotterytea/maxon/ui/ShakingImageButton.kt
+++ /dev/null
@@ -1,37 +0,0 @@
-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.java b/core/src/kz/ilotterytea/maxon/ui/game/QuickActionsTable.java
new file mode 100644
index 0000000..1940d65
--- /dev/null
+++ b/core/src/kz/ilotterytea/maxon/ui/game/QuickActionsTable.java
@@ -0,0 +1,71 @@
+package kz.ilotterytea.maxon.ui.game;
+
+import com.badlogic.gdx.Gdx;
+import com.badlogic.gdx.audio.Sound;
+import com.badlogic.gdx.graphics.g2d.Batch;
+import com.badlogic.gdx.scenes.scene2d.InputEvent;
+import com.badlogic.gdx.scenes.scene2d.ui.Cell;
+import com.badlogic.gdx.scenes.scene2d.ui.Skin;
+import com.badlogic.gdx.scenes.scene2d.ui.Table;
+import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
+import com.badlogic.gdx.utils.Align;
+import kz.ilotterytea.maxon.MaxonGame;
+import kz.ilotterytea.maxon.constants.SettingsConstants;
+import kz.ilotterytea.maxon.screens.MenuScreen;
+import kz.ilotterytea.maxon.screens.SlotsMinigameScreen;
+import kz.ilotterytea.maxon.ui.ShakingImageButton;
+import kz.ilotterytea.maxon.utils.OsUtils;
+
+public class QuickActionsTable extends Table {
+ public QuickActionsTable(Skin widgetSkin, Skin uiSkin) {
+ super(uiSkin);
+
+ MaxonGame game = MaxonGame.getInstance();
+
+ Sound clickSound = game.assetManager.get("sfx/ui/click.ogg");
+ float soundVolume = game.prefs.getInteger("sfx", 10) / 10f;
+
+ float iconSize = (OsUtils.isMobile ? 256f : 64f)
+ * game.prefs.getFloat("guiScale", SettingsConstants.UI_DEFAULT_SCALE);
+
+ ShakingImageButton slotsButton = new ShakingImageButton(widgetSkin, "slots");
+ slotsButton.setOrigin(iconSize / 2f, iconSize / 2f);
+ slotsButton.addListener(new ClickListener() {
+ @Override
+ public void clicked(InputEvent event, float x, float y) {
+ super.clicked(event, x, y);
+ clickSound.play(soundVolume);
+ game.setScreen(new SlotsMinigameScreen());
+ }
+ });
+ Cell<ShakingImageButton> slotsCell = add(slotsButton).size(iconSize).padRight(8f);
+
+ ShakingImageButton quitButton = new ShakingImageButton(widgetSkin, "exit");
+ quitButton.setOrigin(iconSize / 2f, iconSize / 2f);
+ quitButton.addListener(new ClickListener() {
+ @Override
+ public void clicked(InputEvent event, float x, float y) {
+ super.clicked(event, x, y);
+ clickSound.play(soundVolume);
+ game.setScreen(new MenuScreen());
+ }
+ });
+ Cell<ShakingImageButton> quitCell = add(quitButton).size(iconSize);
+
+ if (OsUtils.isMobile) {
+ slotsCell.expandX();
+ quitCell.expandX();
+ }
+ }
+
+ @Override
+ public void draw(Batch batch, float parentAlpha) {
+ super.draw(batch, parentAlpha);
+
+ if (OsUtils.isMobile) return;
+
+ // i'm not sure how much does it affect on performance
+ setX(Gdx.graphics.getWidth() - 36f * 2f, Align.left);
+ setY(Gdx.graphics.getHeight() - 36f, Align.top);
+ }
+}
diff --git a/core/src/kz/ilotterytea/maxon/ui/game/QuickActionsTable.kt b/core/src/kz/ilotterytea/maxon/ui/game/QuickActionsTable.kt
deleted file mode 100644
index 08b4bb7..0000000
--- a/core/src/kz/ilotterytea/maxon/ui/game/QuickActionsTable.kt
+++ /dev/null
@@ -1,66 +0,0 @@
-package kz.ilotterytea.maxon.ui.game
-
-import com.badlogic.gdx.Gdx
-import com.badlogic.gdx.audio.Sound
-import com.badlogic.gdx.graphics.g2d.Batch
-import com.badlogic.gdx.scenes.scene2d.InputEvent
-import com.badlogic.gdx.scenes.scene2d.ui.Skin
-import com.badlogic.gdx.scenes.scene2d.ui.Table
-import com.badlogic.gdx.scenes.scene2d.utils.ClickListener
-import com.badlogic.gdx.utils.Align
-import kz.ilotterytea.maxon.MaxonGame
-import kz.ilotterytea.maxon.constants.SettingsConstants
-import kz.ilotterytea.maxon.screens.MenuScreen
-import kz.ilotterytea.maxon.screens.SlotsMinigameScreen
-import kz.ilotterytea.maxon.ui.ShakingImageButton
-import kz.ilotterytea.maxon.utils.OsUtils
-
-class QuickActionsTable(widgetSkin: Skin, uiSkin: Skin) : Table(uiSkin) {
- init {
- val game = MaxonGame.getInstance()
- val clickSound = game.assetManager.get("sfx/ui/click.ogg", Sound::class.java)
- val soundVolume = game.prefs.getInteger("sfx", 10) / 10f
- val iconSize = if (OsUtils.isMobile) {
- 256f
- } else {
- 64f
- } * game.prefs.getFloat("guiScale", SettingsConstants.UI_DEFAULT_SCALE)
-
- val slotsButton = ShakingImageButton(widgetSkin, "slots")
- slotsButton.setOrigin(iconSize / 2f, iconSize / 2f)
- slotsButton.addListener(object : ClickListener() {
- override fun clicked(event: InputEvent, x: Float, y: Float) {
- super.clicked(event, x, y)
- clickSound.play(soundVolume)
- game.screen = SlotsMinigameScreen()
- }
- })
- val slotsCell = add(slotsButton).size(iconSize).padRight(8f)
-
- val quitButton = ShakingImageButton(widgetSkin, "exit")
- quitButton.setOrigin(iconSize / 2f, iconSize / 2f)
- quitButton.addListener(object : ClickListener() {
- override fun clicked(event: InputEvent, x: Float, y: Float) {
- super.clicked(event, x, y)
- clickSound.play(soundVolume)
- game.screen = MenuScreen()
- }
- })
- val quitCell = add(quitButton).size(iconSize)
-
- if (OsUtils.isMobile) {
- slotsCell.expandX()
- quitCell.expandX()
- }
- }
-
- override fun draw(batch: Batch?, parentAlpha: Float) {
- super.draw(batch, parentAlpha)
-
- if (OsUtils.isMobile) return
-
- // i'm not sure how much does it affect on performance
- setX(Gdx.graphics.width - 36f * 2f, Align.left)
- setY(Gdx.graphics.height - 36f, Align.top)
- }
-} \ No newline at end of file