Clean up dead code (#363)
* Clean up dead code We had a lot of old code-behind comments. I've removed them for better readability of the code and easier maintenance. (when searching stiff in the code, it sometimes brings you to dead code ...) Also, the methods on the gamePage observing the routes does only log "/" as we don't use namedRoutes. * Update position.dart Co-authored-by: Calcitem <calcitem@outlook.com>
This commit is contained in:
parent
3bad4f0942
commit
ec9ec27c05
|
@ -161,8 +161,7 @@ class Position {
|
|||
recorder = GameRecorder(lastPositionWithRemove: fen());
|
||||
}
|
||||
|
||||
/// fen() returns a FEN representation of the position.
|
||||
|
||||
/// Return a FEN representation of the position.
|
||||
String fen() {
|
||||
final buffer = StringBuffer();
|
||||
|
||||
|
@ -1074,11 +1073,6 @@ class Position {
|
|||
Future<String> gotoHistory(HistoryMove move, [int? index]) async {
|
||||
final int moveIndex = _gotoHistoryIndex(move, index);
|
||||
|
||||
//if (recorder == null) {
|
||||
// debugPrint("[goto] recorder is null.");
|
||||
// return "null";
|
||||
//}
|
||||
|
||||
if (recorder.cur == moveIndex) {
|
||||
debugPrint("[goto] cur is equal to moveIndex.");
|
||||
return "equal";
|
||||
|
@ -1169,10 +1163,7 @@ class Position {
|
|||
final buffer = StringBuffer();
|
||||
int posAfterLastRemove = 0;
|
||||
|
||||
//debugPrint("recorder.movesCount = ${recorder.movesCount}");
|
||||
|
||||
for (i = recorder.movesCount - 1; i >= 0; i--) {
|
||||
//if (recorder.moveAt(i).type == MoveType.remove) break;
|
||||
if (recorder.moveAt(i).move[0] == '-') break;
|
||||
}
|
||||
|
||||
|
@ -1180,18 +1171,14 @@ class Position {
|
|||
posAfterLastRemove = i + 1;
|
||||
}
|
||||
|
||||
//debugPrint("[movesSinceLastRemove] posAfterLastRemove = $posAfterLastRemove");
|
||||
|
||||
for (int i = posAfterLastRemove; i < recorder.movesCount; i++) {
|
||||
buffer.write(" ${recorder.moveAt(i).move}");
|
||||
}
|
||||
|
||||
final String moves = buffer.toString();
|
||||
//debugPrint("moves = $moves");
|
||||
|
||||
final idx = moves.indexOf('-(');
|
||||
if (idx != -1) {
|
||||
//debugPrint("moves[$idx] is -(");
|
||||
assert(false);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//import 'dart:typed_data';
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:fluentui_system_icons/fluentui_system_icons.dart';
|
||||
|
@ -39,7 +37,6 @@ import 'package:sanmill/shared/dialog.dart';
|
|||
import 'package:sanmill/shared/picker.dart';
|
||||
import 'package:sanmill/shared/snackbar.dart';
|
||||
import 'package:sanmill/shared/theme/app_theme.dart';
|
||||
//import 'package:screen_recorder/screen_recorder.dart';
|
||||
import 'package:stack_trace/stack_trace.dart';
|
||||
|
||||
part 'package:sanmill/screens/game_page/board.dart';
|
||||
|
@ -71,12 +68,6 @@ class _GamePageState extends State<GamePage>
|
|||
bool isReady = false;
|
||||
bool isGoingToHistory = false;
|
||||
late Timer timer;
|
||||
/*
|
||||
ScreenRecorderController screenRecorderController = ScreenRecorderController(
|
||||
pixelRatio: 1.0,
|
||||
skipFramesBetweenCaptures: 0,
|
||||
);
|
||||
*/
|
||||
late AnimationController _animationController;
|
||||
late Animation<double> animation;
|
||||
bool disposed = false;
|
||||
|
@ -487,12 +478,6 @@ class _GamePageState extends State<GamePage>
|
|||
position.recorder.prune();
|
||||
position.recorder.moveIn(m, position);
|
||||
|
||||
/*
|
||||
if (LocalDatabaseService.preferences.screenReaderSupport && m.notation != null) {
|
||||
showSnackBar(context, S.of(context).human + ": " + m.notation!);
|
||||
}
|
||||
*/
|
||||
|
||||
setState(() {});
|
||||
|
||||
if (position.winner == PieceColor.nobody) {
|
||||
|
@ -696,88 +681,6 @@ class _GamePageState extends State<GamePage>
|
|||
});
|
||||
}
|
||||
|
||||
/*
|
||||
onStartRecordingButtonPressed() async {
|
||||
Navigator.pop(context);
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: true,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text(
|
||||
S.of(context).appName,
|
||||
style: TextStyle(
|
||||
color: AppTheme.dialogTitleColor,
|
||||
fontSize: LocalDatabaseService.display.fontSize + 4,
|
||||
),
|
||||
),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
S.of(context).experimental,
|
||||
style: TextStyle(
|
||||
fontSize: LocalDatabaseService.display.fontSize,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: Text(
|
||||
S.of(context).ok,
|
||||
style: TextStyle(
|
||||
fontSize: LocalDatabaseService.display.fontSize,
|
||||
),
|
||||
),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
screenRecorderController.start();
|
||||
showSnackBar(
|
||||
S.of(context).recording,
|
||||
duration: Duration(seconds: 1 << 31),
|
||||
);
|
||||
}
|
||||
|
||||
onStopRecordingButtonPressed() async {
|
||||
Navigator.pop(context);
|
||||
screenRecorderController.stop();
|
||||
showSnackBar(
|
||||
S.of(context).stopRecording,
|
||||
duration: Duration(seconds: 2),
|
||||
);
|
||||
}
|
||||
|
||||
onShowRecordingButtonPressed() async {
|
||||
Navigator.pop(context);
|
||||
showSnackBar(
|
||||
S.of(context).pleaseWait,
|
||||
duration: Duration(seconds: 1 << 31),
|
||||
);
|
||||
var gif = await screenRecorderController.export();
|
||||
ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
||||
if (gif == null) {
|
||||
showSnackBar(S.of(context).noRecording);
|
||||
return;
|
||||
}
|
||||
|
||||
var image = Image.memory(
|
||||
Uint8List.fromList(gif),
|
||||
);
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(backgroundColor: Colors.black, content: image);
|
||||
},
|
||||
);
|
||||
}
|
||||
*/
|
||||
|
||||
Future<void> onAutoReplayButtonPressed() async {
|
||||
Navigator.pop(context);
|
||||
|
||||
|
@ -831,56 +734,6 @@ class _GamePageState extends State<GamePage>
|
|||
),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
/*
|
||||
SizedBox(height: AppTheme.sizedBoxHeight),
|
||||
LocalDatabaseService.experimentsEnabled
|
||||
? SimpleDialogOption(
|
||||
child: Text(
|
||||
S.of(context).startRecording,
|
||||
style: AppTheme.simpleDialogOptionTextStyle,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
onPressed: onStartRecordingButtonPressed,
|
||||
)
|
||||
: SizedBox(height: 1),
|
||||
LocalDatabaseService.experimentsEnabled
|
||||
? SizedBox(height: AppTheme.sizedBoxHeight)
|
||||
: SizedBox(height: 1),
|
||||
LocalDatabaseService.experimentsEnabled
|
||||
? SimpleDialogOption(
|
||||
child: Text(
|
||||
S.of(context).stopRecording,
|
||||
style: AppTheme.simpleDialogOptionTextStyle,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
onPressed: onStopRecordingButtonPressed,
|
||||
)
|
||||
: SizedBox(height: 1),
|
||||
LocalDatabaseService.experimentsEnabled
|
||||
? SizedBox(height: AppTheme.sizedBoxHeight)
|
||||
: SizedBox(height: 1),
|
||||
LocalDatabaseService.experimentsEnabled
|
||||
? SimpleDialogOption(
|
||||
child: Text(
|
||||
S.of(context).showRecording,
|
||||
style: AppTheme.simpleDialogOptionTextStyle,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
onPressed: onShowRecordingButtonPressed,
|
||||
)
|
||||
: SizedBox(height: 1),
|
||||
*/
|
||||
/*
|
||||
SizedBox(height: AppTheme.sizedBoxHeight),
|
||||
SimpleDialogOption(
|
||||
child: Text(
|
||||
S.of(context).autoReplay,
|
||||
style: AppTheme.simpleDialogOptionTextStyle,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
onPressed: onAutoReplayButtonPressed,
|
||||
),
|
||||
*/
|
||||
],
|
||||
),
|
||||
),
|
||||
|
@ -1017,17 +870,6 @@ class _GamePageState extends State<GamePage>
|
|||
|
||||
if (mounted) {
|
||||
final pos = gameInstance.position;
|
||||
/*
|
||||
String us = "";
|
||||
String them = "";
|
||||
if (pos.side == PieceColor.white) {
|
||||
us = S.of(context).player1;
|
||||
them = S.of(context).player2;
|
||||
} else if (pos.side == PieceColor.black) {
|
||||
us = S.of(context).player2;
|
||||
them = S.of(context).player1;
|
||||
}
|
||||
*/
|
||||
|
||||
late final String text;
|
||||
final lastEffectiveMove = pos.recorder.lastEffectiveMove;
|
||||
|
@ -1195,8 +1037,6 @@ class _GamePageState extends State<GamePage>
|
|||
}
|
||||
|
||||
String getGameOverReasonString(GameOverReason? reason, String? winner) {
|
||||
//String winnerStr =
|
||||
// winner == Color.white ? S.of(context).white : S.of(context).black;
|
||||
final String loserStr =
|
||||
winner == PieceColor.white ? S.of(context).black : S.of(context).white;
|
||||
|
||||
|
@ -1829,18 +1669,6 @@ class _GamePageState extends State<GamePage>
|
|||
],
|
||||
),
|
||||
),
|
||||
/*
|
||||
body: Column(children: <Widget>[
|
||||
header,
|
||||
ScreenRecorder(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: MediaQuery.of(context).size.width,
|
||||
controller: screenRecorderController,
|
||||
child: board,
|
||||
),
|
||||
toolbar
|
||||
]),
|
||||
*/
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1854,28 +1682,4 @@ class _GamePageState extends State<GamePage>
|
|||
LocalDatabaseService.listenPreferences.removeListener(_refeshEngine);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void didPush() {
|
||||
final route = ModalRoute.of(context)!.settings.name;
|
||||
debugPrint('$_tag Game Page didPush route: $route');
|
||||
}
|
||||
|
||||
@override
|
||||
void didPopNext() {
|
||||
final route = ModalRoute.of(context)!.settings.name;
|
||||
debugPrint('$_tag Game Page didPopNext route: $route');
|
||||
}
|
||||
|
||||
@override
|
||||
void didPushNext() {
|
||||
final route = ModalRoute.of(context)!.settings.name;
|
||||
debugPrint('$_tag Game Page didPushNext route: $route');
|
||||
}
|
||||
|
||||
@override
|
||||
void didPop() {
|
||||
final route = ModalRoute.of(context)!.settings.name;
|
||||
debugPrint('$_tag Game Page didPop route: $route');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,15 +49,6 @@ class _PointStyleModal extends StatelessWidget {
|
|||
value: 1,
|
||||
onChanged: onChanged,
|
||||
),
|
||||
/*
|
||||
RadioListTile(
|
||||
activeColor: AppTheme.switchListTileActiveColor,
|
||||
title: const Text(S.of(context).hollow),
|
||||
groupValue: LocalDatabaseService.display.pointStyle,
|
||||
value: 2,
|
||||
onChanged: callback,
|
||||
),
|
||||
*/
|
||||
],
|
||||
),
|
||||
);
|
||||
|
|
|
@ -137,7 +137,7 @@ class BoardPainter extends PiecesBasePainter {
|
|||
|
||||
final offset = (boardWidth - squareWidth * 6) / 4;
|
||||
|
||||
/* Show notations "a b c d e f" on board */
|
||||
// Show notations "a b c d e f" on board
|
||||
|
||||
if (LocalDatabaseService.preferences.developerMode) {
|
||||
notationPainterV.paint(
|
||||
|
@ -157,7 +157,7 @@ class BoardPainter extends PiecesBasePainter {
|
|||
),
|
||||
);
|
||||
|
||||
/* Show notations "1 2 3 4 5 6 7" on board */
|
||||
// Show notations "1 2 3 4 5 6 7" on board
|
||||
|
||||
notationPainterH.paint(
|
||||
canvas,
|
||||
|
|
|
@ -93,7 +93,6 @@ class PiecesPainter extends PiecesBasePainter {
|
|||
int focusIndex = invalidIndex,
|
||||
int blurIndex = invalidIndex,
|
||||
}) {
|
||||
//
|
||||
final left = offsetX;
|
||||
final top = offsetY;
|
||||
|
||||
|
@ -111,8 +110,7 @@ class PiecesPainter extends PiecesBasePainter {
|
|||
|
||||
if (piece == Piece.noPiece) continue;
|
||||
|
||||
final pos =
|
||||
Offset(left+ squareWidth* col, top+ squareWidth * row);
|
||||
final pos = Offset(left + squareWidth * col, top + squareWidth * row);
|
||||
final animated = focusIndex == index;
|
||||
|
||||
piecesToDraw
|
||||
|
@ -129,19 +127,11 @@ class PiecesPainter extends PiecesBasePainter {
|
|||
|
||||
paint.style = PaintingStyle.fill;
|
||||
|
||||
/*
|
||||
final textStyle = TextStyle(
|
||||
color: ColorConst.PieceTextColor,
|
||||
fontSize: pieceSide * 0.8,
|
||||
height: 1.0,
|
||||
);
|
||||
*/
|
||||
|
||||
for (final pps in piecesToDraw) {
|
||||
final pieceRadius = pieceWidth/ 2;
|
||||
final pieceRadius = pieceWidth / 2;
|
||||
final pieceInnerRadius = pieceRadius * 0.99;
|
||||
|
||||
final animatedPieceRadius = animatedPieceWidth/ 2;
|
||||
final animatedPieceRadius = animatedPieceWidth / 2;
|
||||
final animatedPieceInnerRadius = animatedPieceRadius * 0.99;
|
||||
|
||||
// Draw Border of Piece
|
||||
|
@ -189,27 +179,10 @@ class PiecesPainter extends PiecesBasePainter {
|
|||
|
||||
// draw focus and blur position
|
||||
|
||||
final int row = focusIndex~/ 7;
|
||||
final int row = focusIndex ~/ 7;
|
||||
final int column = focusIndex % 7;
|
||||
|
||||
if (focusIndex != invalidIndex) {
|
||||
/*
|
||||
focusPositionColor = Color.fromARGB(
|
||||
(LocalDatabaseService.colorSettings.whitePieceColor).alpha +
|
||||
LocalDatabaseService.colorSettings.blackPieceColor).alpha) ~/
|
||||
2,
|
||||
(LocalDatabaseService.colorSettings.whitePieceColor).red +
|
||||
LocalDatabaseService.colorSettings.blackPieceColor).red) ~/
|
||||
2,
|
||||
(LocalDatabaseService.colorSettings.whitePieceColor).green +
|
||||
LocalDatabaseService.colorSettings.blackPieceColor).green) ~/
|
||||
2,
|
||||
(LocalDatabaseService.colorSettings.whitePieceColor).blue +
|
||||
LocalDatabaseService.colorSettings.blackPieceColor).blue) ~/
|
||||
2)
|
||||
.withOpacity(0.5);
|
||||
*/
|
||||
|
||||
focusPositionColor =
|
||||
LocalDatabaseService.colorSettings.pieceHighlightColor;
|
||||
|
||||
|
@ -218,22 +191,22 @@ class PiecesPainter extends PiecesBasePainter {
|
|||
paint.strokeWidth = 2;
|
||||
|
||||
canvas.drawCircle(
|
||||
Offset(left+ column * squareWidth, top+ row * squareWidth),
|
||||
animatedPieceWidth/ 2,
|
||||
Offset(left + column * squareWidth, top + row * squareWidth),
|
||||
animatedPieceWidth / 2,
|
||||
paint,
|
||||
);
|
||||
}
|
||||
|
||||
if (blurIndex != invalidIndex) {
|
||||
final row = blurIndex~/ 7;
|
||||
final row = blurIndex ~/ 7;
|
||||
final column = blurIndex % 7;
|
||||
|
||||
paint.color = blurPositionColor;
|
||||
paint.style = PaintingStyle.fill;
|
||||
|
||||
canvas.drawCircle(
|
||||
Offset(left+ column * squareWidth, top+ row * squareWidth),
|
||||
animatedPieceWidth/ 2 * 0.8,
|
||||
Offset(left + column * squareWidth, top + row * squareWidth),
|
||||
animatedPieceWidth / 2 * 0.8,
|
||||
paint,
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue