mirror of
https://github.com/an-anime-team/an-anime-game-launcher.git
synced 2024-12-29 21:18:17 +03:00
Added fps unlocker
This commit is contained in:
parent
9a2666b8b3
commit
d90f339eb1
6 changed files with 81 additions and 11 deletions
|
@ -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 @@
|
|||
}
|
||||
</script>
|
||||
|
||||
<div class="checkbox" class:checkbox-active={active}>
|
||||
<div class="checkbox" class:checkbox-active={active} class:checkbox-disabled={disabled}>
|
||||
<span
|
||||
class:hint--bottom={tooltip !== ''}
|
||||
class:hint--medium={tooltip !== ''}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
import { _, locale, locales } from 'svelte-i18n';
|
||||
|
||||
import Configs from './ts/Configs';
|
||||
import FPSUnlock from './ts/FPSUnlock';
|
||||
|
||||
import Checkbox from './components/Checkbox.svelte';
|
||||
import SelectionBox from './components/SelectionBox.svelte';
|
||||
|
@ -102,7 +103,8 @@
|
|||
};
|
||||
|
||||
let dxvkRecommendable = true,
|
||||
runnersRecommendable = true;
|
||||
runnersRecommendable = true,
|
||||
fpsUnlockerAvailable = true;
|
||||
|
||||
// Auto theme switcher
|
||||
Configs.get('theme').then((theme) => 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);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
|
||||
<Checkbox
|
||||
|
|
|
@ -144,6 +144,18 @@ class Paths
|
|||
{
|
||||
return new Promise(async (resolve) => 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<string>
|
||||
{
|
||||
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
|
||||
|
|
46
src/ts/FPSUnlock.ts
Normal file
46
src/ts/FPSUnlock.ts
Normal file
|
@ -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<boolean>
|
||||
{
|
||||
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<void>
|
||||
{
|
||||
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());
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
|
@ -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;
|
||||
|
|
|
@ -114,15 +114,13 @@ export default (): Promise<void> => {
|
|||
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,
|
||||
|
|
Loading…
Reference in a new issue