From cef45803fbf2589b06aaaddf47ceeadae4f1fce8 Mon Sep 17 00:00:00 2001 From: Fruktus Date: Wed, 3 Jun 2026 18:54:38 +0200 Subject: [PATCH] feat: migrate old index to web app --- web/public/fullscreen-close.svg | 3 + web/public/fullscreen-open.svg | 3 + web/public/index.html | 113 ------------------ web/src/app/(main)/index.module.css | 28 +++++ web/src/app/(main)/layout.tsx | 12 ++ web/src/app/(main)/page.tsx | 27 ++++- web/src/components/ruffle/ruffle-config.tsx | 31 +++++ web/src/components/ruffle/ruffle-loader.tsx | 27 +++++ web/src/components/ruffle/ruffle.tsx | 14 +++ .../components/ui/footer/footer.module.css | 7 ++ web/src/components/ui/footer/footer.tsx | 9 ++ .../fullscreen-toggle.module.css | 40 +++++++ .../fullscreen-toggle/fullscreen-toggle.tsx | 44 +++++++ web/src/configurations/config.json | 1 + web/src/hooks/use-unload-warning.js | 17 +++ web/src/styles/globals.css | 22 +++- web/src/types/declarations.d.ts | 1 + web/src/types/ruffle.d.ts | 8 ++ 18 files changed, 290 insertions(+), 117 deletions(-) create mode 100644 web/public/fullscreen-close.svg create mode 100644 web/public/fullscreen-open.svg delete mode 100644 web/public/index.html create mode 100644 web/src/app/(main)/index.module.css create mode 100644 web/src/components/ruffle/ruffle-config.tsx create mode 100644 web/src/components/ruffle/ruffle-loader.tsx create mode 100644 web/src/components/ruffle/ruffle.tsx create mode 100644 web/src/components/ui/footer/footer.module.css create mode 100644 web/src/components/ui/footer/footer.tsx create mode 100644 web/src/components/ui/fullscreen-toggle/fullscreen-toggle.module.css create mode 100644 web/src/components/ui/fullscreen-toggle/fullscreen-toggle.tsx create mode 100644 web/src/hooks/use-unload-warning.js create mode 100644 web/src/types/declarations.d.ts create mode 100644 web/src/types/ruffle.d.ts diff --git a/web/public/fullscreen-close.svg b/web/public/fullscreen-close.svg new file mode 100644 index 00000000..63ecc7e3 --- /dev/null +++ b/web/public/fullscreen-close.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/web/public/fullscreen-open.svg b/web/public/fullscreen-open.svg new file mode 100644 index 00000000..9e8d031e --- /dev/null +++ b/web/public/fullscreen-open.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/web/public/index.html b/web/public/index.html deleted file mode 100644 index a9da110f..00000000 --- a/web/public/index.html +++ /dev/null @@ -1,113 +0,0 @@ - - - - - Quadradius - - - - - - - - -
- How to play & Powerup Cheatsheet. -
-
- - - - - -
- - - - - diff --git a/web/src/app/(main)/index.module.css b/web/src/app/(main)/index.module.css new file mode 100644 index 00000000..466bd458 --- /dev/null +++ b/web/src/app/(main)/index.module.css @@ -0,0 +1,28 @@ +.container { + width: 100%; + height: 100vh; + display: flex; + flex-direction: column; + flex-wrap: wrap; + justify-content: space-between; + align-items: stretch; + align-content: stretch; + position: relative; +} + +.game { + flex: 1; +} + +.embed { + width: 100%; + height: 100%; +} + +.directions { + position: absolute; + right: 8px; + z-index: 1; + top: 8px; + font-size: clamp(0.8rem, 1vw, 1rem); +} diff --git a/web/src/app/(main)/layout.tsx b/web/src/app/(main)/layout.tsx index 8aa91099..1fb368c0 100644 --- a/web/src/app/(main)/layout.tsx +++ b/web/src/app/(main)/layout.tsx @@ -1,3 +1,15 @@ +import '@/styles/globals.css' + +export const metadata = { + title: 'Quadradius', + description: 'Quadradius is a two-player turn-based strategy game from 2007 made in Flash. A game of skill, luck, and deception, with the gameplay of checkerboards on steroids. Originally created by Jimmi Heiserman and Brad Kayal.', +}; + +export const viewport = { + width: 'device-width', + initialScale: 1, +}; + export default function MainLayout({ children, }: { diff --git a/web/src/app/(main)/page.tsx b/web/src/app/(main)/page.tsx index d09daed8..20358d04 100644 --- a/web/src/app/(main)/page.tsx +++ b/web/src/app/(main)/page.tsx @@ -1,5 +1,30 @@ +'use client'; + +import styles from './index.module.css'; +import Ruffle from '@/components/ruffle/ruffle'; +import FullscreenToggle from '@/components/ui/fullscreen-toggle/fullscreen-toggle'; +import Footer from "@/components/ui/footer/footer"; +import { useUnloadWarning } from '@/hooks/use-unload-warning'; + + export default function Home() { + useUnloadWarning(); + return ( -

Quadradius Web App

+ <> +
+ How to play & Powerup Cheatsheet +
+ + + + +
+ + + +
+
+ ) } diff --git a/web/src/components/ruffle/ruffle-config.tsx b/web/src/components/ruffle/ruffle-config.tsx new file mode 100644 index 00000000..d37baafd --- /dev/null +++ b/web/src/components/ruffle/ruffle-config.tsx @@ -0,0 +1,31 @@ +'use client'; + +import { useEffect } from 'react'; + +export default function RuffleConfig() { + useEffect(() => { + const host = window.location.host; + const protocol = window.location.protocol == 'http:' ? 'ws:' : 'wss:'; + + window.RufflePlayer = window.RufflePlayer || {}; + window.RufflePlayer.config = { + autoplay: "on", + contextMenu: "off", + logLevel: "debug", + socketProxy: [ + { + host: "127.0.0.1", + port: 3000, + proxyUrl: `${protocol}//${host}/websocket/lobby`, + }, + { + host: "127.0.0.1", + port: 3001, + proxyUrl: `${protocol}//${host}/websocket/game`, + }, + ], + }; + }, []); + + return null; +} diff --git a/web/src/components/ruffle/ruffle-loader.tsx b/web/src/components/ruffle/ruffle-loader.tsx new file mode 100644 index 00000000..2083efdf --- /dev/null +++ b/web/src/components/ruffle/ruffle-loader.tsx @@ -0,0 +1,27 @@ +'use client'; + +import Script from 'next/script'; +import { useSearchParams } from 'next/navigation'; +import config from '@/configurations/config.json'; + +export default function RuffleLoader() { + const searchParams = useSearchParams(); + + const queryVersion = searchParams.get('ruffle_version'); + + const version = + queryVersion ?? + config.ruffleVersion ?? + ''; + + const ruffleUrl = version + ? `https://unpkg.com/@ruffle-rs/ruffle@${version}/ruffle.js` + : 'https://unpkg.com/@ruffle-rs/ruffle'; + + return ( +