Skip to content

Commit

Permalink
add option to show coordinates on every square to learn itens
Browse files Browse the repository at this point in the history
  • Loading branch information
henrique-barros committed Jun 28, 2024
1 parent e6aae67 commit 2c066fc
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/views/study.scala
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def show(
localMod = ctx.userId.exists(s.canContribute)
),
"socketUrl" -> socketUrl(s.id),
"socketVersion" -> socketVersion
"socketVersion" -> socketVersion,
) ++ views.board.explorerAndCevalConfig
)
)
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ lazy val root = Project("lila", file("."))
.settings(scalacOptions ++= Seq("-unchecked", "-deprecation"))

organization := "org.lichess"
Compile / run / fork := true
Compile / run / fork := false
javaOptions ++= Seq("-Xms64m", "-Xmx512m", "-Dlogger.file=conf/logger.dev.xml")
ThisBuild / usePipelining := false
// shorter prod classpath
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 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/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 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

0 comments on commit 2c066fc

Please sign in to comment.