diff --git a/interface/src/utils.ts b/interface/src/utils.ts new file mode 100644 index 0000000..2ced547 --- /dev/null +++ b/interface/src/utils.ts @@ -0,0 +1,31 @@ +export function chooseFile(setter: (value: string) => void, cancel?: () => void) +{ + window.saucer.call("choose-path", []).then(result => + { + if (result) + { + setter(result); + return; + } + + if (!cancel) + { + return; + } + + cancel(); + }); +} + +export function chooseFolder(setter: (value: string) => void) +{ + window.saucer.call("choose-folder", []).then(result => + { + if (!result) + { + return; + } + + setter(result); + }); +} diff --git a/interface/types/global.d.ts b/interface/types/global.d.ts index 8e87caf..3726512 100644 --- a/interface/types/global.d.ts +++ b/interface/types/global.d.ts @@ -4,21 +4,22 @@ interface Window { call: { - (func: "load", args: [string: path]): Promise; + (func: "load", args: [string: path]): Promise; (func: "list", args: []): Promise; (func: "decompile", args: [string: name]): Promise; (func: "cancel", args: []): Promise; - (func: "export", args: []): Promise; + (func: "export", args: [string: path]): Promise; - (func: "java-path", args: []): Promise; - (func: "unluac-path", args: []): Promise; + (func: "java-path", args: []): Promise; + (func: "unluac-path", args: []): Promise; - (func: "set-java-path", args: [string: path]): Promise; - (func: "set-unluac-path", args: [string: path]): Promise; + (func: "set-java-path", args: [string?: path]): Promise; + (func: "set-unluac-path", args: [string?: path]): Promise; - (func: "choose-path", args: []): Promise; + (func: "choose-path", args: [string?: path]): Promise; + (func: "choose-folder", args: [string?: path]): Promise; }; }