summaryrefslogtreecommitdiff
path: root/frontend/src/components/modals/filepicker/patches/library.ts
diff options
context:
space:
mode:
authorAAGaming <aa@mail.catvibers.me>2022-09-09 16:25:52 -0400
committerAAGaming <aa@mail.catvibers.me>2022-09-09 16:25:52 -0400
commitb5b041fdee3cdb3576cd4d1c77580f57da0b6435 (patch)
tree2b63ccb6410868fe4f0c6f3882614d0f7a180be4 /frontend/src/components/modals/filepicker/patches/library.ts
parent9d980618a78b41bc3262c5185df67ccf6076a296 (diff)
downloaddecky-loader-b5b041fdee3cdb3576cd4d1c77580f57da0b6435.tar.gz
decky-loader-b5b041fdee3cdb3576cd4d1c77580f57da0b6435.zip
add file picker, add library file picker patch, bump lib, logger tweaks
Diffstat (limited to 'frontend/src/components/modals/filepicker/patches/library.ts')
-rw-r--r--frontend/src/components/modals/filepicker/patches/library.ts32
1 files changed, 32 insertions, 0 deletions
diff --git a/frontend/src/components/modals/filepicker/patches/library.ts b/frontend/src/components/modals/filepicker/patches/library.ts
new file mode 100644
index 00000000..8792900d
--- /dev/null
+++ b/frontend/src/components/modals/filepicker/patches/library.ts
@@ -0,0 +1,32 @@
+import { replacePatch, sleep } from 'decky-frontend-lib';
+
+declare global {
+ interface Window {
+ SteamClient: any;
+ appDetailsStore: any;
+ }
+}
+
+export default async function libraryPatch() {
+ await sleep(10000); // If you patch anything on SteamClient within the first few seconds of the client having loaded it will get redefined for some reason, so wait 10s
+ const patch = replacePatch(window.SteamClient.Apps, 'PromptToChangeShortcut', async ([appid]: number[]) => {
+ try {
+ const details = window.appDetailsStore.GetAppDetails(appid);
+ console.log(details);
+ // strShortcutStartDir
+ const file = await window.DeckyPluginLoader.openFilePicker(details.strShortcutStartDir.replaceAll('"', ''));
+ console.log('user selected', file);
+ window.SteamClient.Apps.SetShortcutExe(appid, JSON.stringify(file.path));
+ const pathArr = file.path.split('/');
+ pathArr.pop();
+ const folder = pathArr.join('/');
+ window.SteamClient.Apps.SetShortcutStartDir(appid, JSON.stringify(folder));
+ } catch (e) {
+ console.error(e);
+ }
+ });
+
+ return () => {
+ patch.unpatch();
+ };
+}