summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2024-10-06 00:17:50 +0500
committerilotterytea <iltsu@alright.party>2024-10-06 00:17:50 +0500
commit964aca366e36b8d3a60d57bbbb2838cd04314e03 (patch)
treec4891a8951e962cfa75067c9eea24477d5577b77 /core
parent2eee5c2cc487d0657fadef78d3fcb547885619e3 (diff)
feat: quick actions (just a quit button)
Diffstat (limited to 'core')
-rw-r--r--core/src/kz/ilotterytea/maxon/screens/game/GameScreen.java3
-rw-r--r--core/src/kz/ilotterytea/maxon/ui/game/QuickActionsTable.kt42
2 files changed, 45 insertions, 0 deletions
diff --git a/core/src/kz/ilotterytea/maxon/screens/game/GameScreen.java b/core/src/kz/ilotterytea/maxon/screens/game/GameScreen.java
index 29756bf..b5f99be 100644
--- a/core/src/kz/ilotterytea/maxon/screens/game/GameScreen.java
+++ b/core/src/kz/ilotterytea/maxon/screens/game/GameScreen.java
@@ -33,6 +33,7 @@ import kz.ilotterytea.maxon.player.Savegame;
import kz.ilotterytea.maxon.screens.MenuScreen;
import kz.ilotterytea.maxon.screens.game.shop.ShopUI;
import kz.ilotterytea.maxon.ui.*;
+import kz.ilotterytea.maxon.ui.game.QuickActionsTable;
import kz.ilotterytea.maxon.utils.OsUtils;
import kz.ilotterytea.maxon.utils.math.Math;
import com.rafaskoberg.gdx.typinglabel.TypingLabel;
@@ -445,6 +446,8 @@ public class GameScreen implements Screen, InputProcessor {
DebugWidget debugWidget = new DebugWidget(uiSkin);
this.stage.addActor(debugWidget);
+
+ this.stage.addActor(new QuickActionsTable(this.game.assetManager.get("sprites/gui/widgets.skin", Skin.class)));
}
@Override
diff --git a/core/src/kz/ilotterytea/maxon/ui/game/QuickActionsTable.kt b/core/src/kz/ilotterytea/maxon/ui/game/QuickActionsTable.kt
new file mode 100644
index 0000000..b5df026
--- /dev/null
+++ b/core/src/kz/ilotterytea/maxon/ui/game/QuickActionsTable.kt
@@ -0,0 +1,42 @@
+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.ImageButton
+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.player.Savegame
+import kz.ilotterytea.maxon.screens.MenuScreen
+
+class QuickActionsTable(skin: Skin) : Table() {
+ init {
+ val game = MaxonGame.getInstance()
+ val quitButton = ImageButton(skin, "quit")
+
+ val clickSound = game.assetManager.get("sfx/ui/click.ogg", Sound::class.java)
+
+ quitButton.addListener(object : ClickListener() {
+ override fun clicked(event: InputEvent, x: Float, y: Float) {
+ super.clicked(event, x, y)
+ clickSound.play()
+ Savegame.getInstance().save()
+ game.screen = MenuScreen()
+ }
+ })
+
+ add(quitButton).height(64f).width(64f)
+ }
+
+ override fun draw(batch: Batch?, parentAlpha: Float) {
+ super.draw(batch, parentAlpha)
+
+ // i'm not sure how much does it affect on performance
+ setX(Gdx.graphics.width - 36f, Align.left)
+ setY(Gdx.graphics.height - 36f, Align.top)
+ }
+} \ No newline at end of file