From e5cae1fd2ae2c9ba9b8c7836f210e5c5fef402bf Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Fri, 25 Oct 2024 22:57:14 +0500 Subject: upd: use hide() method to save game --- .../src/kz/ilotterytea/maxon/screens/SlotsMinigameScreen.kt | 13 ++----------- core/src/kz/ilotterytea/maxon/screens/game/GameScreen.java | 8 ++++---- 2 files changed, 6 insertions(+), 15 deletions(-) (limited to 'core/src/kz/ilotterytea/maxon/screens') diff --git a/core/src/kz/ilotterytea/maxon/screens/SlotsMinigameScreen.kt b/core/src/kz/ilotterytea/maxon/screens/SlotsMinigameScreen.kt index 18adb38..bd164c3 100644 --- a/core/src/kz/ilotterytea/maxon/screens/SlotsMinigameScreen.kt +++ b/core/src/kz/ilotterytea/maxon/screens/SlotsMinigameScreen.kt @@ -1,9 +1,6 @@ package kz.ilotterytea.maxon.screens import com.badlogic.gdx.Gdx -import com.badlogic.gdx.Input -import com.badlogic.gdx.InputMultiplexer -import com.badlogic.gdx.InputProcessor import com.badlogic.gdx.Screen import com.badlogic.gdx.assets.AssetManager import com.badlogic.gdx.audio.Music @@ -14,20 +11,13 @@ import com.badlogic.gdx.graphics.g2d.TextureAtlas import com.badlogic.gdx.scenes.scene2d.Actor import com.badlogic.gdx.scenes.scene2d.InputEvent import com.badlogic.gdx.scenes.scene2d.Stage -import com.badlogic.gdx.scenes.scene2d.ui.Image -import com.badlogic.gdx.scenes.scene2d.ui.Label -import com.badlogic.gdx.scenes.scene2d.ui.Skin -import com.badlogic.gdx.scenes.scene2d.ui.Stack -import com.badlogic.gdx.scenes.scene2d.ui.Table -import com.badlogic.gdx.scenes.scene2d.ui.TextButton -import com.badlogic.gdx.scenes.scene2d.ui.TextField +import com.badlogic.gdx.scenes.scene2d.ui.* import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener import com.badlogic.gdx.scenes.scene2d.utils.ClickListener import com.badlogic.gdx.utils.Align import com.badlogic.gdx.utils.Timer import com.badlogic.gdx.utils.Timer.Task import com.badlogic.gdx.utils.viewport.FitViewport -import com.badlogic.gdx.utils.viewport.ScreenViewport import kz.ilotterytea.maxon.MaxonGame import kz.ilotterytea.maxon.localization.LineId import kz.ilotterytea.maxon.player.Savegame @@ -396,6 +386,7 @@ class SlotsMinigameScreen : Screen { } override fun hide() { + savegame.save() dispose() } diff --git a/core/src/kz/ilotterytea/maxon/screens/game/GameScreen.java b/core/src/kz/ilotterytea/maxon/screens/game/GameScreen.java index 709a1f1..0468307 100644 --- a/core/src/kz/ilotterytea/maxon/screens/game/GameScreen.java +++ b/core/src/kz/ilotterytea/maxon/screens/game/GameScreen.java @@ -265,6 +265,10 @@ public class GameScreen implements Screen, InputProcessor { tasks.clear(); playlist.getPlayingNow().stop(); + + savegame.setElapsedTime((System.currentTimeMillis() - playTimestamp) + savegame.getElapsedTime()); + savegame.save(); + dispose(); } @@ -279,11 +283,7 @@ public class GameScreen implements Screen, InputProcessor { @Override public boolean keyDown(int keycode) { if (Gdx.input.isKeyPressed(Input.Keys.ESCAPE)) { - savegame.setElapsedTime((System.currentTimeMillis() - playTimestamp) + savegame.getElapsedTime()); - savegame.save(); - game.setScreen(new MenuScreen()); - dispose(); } //if (Gdx.input.isKeyPressed(Input.Keys.SPACE) || Gdx.input.isKeyPressed(Input.Keys.UP)) { // displayPointIncrease(); -- cgit v1.2.3