diff --git a/src/App.tsx b/src/App.tsx index 32f2d13..45ea1f8 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -7,6 +7,7 @@ import MainPage from "./dom-components/MainPage"; import Guide from "./dom-components/Guide"; import Keybinding from "./dom-components/Keybinding"; import { useStore } from "./store"; +import Savefile from "./dom-components/Savefile"; const App = () => { const setKeybindings = useStore((state) => state.setKeybindings); @@ -24,6 +25,7 @@ const App = () => { + ); diff --git a/src/dom-components/Game.tsx b/src/dom-components/Game.tsx index 9f6bb3c..1f84323 100644 --- a/src/dom-components/Game.tsx +++ b/src/dom-components/Game.tsx @@ -50,17 +50,6 @@ const Game = () => { const handleWindowKeypress = useCallback((event) => { switch (event.key) { - case "l": - const saveState = prompt( - `This is your current save state. It's empty if you haven't saved the game yet. To export it, just copy this value and save it somewhere, to import another one, simply replace it and click ok. - \n If you wish to reset your progress, simply delete it and click ok. - \n Keep in mind replacing this with something other than a save state/manually modifying it without being careful will result in a crash upon trying to load it.`, - localStorage.getItem("lainSaveState") || undefined - ); - - localStorage.setItem("lainSaveState", saveState || ""); - - break; case "k": setWidth((prevWidth) => prevWidth * 1.1); setHeight((prevHeight) => prevHeight * 1.1); diff --git a/src/dom-components/Header.tsx b/src/dom-components/Header.tsx index 1aac193..80c5334 100644 --- a/src/dom-components/Header.tsx +++ b/src/dom-components/Header.tsx @@ -11,6 +11,7 @@ const Header = () => { guide discord keybinding + savefile ); }; diff --git a/src/dom-components/Notes.tsx b/src/dom-components/Notes.tsx index 64da758..726ae7f 100644 --- a/src/dom-components/Notes.tsx +++ b/src/dom-components/Notes.tsx @@ -165,10 +165,6 @@ const Notes = () => { j Downscale Game Window - - l - Save Manager -
diff --git a/src/dom-components/Savefile.tsx b/src/dom-components/Savefile.tsx new file mode 100644 index 0000000..c3ca4c5 --- /dev/null +++ b/src/dom-components/Savefile.tsx @@ -0,0 +1,49 @@ +import React, { useCallback, useEffect, useState } from "react"; +import "../static/css/savefile.css"; +import Header from "./Header"; + +const Savefile = () => { + const [textAreaValue, setTextAreaValue] = useState(""); + + useEffect(() => { + setTextAreaValue(localStorage.getItem("lainSaveState") || ""); + }, []); + + const saveState = useCallback(() => { + if (textAreaValue) localStorage.setItem("lainSaveState", textAreaValue); + else localStorage.setItem("lainSaveState", ""); + }, [textAreaValue]); + + const handleTextValueChange = useCallback((e) => { + setTextAreaValue(e.target.value); + }, []); + + return ( + <> +
+
+

+ If you've saved the game during the playthrough, the text provided in + the box below is your "save file". To export it for future use, just + copy everything inside it and paste it inside a file somewhere + locally. To re-import it later, take the contents of the file, paste + them here, and press "Save state". After that, reload the website. +
+
+ If you're here simply to reset your progress, just delete everything + inside the textbox below and press "Save state". +
+
+ Keep in mind, manually modifying the contents without being + careful/setting it to something random will result in a crash while + trying to load the state in-game. +

+