Skip to content

Commit

Permalink
Added show Eval toggle on broadcast
Browse files Browse the repository at this point in the history
  • Loading branch information
Carbrex committed Jan 23, 2024
1 parent 8b7a25b commit 4159968
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ui/analyse/css/study/panel/_multiboard.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
padding: 0.6em 1em;
}

.playing {
.playing, .eval {
cursor: pointer;
}

.playing input {
.playing input,.eval input {
vertical-align: middle;
margin-#{$end-direction}: 3px;
}
Expand Down
21 changes: 19 additions & 2 deletions ui/analyse/src/study/multiBoard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export class MultiBoardCtrl {
page = 1;
pager?: Paginator<ChapterPreview>;
playing = false;
showEval = false;

private cloudEvals: Map<Fen, CloudEval> = new Map();

Expand Down Expand Up @@ -105,6 +106,11 @@ export class MultiBoardCtrl {
this.reload();
};

setShowEval = (v: boolean) => {
this.showEval = v;
this.reload();
};

onCloudEval = (d: EvalHitMulti) => {
this.cloudEvals.set(d.fen, { ...d, chances: povChances('white', d) });
this.redraw();
Expand Down Expand Up @@ -145,9 +151,10 @@ export function view(ctrl: MultiBoardCtrl, study: StudyCtrl): VNode | undefined

function renderPager(pager: Paginator<ChapterPreview>, study: StudyCtrl): MaybeVNodes {
const ctrl = study.multiBoard;
const cloudEval = study.ctrl.ceval?.enabled() ? ctrl.getCloudEval : undefined;
const cloudEval = ctrl.showEval && study.ctrl.ceval?.enabled() ? ctrl.getCloudEval : undefined;
console.log('renderPager', pager, study, cloudEval);
return [
h('div.top', [renderPagerNav(pager, ctrl), renderPlayingToggle(ctrl)]),
h('div.top', [renderPagerNav(pager, ctrl), renderEvalToggle(ctrl), renderPlayingToggle(ctrl)]),
h('div.now-playing', pager.currentPageResults.map(makePreview(study, cloudEval))),
];
}
Expand All @@ -162,6 +169,16 @@ function renderPlayingToggle(ctrl: MultiBoardCtrl): VNode {
]);
}

function renderEvalToggle(ctrl: MultiBoardCtrl): VNode {
return h('label.eval', [
h('input', {
attrs: { type: 'checkbox', checked: ctrl.showEval },
hook: bind('change', e => ctrl.setShowEval((e.target as HTMLInputElement).checked)),
}),
'Show Eval'
]);
}

function renderPagerNav(pager: Paginator<ChapterPreview>, ctrl: MultiBoardCtrl): VNode {
const page = ctrl.page,
from = Math.min(pager.nbResults, (page - 1) * pager.maxPerPage + 1),
Expand Down

0 comments on commit 4159968

Please sign in to comment.