Skip to content

Commit

Permalink
obs-vkcapture support
Browse files Browse the repository at this point in the history
  • Loading branch information
EliteAsian123 committed Aug 28, 2024
1 parent 08e6459 commit 54d1b4f
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 8 deletions.
19 changes: 14 additions & 5 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,15 +243,24 @@ fn uninstall_profile(profile_path: String) -> Result<(), String> {
}

#[tauri::command]
fn launch_profile(profile_path: String, exec_path: String, arguments: Vec<String>) -> Result<(), String> {
fn launch_profile(profile_path: String, exec_path: String, use_obs_vkcapture: bool, arguments: Vec<String>) -> Result<(), String> {
let mut path = PathBuf::from(&profile_path);
path.push("installation");
path.push(exec_path);

Command::new(path)
.args(arguments)
.spawn()
.map_err(|e| format!("Failed to launch profile? Is the executable installed?\n{:?}", e))?;
if !use_obs_vkcapture {
Command::new(path)
.args(arguments)
.spawn()
.map_err(|e| format!("Failed to launch profile! Is the executable installed?\n{:?}", e))?;
} else {
let path_str = path_to_string(path)?;

Command::new("obs-gamecapture")
.args([path_str].iter().chain(&arguments))
.spawn()
.map_err(|e| format!("Failed to launch profile! Is the executable installed? Is obs-vkcapture installed and pathed?\n{:?}", e))?;
}

Ok(())
}
Expand Down
1 change: 1 addition & 0 deletions src/profiles/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export const launch = async (activeProfile: ActiveProfile, profilePath: string):
await invoke("launch_profile", {
profilePath: profilePath,
execPath: launchOptions.executablePath,
useObsVkcapture: os === "linux" && activeProfile.useObsVkcapture,
arguments: [...launchOptions.arguments, ...otherArguments, ...customArguments]
});
} catch (e) {
Expand Down
1 change: 1 addition & 0 deletions src/profiles/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export const useProfileStore = create<ProfileStore>()((set, get) => ({
displayName: undefined,
selectedVersion: undefined,
launchArguments: "",
useObsVkcapture: false,

lastPlayed: undefined,

Expand Down
1 change: 1 addition & 0 deletions src/profiles/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export interface ActiveProfile {
displayName?: string,
selectedVersion?: string,
launchArguments: string,
useObsVkcapture: boolean,

lastPlayed?: string,

Expand Down
12 changes: 12 additions & 0 deletions src/routes/AppProfile/AppSettings.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,29 @@
gap: 15px;
}

.setting.wide {
justify-content: space-between;
}

.setting > p {
width: 175px;

color: #41475F;
}

.setting.wide > p {
width: auto;
}

.setting > input {
align-self: center;
flex: 1 0 0;
}

.setting > button {
align-self: center;
}

.navigation {
display: flex;
flex-direction: row;
Expand Down
36 changes: 33 additions & 3 deletions src/routes/AppProfile/AppSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Button, { ButtonColor } from "@app/components/Button";
import styles from "./AppSettings.module.css";
import { useState } from "react";
import { useEffect, useState } from "react";
import { ActiveProfile, VersionInfoList, VersionList } from "@app/profiles/types";
import { localizeMetadata } from "@app/profiles/utils";
import { tryFetchVersion, useProfileStore } from "@app/profiles/store";
Expand All @@ -11,6 +11,7 @@ import { useQuery } from "@tanstack/react-query";
import { createAndShowDialog, showErrorDialog } from "@app/dialogs";
import { distanceFromToday } from "@app/utils/timeFormat";
import { OldVersionDialog } from "@app/dialogs/Dialogs/OldVersionDialog";
import { OS, getOS } from "@app/utils/os";

interface VersionListProps {
activeProfile: ActiveProfile,
Expand All @@ -36,7 +37,7 @@ const VersionListComp: React.FC<VersionListProps> = ({ activeProfile, selectedVe

if (versionDialogOutput === "okay") {
setSelectedVersion(uuid);
}
}
} else {
setSelectedVersion(uuid);
}
Expand Down Expand Up @@ -100,8 +101,17 @@ const AppSettings: React.FC<Props> = ({ activeProfile, setSettingsOpen }: Props)
initalDisplayName = localizeMetadata(activeProfile.profile, "en-US").name;
}

const [os, setOs] = useState<OS | undefined>();
useEffect(() => {
(async () => {
setOs(await getOS());
})();
});

const [displayName, setDisplayName] = useState<string>(initalDisplayName);
const [launchArguments, setLaunchArguments] = useState<string>(activeProfile.launchArguments);
const [obsVkcapture, setObsVkcapture] = useState<boolean>(activeProfile.useObsVkcapture);

const [selectedVerison, setSelectedVersion] = useState<string | undefined>(activeProfile.selectedVersion);

return <div className={styles.popup}>
Expand All @@ -124,6 +134,25 @@ const AppSettings: React.FC<Props> = ({ activeProfile, setSettingsOpen }: Props)
<p>Additional Launch Arguments</p>
<InputBox state={launchArguments} setState={setLaunchArguments} placeholder="Launch arguments..." />
</div>
{os === "linux" &&
<div className={[styles.setting, styles.wide].join(" ")}>
<p>Use obs-vkcapture wrapper (you need to have it installed)</p>
{obsVkcapture &&
<Button color={ButtonColor.GREEN} rounded border
onClick={() => setObsVkcapture(false)}>

Enabled
</Button>
}
{!obsVkcapture &&
<Button color={ButtonColor.LIGHT} rounded
onClick={() => setObsVkcapture(true)}>

Disabled
</Button>
}
</div>
}
</Tabs.Content>
<Tabs.Content className={styles.versionList} value="version">
<VersionListComp
Expand All @@ -144,8 +173,9 @@ const AppSettings: React.FC<Props> = ({ activeProfile, setSettingsOpen }: Props)
activeProfile.displayName = displayName;
}

// Update launch arguments
// Update other fields
activeProfile.launchArguments = launchArguments;
activeProfile.useObsVkcapture = obsVkcapture;

// Update profile version
if (selectedVerison !== activeProfile.selectedVersion) {
Expand Down

0 comments on commit 54d1b4f

Please sign in to comment.