Skip to content
Snippets Groups Projects
Commit 45fe7ba0 authored by Benoît Harrault's avatar Benoît Harrault
Browse files

Merge branch '80-restore-save-resume-game-feature' into 'master'

Resolve "Restore "save / resume game" feature"

Closes #80

See merge request !76
parents 48f25e35 54e43c60
No related branches found
No related tags found
1 merge request!76Resolve "Restore "save / resume game" feature"
Pipeline #5604 passed
Showing with 100 additions and 6 deletions
org.gradle.jvmargs=-Xmx1536M org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true android.useAndroidX=true
android.enableJetifier=true android.enableJetifier=true
app.versionName=0.1.19 app.versionName=0.1.20
app.versionCode=68 app.versionCode=69
assets/icons/button_delete_saved_game.png

5.68 KiB

assets/icons/button_resume_game.png

3.57 KiB

Restore delete/resume saved game.
Restauration de la suppression ou reprise de partie sauvegardée.
...@@ -18,6 +18,8 @@ ICON_SIZE=192 ...@@ -18,6 +18,8 @@ ICON_SIZE=192
AVAILABLE_GAME_IMAGES=" AVAILABLE_GAME_IMAGES="
button_back button_back
button_start button_start
button_resume_game
button_delete_saved_game
button_help button_help
button_show_conflicts button_show_conflicts
game_win game_win
......
<?xml version="1.0" encoding="UTF-8"?>
<svg enable-background="new 0 0 100 100" version="1.1" viewBox="0 0 93.665 93.676" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"><rect x=".44662" y=".89101" width="92.772" height="91.894" ry="11.689" fill="#ee7d49" stroke="#fff" stroke-width=".238"/><path d="m61.07 35.601-1.7399 27.837c-0.13442 2.1535-1.9205 3.8312-4.0781 3.8312h-16.84c-2.1576 0-3.9437-1.6777-4.0781-3.8312l-1.7399-27.837h-2.6176c-0.84621 0-1.5323-0.68613-1.5323-1.5323 0-0.84655 0.68613-1.5323 1.5323-1.5323h33.711c0.84621 0 1.5323 0.68578 1.5323 1.5323 0 0.84621-0.68613 1.5323-1.5323 1.5323zm-3.2617 0h-21.953l1.4715 26.674c0.05985 1.0829 0.95531 1.9305 2.0403 1.9305h14.929c1.085 0 1.9804-0.84757 2.0403-1.9305zm-10.977 3.0647c0.78977 0 1.4301 0.6403 1.4301 1.4301v19.614c0 0.78977-0.6403 1.4301-1.4301 1.4301s-1.4301-0.6403-1.4301-1.4301v-19.614c0-0.78977 0.6403-1.4301 1.4301-1.4301zm-6.1293 0c0.80004 0 1.4588 0.62935 1.495 1.4286l0.89647 19.719c0.03182 0.70016-0.50998 1.2933-1.2101 1.3255-0.01915 7.02e-4 -0.03831 1e-3 -0.05781 1e-3 -0.74462 0-1.3596-0.58215-1.4003-1.3261l-1.0757-19.719c-0.0407-0.74701 0.53188-1.3852 1.2786-1.4259 0.02462-0.0014 0.04926-2e-3 0.07388-2e-3zm12.259 0c0.74804 0 1.3541 0.60609 1.3541 1.3541 0 0.02462-3.28e-4 0.04926-0.0017 0.07388l-1.0703 19.618c-0.04379 0.80106-0.70597 1.4281-1.5081 1.4281-0.74804 0-1.3541-0.60609-1.3541-1.3541 0-0.02462 3.49e-4 -0.04925 0.0017-0.07388l1.0703-19.618c0.04379-0.80106 0.70597-1.4281 1.5081-1.4281zm-10.216-12.259h8.1728c2.2567 0 4.086 1.8293 4.086 4.086v2.0433h-16.344v-2.0433c0-2.2567 1.8293-4.086 4.086-4.086zm0.20453 3.0647c-0.67725 0-1.2259 0.54863-1.2259 1.2259v1.8388h10.215v-1.8388c0-0.67725-0.54863-1.2259-1.2259-1.2259z" fill="#fff" fill-rule="evenodd" stroke="#bd4812" stroke-width=".75383"/></svg>
<?xml version="1.0" encoding="UTF-8"?>
<svg enable-background="new 0 0 100 100" version="1.1" viewBox="0 0 93.665 93.676" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"><rect x=".44662" y=".89101" width="92.772" height="91.894" ry="11.689" fill="#49a1ee" stroke="#fff" stroke-width=".238"/><path d="m39.211 31.236c-0.84086-0.84489-2.9911-0.84489-2.9911 0v34.329c0 0.84594 2.1554 0.84594 2.9993 0l28.178-15.637c0.84392-0.84086 0.85812-2.2091 0.01623-3.053z" fill="#fefeff" stroke="#105ca1" stroke-linecap="round" stroke-linejoin="round" stroke-width="6.1726"/><path d="m40.355 33.714c-0.71948-0.72294-2.5594-0.72294-2.5594 0v29.373c0 0.72383 1.8442 0.72383 2.5663 0l24.11-13.38c0.7221-0.71948 0.73426-1.8902 0.01389-2.6124z" fill="#fefeff" stroke="#feffff" stroke-linecap="round" stroke-linejoin="round" stroke-width="3.225"/><path d="m28.369 66.919v-37.591" fill="#105ca2" stroke="#105ca2" stroke-linecap="round" stroke-width="4.0337"/></svg>
...@@ -34,6 +34,7 @@ class GameCubit extends HydratedCubit<GameState> { ...@@ -34,6 +34,7 @@ class GameCubit extends HydratedCubit<GameState> {
board: state.game.board, board: state.game.board,
solvedBoard: state.game.solvedBoard, solvedBoard: state.game.solvedBoard,
isRunning: state.game.isRunning, isRunning: state.game.isRunning,
isStarted: state.game.isStarted,
isFinished: state.game.isFinished, isFinished: state.game.isFinished,
blockSizeHorizontal: state.game.blockSizeHorizontal, blockSizeHorizontal: state.game.blockSizeHorizontal,
blockSizeVertical: state.game.blockSizeVertical, blockSizeVertical: state.game.blockSizeVertical,
...@@ -86,6 +87,7 @@ class GameCubit extends HydratedCubit<GameState> { ...@@ -86,6 +87,7 @@ class GameCubit extends HydratedCubit<GameState> {
isFixed: false, isFixed: false,
), ),
); );
state.game.isStarted = true;
refresh(); refresh();
} }
...@@ -125,6 +127,17 @@ class GameCubit extends HydratedCubit<GameState> { ...@@ -125,6 +127,17 @@ class GameCubit extends HydratedCubit<GameState> {
refresh(); refresh();
} }
void resumeSavedGame() {
state.game.isRunning = true;
refresh();
}
void deleteSavedGame() {
state.game.isRunning = false;
state.game.isFinished = true;
refresh();
}
void updateAnimationInProgress(bool animationInProgress) { void updateAnimationInProgress(bool animationInProgress) {
state.game.animationInProgress = animationInProgress; state.game.animationInProgress = animationInProgress;
refresh(); refresh();
......
...@@ -19,6 +19,7 @@ class Game { ...@@ -19,6 +19,7 @@ class Game {
required this.board, required this.board,
required this.solvedBoard, required this.solvedBoard,
required this.isRunning, required this.isRunning,
required this.isStarted,
required this.isFinished, required this.isFinished,
this.shuffledCellValues = const [], this.shuffledCellValues = const [],
this.boardConflicts = const [], this.boardConflicts = const [],
...@@ -37,6 +38,7 @@ class Game { ...@@ -37,6 +38,7 @@ class Game {
final GlobalSettings globalSettings; final GlobalSettings globalSettings;
bool isRunning = false; bool isRunning = false;
bool isStarted = false;
bool isFinished = false; bool isFinished = false;
int blockSizeVertical = 0; int blockSizeVertical = 0;
...@@ -65,6 +67,7 @@ class Game { ...@@ -65,6 +67,7 @@ class Game {
solvedBoard: Board.createEmpty(), solvedBoard: Board.createEmpty(),
shuffledCellValues: [], shuffledCellValues: [],
isRunning: false, isRunning: false,
isStarted: false,
isFinished: false, isFinished: false,
givenTipsCount: 0, givenTipsCount: 0,
blockSizeHorizontal: 0, blockSizeHorizontal: 0,
...@@ -133,6 +136,7 @@ class Game { ...@@ -133,6 +136,7 @@ class Game {
board: board, board: board,
solvedBoard: solvedBoard, solvedBoard: solvedBoard,
isRunning: true, isRunning: true,
isStarted: false,
isFinished: false, isFinished: false,
boardConflicts: nonConflictedBoard, boardConflicts: nonConflictedBoard,
shuffledCellValues: shuffledCellValues, shuffledCellValues: shuffledCellValues,
...@@ -384,6 +388,7 @@ class Game { ...@@ -384,6 +388,7 @@ class Game {
printlog(' shuffledCellValues: $shuffledCellValues'); printlog(' shuffledCellValues: $shuffledCellValues');
printlog(''); printlog('');
printlog(' isRunning: $isRunning'); printlog(' isRunning: $isRunning');
printlog(' isStarted: $isStarted');
printlog(' isFinished: $isFinished'); printlog(' isFinished: $isFinished');
printlog(' selectedCell: ${selectedCell?.toString() ?? ''}'); printlog(' selectedCell: ${selectedCell?.toString() ?? ''}');
printlog(' showConflicts: $showConflicts'); printlog(' showConflicts: $showConflicts');
......
...@@ -6,11 +6,15 @@ import 'package:sudoku/config/default_global_settings.dart'; ...@@ -6,11 +6,15 @@ import 'package:sudoku/config/default_global_settings.dart';
import 'package:sudoku/cubit/settings_game_cubit.dart'; import 'package:sudoku/cubit/settings_game_cubit.dart';
import 'package:sudoku/cubit/settings_global_cubit.dart'; import 'package:sudoku/cubit/settings_global_cubit.dart';
import 'package:sudoku/ui/painters/parameter_painter.dart'; import 'package:sudoku/ui/painters/parameter_painter.dart';
import 'package:sudoku/ui/widgets/button_delete_saved_game.dart';
import 'package:sudoku/ui/widgets/button_game_start_new.dart'; import 'package:sudoku/ui/widgets/button_game_start_new.dart';
import 'package:sudoku/ui/widgets/button_resume_saved_game.dart';
import 'package:sudoku/ui/widgets/parameter_image.dart'; import 'package:sudoku/ui/widgets/parameter_image.dart';
class ScreenParameters extends StatelessWidget { class ScreenParameters extends StatelessWidget {
const ScreenParameters({super.key}); const ScreenParameters({super.key, required this.canResume});
final bool canResume;
final double separatorHeight = 8.0; final double separatorHeight = 8.0;
...@@ -32,7 +36,13 @@ class ScreenParameters extends StatelessWidget { ...@@ -32,7 +36,13 @@ class ScreenParameters extends StatelessWidget {
} }
lines.add(SizedBox(height: separatorHeight)); lines.add(SizedBox(height: separatorHeight));
lines.add(const Expanded(child: StartNewGameButton())); lines.add(Expanded(
child: canResume ? const ResumeSavedGameButton() : const StartNewGameButton(),
));
lines.add(SizedBox.square(
dimension: MediaQuery.of(context).size.width / 4,
child: canResume ? const DeleteSavedGameButton() : const SizedBox.shrink(),
));
lines.add(SizedBox(height: separatorHeight)); lines.add(SizedBox(height: separatorHeight));
// Global settings // Global settings
......
...@@ -22,7 +22,11 @@ class SkeletonScreen extends StatelessWidget { ...@@ -22,7 +22,11 @@ class SkeletonScreen extends StatelessWidget {
), ),
child: BlocBuilder<GameCubit, GameState>( child: BlocBuilder<GameCubit, GameState>(
builder: (BuildContext context, GameState gameState) { builder: (BuildContext context, GameState gameState) {
return gameState.game.isRunning ? const ScreenGame() : const ScreenParameters(); return gameState.game.isRunning
? const ScreenGame()
: ScreenParameters(
canResume: gameState.game.isStarted && !gameState.game.isFinished,
);
}, },
), ),
), ),
......
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:sudoku/cubit/game_cubit.dart';
class DeleteSavedGameButton extends StatelessWidget {
const DeleteSavedGameButton({super.key});
@override
Widget build(BuildContext context) {
return BlocBuilder<GameCubit, GameState>(
builder: (BuildContext context, GameState gameState) {
final GameCubit gameCubit = BlocProvider.of<GameCubit>(context);
return TextButton(
child: const Image(
image: AssetImage('assets/icons/button_delete_saved_game.png'),
fit: BoxFit.fill,
),
onPressed: () {
gameCubit.deleteSavedGame();
},
);
},
);
}
}
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:sudoku/cubit/game_cubit.dart';
class ResumeSavedGameButton extends StatelessWidget {
const ResumeSavedGameButton({super.key});
@override
Widget build(BuildContext context) {
return BlocBuilder<GameCubit, GameState>(
builder: (BuildContext context, GameState gameState) {
final GameCubit gameCubit = BlocProvider.of<GameCubit>(context);
return TextButton(
child: const Image(
image: AssetImage('assets/icons/button_resume_game.png'),
fit: BoxFit.fill,
),
onPressed: () {
gameCubit.resumeSavedGame();
},
);
},
);
}
}
...@@ -3,7 +3,7 @@ description: A sudoku game application. ...@@ -3,7 +3,7 @@ description: A sudoku game application.
publish_to: 'none' publish_to: 'none'
version: 0.1.19+68 version: 0.1.20+69
environment: environment:
sdk: '^3.0.0' sdk: '^3.0.0'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment