mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 16:21:33 +11:00
load game based on path hash
This commit is contained in:
parent
3574253df8
commit
713fc168ae
2
justfile
2
justfile
|
@ -99,7 +99,6 @@ build-mgba-wasm:
|
||||||
|
|
||||||
build-combo-rom-site:
|
build-combo-rom-site:
|
||||||
just _build-rom "examples/combo" "AGBGAMES"
|
just _build-rom "examples/combo" "AGBGAMES"
|
||||||
cp examples/target/examples/combo.gba website/app/public/game.gba
|
|
||||||
|
|
||||||
build-site-mgba-wrapper: build-mgba-wasm
|
build-site-mgba-wrapper: build-mgba-wasm
|
||||||
(cd website/app && npm run build)
|
(cd website/app && npm run build)
|
||||||
|
@ -109,6 +108,7 @@ build-site: build-combo-rom-site build-site-mgba-wrapper build-book
|
||||||
cp website/site website/build -r
|
cp website/site website/build -r
|
||||||
cp book/book website/build/book -r
|
cp book/book website/build/book -r
|
||||||
cp website/app/build website/build/mgba -r
|
cp website/app/build website/build/mgba -r
|
||||||
|
cp examples/target/examples/combo.gba website/build/assets/combo.gba
|
||||||
|
|
||||||
_run-tool +tool:
|
_run-tool +tool:
|
||||||
(cd tools && cargo build)
|
(cd tools && cargo build)
|
||||||
|
|
1
website/app/.gitignore
vendored
1
website/app/.gitignore
vendored
|
@ -24,4 +24,3 @@ yarn-error.log*
|
||||||
|
|
||||||
|
|
||||||
src/vendor
|
src/vendor
|
||||||
public/game.gba
|
|
|
@ -68,6 +68,8 @@ function App() {
|
||||||
|
|
||||||
useAvoidItchIoScrolling();
|
useAvoidItchIoScrolling();
|
||||||
|
|
||||||
|
const gameUrl = window.location.hash.slice(1);
|
||||||
|
|
||||||
const [isPlaying, setIsPlaying] = useState(true);
|
const [isPlaying, setIsPlaying] = useState(true);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -86,7 +88,7 @@ function App() {
|
||||||
{isPlaying ? (
|
{isPlaying ? (
|
||||||
<Mgba
|
<Mgba
|
||||||
ref={mgbaRef}
|
ref={mgbaRef}
|
||||||
gameUrl="./game.gba"
|
gameUrl={gameUrl}
|
||||||
volume={volume}
|
volume={volume}
|
||||||
controls={bindings.Actual}
|
controls={bindings.Actual}
|
||||||
paused={paused}
|
paused={paused}
|
||||||
|
|
|
@ -52,7 +52,10 @@ export const Mgba = forwardRef<MgbaHandle, MgbaProps>(
|
||||||
const game = await fetch(gameUrl);
|
const game = await fetch(gameUrl);
|
||||||
const gameData = await game.arrayBuffer();
|
const gameData = await game.arrayBuffer();
|
||||||
|
|
||||||
const gamePath = `${MGBA_ROM_DIRECTORY}/${gameUrl}`;
|
const gameSplit = gameUrl.split("/");
|
||||||
|
const gameBaseName = gameSplit[gameSplit.length - 1];
|
||||||
|
|
||||||
|
const gamePath = `${MGBA_ROM_DIRECTORY}/${gameBaseName}`;
|
||||||
mgbaModule.current.FS.writeFile(gamePath, new Uint8Array(gameData));
|
mgbaModule.current.FS.writeFile(gamePath, new Uint8Array(gameData));
|
||||||
mgbaModule.current.loadGame(gamePath);
|
mgbaModule.current.loadGame(gamePath);
|
||||||
mgbaModule.current.setVolume(0.1); // for some reason you have to do this or you get no sound
|
mgbaModule.current.setVolume(0.1); // for some reason you have to do this or you get no sound
|
||||||
|
|
|
@ -100,7 +100,7 @@
|
||||||
<div class="imageWrapper"><img src="assets/left.png" /></div>
|
<div class="imageWrapper"><img src="assets/left.png" /></div>
|
||||||
<iframe
|
<iframe
|
||||||
onload="this.contentWindow.focus()"
|
onload="this.contentWindow.focus()"
|
||||||
src="mgba/index.html"
|
src="mgba/index.html#/assets/combo.gba"
|
||||||
></iframe>
|
></iframe>
|
||||||
<div class="imageWrapper"><img src="assets/right.png" /></div>
|
<div class="imageWrapper"><img src="assets/right.png" /></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue