Skip to content
This repository has been archived by the owner on Jul 23, 2023. It is now read-only.

Commit

Permalink
Show message explaining VR steps if VR mod is enabled (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
Raicuparta authored Aug 11, 2020
1 parent fb769f6 commit 303d0f9
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 68 deletions.
11 changes: 8 additions & 3 deletions app/components/Settings/SettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import React from 'react';
import { List, Paper } from '@material-ui/core';

import { settingsText } from '../../static-text';
import { SettingsContext, useSettings } from '../../hooks';
import { useSettings } from '../../hooks';
import ResetSettings from './ResetSettings';
import ModManagerSettingControl from './ModManagerSettingControl';
import OwmlSettingControl from './OwmlSettingControl';
import { SettingType } from './SettingFormControl';
import PageContainer from '../PageContainer';

type SettingKey = keyof SettingsContext['settings'];
type OwmlSettingKey = keyof SettingsContext['owmlSettings'];
type SettingKey = keyof Settings;
type OwmlSettingKey = keyof OwmlSettings;

type SettingsInput = {
key: SettingKey | OwmlSettingKey;
Expand Down Expand Up @@ -60,6 +60,11 @@ const settingsInputs: readonly SettingsInput[] = [
type: SettingType.Switch,
isAdvanced: true,
},
{
key: 'disableVrWarning',
type: SettingType.Switch,
isAdvanced: true,
},
{
key: 'owmlPath',
type: SettingType.Text,
Expand Down
40 changes: 36 additions & 4 deletions app/components/TopBar/StartGameButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ import { Button, Tooltip } from '@material-ui/core';
import { PlayArrow as PlayIcon } from '@material-ui/icons';

import { useRecoilValue, useSetRecoilState } from 'recoil';
import { globalText } from '../../static-text';
import { remote } from 'electron';
import { globalText, modsText } from '../../static-text';
import { runOwml, writeSettings } from '../../services';
import {
requiredModNamesState,
isLogServerRunningState,
logServerPortState,
settingsState,
selectedTabState,
isVrModEnabledState,
} from '../../store';

const StartGameButton: React.FunctionComponent = () => {
Expand All @@ -19,16 +21,46 @@ const StartGameButton: React.FunctionComponent = () => {
const logServerPort = useRecoilValue(logServerPortState);
const settings = useRecoilValue(settingsState);
const setSelectedTab = useSetRecoilState(selectedTabState);
const isVrModEnabled = useRecoilValue(isVrModEnabledState);

function setDisableParameterWarnings() {
writeSettings({ ...settings, disableParameterWarning: true });
if (settings.logToSocket) {
setSelectedTab(1);
}

async function showVrWarning() {
if (!isVrModEnabled || settings.disableVrWarning) {
return true;
}

const { response, checkboxChecked } = await remote.dialog.showMessageBox({
type: 'warning',
title: remote.app.name,
message: modsText.vrModWarning.message,
detail: modsText.vrModWarning.detail,
checkboxLabel: modsText.vrModWarning.dontShowAgain,
buttons: ['OK', 'Cancel'],
});

if (response === 1) {
return false;
}

if (checkboxChecked) {
writeSettings({ ...settings, disableVrWarning: true });
}

return true;
}

function handleStartGameClick() {
async function handleStartGameClick() {
const shouldStartGame = await showVrWarning();
if (!shouldStartGame) {
return;
}
runOwml(settings, logServerPort, setDisableParameterWarnings);
if (settings.logToSocket) {
setSelectedTab(1);
}
}

const isMissingRequiredMod = requiredModNames.length > 0;
Expand Down
1 change: 1 addition & 0 deletions app/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"showAdvancedSettings": false,
"openVRParameter": false,
"disableParameterWarning": false,
"disableVrWarning": false,
"modDatabaseUrl": "https://raw.githubusercontent.com/Raicuparta/outer-wilds-mod-db/master/database.json"
},
"ignoredErrors": ["ECONNRESET"]
Expand Down
3 changes: 3 additions & 0 deletions app/globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type Mod = {
isRequired?: boolean;
errors: string[];
dependencies: string[];
requireVR?: boolean;
};

type ModMap = { [uniqueName: string]: Mod };
Expand All @@ -35,6 +36,7 @@ type Manifest = {
uniqueName: string;
version: string;
dependencies?: string[];
requireVR?: boolean;
};

type ModConfig = {
Expand All @@ -56,6 +58,7 @@ type Settings = {
openVRParameter: boolean;
disableParameterWarning: boolean;
owmlPath: string;
disableVrWarning: boolean;
};

type OwmlSettings = {
Expand Down
62 changes: 1 addition & 61 deletions app/services/get-local-mods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,67 +6,6 @@ import { modsText } from '../static-text';
import { isEnabled } from './mod-manager';
import { manifestPartialToFull } from './manifest';

async function getOwml(owmlPath: string) {
const owmlManifestPath = `${owmlPath}/OWML.Manifest.json`;
const owmlManifest: Manifest = fs.existsSync(owmlManifestPath)
? await fs.readJSON(owmlManifestPath)
: null;
const owml: Mod = {
name: owmlManifest?.name ?? 'OWML',
author: owmlManifest?.author ?? 'Alek',
uniqueName: owmlManifest?.uniqueName ?? 'Alek.OWML',
modPath: owmlPath,
localVersion: owmlManifest
? owmlManifest?.version ?? '< 0.3.43'
: undefined,
isEnabled: true,
isRequired: true,
errors: [],
dependencies: [],
};
return owml;
}

export async function getLocalMods(owmlPath: string) {
const manifestPaths = await globby(`${owmlPath}/Mods/**/manifest.json`);

return Promise.allSettled([
...manifestPaths.map<Promise<Mod>>(async (manifestPath) => {
const { manifest, missingAttributes } = manifestPartialToFull(
await fs.readJson(manifestPath)
);

const mod: Mod = {
name: manifest.name,
author: manifest.author,
uniqueName: manifest.uniqueName,
localVersion: manifest.version,
modPath: path.dirname(manifestPath),
errors: [],
dependencies: manifest.dependencies ?? [],
};

if (missingAttributes.length > 0) {
mod.errors.push(
modsText.missingManifestAttributesError(
manifestPath,
missingAttributes
)
);
}

try {
mod.isEnabled = isEnabled(mod);
} catch (error) {
mod.isEnabled = true;
console.error(error);
}
return mod;
}),
getOwml(owmlPath),
]);
}

function getOwmlSync(owmlPath: string) {
const owmlManifestPath = `${owmlPath}/OWML.Manifest.json`;
const owmlManifest: Manifest = fs.existsSync(owmlManifestPath)
Expand Down Expand Up @@ -105,6 +44,7 @@ export function getLocalModsSync(owmlPath: string) {
modPath: path.dirname(manifestPath),
errors: [],
dependencies: manifest.dependencies ?? [],
requireVR: manifest.requireVR,
};

if (missingAttributes.length > 0) {
Expand Down
1 change: 1 addition & 0 deletions app/services/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export function manifestPartialToFull(partialManifest: Partial<Manifest>) {
uniqueName: getAttribute('uniqueName', true),
version: getAttribute('version'),
dependencies: partialManifest.dependencies ?? [],
requireVR: partialManifest.requireVR ?? false,
};

return {
Expand Down
17 changes: 17 additions & 0 deletions app/static-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,18 @@ export const modsText = {
`Failed to load mod. Errors: ${errors.join(' || ')}`,
actionError: (action: string, error: string) =>
`Error executing mod ${action}: ${error}`,
vrModWarning: {
message: 'Follow these steps before starting the game in VR:',
detail: `- Close SteamVR (let the game open SteamVR automatically);
- Make sure your headset and both of your VR controllers are connected and working;
- If you have the game on Steam:
--- Right-click Outer Wilds on your Steam library
--- Select "Properties..."
--- Disable "Use Desktop Game Theatre."`,
dontShowAgain: "Don't show this again",
},
};

export const settingsText = {
Expand Down Expand Up @@ -133,6 +145,11 @@ export const settingsText = {
'Disables warning in the Mod Manager that warns you about the Steam warning. Yeah.',
isAdvanced: true,
},
disableVrWarning: {
label: 'Disable VR steps warning',
tooltip: 'Disables warning about preparation steps for playing in VR',
isAdvanced: true,
},
owmlPath: {
label: 'OWML path',
tooltip:
Expand Down
6 changes: 6 additions & 0 deletions app/store/mods-state/mods-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,9 @@ export const modList = selector({
key: 'ModList',
get: ({ get }) => Object.values(get(modMapState)),
});

export const isVrModEnabledState = selector({
key: 'IsVRModEnabled',
get: ({ get }) =>
Boolean(get(localModList).find((mod) => mod.isEnabled && mod.requireVR)),
});

0 comments on commit 303d0f9

Please sign in to comment.