Skip to content

Commit

Permalink
Merged url and custom color themes into Custom, restored Plain as Plain
Browse files Browse the repository at this point in the history
  • Loading branch information
anoek committed Jan 26, 2024
1 parent 0a76352 commit 424ce80
Show file tree
Hide file tree
Showing 8 changed files with 269 additions and 269 deletions.
4 changes: 2 additions & 2 deletions src/GoThemes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ export const GoThemesSorted: { [n: string]: Array<GoTheme> } = {

import init_board_plain from "./themes/board_plain";
import init_board_woods from "./themes/board_woods";
import init_disc from "./themes/disc";
import init_plain_stones from "./themes/plain_stones";
import init_rendered from "./themes/rendered_stones";
import init_image_stones from "./themes/image_stones";

init_board_plain(GoThemes);
init_board_woods(GoThemes);
init_disc(GoThemes);
init_plain_stones(GoThemes);
init_rendered(GoThemes);
init_image_stones(GoThemes);

Expand Down
10 changes: 10 additions & 0 deletions src/GobanCanvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,16 @@ export class GobanCanvas extends GobanCore {
this.setThemes(this.getSelectedThemes(), true);
let first_pass = true;
const watcher = this.watchSelectedThemes((themes: GobanSelectedThemes) => {
if (
themes.black === "Custom" ||
themes.white === "Custom" ||
themes.board === "Custom"
) {
//first_pass = true;
}
delete __theme_cache.black?.["Custom"];
delete __theme_cache.white?.["Custom"];
delete __theme_cache.board?.["Custom"];
this.setThemes(themes, first_pass ? true : false);
first_pass = false;
});
Expand Down
14 changes: 7 additions & 7 deletions src/GobanCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,13 +328,13 @@ export interface GobanHooks {
watchSelectedThemes?: (cb: (themes: GobanSelectedThemes) => void) => { remove: () => any };
getSelectedThemes?: () => GobanSelectedThemes;

discBlackStoneColor?: () => string;
discBlackTextColor?: () => string;
discWhiteStoneColor?: () => string;
discWhiteTextColor?: () => string;
plainBoardColor?: () => string;
plainBoardLineColor?: () => string;
plainBoardUrl?: () => string;
customBlackStoneColor?: () => string;
customBlackTextColor?: () => string;
customWhiteStoneColor?: () => string;
customWhiteTextColor?: () => string;
customBoardColor?: () => string;
customBoardLineColor?: () => string;
customBoardUrl?: () => string;
customBlackStoneUrl?: () => string;
customWhiteStoneUrl?: () => string;

Expand Down
115 changes: 27 additions & 88 deletions src/themes/board_plain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,60 +34,34 @@ function hexToRgba(raw: string, alpha: number = 1): string {
export default function (GoThemes: GoThemesInterface) {
class Plain extends GoTheme {
sort(): number {
return 199; // second to last, because this is the "customisable" one
return 1;
}
get theme_name(): string {
return "Plain";
}
getBackgroundCSS(): GoThemeBackgroundCSS {
return {
"background-color": GobanCore.hooks.plainBoardColor
? GobanCore.hooks.plainBoardColor()
: "#DCB35C",
"background-image": GobanCore.hooks.plainBoardUrl
? "url('" + GobanCore.hooks.plainBoardUrl() + "')"
: "",
"background-size": "cover",
"background-color": "#DCB35C",
"background-image": "",
};
}
getLineColor(): string {
return GobanCore.hooks.plainBoardLineColor
? GobanCore.hooks.plainBoardLineColor()
: "#000000";
return "#000000";
}
getFadedLineColor(): string {
return hexToRgba(
GobanCore.hooks.plainBoardLineColor
? GobanCore.hooks.plainBoardLineColor()
: "#000000",
0.5,
);
return hexToRgba("#000000", 0.5);
}
getStarColor(): string {
return GobanCore.hooks.plainBoardLineColor
? GobanCore.hooks.plainBoardLineColor()
: "#000000";
return "#000000";
}
getFadedStarColor(): string {
return hexToRgba(
GobanCore.hooks.plainBoardLineColor
? GobanCore.hooks.plainBoardLineColor()
: "#000000",
0.5,
);
return hexToRgba("#000000", 0.5);
}
getBlankTextColor(): string {
return GobanCore.hooks.plainBoardLineColor
? GobanCore.hooks.plainBoardLineColor()
: "#000000";
return "#000000";
}
getLabelTextColor(): string {
return hexToRgba(
GobanCore.hooks.plainBoardLineColor
? GobanCore.hooks.plainBoardLineColor()
: "#000000",
0.75,
);
return hexToRgba("#000000", 0.75);
}
}

Expand All @@ -103,50 +77,51 @@ export default function (GoThemes: GoThemesInterface) {
}
getBackgroundCSS(): GoThemeBackgroundCSS {
return {
"background-color": GobanCore.hooks.plainBoardColor
? GobanCore.hooks.plainBoardColor()
"background-color": GobanCore.hooks.customBoardColor
? GobanCore.hooks.customBoardColor()
: "#DCB35C",
"background-image": GobanCore.hooks.plainBoardUrl
? "url('" + GobanCore.hooks.plainBoardUrl() + "')"
: "",
"background-image":
GobanCore.hooks.customBoardUrl && GobanCore.hooks.customBoardUrl() !== ""
? "url('" + GobanCore.hooks.customBoardUrl() + "')"
: "",
"background-size": "cover",
};
}
getLineColor(): string {
return GobanCore.hooks.plainBoardLineColor
? GobanCore.hooks.plainBoardLineColor()
return GobanCore.hooks.customBoardLineColor
? GobanCore.hooks.customBoardLineColor()
: "#000000";
}
getFadedLineColor(): string {
return hexToRgba(
GobanCore.hooks.plainBoardLineColor
? GobanCore.hooks.plainBoardLineColor()
GobanCore.hooks.customBoardLineColor
? GobanCore.hooks.customBoardLineColor()
: "#000000",
0.5,
);
}
getStarColor(): string {
return GobanCore.hooks.plainBoardLineColor
? GobanCore.hooks.plainBoardLineColor()
return GobanCore.hooks.customBoardLineColor
? GobanCore.hooks.customBoardLineColor()
: "#000000";
}
getFadedStarColor(): string {
return hexToRgba(
GobanCore.hooks.plainBoardLineColor
? GobanCore.hooks.plainBoardLineColor()
GobanCore.hooks.customBoardLineColor
? GobanCore.hooks.customBoardLineColor()
: "#000000",
0.5,
);
}
getBlankTextColor(): string {
return GobanCore.hooks.plainBoardLineColor
? GobanCore.hooks.plainBoardLineColor()
return GobanCore.hooks.customBoardLineColor
? GobanCore.hooks.customBoardLineColor()
: "#000000";
}
getLabelTextColor(): string {
return hexToRgba(
GobanCore.hooks.plainBoardLineColor
? GobanCore.hooks.plainBoardLineColor()
GobanCore.hooks.customBoardLineColor
? GobanCore.hooks.customBoardLineColor()
: "#000000",
0.75,
);
Expand Down Expand Up @@ -302,40 +277,4 @@ export default function (GoThemes: GoThemesInterface) {

_("Book"); // ensure translation exists
GoThemes["board"]["Book"] = Book;

class GreyBook extends GoTheme {
sort(): number {
return 111;
}
get theme_name(): string {
return "Grey Book";
}
getBackgroundCSS(): GoThemeBackgroundCSS {
return {
"background-color": "#dddddd",
"background-image": "",
};
}
getLineColor(): string {
return "#555555";
}
getFadedLineColor(): string {
return "#999999";
}
getStarColor(): string {
return "#555555";
}
getFadedStarColor(): string {
return "#999999";
}
getBlankTextColor(): string {
return "#000000";
}
getLabelTextColor(): string {
return "#555555";
}
}

_("Grey Book"); // ensure translation exists
GoThemes["board"]["Grey Book"] = GreyBook;
}
163 changes: 0 additions & 163 deletions src/themes/disc.ts

This file was deleted.

Loading

0 comments on commit 424ce80

Please sign in to comment.