import { Download, Palette, Save, Upload } from "@mui/icons-material"; import { Box, Button, Link, List, ListItemButton, Paper, Tooltip, Typography } from "@mui/material"; import { default as React, useRef, useState } from "react"; import { FileDiagnosticModal } from "../../Diagnostic/FileDiagnosticModal"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { ImportData, saveObject } from "../../SaveObject"; import { Settings } from "../../Settings/Settings"; import { StyleEditorButton } from "../../Themes/ui/StyleEditorButton"; import { ThemeEditorButton } from "../../Themes/ui/ThemeEditorButton"; import { ConfirmationModal } from "../../ui/React/ConfirmationModal"; import { DeleteGameButton } from "../../ui/React/DeleteGameButton"; import { SnackbarEvents, ToastVariant } from "../../ui/React/Snackbar"; import { SoftResetButton } from "../../ui/React/SoftResetButton"; import { IRouter } from "../../ui/Router"; import { convertTimeMsToTimeElapsedString } from "../../utils/StringHelperFunctions"; import { GameOptionsTabs } from "../GameOptionsTabs"; interface IProps { tab: GameOptionsTabs; setTab: (tab: GameOptionsTabs) => void; player: IPlayer; router: IRouter; save: () => void; export: () => void; forceKill: () => void; softReset: () => void; } interface ITabProps { sideBarProps: IProps; tab: GameOptionsTabs; tabName: string; } const SideBarTab = (props: ITabProps): React.ReactElement => { return ( props.sideBarProps.setTab(props.tab)} > {props.tabName} ); }; export const GameOptionsSidebar = (props: IProps): React.ReactElement => { const importInput = useRef(null); const [diagnosticOpen, setDiagnosticOpen] = useState(false); const [importSaveOpen, setImportSaveOpen] = useState(false); const [importData, setImportData] = useState(null); function startImport(): void { if (!window.File || !window.FileReader || !window.FileList || !window.Blob) return; const ii = importInput.current; if (ii === null) throw new Error("import input should not be null"); ii.click(); } async function onImport(event: React.ChangeEvent): Promise { try { const base64Save = await saveObject.getImportStringFromFile(event.target.files); const data = await saveObject.getImportDataFromString(base64Save); setImportData(data); setImportSaveOpen(true); } catch (ex: any) { SnackbarEvents.emit(ex.toString(), ToastVariant.ERROR, 5000); } } async function confirmedImportGame(): Promise { if (!importData) return; try { await saveObject.importGame(importData.base64); } catch (ex: any) { SnackbarEvents.emit(ex.toString(), ToastVariant.ERROR, 5000); } setImportSaveOpen(false); setImportData(null); } function compareSaveGame(): void { if (!importData) return; props.router.toImportSave(importData.base64); setImportSaveOpen(false); setImportData(null); } return ( Export your game to a text file.}> Import your game from a text file.
This will overwrite your current game. Back it up first! } >
setImportSaveOpen(false)} onConfirm={() => confirmedImportGame()} additionalButton={} confirmationText={ <> Importing a new game will completely wipe the current data!

Make sure to have a backup of your current save file before importing.
The file you are attempting to import seems valid. {(importData?.playerData?.lastSave ?? 0) > 0 && ( <>

The export date of the save file is{" "} {new Date(importData?.playerData?.lastSave ?? 0).toLocaleString()} )} {(importData?.playerData?.totalPlaytime ?? 0) > 0 && ( <>

Total play time of imported game:{" "} {convertTimeMsToTimeElapsedString(importData?.playerData?.totalPlaytime ?? 0)} )}

} /> Forcefully kill all active running scripts, in case there is a bug or some unexpected issue with the game. After using this, save the game and then reload the page. This is different then normal kill in that normal kill will tell the script to shut down while force kill just removes the references to it (and it should crash on it's own). This will not remove the files on your computer. Just forcefully kill all running instance of all scripts. } > If your save file is extremely big you can use this button to view a map of all the files on every server. Be careful there might be spoilers. } > Report bug Changelog Documentation Discord Reddit Incremental game plaza
setDiagnosticOpen(false)} />
); };