Merge pull request #179 from Zagrios/feature/custom-launch-options/177

feature/custom-launch-options/177
This commit is contained in:
MathieuG-P
2023-03-13 01:36:22 +01:00
committed by GitHub
8 changed files with 56 additions and 31 deletions
+5 -1
View File
@@ -28,7 +28,11 @@
"desktop": "Desktop Mode",
"desktop-description": "This allows you to use WASD and the mouse to navigate around the menu in game. This makes testing much easier, because you don't have to put on your headset!",
"debug": "Debug Mode",
"debug-description": "Enables the output log window for IPA. This will show the debug console that mods use."
"debug-description": "Enables the output log window for IPA. This will show the debug console that mods use.",
"advanced-launch": {
"button": "Advanced launch",
"placeholder": "Additional arguments ex: --revert; --nowait"
}
},
"maps": {
"title": "Shared maps",
+5 -1
View File
@@ -28,7 +28,11 @@
"desktop": "Desktop Mod",
"desktop-description": "Esto te permite usar WASD y el mouse para navegar por el menú en juego. Esto hace que las pruebas sean mucho más fáciles, ¡porque no tienes que ponerte el auricular!",
"debug": "Debug Mod",
"debug-description": "Habilita la ventana de registro de salida para IPA. Esto mostrará la consola de depuración que usan los mods."
"debug-description": "Habilita la ventana de registro de salida para IPA. Esto mostrará la consola de depuración que usan los mods.",
"advanced-launch": {
"button": "Lanzamiento avanzado",
"placeholder": "Argumentos adicionales ej: --revert; --no-wait"
}
},
"maps": {
"search-bar": {
+5 -1
View File
@@ -28,7 +28,11 @@
"desktop": "Mode Bureau",
"desktop-description": "Cela vous permet d'utiliser WASD et la souris pour naviguer dans le menu en jeu. Cela rend les tests beaucoup plus faciles, car vous n'avez pas à mettre votre casque!",
"debug": "Mode Debug",
"debug-description": "Active la fenêtre de log pour IPA. Cela affichera la console de débogage utilisée par les mods."
"debug-description": "Active la fenêtre de log pour IPA. Cela affichera la console de débogage utilisée par les mods.",
"advanced-launch": {
"button": "Lancement avancé",
"placeholder": "Arguments supplémentaires ex: --revert; --nowait"
}
},
"maps": {
"search-bar": {
+10 -7
View File
@@ -45,18 +45,21 @@ export class BSLauncherService{
if(!(await pathExist(exePath))){ return "EXE_NOT_FINDED"; }
const launchMods = [];
let launchArgs = [];
if(!launchOptions.version.steam && !launchOptions.version.oculus){ launchMods.push("--no-yeet"); }
if(launchOptions.oculus){ launchMods.push("-vrmode oculus"); }
if(launchOptions.desktop){ launchMods.push("fpfc"); }
if(launchOptions.debug){ launchMods.push("--verbose"); }
if(!launchOptions.version.steam && !launchOptions.version.oculus){ launchArgs.push("--no-yeet"); }
if(launchOptions.oculus){ launchArgs.push("-vrmode oculus"); }
if(launchOptions.desktop){ launchArgs.push("fpfc"); }
if(launchOptions.debug){ launchArgs.push("--verbose"); }
if(launchOptions.additionalArgs){ launchArgs.push(...launchOptions.additionalArgs); }
launchArgs = Array.from(new Set(launchArgs).values());
if(launchOptions.debug){
this.bsProcess = spawn(`\"${exePath}\"`, launchMods, {shell: true, cwd, env: {...process.env, "SteamAppId": BS_APP_ID}, detached: true, windowsVerbatimArguments: true });
this.bsProcess = spawn(`\"${exePath}\"`, launchArgs, {shell: true, cwd, env: {...process.env, "SteamAppId": BS_APP_ID}, detached: true, windowsVerbatimArguments: true });
}
else{
this.bsProcess = spawn(`\"${exePath}\"`, launchMods, {shell: true, cwd, env: {...process.env, "SteamAppId": BS_APP_ID} });
this.bsProcess = spawn(`\"${exePath}\"`, launchArgs, {shell: true, cwd, env: {...process.env, "SteamAppId": BS_APP_ID} });
}
this.bsProcess.on('message', msg => console.log(msg));
@@ -1,6 +1,8 @@
import { useState } from "react";
import { motion } from "framer-motion";
import { ChangeEvent, useEffect, useState } from "react";
import { BsmButton } from "renderer/components/shared/bsm-button.component";
import { useObservable } from "renderer/hooks/use-observable.hook";
import { useTranslation } from "renderer/hooks/use-translation.hook";
import { BSLauncherService, LaunchMods } from "renderer/services/bs-launcher.service";
import { ConfigurationService } from "renderer/services/configuration.service";
import { BSVersion } from "shared/bs-version.interface"
@@ -10,15 +12,23 @@ type Props = {version: BSVersion};
export function LaunchSlide({version}: Props) {
const t = useTranslation();
const configService = ConfigurationService.getInstance();
const bsLauncherService = BSLauncherService.getInstance();
const [oculusMode, setOculusMode] = useState(!!configService.get<boolean>(LaunchMods.OCULUS_MOD));
const [desktopMode, setDesktopMode] = useState(!!configService.get<boolean>(LaunchMods.DESKTOP_MOD));
const [debugMode, setDebugMode] = useState(!!configService.get<boolean>(LaunchMods.DEBUG_MOD));
const [advancedLaunch, setAdvancedLaunch] = useState(false);
const [additionalArgsString, setAdditionalArgsString] = useState<string>(configService.get<string>("additionnal-args") || "");
const launchState = useObservable(bsLauncherService.launchState$);
useEffect(() => {
configService.set("additionnal-args", additionalArgsString);
}, [additionalArgsString]);
const setMode = (mode: LaunchMods, value: boolean) => {
if(mode === LaunchMods.DEBUG_MOD){
setDebugMode(value);
@@ -32,7 +42,12 @@ export function LaunchSlide({version}: Props) {
configService.set(mode, value);
}
const launch = () => bsLauncherService.launch(version, version.oculus ? false : oculusMode, desktopMode, debugMode)
const handleAdditionalArgsChange = (e: ChangeEvent<HTMLInputElement>) => setAdditionalArgsString(() => e.target.value);
const launch = () => {
const additionalArgs = advancedLaunch ? additionalArgsString.split(";").map(arg => arg.trim()).filter(arg => arg.length > 0) : undefined;
bsLauncherService.launch(version, version.oculus ? false : oculusMode, desktopMode, debugMode, additionalArgs);
}
return (
<div className="w-full shrink-0 items-center relative flex flex-col justify-start">
@@ -41,8 +56,14 @@ export function LaunchSlide({version}: Props) {
<LaunchModToogle infoText="pages.version-viewer.launch-mods.desktop-description" icon='desktop' onClick={() => setMode(LaunchMods.DESKTOP_MOD, !desktopMode)} active={desktopMode} text="pages.version-viewer.launch-mods.desktop"/>
<LaunchModToogle infoText="pages.version-viewer.launch-mods.debug-description" icon='terminal' onClick={() => setMode(LaunchMods.DEBUG_MOD, !debugMode)} active={debugMode} text="pages.version-viewer.launch-mods.debug"/>
</div>
<div className="pt-4 w-2/3 flex flex-col items-center gap-3">
<BsmButton className="rounded-full w-fit text-lg py-1 px-7 shadow-md shadow-black bg-light-main-color-2 dark:bg-main-color-2 text-gray-800 dark:text-white" text="pages.version-viewer.launch-mods.advanced-launch.button" withBar={false} onClick={e => {e.preventDefault(); setAdvancedLaunch(prev => !prev)}}/>
<motion.div className="bg-light-main-color-2 dark:bg-main-color-2 h-9 rounded-full overflow-hidden flex items-center justify-center" initial={{width: "0px"}} animate={{width: advancedLaunch ? "100%" : "0px"}}>
<input className="w-[calc(100%-12px)] h-[calc(100%-12px)] bg-light-main-color-1 dark:bg-main-color-1 text-black dark:text-white rounded-full outline-none text-center" type="text" placeholder={t("pages.version-viewer.launch-mods.advanced-launch.placeholder")} value={additionalArgsString} onChange={handleAdditionalArgsChange}/>
</motion.div>
</div>
<div className='grow flex justify-center items-center'>
<BsmButton onClick={launch} active={JSON.stringify(version) === JSON.stringify(launchState)} className='relative text-5xl text-gray-800 dark:text-gray-200 font-bold tracking-wide pt-1 pb-3 px-7 rounded-lg shadow-md italic shadow-black active:scale-90 transition-transform' text="misc.launch"/>
<BsmButton onClick={launch} active={JSON.stringify(version) === JSON.stringify(launchState)} className='relative -translate-y-1/2 text-5xl text-gray-800 dark:text-gray-200 font-bold tracking-wide pt-1 pb-3 px-7 rounded-lg shadow-md italic shadow-black active:scale-90 transition-transform' text="misc.launch"/>
</div>
</div>
)
@@ -40,7 +40,6 @@ export function SettingsPage() {
const modalService: ModalService = ModalService.getInsance();
const downloaderService: BsDownloaderService = BsDownloaderService.getInstance();
const progressBarService: ProgressBarService = ProgressBarService.getInstance();
const authService: AuthUserService = AuthUserService.getInstance();
const notificationService: NotificationService = NotificationService.getInstance();
const i18nService: I18nService = I18nService.getInstance();
const linkOpener: LinkOpenerService = LinkOpenerService.getInstance();
@@ -49,7 +48,6 @@ export function SettingsPage() {
const modelsManager = ModelsManagerService.getInstance();
const {firstColor, secondColor} = useThemeColor();
const sessionExist = useObservable(authService.sessionExist$);
const themeItem: RadioItem[] = [
{id: 0, text: "pages.settings.appearance.themes.dark", value: "dark" as ThemeConfig},
@@ -133,12 +131,6 @@ export function SettingsPage() {
});
}
const deleteSteamSession = () => {
if(!sessionExist){ return; }
authService.deleteSteamSession();
notificationService.notifySuccess({title: "notifications.settings.steam.success.titles.logout", duration: 3000});
};
const toogleShowSupporters = () => {
setShowSupporters(show => !show);
@@ -196,10 +188,6 @@ export function SettingsPage() {
<BsmButton className="inline-block grow-0 bg-transparent sticky h-full w-full top-20 right-20 !m-0 rounded-full p-1" onClick={() => nav(-1)} icon="close" withBar={false}/>
</div>
<SettingContainer title="pages.settings.steam.title" description="pages.settings.steam.description">
<BsmButton onClick={deleteSteamSession} className="w-fit px-3 py-[2px] text-white rounded-md" withBar={false} text="pages.settings.steam.logout" typeColor="error" disabled={!sessionExist}/>
</SettingContainer>
<SettingContainer title="pages.settings.appearance.title" description="pages.settings.appearance.description">
<div className="relative w-full h-8 bg-light-main-color-1 dark:bg-main-color-1 flex justify-center rounded-md py-1">
<SettingColorChooser color={firstColor} onChange={setFirstColorSetting}/>
+2 -2
View File
@@ -40,8 +40,8 @@ export class BSLauncherService{
public launch(version: BSVersion, oculus: boolean, desktop: boolean, debug: boolean): Promise<NotificationResult|string>{
const lauchOption: LauchOption = {debug, oculus, desktop, version};
public launch(version: BSVersion, oculus: boolean, desktop: boolean, debug: boolean, additionalArgs?: string[]): Promise<NotificationResult|string>{
const lauchOption: LauchOption = {debug, oculus, desktop, version, additionalArgs};
if(this.launchState$.value){ return this.notificationService.notifyError({title: "notifications.bs-launch.errors.titles.BS_ALREADY_RUNNING"}); }
this.launchState$.next(version);
return this.ipcService.send<LaunchResult>("bs-launch.launch", {args: lauchOption}).then(res => {
@@ -1,8 +1,9 @@
import { BSVersion } from "shared/bs-version.interface";
export interface LauchOption {
version: BSVersion,
oculus: boolean,
desktop: boolean,
debug: boolean
version: BSVersion,
oculus: boolean,
desktop: boolean,
debug: boolean,
additionalArgs?: string[]
}