import {createRoot} from 'react-dom/client'; import React, {Component} from "react"; import Startup from "./Startup"; import WiFi from "./WiFi"; import Game from "./Game"; import GameSetup from "./GameSetup"; import GameEnd from "./GameEnd"; import Setup from "./Setup"; const root = createRoot(document.getElementById("root")); export enum PAGE { STARTUP, SETUP, WIFI, CLOUD, GAME_SETUP, GAME, GAME_END } interface AppState { currentPage: PAGE, showWiFi: boolean, } export class App extends Component<{}, AppState> { static PAGES: Map = new Map(); constructor(props: {}) { super(props); this.state = { currentPage: PAGE.GAME_SETUP, showWiFi: false, } } toggleWiFiSettings = (state: boolean) => { this.setState((prevState) => ({ ...prevState, showWiFi: state })); } toggleSetup = (state: boolean) => { this.setState((prevState) => ({ ...prevState, showSetup: state })); } public setPage = (page: PAGE) => { this.setState((prevState) => ({ ...prevState, currentPage: page })); } render() { return (
{this.state.showWiFi ? : null} {this.state.currentPage == PAGE.STARTUP || this.state.currentPage == PAGE.SETUP ? { App.PAGES.set(PAGE.STARTUP, ref); }}/> : null} {this.state.currentPage == PAGE.SETUP ? { App.PAGES.set(PAGE.SETUP, ref); }}/> : null} {this.state.currentPage == PAGE.GAME_SETUP ? { App.PAGES.set(PAGE.GAME_SETUP, ref); }}/> : null} {this.state.currentPage == PAGE.GAME ? { App.PAGES.set(PAGE.GAME, ref); }}/> : null} {this.state.currentPage == PAGE.GAME_END ? { App.PAGES.set(PAGE.GAME_END, ref); }}/> : null}
); } } root.render( { window.app = ref; }}/> )