diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json index c98ea41..4ee28e5 100644 --- a/src-tauri/capabilities/default.json +++ b/src-tauri/capabilities/default.json @@ -31,14 +31,11 @@ "fs:allow-applocaldata-write", { "identifier": "fs:scope", - "allow": [ - { "path": "$APPLOCALDATA/game/**" }, - { "path": "$APPCONFIG/versions.json" } - ] + "allow": [{ "path": "**" }] }, { "identifier": "opener:allow-open-path", - "allow": [{ "path": "$APPLOCALDATA/game/**" }] + "allow": [{ "path": "**" }] }, { "identifier": "http:default", diff --git a/src/app/main/game/page.tsx b/src/app/main/game/page.tsx index 6305881..bf12923 100644 --- a/src/app/main/game/page.tsx +++ b/src/app/main/game/page.tsx @@ -29,7 +29,8 @@ export default function Installs () { downloadProgress, linuxUseWine, linuxWineCommand, - versions + versions, + customDataLocation } = useGlobal() const params = useSearchParams() @@ -271,14 +272,28 @@ export default function Installs () { ) if ( - await exists('game/' + v, { - baseDir: BaseDirectory.AppLocalData - }) + await exists( + customDataLocation + ? customDataLocation + '/' + : null + 'game/' + v, + { + baseDir: customDataLocation + ? undefined + : BaseDirectory.AppLocalData + } + ) ) - await remove('game/' + v, { - baseDir: BaseDirectory.AppLocalData, - recursive: true - }) + await remove( + customDataLocation + ? customDataLocation + '/' + : null + 'game/' + v, + { + baseDir: customDataLocation + ? undefined + : BaseDirectory.AppLocalData, + recursive: true + } + ) //reinstall setSelectedVersionList([v]) @@ -356,9 +371,16 @@ export default function Installs () { e.stopPropagation() if ( - !(await exists('game/' + v + '/BepInEx', { - baseDir: BaseDirectory.AppLocalData - })) + !(await exists( + customDataLocation + ? customDataLocation + '/' + : null + 'game/' + v + '/BepInEx', + { + baseDir: customDataLocation + ? undefined + : BaseDirectory.AppLocalData + } + )) ) { if ( (await ask( diff --git a/src/popups/ManageVersion.tsx b/src/popups/ManageVersion.tsx index 5b75679..e368cd6 100644 --- a/src/popups/ManageVersion.tsx +++ b/src/popups/ManageVersion.tsx @@ -27,7 +27,8 @@ export default function ManageVersionPopup () { setPopupMode, setSelectedVersionList, downloadVersions, - versions + versions, + customDataLocation } = useGlobal() const [versionSize, setVersionSize] = useState(0) @@ -140,14 +141,28 @@ export default function ManageVersionPopup () { ) if ( - await exists('game/' + managingVersion, { - baseDir: BaseDirectory.AppLocalData - }) + await exists( + (customDataLocation ? customDataLocation + '/' : null) + + 'game/' + + managingVersion, + { + baseDir: customDataLocation + ? undefined + : BaseDirectory.AppLocalData + } + ) ) - await remove('game/' + managingVersion, { - baseDir: BaseDirectory.AppLocalData, - recursive: true - }) + await remove( + (customDataLocation ? customDataLocation + '/' : null) + + 'game/' + + managingVersion, + { + baseDir: customDataLocation + ? undefined + : BaseDirectory.AppLocalData, + recursive: true + } + ) }} title='Click to uninstall this game. This will NOT remove any progress or any save files.' hidden={viewingInfoFromDownloads} @@ -172,14 +187,28 @@ export default function ManageVersionPopup () { ) if ( - await exists('game/' + managingVersion, { - baseDir: BaseDirectory.AppLocalData - }) + await exists( + (customDataLocation ? customDataLocation + '/' : null) + + 'game/' + + managingVersion, + { + baseDir: customDataLocation + ? undefined + : BaseDirectory.AppLocalData + } + ) ) - await remove('game/' + managingVersion, { - baseDir: BaseDirectory.AppLocalData, - recursive: true - }) + await remove( + (customDataLocation ? customDataLocation + '/' : null) + + 'game/' + + managingVersion, + { + baseDir: customDataLocation + ? undefined + : BaseDirectory.AppLocalData, + recursive: true + } + ) //reinstall setSelectedVersionList([managingVersion]) diff --git a/src/popups/ModDownloads.tsx b/src/popups/ModDownloads.tsx index 117a03a..4f51658 100644 --- a/src/popups/ModDownloads.tsx +++ b/src/popups/ModDownloads.tsx @@ -30,7 +30,8 @@ export default function ModDownloadsPopup () { setShowModInfo, downloadVersions, downloadProgress, - versions + versions, + customDataLocation } = useGlobal() const [mods, setMods] = useState(0) @@ -208,14 +209,28 @@ export default function ModDownloadsPopup () { '/BepInEx/plugins/' + v.id if ( - await exists(path, { - baseDir: BaseDirectory.AppLocalData - }) + await exists( + (customDataLocation + ? customDataLocation + '/' + : null) + path, + { + baseDir: customDataLocation + ? undefined + : BaseDirectory.AppLocalData + } + ) ) - await remove(path, { - baseDir: BaseDirectory.AppLocalData, - recursive: true - }) + await remove( + (customDataLocation + ? customDataLocation + '/' + : null) + path, + { + baseDir: customDataLocation + ? undefined + : BaseDirectory.AppLocalData, + recursive: true + } + ) versions?.set( 'mods', Object.fromEntries( @@ -295,14 +310,26 @@ export default function ModDownloadsPopup () { '/BepInEx/plugins/' + showModInfo.id if ( - await exists(path, { - baseDir: BaseDirectory.AppLocalData - }) + await exists( + (customDataLocation ? customDataLocation + '/' : null) + + path, + { + baseDir: customDataLocation + ? undefined + : BaseDirectory.AppLocalData + } + ) ) - await remove(path, { - baseDir: BaseDirectory.AppLocalData, - recursive: true - }) + await remove( + (customDataLocation ? customDataLocation + '/' : null) + + path, + { + baseDir: customDataLocation + ? undefined + : BaseDirectory.AppLocalData, + recursive: true + } + ) versions?.set( 'mods', Object.fromEntries(