From cbdd277c779117f087525ec1896898623675875a Mon Sep 17 00:00:00 2001 From: Pere Date: Sun, 7 May 2023 19:58:57 +0200 Subject: [PATCH 1/2] Hide next level button when winning last level --- .../com/example/superslidegame/fragments/PopUpFragment.kt | 7 +++++++ .../com/example/superslidegame/game/screen/GameScreen.kt | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/app/src/main/java/com/example/superslidegame/fragments/PopUpFragment.kt b/app/src/main/java/com/example/superslidegame/fragments/PopUpFragment.kt index 97f2da3..6cfe070 100644 --- a/app/src/main/java/com/example/superslidegame/fragments/PopUpFragment.kt +++ b/app/src/main/java/com/example/superslidegame/fragments/PopUpFragment.kt @@ -8,6 +8,7 @@ import android.view.ViewGroup import android.widget.Button import androidx.fragment.app.DialogFragment import com.example.superslidegame.databinding.FragmentPopUpBinding +import com.example.superslidegame.game.screen.GameScreen import com.example.superslidegame.game.screen.SelectLevel import com.example.superslidegame.log.screen.LogScreen @@ -33,6 +34,12 @@ class PopUpFragment : DialogFragment() { val nextLevelButton : Button = binding.nextLevelButtonWin val logButton : Button = binding.logButtonWin + if ((activity as GameScreen).isLastLevel()) { + nextLevelButton.visibility = View.GONE + } else { + nextLevelButton.visibility = View.VISIBLE + } + menuButton.setOnClickListener { activity?.finish() dismiss() diff --git a/app/src/main/java/com/example/superslidegame/game/screen/GameScreen.kt b/app/src/main/java/com/example/superslidegame/game/screen/GameScreen.kt index b28a7b1..7a980fb 100644 --- a/app/src/main/java/com/example/superslidegame/game/screen/GameScreen.kt +++ b/app/src/main/java/com/example/superslidegame/game/screen/GameScreen.kt @@ -118,6 +118,10 @@ class GameScreen : AppCompatActivity() { return gameState.level } + fun isLastLevel() : Boolean { + return gameState.level == GameLevel.MAX_LEVEL + } + /** * getPlayingDifficulty returns the difficulty of the game. */ From 7bd3bdf8180d98733b746a4678b7c62cacaf7fe8 Mon Sep 17 00:00:00 2001 From: Pere Date: Sun, 7 May 2023 19:59:33 +0200 Subject: [PATCH 2/2] Kdoc --- .../java/com/example/superslidegame/game/screen/GameScreen.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/java/com/example/superslidegame/game/screen/GameScreen.kt b/app/src/main/java/com/example/superslidegame/game/screen/GameScreen.kt index 7a980fb..d284889 100644 --- a/app/src/main/java/com/example/superslidegame/game/screen/GameScreen.kt +++ b/app/src/main/java/com/example/superslidegame/game/screen/GameScreen.kt @@ -118,6 +118,9 @@ class GameScreen : AppCompatActivity() { return gameState.level } + /** + * isLastLevel returns true if the game is in the last level. + */ fun isLastLevel() : Boolean { return gameState.level == GameLevel.MAX_LEVEL }