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
1 change: 1 addition & 0 deletions modules/coreI18n/src/main/key.scala
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ object I18nKey:
val `slow`: I18nKey = "slow"
val `insideTheBoard`: I18nKey = "insideTheBoard"
val `outsideTheBoard`: I18nKey = "outsideTheBoard"
val `allSquaresOfTheBoard`: I18nKey = "allSquaresOfTheBoard"
val `onSlowGames`: I18nKey = "onSlowGames"
val `always`: I18nKey = "always"
val `never`: I18nKey = "never"
Expand Down
5 changes: 4 additions & 1 deletion modules/pref/src/main/Pref.scala
Original file line number Diff line number Diff line change
Expand Up @@ -329,17 +329,20 @@ object Pref:
val NONE = 0
val INSIDE = 1
val OUTSIDE = 2
val ALL = 3

val choices = Seq(
NONE -> "No",
INSIDE -> "Inside the board",
OUTSIDE -> "Outside the board"
OUTSIDE -> "Outside the board",
ALL -> "Inside all squares of the board"
)

def classOf(v: Int) =
v match
case INSIDE => "in"
case OUTSIDE => "out"
case ALL => "all"
case _ => "no"

object Replay:
Expand Down
3 changes: 2 additions & 1 deletion modules/pref/src/main/ui/PrefHelper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ trait PrefHelper:
List(
(Pref.Coords.NONE, trans.site.no.txt()),
(Pref.Coords.INSIDE, trans.site.insideTheBoard.txt()),
(Pref.Coords.OUTSIDE, trans.site.outsideTheBoard.txt())
(Pref.Coords.OUTSIDE, trans.site.outsideTheBoard.txt()),
(Pref.Coords.ALL, trans.site.allSquaresOfTheBoard.txt())
)

def translatedMoveListWhilePlayingChoices(using Translate) =
Expand Down
10 changes: 8 additions & 2 deletions modules/web/src/main/ui/LearnUi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,18 @@ final class LearnUi(helpers: Helpers):
import helpers.{ *, given }
import trans.{ learn as trl }

def apply(data: Option[play.api.libs.json.JsValue])(using Context) =
def apply(data: Option[play.api.libs.json.JsValue])(using ctx: Context) =
Page(s"${trl.learnChess.txt()} - ${trl.byPlaying.txt()}")
.js:
PageModule(
"learn",
Json.obj("data" -> data, "i18n" -> i18nJsObject(i18nKeys))
Json.obj(
"data" -> data,
"i18n" -> i18nJsObject(i18nKeys),
"pref" -> Json.obj(
"coords" -> ctx.pref.coords
)
)
)
.css("learn")
.graph(
Expand Down
1 change: 1 addition & 0 deletions translation/source/site.xml
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,7 @@
<string name="slow">Slow</string>
<string name="insideTheBoard">Inside the board</string>
<string name="outsideTheBoard">Outside the board</string>
<string name="allSquaresOfTheBoard">All squares of the board</string>
<string name="onSlowGames">On slow games</string>
<string name="always">Always</string>
<string name="never">Never</string>
Expand Down
1 change: 1 addition & 0 deletions ui/analyse/src/ground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export function makeConfig(ctrl: AnalyseCtrl): CgConfig {
lastMove: opts.lastMove,
orientation: ctrl.bottomColor(),
coordinates: pref.coords !== Prefs.Coords.Hidden,
coordinatesOnSquares: pref.coords === Prefs.Coords.All,
addPieceZIndex: pref.is3d,
addDimensionsCssVarsTo: document.body,
viewOnly: false,
Expand Down
1 change: 1 addition & 0 deletions ui/common/src/prefs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const Coords = {
Hidden: 0,
Inside: 1,
Outside: 2,
All: 3,
};
export type Coords = (typeof Coords)[keyof typeof Coords];

Expand Down
6 changes: 4 additions & 2 deletions ui/learn/src/chessground.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Config as CgConfig } from 'chessground/config';
import { h, VNode } from 'snabbdom';
import { RunCtrl } from './run/runCtrl';
import * as Prefs from 'common/prefs';

export interface Shape {
orig: Key;
Expand All @@ -19,17 +20,18 @@ export default function (ctrl: RunCtrl): VNode {
insert: vnode => {
const el = vnode.elm as HTMLElement;
el.addEventListener('contextmenu', e => e.preventDefault());
ctrl.setChessground(site.makeChessground(el, makeConfig()));
ctrl.setChessground(site.makeChessground(el, makeConfig(ctrl)));
},
destroy: () => ctrl.chessground!.destroy(),
},
});
}

