This commit is contained in:
Maciej Caderek
2022-03-09 23:56:34 +01:00
parent db3c689727
commit 84bb4efd80
6 changed files with 49 additions and 21 deletions

View File

@@ -205,6 +205,12 @@ class Board {
return this; return this;
} }
toggleShadows() {
this.cfg.showShadows = !this.cfg.showShadows;
this.refresh();
return this;
}
private getFinalHeader() { private getFinalHeader() {
return this._anonymous return this._anonymous
? { ? {
@@ -341,7 +347,8 @@ class Board {
this.borderWidth, this.borderWidth,
this.cfg.flipped, this.cfg.flipped,
this.margin, this.margin,
this.cfg.piecesStyle this.cfg.piecesStyle,
this.cfg.showShadows
); );
if (this.cfg.showExtraInfo && header) { if (this.cfg.showExtraInfo && header) {

View File

@@ -90,6 +90,11 @@ const main = async () => {
setState("gameConfig", "titleScreen", !state.gameConfig.titleScreen); setState("gameConfig", "titleScreen", !state.gameConfig.titleScreen);
saveConfig("game"); saveConfig("game");
}, },
toggleShadows() {
board.toggleShadows();
setState("boardConfig", "showShadows", !state.boardConfig.showShadows);
saveConfig("board");
},
flip() { flip() {
console.log("FLIP"); console.log("FLIP");
board.flip(); board.flip();

View File

@@ -19,6 +19,7 @@ const initialBoardConfig: BoardConfig = {
showMoveIndicator: true, showMoveIndicator: true,
showChecks: true, showChecks: true,
showCoords: true, showCoords: true,
showShadows: false,
flipped: false, flipped: false,
}; };

View File

@@ -104,6 +104,7 @@ export type BoardConfig = {
showMoveIndicator: boolean; showMoveIndicator: boolean;
showChecks: boolean; showChecks: boolean;
showCoords: boolean; showCoords: boolean;
showShadows: boolean;
flipped: boolean; flipped: boolean;
}; };
@@ -174,6 +175,7 @@ export type Handlers = {
toggleExtraInfo(): void; toggleExtraInfo(): void;
toggleAnonymous(): void; toggleAnonymous(): void;
toggleTitleScreen(): void; toggleTitleScreen(): void;
toggleShadows(): void;
flip(): void; flip(): void;
togglePlay(): void; togglePlay(): void;
goto(ply: number): void; goto(ply: number): void;

View File

@@ -38,12 +38,30 @@ const Controls: Component<{ handlers: Handlers }> = (props) => {
<i class="las la-angle-right"></i> <i class="las la-angle-right"></i>
</button> </button>
<button <button
class="controls__button controls__button--last" class="controls__button"
onClick={props.handlers.last} onClick={props.handlers.last}
title="LAST" title="LAST"
> >
<i class="las la-angle-double-right"></i> <i class="las la-angle-double-right"></i>
</button> </button>
<button
onClick={props.handlers.flip}
title="FLIP"
classList={{
options__button: true,
"options__button--last": true,
"options__button--active": true,
}}
>
<i
classList={{
rotated: state.boardConfig.flipped,
las: true,
"la-sync": true,
rotatable: true,
}}
></i>
</button>
</div> </div>
); );
}; };

View File

@@ -19,24 +19,6 @@ const Share: Component<{ handlers: Handlers; class?: string }> = (props) => {
<Scrollable class={"share" + (props.class ? ` ${props.class}` : "")}> <Scrollable class={"share" + (props.class ? ` ${props.class}` : "")}>
<div className="share__view"> <div className="share__view">
<h2 class="header--first">Board options</h2> <h2 class="header--first">Board options</h2>
<button
onClick={props.handlers.flip}
title="FLIP"
classList={{
options__button: true,
"options__button--first": true,
"options__button--active": true,
}}
>
<i
classList={{
rotated: state.boardConfig.flipped,
las: true,
"la-sync": true,
rotatable: true,
}}
></i>
</button>
<button <button
classList={{ classList={{
options__button: true, options__button: true,
@@ -78,7 +60,7 @@ const Share: Component<{ handlers: Handlers; class?: string }> = (props) => {
<button <button
classList={{ classList={{
options__button: true, options__button: true,
"options__button--last": true, "options__button--last": false,
"options__button--active": state.anonymous, "options__button--active": state.anonymous,
}} }}
onClick={props.handlers.toggleAnonymous} onClick={props.handlers.toggleAnonymous}
@@ -86,6 +68,19 @@ const Share: Component<{ handlers: Handlers; class?: string }> = (props) => {
> >
<i class="las la-user-secret"></i> <i class="las la-user-secret"></i>
</button> </button>
<button
classList={{
options__button: true,
"options__button--last": true,
"options__button--active": state.boardConfig.showShadows,
}}
onClick={props.handlers.toggleShadows}
title={
state.boardConfig.showShadows ? "HIDE SHADOWS" : "SHOW SHADOWS"
}
>
<i class="las la-cloud"></i>
</button>
</div> </div>
<hr /> <hr />
<div className="share__fen"> <div className="share__fen">