главный экран

This commit is contained in:
azykov@mail.ru
2026-09-04 17:22:49 +03:00
parent 03a7552b9a
commit 982bbce813
5 changed files with 129 additions and 2 deletions
+22 -1
View File
@@ -1,16 +1,37 @@
import { useState } from 'react';
import GameMap from './components/GameMap';
import MainMenu from './components/MainMenu';
import Sidebar from './components/Sidebar';
import Topbar from './components/Topbar';
import { GameStore } from './game/GameStore';
import { clearSave } from './game/persistence';
import './App.css';
type Screen = 'menu' | 'game';
function App() {
const [store] = useState(() => new GameStore());
// Always starts on the menu, regardless of whether a save exists — loading straight into a
// resumed game on every page (re)load isn't what was asked for.
const [screen, setScreen] = useState<Screen>('menu');
function handleNewGame() {
clearSave();
setScreen('game');
}
function handleExitToMenu() {
store.save();
setScreen('menu');
}
if (screen === 'menu') {
return <MainMenu onNewGame={handleNewGame} onContinue={() => setScreen('game')} />;
}
return (
<div className="app">
<Topbar store={store} />
<Topbar store={store} onExitToMenu={handleExitToMenu} />
<div className="main-row">
<Sidebar store={store} />
<GameMap store={store} />