Skip to content

Commit

Permalink
Support for supplying a url to stone images via Goban hook
Browse files Browse the repository at this point in the history
  • Loading branch information
GreenAsJade committed Jan 14, 2024
1 parent 02c4c5e commit 5911cbc
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/GobanCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,8 @@ export interface GobanHooks {
plainBoardColor?: () => string;
plainBoardLineColor?: () => string;
plainBoardUrl?: () => string;
customBlackStoneUrl?: () => string;
customWhiteStoneUrl?: () => string;

canvasAllocationErrorHandler?: (
note: string | null,
Expand Down Expand Up @@ -3270,9 +3272,9 @@ export abstract class GobanCore extends EventEmitter<Events> {
const elapsed: number = original_clock.start_mode
? 0
: paused && original_clock.paused_since
? Math.max(original_clock.paused_since, original_clock.last_move) -
original_clock.last_move
: current_server_time - original_clock.last_move;
? Math.max(original_clock.paused_since, original_clock.last_move) -

Check failure on line 3275 in src/GobanCore.ts

View workflow job for this annotation

GitHub Actions / build

Insert `··`
original_clock.last_move

Check failure on line 3276 in src/GobanCore.ts

View workflow job for this annotation

GitHub Actions / build

Insert `··`
: current_server_time - original_clock.last_move;

Check failure on line 3277 in src/GobanCore.ts

View workflow job for this annotation

GitHub Actions / build

Insert `··`

const clock = this.computeNewPlayerClock(
original_clock[`${color}_time`] as any,
Expand Down
54 changes: 54 additions & 0 deletions src/themes/image_stones.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,58 @@ export default function (GoThemes: GoThemesInterface) {
}
}
GoThemes["white"]["Anime"] = AnimeWhite;

class CustomBlack extends Common {
sort() {
return 400;
}
get theme_name(): string {
return "Custom";
}

preRenderBlack(
radius: number,
_seed: number,
deferredRenderCallback: () => void,
): StoneTypeArray {
return preRenderImageStone(
radius,
GobanCore.hooks.customBlackStoneUrl ? GobanCore.hooks.customBlackStoneUrl() : "",
deferredRenderCallback,
);
//return preRenderImageStone(radius, anime_black_imagedata);
}
getBlackTextColor(_color: string): string {
return "#ffffff";
}
}

GoThemes["black"]["Custom"] = CustomBlack;

class CustomWhite extends Common {
sort() {
return 400;
}
get theme_name(): string {
return "Custom";
}

preRenderWhite(
radius: number,
_seed: number,
deferredRenderCallback: () => void,
): StoneTypeArray {
return preRenderImageStone(
radius,
GobanCore.hooks.customWhiteStoneUrl ? GobanCore.hooks.customWhiteStoneUrl() : "",
deferredRenderCallback,
);
//return preRenderImageStone(radius, anime_white_imagedata);
}

getWhiteTextColor(_color: string): string {
return "#000000";
}
}
GoThemes["white"]["Custom"] = CustomWhite;
}

0 comments on commit 5911cbc

Please sign in to comment.