Skip to content

Commit

Permalink
Merge pull request #673 from julien4215/fix/analysis-screen-index
Browse files Browse the repository at this point in the history
Change index for analysis that doesn't start from chess initial position
  • Loading branch information
veloce authored May 12, 2024
2 parents 9ddf27d + c258da4 commit 7d92683
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/src/model/analysis/analysis_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ class AnalysisController extends _$AnalysisController {
onVisitNode: (root, branch, isMainline) {
if (isMainline &&
options.initialMoveCursor != null &&
branch.position.ply <= options.initialMoveCursor!) {
branch.position.ply <=
root.position.ply + options.initialMoveCursor!) {
path = path + branch.id;
lastMove = branch.sanMove.move;
}
Expand Down
7 changes: 6 additions & 1 deletion lib/src/view/analysis/analysis_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1248,6 +1248,11 @@ class AcplChart extends ConsumerWidget {
.select((value) => value.acplChartData),
);

final rootPly = ref.watch(
analysisControllerProvider(pgn, options)
.select((value) => value.root.position.ply),
);

final currentNode = ref.watch(
analysisControllerProvider(pgn, options)
.select((value) => value.currentNode),
Expand Down Expand Up @@ -1329,7 +1334,7 @@ class AcplChart extends ConsumerWidget {
verticalLines: [
if (isOnMainline)
VerticalLine(
x: (currentNode.position.ply - 1).toDouble(),
x: (currentNode.position.ply - 1 - rootPly).toDouble(),
color: mainLineColor,
strokeWidth: 1.0,
),
Expand Down

0 comments on commit 7d92683

Please sign in to comment.