Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions ui/analyse/src/study/multiBoard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,26 @@ import { type StudyChapters, gameLinkAttrs, gameLinksListener } from './studyCha
import { playerFed } from './playerBars';
import { userTitle } from 'common/userLink';
import { h } from 'snabbdom';
import { storage, storedBooleanProp, StoredProp } from 'common/storage';
import { storage, storedBooleanProp } from 'common/storage';
import { Chessground as makeChessground } from 'chessground';
import { EMPTY_BOARD_FEN } from 'chessops/fen';

export class MultiBoardCtrl {
playing: Toggle;
showResults: StoredProp<boolean>;
showResults: Prop<boolean>;
teamSelect: Prop<string> = prop('');
page: number = 1;
maxPerPageStorage = storage.make('study.multiBoard.maxPerPage');

constructor(
readonly chapters: StudyChapters,
readonly isRelay: boolean,
readonly multiCloudEval: MultiCloudEval | undefined,
private readonly initialTeamSelect: ChapterId | undefined,
readonly redraw: () => void,
) {
this.playing = toggle(false, this.redraw);
this.showResults = storedBooleanProp('study.showResults', true);
this.showResults = this.isRelay ? storedBooleanProp('study.showResults', true) : toggle(true);
if (this.initialTeamSelect) this.onChapterChange(this.initialTeamSelect);
}

Expand Down Expand Up @@ -104,8 +105,8 @@ export function view(ctrl: MultiBoardCtrl, study: StudyCtrl): MaybeVNode {
h('div.study__multiboard__options', [
ctrl.multiCloudEval &&
h('label.eval', [renderEvalToggle(ctrl.multiCloudEval), i18n.study.showEvalBar]),
renderPlayingToggle(ctrl),
renderShowResultsToggle(ctrl),
ctrl.isRelay ? renderPlayingToggle(ctrl) : undefined,
ctrl.isRelay ? renderShowResultsToggle(ctrl) : undefined,
]),
]),
!ctrl.showResults()
Expand Down
7 changes: 6 additions & 1 deletion ui/analyse/src/study/playerBars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { userTitle } from 'common/userLink';
import RelayPlayers, { fidePageLinkAttrs } from './relay/relayPlayers';
import { StudyCtrl } from './studyDeps';
import { intersection } from 'tree/path';
import { defined } from 'common';

export default function (ctrl: AnalyseCtrl): VNode[] | undefined {
const study = ctrl.study;
Expand Down Expand Up @@ -55,11 +56,15 @@ function renderPlayer(
showRatings: boolean,
relayPlayers?: RelayPlayers,
): VNode {
const showResult: boolean =
!defined(ctrl.study?.relay) ||
ctrl.study?.multiBoard.showResults() ||
ctrl.node.ply == ctrl.tree.lastPly();
const player = players?.[color],
fideId = parseInt(findTag(tags, `${color}fideid`) || ''),
team = findTag(tags, `${color}team`),
rating = showRatings && player?.rating,
result = resultOf(tags, color === 'white'),
result = showResult && resultOf(tags, color === 'white'),
top = ctrl.bottomColor() !== color;
return h(`div.study__player.study__player-${top ? 'top' : 'bot'}`, { class: { ticking } }, [
h('div.left', [
Expand Down
1 change: 1 addition & 0 deletions ui/analyse/src/study/studyCtrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ export default class StudyCtrl {
);
this.multiBoard = new MultiBoardCtrl(
this.chapters.list,
defined(this.relay),
this.multiCloudEval,
this.relay?.tourShow() ? undefined : this.data.chapter.id,
this.redraw,
Expand Down
11 changes: 11 additions & 0 deletions ui/analyse/src/view/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,17 @@ export function makeChatEl(ctrl: AnalyseCtrl, insert: (chat: HTMLElement) => voi
}

function makeConcealOf(ctrl: AnalyseCtrl): ConcealOf | undefined {
if (defined(ctrl.study?.relay)) {
if (!ctrl.study.multiBoard.showResults()) {
return (isMainline: boolean) => (path: Tree.Path, node: Tree.Node) => {
if (isMainline && ctrl.node.ply >= node.ply) return null;
if (treePath.contains(ctrl.path, path)) return null;
return 'hide';
};
}
return undefined;
}

const conceal =
ctrl.study && ctrl.study.data.chapter.conceal !== undefined
? {
Expand Down
Loading