diff options
| -rw-r--r-- | assets/i18n/en_us.json | 1 | ||||
| -rw-r--r-- | assets/i18n/ru_ru.json | 1 | ||||
| -rw-r--r-- | core/src/com/ilotterytea/maxoning/screens/GameScreen.java | 8 | ||||
| -rw-r--r-- | core/src/com/ilotterytea/maxoning/screens/MenuScreen.java | 12 | ||||
| -rw-r--r-- | core/src/com/ilotterytea/maxoning/ui/DebugInfo.kt | 33 | ||||
| -rw-r--r-- | core/src/com/ilotterytea/maxoning/ui/DebugLabel.java | 19 |
6 files changed, 47 insertions, 27 deletions
diff --git a/assets/i18n/en_us.json b/assets/i18n/en_us.json index 810bd10..3454aaf 100644 --- a/assets/i18n/en_us.json +++ b/assets/i18n/en_us.json @@ -1,4 +1,5 @@ { + "debug.fps": "%s FPS", "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.", diff --git a/assets/i18n/ru_ru.json b/assets/i18n/ru_ru.json index 7a3898a..de7942f 100644 --- a/assets/i18n/ru_ru.json +++ b/assets/i18n/ru_ru.json @@ -1,4 +1,5 @@ { + "debug.fps": "%s FPS", "splash.disclaimer": "Эта игра содержит невероятную дозу щекастых \"шерстяных мешков\". Никому не рекомендуется не играть в эту игру. Любое сходство в реальной жизни с представленными изображениями котов - чистое совпадение! Все изображения котов были сгенерированы нейросетью \"NUT-S\".", "menu.last_savegame.found": "Сохранение: %s - %s баллы жмякания (х%s/клик) - %s куплено предметов.", 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())); - } -} |
