Skip to content

Commit

Permalink
sorry nikki im indecisive ok
Browse files Browse the repository at this point in the history
  • Loading branch information
vinceau committed Jul 13, 2023
1 parent 4baea8a commit b8545d6
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 30 deletions.
12 changes: 6 additions & 6 deletions src/dolphin/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { IniFile } from "./iniFile";
export type SyncedDolphinSettings = {
useMonthlySubfolders: boolean;
replayPath: string;
jukebox: boolean;
enableJukebox: boolean;
};

export async function addGamePath(iniFile: IniFile, gameDir: string): Promise<void> {
Expand All @@ -20,16 +20,16 @@ export async function addGamePath(iniFile: IniFile, gameDir: string): Promise<vo

export async function setSlippiSettings(iniFile: IniFile, options: Partial<SyncedDolphinSettings>): Promise<void> {
const useMonthlySubfolders = options.useMonthlySubfolders ? "True" : "False";
const jukebox = options.jukebox ? "True" : "False";
const enableJukebox = options.enableJukebox ? "True" : "False";
const coreSection = iniFile.getOrCreateSection("Core");
if (options.replayPath !== undefined) {
coreSection.set("SlippiReplayDir", options.replayPath);
}
if (options.useMonthlySubfolders !== undefined) {
coreSection.set("SlippiReplayMonthFolders", useMonthlySubfolders);
}
if (options.jukebox !== undefined) {
coreSection.set("SlippiJukeboxEnabled", jukebox);
if (options.enableJukebox !== undefined) {
coreSection.set("SlippiJukeboxEnabled", enableJukebox);
}
await iniFile.save();
}
Expand All @@ -39,9 +39,9 @@ export async function getSlippiSettings(iniFile: IniFile): Promise<SyncedDolphin
const useMonthlySubfolders = coreSection.get("SlippiReplayMonthFolders", "False") === "True";
const replayPath = coreSection.get("SlippiReplayDir", defaultAppSettings.settings.rootSlpPath);

const jukebox = coreSection.get("SlippiJukeboxEnabled", "True") === "True";
const enableJukebox = coreSection.get("SlippiJukeboxEnabled", "True") === "True";

return { useMonthlySubfolders, replayPath, jukebox };
return { useMonthlySubfolders, replayPath, enableJukebox };
}

export async function setBootToCss(globalIni: IniFile, localIni: IniFile, enable: boolean): Promise<void> {
Expand Down
2 changes: 1 addition & 1 deletion src/dolphin/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ export class DolphinManager {

await this.settingsManager.setRootSlpPath(newSettings.replayPath);
await this.settingsManager.setUseMonthlySubfolders(newSettings.useMonthlySubfolders);
await this.settingsManager.setJukebox(newSettings.jukebox);
await this.settingsManager.setEnableJukebox(newSettings.enableJukebox);
}

private _onStart(dolphinType: DolphinLaunchType) {
Expand Down
10 changes: 5 additions & 5 deletions src/renderer/containers/Settings/MeleeOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { Toggle } from "@/components/FormInputs/Toggle";
import { PathInput } from "@/components/PathInput";
import { useDolphinStore } from "@/lib/dolphin/useDolphinStore";
import { useIsoVerification } from "@/lib/hooks/useIsoVerification";
import { useIsoPath, useJukebox, useLaunchMeleeOnPlay } from "@/lib/hooks/useSettings";
import { useEnableJukebox, useIsoPath, useLaunchMeleeOnPlay } from "@/lib/hooks/useSettings";

import { SettingItem } from "./SettingItem";

Expand All @@ -39,7 +39,7 @@ export const MeleeOptions = React.memo(() => {
const isoValidity = useIsoVerification((state) => state.validity);
const [isoPath, setIsoPath] = useIsoPath();
const [launchMeleeOnPlay, setLaunchMelee] = useLaunchMeleeOnPlay();
const [jukebox, setJukebox] = useJukebox();
const [enableJukebox, setEnableJukebox] = useEnableJukebox();
const netplayDolphinOpen = useDolphinStore((store) => store.netplayOpened);
const playbackDolphinOpen = useDolphinStore((store) => store.playbackOpened);

Expand Down Expand Up @@ -89,10 +89,10 @@ export const MeleeOptions = React.memo(() => {
{showJukeboxToggle && (
<SettingItem name="">
<Toggle
value={jukebox}
onChange={(checked) => setJukebox(checked)}
value={enableJukebox}
onChange={(checked) => setEnableJukebox(checked)}
label="Enable Music"
description="Enable music in game via Slippi Jukebox. Incompatible with WASAPI."
description="Enable in-game music via Slippi Jukebox. Incompatible with WASAPI."
disabled={netplayDolphinOpen}
/>
</SettingItem>
Expand Down
12 changes: 6 additions & 6 deletions src/renderer/lib/hooks/useSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ export const useMonthlySubfolders = () => {
return [useMonthlySubfolders, setUseMonthlySubfolders] as const;
};

export const useJukebox = () => {
const jukebox = useSettings((store) => store.settings.jukebox);
const setJukebox = async (toggle: boolean) => {
await window.electron.settings.setJukebox(toggle);
};
return [jukebox, setJukebox] as const;
export const useEnableJukebox = () => {
const enableJukebox = useSettings((store) => store.settings.enableJukebox);
const setEnableJukebox = useCallback(async (toggle: boolean) => {
await window.electron.settings.setEnableJukebox(toggle);
}, []);
return [enableJukebox, setEnableJukebox] as const;
};

export const useSpectateSlpPath = () => {
Expand Down
6 changes: 3 additions & 3 deletions src/settings/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import {
ipc_editConnection,
ipc_openSettingsModalEvent,
ipc_setAutoUpdateLauncher,
ipc_setEnableJukebox,
ipc_setExtraSlpPaths,
ipc_setIsoPath,
ipc_setJukebox,
ipc_setLaunchMeleeOnPlay,
ipc_setNetplayDolphinPath,
ipc_setPlaybackDolphinPath,
Expand Down Expand Up @@ -45,8 +45,8 @@ export default {
async setUseMonthlySubfolders(toggle: boolean): Promise<void> {
await ipc_setUseMonthlySubfolders.renderer!.trigger({ toggle });
},
async setJukebox(toggle: boolean): Promise<void> {
await ipc_setJukebox.renderer!.trigger({ toggle });
async setEnableJukebox(toggle: boolean): Promise<void> {
await ipc_setEnableJukebox.renderer!.trigger({ toggle });
},
async setSpectateSlpPath(spectateSlpPath: string): Promise<void> {
await ipc_setSpectateSlpPath.renderer!.trigger({ path: spectateSlpPath });
Expand Down
2 changes: 1 addition & 1 deletion src/settings/defaultSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const defaultAppSettings: AppSettings = {
isoPath: null,
rootSlpPath: getDefaultRootSlpPath(),
useMonthlySubfolders: false,
jukebox: true,
enableJukebox: true,
spectateSlpPath: path.join(getDefaultRootSlpPath(), "Spectate"),
extraSlpPaths: [],
netplayDolphinPath: path.join(app.getPath("userData"), "netplay"),
Expand Down
2 changes: 1 addition & 1 deletion src/settings/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const ipc_setUseMonthlySubfolders = makeEndpoint.main(
<SuccessPayload>_,
);

export const ipc_setJukebox = makeEndpoint.main("setJukebox", <{ toggle: boolean }>_, <SuccessPayload>_);
export const ipc_setEnableJukebox = makeEndpoint.main("setEnableJukebox", <{ toggle: boolean }>_, <SuccessPayload>_);

export const ipc_setSpectateSlpPath = makeEndpoint.main("setSpectateSlpPath", <{ path: string }>_, <SuccessPayload>_);

Expand Down
4 changes: 2 additions & 2 deletions src/settings/settingsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ export class SettingsManager {
await this._set("settings.useMonthlySubfolders", toggle);
}

public async setJukebox(toggle: boolean): Promise<void> {
await this._set("settings.jukebox", toggle);
public async setEnableJukebox(toggle: boolean): Promise<void> {
await this._set("settings.enableJukebox", toggle);
}

public async setSpectateSlpPath(slpPath: string): Promise<void> {
Expand Down
8 changes: 4 additions & 4 deletions src/settings/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import {
ipc_deleteConnection,
ipc_editConnection,
ipc_setAutoUpdateLauncher,
ipc_setEnableJukebox,
ipc_setExtraSlpPaths,
ipc_setIsoPath,
ipc_setJukebox,
ipc_setLaunchMeleeOnPlay,
ipc_setNetplayDolphinPath,
ipc_setPlaybackDolphinPath,
Expand Down Expand Up @@ -63,10 +63,10 @@ export default function setupSettingsIpc({
return { success: true };
});

ipc_setJukebox.main!.handle(async ({ toggle }) => {
await settingsManager.setJukebox(toggle);
ipc_setEnableJukebox.main!.handle(async ({ toggle }) => {
await settingsManager.setEnableJukebox(toggle);
const installation = dolphinManager.getInstallation(DolphinLaunchType.NETPLAY);
await installation.updateSettings({ jukebox: toggle });
await installation.updateSettings({ enableJukebox: toggle });
return { success: true };
});

Expand Down
2 changes: 1 addition & 1 deletion src/settings/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export type AppSettings = {
isoPath: string | null;
rootSlpPath: string;
useMonthlySubfolders: boolean;
jukebox: boolean;
enableJukebox: boolean;
spectateSlpPath: string;
extraSlpPaths: string[];
netplayDolphinPath: string;
Expand Down

0 comments on commit b8545d6

Please sign in to comment.