const makeConfig = (): CgConfig => ({
const makeConfig = (ctrl: RunCtrl): CgConfig => ({
fen: '8/8/8/8/8/8/8/8',
blockTouchScroll: true,
coordinates: true,
coordinatesOnSquares: ctrl.pref.coords === Prefs.Coords.All,
movable: { free: false, color: undefined },
drawable: { enabled: false },
draggable: { enabled: true },
Expand Down
10 changes: 9 additions & 1 deletion ui/learn/src/learn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from 'snabbdom';
import { LearnCtrl } from './ctrl';
import { view } from './view';
import * as Prefs from 'common/prefs';

import storage, { Storage } from './storage';

Expand All @@ -28,20 +29,27 @@ export interface LearnOpts {
stageId: number | null;
levelId: number | null;
route?: string;
pref: LearnPrefs;
}

export interface LearnPrefs {
coords: Prefs.Coords;
}

interface LearnServerOpts {
data?: LearnProgress;
i18n: I18nDict;
pref: LearnPrefs;
}

export function initModule({ data, i18n }: LearnServerOpts) {
export function initModule({ data, i18n, pref }: LearnServerOpts) {
const _storage = storage(data);
const opts: LearnOpts = {
i18n,
storage: _storage,
stageId: null,
levelId: null,
pref: pref,
};
const ctrl = new LearnCtrl(opts, redraw);

Expand Down
2 changes: 2 additions & 0 deletions ui/learn/src/run/runCtrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ export class RunCtrl {
this.withGround(this.levelCtrl.initializeWithGround);
};

pref = this.opts.pref;

withGround: WithGround = f => (this.chessground ? f(this.chessground) : undefined);

stageScore = () => {
Expand Down
1 change: 1 addition & 0 deletions ui/puz/src/view/chessground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export function makeConfig(opts: CgConfig, pref: PuzPrefs, userMove: UserMove):
check: opts.check,
lastMove: opts.lastMove,
coordinates: pref.coords !== Prefs.Coords.Hidden,
coordinatesOnSquares: pref.coords === Prefs.Coords.All,
addPieceZIndex: pref.is3d,
addDimensionsCssVarsTo: document.body,
movable: {
Expand Down
1 change: 1 addition & 0 deletions ui/puzzle/src/view/chessground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export function makeConfig(ctrl: PuzzleCtrl): CgConfig {
check: opts.check,
lastMove: opts.lastMove,
coordinates: ctrl.pref.coords !== Prefs.Coords.Hidden,
coordinatesOnSquares: ctrl.pref.coords === Prefs.Coords.All,
addPieceZIndex: ctrl.pref.is3d,
addDimensionsCssVarsTo: document.body,
movable: {
Expand Down
1 change: 1 addition & 0 deletions ui/round/src/ground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export function makeConfig(ctrl: RoundController): Config {
lastMove: uciToMove(step.uci),
check: !!step.check,
coordinates: data.pref.coords !== Prefs.Coords.Hidden,
coordinatesOnSquares: data.pref.coords === Prefs.Coords.All,
addPieceZIndex: ctrl.data.pref.is3d,
addDimensionsCssVarsTo: document.body,
highlight: {
Expand Down