summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2022-12-10 13:41:54 +0600
committerilotterytea <iltsu@alright.party>2022-12-10 13:41:54 +0600
commitaf41b7e39b4227bef2817ffc1c2fea221440b141 (patch)
treea1b396f99ae2c19951bb070eb4bb67fab44429c0 /core
parent640a8c0bee92dae0e2e1b42ffe0551683cfe979e (diff)
Debug info can now be disabled/enabled
Diffstat (limited to 'core')
-rw-r--r--core/src/com/ilotterytea/maxoning/screens/GameScreen.java8
-rw-r--r--core/src/com/ilotterytea/maxoning/screens/MenuScreen.java12
-rw-r--r--core/src/com/ilotterytea/maxoning/ui/DebugInfo.kt33
-rw-r--r--core/src/com/ilotterytea/maxoning/ui/DebugLabel.java19
4 files changed, 45 insertions, 27 deletions
diff --git a/core/src/com/ilotterytea/maxoning/screens/GameScreen.java b/core/src/com/ilotterytea/maxoning/screens/GameScreen.java
index 3382456..96adaf3 100644
--- a/core/src/com/ilotterytea/maxoning/screens/GameScreen.java
+++ b/core/src/com/ilotterytea/maxoning/screens/GameScreen.java
@@ -180,14 +180,14 @@ public class GameScreen implements Screen, InputProcessor {
stage.addActor(maxon);
- DebugLabel debugLabel = new DebugLabel(skin);
+ DebugInfo debugInfo = new DebugInfo(skin, game.locale);
- debugLabel.setPosition(
+ debugInfo.setPosition(
8,
- (Gdx.graphics.getHeight() - debugLabel.getHeight()) - 8
+ (Gdx.graphics.getHeight() - debugInfo.getHeight()) - 8
);
- stage.addActor(debugLabel);
+ if (game.prefs.getBoolean("debug")) stage.addActor(debugInfo);
notEnoughPointsDialog = new Dialog(game.locale.TranslatableText("dialogs.not_enough_points"), skin, "dialog");
diff --git a/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java b/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java
index 6c40ecd..c5706ad 100644
--- a/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java
+++ b/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java
@@ -48,6 +48,7 @@ public class MenuScreen implements Screen {
TextButton startBtn;
ImageButton rArrowBtn, lArrowBtn;
Label savLabel;
+ final DebugInfo debugInfo;
MaxonSavegame sav;
@@ -145,10 +146,10 @@ public class MenuScreen implements Screen {
stage.addActor(brandLogo);
- // Debug label:
- DebugLabel debug = new DebugLabel(skin);
- debug.setPosition(4, stage.getHeight() - debug.getHeight() - 4);
- stage.addActor(debug);
+ // Debug info:
+ debugInfo = new DebugInfo(skin, game.locale);
+ debugInfo.setPosition(4, stage.getHeight() - debugInfo.getHeight() - 4);
+ if (game.prefs.getBoolean("debug")) stage.addActor(debugInfo);
Gdx.input.setInputProcessor(new InputMultiplexer(stage));
@@ -284,6 +285,9 @@ public class MenuScreen implements Screen {
value = !value;
+ if (value) stage.addActor(debugInfo);
+ else debugInfo.remove();
+
debButton.getLabel().setText((value) ? "ON" : "OFF");
}
});
diff --git a/core/src/com/ilotterytea/maxoning/ui/DebugInfo.kt b/core/src/com/ilotterytea/maxoning/ui/DebugInfo.kt
new file mode 100644
index 0000000..38a2f2b
--- /dev/null
+++ b/core/src/com/ilotterytea/maxoning/ui/DebugInfo.kt
@@ -0,0 +1,33 @@
+package com.ilotterytea.maxoning.ui
+
+import com.badlogic.gdx.Gdx
+import com.badlogic.gdx.scenes.scene2d.ui.Label
+import com.badlogic.gdx.scenes.scene2d.ui.Skin
+import com.badlogic.gdx.scenes.scene2d.ui.Table
+import com.badlogic.gdx.utils.Align
+import com.ilotterytea.maxoning.utils.I18N
+
+/**
+ * Debug information.
+ * @since a_1.0
+ * @author ilotterytea
+ */
+class DebugInfo(skin: Skin, locale: I18N) : Table() {
+ private val i18n = locale
+ private var fps: Label
+
+ init {
+ // Frames per second:
+ fps = Label(i18n.FormattedText("debug.fps", Gdx.graphics.framesPerSecond.toString()), skin, "debug")
+ this.add(fps).row()
+
+ this.align(Align.top)
+ this.height = 100f
+ this.width = 100f
+ }
+
+ override fun act(delta: Float) {
+ super.act(delta)
+ fps.setText(i18n.FormattedText("debug.fps", Gdx.graphics.framesPerSecond.toString()))
+ }
+} \ No newline at end of file
diff --git a/core/src/com/ilotterytea/maxoning/ui/DebugLabel.java b/core/src/com/ilotterytea/maxoning/ui/DebugLabel.java
deleted file mode 100644
index 5335450..0000000
--- a/core/src/com/ilotterytea/maxoning/ui/DebugLabel.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package com.ilotterytea.maxoning.ui;
-
-import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.graphics.Color;
-import com.badlogic.gdx.scenes.scene2d.ui.Label;
-import com.badlogic.gdx.scenes.scene2d.ui.Skin;
-
-public class DebugLabel extends Label {
- private static final String str_placeholder = "%s fps";
-
- public DebugLabel(Skin skin) {
- super(String.format(str_placeholder, Gdx.graphics.getFramesPerSecond()), skin, "debug");
- super.setColor(Color.LIME);
- }
-
- @Override public void act(float delta) {
- super.setText(String.format(str_placeholder, Gdx.graphics.getFramesPerSecond()));
- }
-}