agb/website/src/App.tsx

38 lines
954 B
TypeScript
Raw Normal View History

2023-04-13 21:44:00 +01:00
import React, { useState } from "react";
import { Mgba } from "./mgba";
2023-04-17 22:57:24 +01:00
import { BindingsControl, DefaultBindingsSet } from "./bindings";
2023-04-13 20:12:45 +01:00
function App() {
2023-04-13 21:32:40 +01:00
const [onGame, setOnGame] = useState(false);
const [volume, setVolume] = useState(1.0);
2023-04-17 22:57:24 +01:00
const [bindings, setBindings] = useState(DefaultBindingsSet());
2023-04-13 21:32:40 +01:00
2023-04-13 20:12:45 +01:00
return (
2023-04-13 21:32:40 +01:00
<div>
2023-04-13 21:44:00 +01:00
{onGame && (
<>
2023-04-17 22:57:24 +01:00
<Mgba
gameUrl="/game.gba"
volume={volume}
controls={bindings.Actual}
/>
2023-04-13 21:44:00 +01:00
<input
type="range"
value={volume}
min="0"
max="1"
step="0.05"
onChange={(e) => setVolume(Number(e.target.value))}
></input>
</>
)}
<button onClick={() => setOnGame(!onGame)}>
{onGame ? "End Game" : "Start Game"}
</button>
2023-04-17 22:57:24 +01:00
<BindingsControl bindings={bindings} setBindings={setBindings} />
2023-04-13 20:12:45 +01:00
</div>
);
}
export default App;