diff --git a/src/renderer/react/ModManagerSettings.tsx b/src/renderer/react/ModManagerSettings.tsx index 64364b2..c2d674b 100644 --- a/src/renderer/react/ModManagerSettings.tsx +++ b/src/renderer/react/ModManagerSettings.tsx @@ -1,4 +1,5 @@ import BridgeAPI from 'renderer/BridgeAPI'; +import { useDataPath } from 'renderer/react/context/DataPathContext'; import { useExtraGameLaunchArgs } from 'renderer/react/context/ExtraGameLaunchArgsContext'; import { useGamePath, @@ -77,6 +78,8 @@ export default function ModManagerSettings(_props: Props): JSX.Element { usePreExtractedDataPath(); const [outputModName, setOutputModName] = useOutputModName(); const mergedPath = useOutputPath(); + const dataPath = useDataPath(); + const outputPath = isDirectMode ? dataPath : mergedPath; const [themeMode, setThemeMode] = useThemeMode(); @@ -97,6 +100,9 @@ export default function ModManagerSettings(_props: Props): JSX.Element { ), ) ?? true; + const isIdenticalInputAndOutput = + preExtractedDataPath.toLowerCase() === outputPath.toLowerCase(); + const { nexusApiState, nexusAuthState, @@ -107,6 +113,12 @@ export default function ModManagerSettings(_props: Props): JSX.Element { unregisterAsNxmProtocolHandler, } = useNexusAuthState(); + console.log( + 'DEBUG', + preExtractedDataPath.toLowerCase(), + outputPath.toLowerCase(), + ); + return ( - {isDirectMode && - preExtractedDataPath === `${rawGamePath}\\data` ? ( - - It looks like you are using direct mode and are setting the - source Data Directory to the "data" folder in the - game's installation directory. Are you{' '} - sure you want to do this? You will be reading - the vanilla state of the game's files from the same - directory that D2RMM will install mods to. + {isIdenticalInputAndOutput ? ( + + It looks like you are reading pre-extracted game data from the + same directory that D2RMM will generate output modded files + into ("{outputPath}"). Are you sure you want + to do this? This will most likely lead to completely broken + behavior. ) : null} @@ -217,7 +231,7 @@ export default function ModManagerSettings(_props: Props): JSX.Element { variant="filled" /> - Generated files will be located in “{mergedPath}\”. + Generated files will be located in “{outputPath}\”. Save game files will be located in “%UserProfile%\Saved @@ -272,7 +286,7 @@ export default function ModManagerSettings(_props: Props): JSX.Element { {!isDirectMode ? null : ( - Generated files will be located in “{gamePath}\data\”. + Generated files will be located in “{outputPath}\”. )} diff --git a/src/renderer/react/hooks/useSavedState.tsx b/src/renderer/react/hooks/useSavedState.tsx index 47b5c2b..4167f01 100644 --- a/src/renderer/react/hooks/useSavedState.tsx +++ b/src/renderer/react/hooks/useSavedState.tsx @@ -27,12 +27,21 @@ export default function useSavedState( deserialize: (value: string) => T = deserializeImplicit, ): [T, React.Dispatch>] { const [value, setValue] = useState(() => { - const savedValue = localStorage.getItem(key); - return savedValue != null ? deserialize(savedValue) : initialValue; + try { + const savedValue = localStorage.getItem(key); + return savedValue != null ? deserialize(savedValue) : initialValue; + } catch (e) { + console.error(e); + return initialValue; + } }); useEffect(() => { - localStorage.setItem(key, serialize(value)); + try { + localStorage.setItem(key, serialize(value)); + } catch (e) { + console.error(e); + } }, [key, value, serialize]); return [value, setValue];