Skip to content

Commit

Permalink
Don't rename OBS files by default
Browse files Browse the repository at this point in the history
  • Loading branch information
vinceau committed Nov 30, 2020
1 parent 67f97a2 commit 3356bc2
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 12 deletions.
13 changes: 9 additions & 4 deletions src/renderer/containers/OBSStatusBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,14 @@ const StopButton = styled(Button)`

export const OBSStatusBar: React.FC = () => {
const history = useHistory();
const { recordSeparateClips } = useSelector((state: iRootState) => state.filesystem);
const { obsConnectionStatus, obsRecordingStatus, dolphinQueue, dolphinPlaybackFile, dolphinRunning } = useSelector(
(state: iRootState) => state.tempContainer
);
const autoNameRecordedFiles = useSelector((state: iRootState) => state.appContainer.autoNameRecordedFiles);
const recordSeparateClips = useSelector((state: iRootState) => state.filesystem.recordSeparateClips);
const obsConnectionStatus = useSelector((state: iRootState) => state.tempContainer.obsConnectionStatus);
const obsRecordingStatus = useSelector((state: iRootState) => state.tempContainer.obsRecordingStatus);
const dolphinQueue = useSelector((state: iRootState) => state.tempContainer.dolphinQueue);
const dolphinPlaybackFile = useSelector((state: iRootState) => state.tempContainer.dolphinPlaybackFile);
const dolphinRunning = useSelector((state: iRootState) => state.tempContainer.dolphinRunning);

const dispatch = useDispatch<Dispatch>();

const recordValue = recordSeparateClips ? RecordingMethod.SEPARATE : RecordingMethod.TOGETHER;
Expand All @@ -71,6 +75,7 @@ export const OBSStatusBar: React.FC = () => {
loadQueueIntoDolphin({
record: true,
recordAsOneFile: !recordSeparateClips,
renameOutput: autoNameRecordedFiles,
}).catch(console.error);
};

Expand Down
14 changes: 9 additions & 5 deletions src/renderer/lib/dolphin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ import { toastNoDolphin } from "./toasts";
const defaultDolphinRecorderOptions = {
record: false,
recordAsOneFile: true,
renameOutput: false,
outputFilename: "",
outputFolder: "ProjectClippi",
outputFolder: "",
gameEndDelayMs: 1000,
};

Expand Down Expand Up @@ -162,8 +163,8 @@ export class DolphinRecorder extends DolphinLauncher {
}

private async _handleSetOBSFilename(filename: string): Promise<void> {
// Return if recording is off, or if recording has already started
if (!this.recordOptions.record || obsConnection.isRecording()) {
// Return if recording is off, or if recording has already started, or if we're not changing output names
if (!this.recordOptions.record || obsConnection.isRecording() || !this.recordOptions.renameOutput) {
return;
}

Expand Down Expand Up @@ -196,8 +197,11 @@ export class DolphinRecorder extends DolphinLauncher {
if (obsConnection.isRecording()) {
await obsConnection.setRecordingState(OBSRecordingAction.STOP);
}
// Restore the original user filename format
await obsConnection.setFilenameFormat(this.userFilenameFormat);

// Restore the original user filename format if we changed it
if (this.recordOptions.renameOutput) {
await obsConnection.setFilenameFormat(this.userFilenameFormat);
}

if (killDolphin) {
this.killDolphin();
Expand Down
7 changes: 7 additions & 0 deletions src/renderer/store/models/appContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import { createModel } from "@rematch/core";

export interface AppContainerState {
showDevOptions: boolean;
autoNameRecordedFiles: boolean;
}

const initialState: AppContainerState = {
showDevOptions: false,
autoNameRecordedFiles: false,
};

export const appContainer = createModel({
Expand All @@ -18,5 +20,10 @@ export const appContainer = createModel({
draft.showDevOptions = payload;
});
},
setAutoNameRecordedFiles: (state: AppContainerState, payload: boolean): AppContainerState => {
return produce(state, (draft) => {
draft.autoNameRecordedFiles = payload;
});
},
},
});
21 changes: 18 additions & 3 deletions src/renderer/views/settings/PlaybackSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from "react";

import { FileInput } from "@/components/FileInput";

import { Field, FormContainer, Label, PageHeader, Text } from "@/components/Form";
import { Field, FormContainer, Label, PageHeader, Text, Toggle } from "@/components/Form";
import { getDolphinExecutableNames, getDolphinPath } from "@/lib/dolphin";
import { Dispatch, iRootState } from "@/store";
import { useDispatch, useSelector } from "react-redux";
Expand Down Expand Up @@ -49,10 +49,12 @@ const PlaybackExecutableNames: React.FC = () => {
export const PlaybackSettings: React.FC = () => {
const dispatch = useDispatch<Dispatch>();
const { meleeIsoPath, dolphinPath } = useSelector((state: iRootState) => state.filesystem);
const { showDevOptions } = useSelector((state: iRootState) => state.appContainer);
const showDevOptions = useSelector((state: iRootState) => state.appContainer.showDevOptions);
const autoNameRecordedFiles = useSelector((state: iRootState) => state.appContainer.autoNameRecordedFiles);
const setMeleeIsoPath = (filePath: string) => dispatch.filesystem.setMeleeIsoPath(filePath);
const setDolphinPath = (filePath: string) => dispatch.filesystem.setDolphinPath(filePath);
const resetDolphinPath = () => dispatch.filesystem.setDolphinPath(defaultDolphinPath);
const setAutoNameRecordedFiles = () => dispatch.appContainer.setAutoNameRecordedFiles(!autoNameRecordedFiles);
const showDolphinPathField = showDevOptions || !IS_MAC_OR_WIN;
const showResetButton = showDolphinPathField && dolphinPath !== defaultDolphinPath;
return (
Expand All @@ -66,8 +68,9 @@ export const PlaybackSettings: React.FC = () => {
should match the Melee ISO File in the Slippi Desktop App.
</Text>
</Field>

{showDolphinPathField && (
<Field border="top">
<Field padding="bottom">
<DolphinPathLabel>
<Label>Playback Dolphin Path</Label>
{showResetButton && (
Expand All @@ -84,6 +87,18 @@ export const PlaybackSettings: React.FC = () => {
</Text>
</Field>
)}

<Field border="top">
<Toggle
value={autoNameRecordedFiles}
onChange={setAutoNameRecordedFiles}
label="Auto-name Recorded Files (experimental)"
/>
<Text>
If enabled, games that are recorded separately will have their video file named to match the SLP filename.
Restoration of the original OBS filename format is NOT guaranteed. Use at own risk.
</Text>
</Field>
</FormContainer>
);
};

0 comments on commit 3356bc2

Please sign in to comment.