Skip to content

Commit

Permalink
Merge pull request #16700 from schlawg/ui-learn-z-index-3d
Browse files Browse the repository at this point in the history
set z-index on 3d pieces in learn
  • Loading branch information
ornicar authored Dec 30, 2024
2 parents 5694d21 + 129d188 commit deef7e1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
3 changes: 2 additions & 1 deletion modules/web/src/main/ui/LearnUi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ final class LearnUi(helpers: Helpers):
"data" -> data,
"pref" -> Json.obj(
"coords" -> ctx.pref.coords,
"destination" -> ctx.pref.destination
"destination" -> ctx.pref.destination,
"is3d" -> ctx.pref.is3d
)
)
)
Expand Down
10 changes: 5 additions & 5 deletions ui/analyse/src/ctrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,11 @@ export default class AnalyseCtrl {
this.jumpToIndex(index);
this.redraw();
});
pubsub.on('board.change', redraw);
pubsub.on('board.change', (is3d: boolean) => {
this.chessground.state.addPieceZIndex = is3d;
this.chessground.redrawAll();
redraw();
});
this.persistence?.merge();
(window as any).lichess.analysis = api(this);
}
Expand Down Expand Up @@ -375,10 +379,6 @@ export default class AnalyseCtrl {
this.setAutoShapes();
if (this.node.shapes) this.chessground.setShapes(this.node.shapes as DrawShape[]);
this.cgVersion.dom = this.cgVersion.js;
pubsub.on('board.change', (is3d: boolean) => {
this.chessground.state.addPieceZIndex = is3d;
this.chessground.redrawAll();
});
};

private onChange: () => void = throttle(300, () => {
Expand Down
1 change: 1 addition & 0 deletions ui/learn/src/chessground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ const makeConfig = (ctrl: RunCtrl): CgConfig => ({
drawable: { enabled: false },
draggable: { enabled: true },
selectable: { enabled: true },
addPieceZIndex: ctrl.pref.is3d,
});
1 change: 1 addition & 0 deletions ui/learn/src/learn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export interface LearnOpts {
export interface LearnPrefs {
coords: Coords;
destination: boolean;
is3d: boolean;
}

interface LearnServerOpts {
Expand Down
5 changes: 5 additions & 0 deletions ui/learn/src/run/runCtrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { clearTimeouts } from '../timeouts';
import { LevelCtrl } from '../levelCtrl';
import { hashNavigate } from '../hashRouting';
import type { WithGround } from '../util';
import { pubsub } from 'common/pubsub';

export class RunCtrl {
data: LearnProgress = this.opts.storage.data;
Expand All @@ -30,6 +31,10 @@ export class RunCtrl {

// Helpful for debugging:
// site.mousetrap.bind(['shift+enter'], this.levelCtrl.complete);
pubsub.on('board.change', (is3d: boolean) => {
this.chessground!.state.addPieceZIndex = is3d;
this.chessground!.redrawAll();
});
}

initializeLevel = (restarting = false) => {
Expand Down

0 comments on commit deef7e1

Please sign in to comment.