diff --git a/src/components/Checkbox.svelte b/src/components/Checkbox.svelte
index a5476e0..cab820d 100644
--- a/src/components/Checkbox.svelte
+++ b/src/components/Checkbox.svelte
@@ -2,6 +2,7 @@
import { _ } from 'svelte-i18n';
export let active: boolean = false;
+ export let disabled: boolean = false;
export let prop: string = '';
export let lang: string = '';
@@ -27,7 +28,7 @@
}
-
+
switchTheme(theme as string));
@@ -168,6 +170,15 @@
lang="settings.enhancements.items.fps_unlocker.title"
tooltip="settings.enhancements.items.fps_unlocker.tooltip"
prop="fps_unlocker"
+ disabled={!fpsUnlockerAvailable}
+ valueChanged={async (checked) => {
+ if (checked && !await FPSUnlock.installed())
+ {
+ fpsUnlockerAvailable = false;
+
+ FPSUnlock.install().then(() => fpsUnlockerAvailable = true);
+ }
+ }}
/>
resolve(`${await this.gameDataDir}/StreamingAssets/Audio/GeneratedSoundBanks/Windows`));
}
+
+ /**
+ * FPS Unlock directory
+ *
+ * @default "~/.local/share/anime-game-launcher/game/drive_c/Program Files/fpsunlock"
+ *
+ * @returns "[constants.paths.prefix.current]/drive_c/Program Files/fpsunlock"
+ */
+ public static get fpsunlockDir(): Promise
+ {
+ return new Promise(async (resolve) => resolve(`${await this.prefix.current}/drive_c/Program Files/fpsunlock`));
+ }
}
export default class constants
@@ -175,7 +187,11 @@ export default class constants
`log-upload-os.${this.placeholders.lowercase.company}.com`,
'overseauspider.yuanshen.com'
],
- winetricks: 'https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks'
+ winetricks: 'https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks',
+ fpsunlock: {
+ unlocker: `https://github.com/34736384/${this.placeholders.lowercase.first}-fps-unlock/releases/download/v1.4.2/unlockfps.exe`,
+ bat: 'https://dev.kaifa.ch/Maroxy/an-anime-game-aur/raw/branch/fpsunlock/fpsunlock.bat'
+ }
};
// TODO: cache drops at that dates instead of the 7 days period
diff --git a/src/ts/FPSUnlock.ts b/src/ts/FPSUnlock.ts
new file mode 100644
index 0000000..ec7d77c
--- /dev/null
+++ b/src/ts/FPSUnlock.ts
@@ -0,0 +1,46 @@
+import constants from './Constants';
+import Downloader from './core/Downloader';
+import Process from './neutralino/Process';
+
+declare const Neutralino;
+
+export default class FPSUnlock
+{
+ /**
+ * Check if the FPS Unlock installed
+ */
+ public static installed(): Promise
+ {
+ return new Promise(async (resolve) => {
+ Neutralino.filesystem.getStats(await constants.paths.fpsunlockDir)
+ .then(() => resolve(true))
+ .catch(() => resolve(false));
+ });
+ }
+
+ /**
+ * Install FPS unlocker
+ */
+ public static install(): Promise
+ {
+ return new Promise(async (resolve) => {
+ const fpsunlockDir = await constants.paths.fpsunlockDir;
+
+ await Neutralino.filesystem.createDirectory(fpsunlockDir);
+
+ Downloader.download(constants.uri.fpsunlock.unlocker, `${fpsunlockDir}/unlockfps.exe`).then((stream) => {
+ stream.finish(async () => {
+ const fpsunlockBat = `${await constants.paths.gameDir}/unlockfps.bat`;
+
+ Downloader.download(constants.uri.fpsunlock.bat, fpsunlockBat).then((stream) => {
+ stream.finish(async () => {
+ // sed -i 's/start ..\/GI_FPSUnlocker\/unlockfps.exe \%\*/start ..\/fpsunlock\/unlockfps.exe \%\*/g' unlockfps.bat
+ Neutralino.os.execCommand(`sed -i 's/start ..\\/GI_FPSUnlocker\\/unlockfps.exe \\%\\*/start ..\\/fpsunlock\\/unlockfps.exe \\%\\*/g' '${Process.addSlashes(fpsunlockBat)}'`)
+ .then(() => resolve());
+ });
+ });
+ });
+ });
+ });
+ }
+};
diff --git a/src/ts/launcher/State.ts b/src/ts/launcher/State.ts
index 811c2c8..5f9f399 100644
--- a/src/ts/launcher/State.ts
+++ b/src/ts/launcher/State.ts
@@ -11,8 +11,6 @@ import { DebugThread } from '../core/Debug';
import DXVK from '../core/DXVK';
import IPC from '../core/IPC';
-declare const Neutralino;
-
export default class State
{
public launcher: Launcher;
@@ -157,7 +155,7 @@ export default class State
break;
case 'patch-unavailable':
- // todo some warning message
+ // TODO: some warning message
this.launchButton.textContent = 'Patch unavailable';
break;
diff --git a/src/ts/launcher/states/Launch.ts b/src/ts/launcher/states/Launch.ts
index 27ba12e..5b872b4 100644
--- a/src/ts/launcher/states/Launch.ts
+++ b/src/ts/launcher/states/Launch.ts
@@ -114,15 +114,13 @@ export default (): Promise => {
else console.warn(`GPU ${LauncherLib.getConfig('gpu')} not found. Launching on the default GPU`);
}*/
- // let command = `${wineExeutable} ${LauncherLib.getConfig('fpsunlock') ? 'fpsunlock.bat' : 'launcher.bat'}`;
+ let command = `'${Process.addSlashes(wineExeutable)}' ${await Configs.get('fps_unlocker') ? 'unlockfps.bat' : 'launcher.bat'}`;
/**
* Gamemode integration
*/
- /*if (LauncherLib.getConfig('gamemode'))
- command = `gamemoderun ${command}`;*/
-
- const command = `'${Process.addSlashes(wineExeutable)}' launcher.bat`;
+ if (await Configs.get('gamemode'))
+ command = `gamemoderun ${command}`;
console.log({
WINEPREFIX: await constants.paths.prefix.current,