From 821dd33a683635715a74881534bec1351633fc9b Mon Sep 17 00:00:00 2001 From: n8kim1 Date: Mon, 27 May 2024 18:24:05 -0400 Subject: [PATCH 1/5] allow for skipping without canvas --- client/src/playback/Match.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/client/src/playback/Match.ts b/client/src/playback/Match.ts index 0ddb1fe0..7757dfad 100644 --- a/client/src/playback/Match.ts +++ b/client/src/playback/Match.ts @@ -161,8 +161,8 @@ export default class Match { /** * Change the rounds current turn to the current turn + delta. */ - public stepTurn(delta: number, rerender: boolean = true): void { - this.jumpToTurn(this.currentTurn.turnNumber + delta, rerender) + public stepTurn(delta: number, rerender: boolean = true, headless: boolean = false): void { + this.jumpToTurn(this.currentTurn.turnNumber + delta, rerender, headless) } /** @@ -175,7 +175,7 @@ export default class Match { /** * Sets the current turn to the turn at the given turn number. */ - public jumpToTurn(turnNumber: number, rerender: boolean = true): void { + public jumpToTurn(turnNumber: number, rerender: boolean = true, headless: boolean = false): void { if (!this.game.playable) return turnNumber = Math.max(0, Math.min(turnNumber, this.deltas.length)) @@ -209,7 +209,9 @@ export default class Match { } this.currentTurn = updatingTurn - publishEvent(EventType.TURN_PROGRESS, {}) + if (!headless) { + publishEvent(EventType.TURN_PROGRESS, {}) + } if (rerender) this.rerender() } } From e66bab44c24524ce4ccc9dfcb6eb315295098274 Mon Sep 17 00:00:00 2001 From: n8kim1 Date: Mon, 27 May 2024 22:47:59 -0400 Subject: [PATCH 2/5] Register battletrack submodule --- .gitmodules | 3 +++ battletrack | 1 + 2 files changed, 4 insertions(+) create mode 100644 .gitmodules create mode 160000 battletrack diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..680d7dd7 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "battletrack"] + path = battletrack + url = git@github.com:n8kim1/battletrack.git diff --git a/battletrack b/battletrack new file mode 160000 index 00000000..c6beba8a --- /dev/null +++ b/battletrack @@ -0,0 +1 @@ +Subproject commit c6beba8a424d0aa2f3f63d516d4789f02f12c24b From b56cd3bcce0c53bd6c0216637bedb78329ab5b88 Mon Sep 17 00:00:00 2001 From: n8kim1 Date: Sat, 1 Jun 2024 14:15:00 -0400 Subject: [PATCH 3/5] fixup! Register battletrack submodule --- .gitmodules | 2 +- battletrack | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 160000 battletrack diff --git a/.gitmodules b/.gitmodules index 680d7dd7..d5ea7b96 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "battletrack"] - path = battletrack + path = client/battletrack url = git@github.com:n8kim1/battletrack.git diff --git a/battletrack b/battletrack deleted file mode 160000 index c6beba8a..00000000 --- a/battletrack +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c6beba8a424d0aa2f3f63d516d4789f02f12c24b From df9072a2c5a8724ff5bbec7e3a5bcf940fcda226 Mon Sep 17 00:00:00 2001 From: n8kim1 Date: Sat, 1 Jun 2024 14:15:25 -0400 Subject: [PATCH 4/5] Create new entrypoint and webpack conf --- client/package.json | 3 +- client/webpack-battletrack.config.js | 69 ++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 client/webpack-battletrack.config.js diff --git a/client/package.json b/client/package.json index 9f083df8..01aed327 100644 --- a/client/package.json +++ b/client/package.json @@ -16,7 +16,8 @@ "tauri-build": "npm run build && npm run tauri-pack", "electron-watch": "concurrently --kill-others \"npm run watch\" \"wait-on http://localhost:3000 && electron .\"", "electron-pack": "cross-env USE_HARD_LINKS=false CSC_IDENTITY_AUTO_DISCOVERY=false NODE_ENV=production electron-builder build --publish never", - "electron-build": "npm run build && npm run electron-pack" + "electron-build": "npm run build && npm run electron-pack", + "battletrack-watch": "cross-env NODE_ENV=development webpack serve --config webpack-battletrack.config.js --mode development --env dev" }, "build": { "asar": false, diff --git a/client/webpack-battletrack.config.js b/client/webpack-battletrack.config.js new file mode 100644 index 00000000..111dce24 --- /dev/null +++ b/client/webpack-battletrack.config.js @@ -0,0 +1,69 @@ +const webpack = require('webpack') +const path = require('path') +const HtmlWebpackPlugin = require('html-webpack-plugin') +const CopyPlugin = require('copy-webpack-plugin') + +module.exports = (env) => { + const development = env.dev + + var config = { + entry: './battletrack/src/app.tsx', + target: 'web', + devtool: development ? 'source-map' : undefined, + resolve: { + extensions: ['.tsx', '.ts', '.js'], + fallback: { + assert: require.resolve('assert/') + } + }, + module: { + rules: [ + { + test: /\.ts(x?)$/, + exclude: [/node_modules/, /src-tauri/, /packaged-client/], + loader: 'ts-loader' + }, + { + test: /\.css$/, + exclude: [/node_modules/, /src-tauri/, /packaged-client/], + use: ['style-loader', 'css-loader', 'postcss-loader'] + }, + { + test: /\.(png|jpg|jpeg|gif|svg|ttf|otf|woff|woff2|eot)$/, + exclude: [/node_modules/, /src-tauri/, /packaged-client/], + loader: 'url-loader' + } + ] + }, + devServer: { + compress: true, + hot: true, + port: 3000, + static: { + directory: path.join(__dirname, '/src') + } + }, + output: { + path: path.resolve(__dirname, './dist'), + filename: 'bundle.js' + }, + plugins: [ + new HtmlWebpackPlugin({ + template: './index.html', + favicon: './icons/icon.ico' + }), + new webpack.LoaderOptionsPlugin({ + minimize: !development, + debug: development + }), + new webpack.ProvidePlugin({ + process: 'process/browser' + }), + new CopyPlugin({ + patterns: [{ from: 'src/static', to: 'static' }] + }) + ] + } + + return config +} From 9c7170e1cedc1f12db4722c3439eacafd725f329 Mon Sep 17 00:00:00 2001 From: n8kim1 Date: Sat, 1 Jun 2024 14:17:36 -0400 Subject: [PATCH 5/5] refactor: Method to fetch tour games (without load on client page) --- client/src/components/sidebar/sidebar.tsx | 41 ++++++++++++----------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/client/src/components/sidebar/sidebar.tsx b/client/src/components/sidebar/sidebar.tsx index 33c07c69..5e746982 100644 --- a/client/src/components/sidebar/sidebar.tsx +++ b/client/src/components/sidebar/sidebar.tsx @@ -19,6 +19,20 @@ import { ConfigPage } from '../../client-config' import { UpdateWarning } from './update-warning' import Game from '../../playback/Game' +export const fetchTournamentPage = (tournamentSource: string, rawGames: JsonTournamentGame[]) => { + fetch(tournamentSource) + .then((response) => response.text()) + .then((text) => { + const data = JSON.parse(text) + const newGames = data.results as JsonTournamentGame[] + rawGames.push(...newGames) + + if (data.next) { + fetchTournamentPage(data.next, rawGames) + } + }) +} + export const Sidebar: React.FC = () => { const { width, height } = useWindowDimensions() const [page, setPage] = usePage() @@ -40,24 +54,13 @@ export const Sidebar: React.FC = () => { const [localTournament] = useSearchParamBool('localTournament', false) const [tournamentSource, setTournamentSource] = useSearchParamString('tournamentSource', '') - const fetchTournamentPage = (tournamentSource: string, rawGames: JsonTournamentGame[]) => { - fetch(tournamentSource) - .then((response) => response.text()) - .then((text) => { - const data = JSON.parse(text) - const newGames = data.results as JsonTournamentGame[] - rawGames.push(...newGames) - - if (data.next) { - fetchTournamentPage(data.next, rawGames) - } else { - context.setState((prevState) => ({ - ...prevState, - tournament: new Tournament(rawGames), - loadingRemoteContent: '' - })) - } - }) + const loadTournamentPage = (tournamentSource: string, rawGames: JsonTournamentGame[]) => { + fetchTournamentPage(tournamentSource, rawGames) + context.setState((prevState) => ({ + ...prevState, + tournament: new Tournament(rawGames), + loadingRemoteContent: '' + })) } React.useEffect(() => { if (tournamentSource) { @@ -65,7 +68,7 @@ export const Sidebar: React.FC = () => { ...prevState, loadingRemoteContent: 'tournament' })) - fetchTournamentPage(tournamentSource, []) + loadTournamentPage(tournamentSource, []) setPage(PageType.TOURNAMENT) } }, [tournamentSource])