summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xdefaults/assets/fgmod.sh4
-rw-r--r--main.py19
-rw-r--r--src/components/CustomPathOverride.tsx4
-rw-r--r--src/components/InstalledGamesSection.tsx6
-rw-r--r--src/utils/constants.ts13
-rw-r--r--src/utils/index.ts2
6 files changed, 19 insertions, 29 deletions
diff --git a/defaults/assets/fgmod.sh b/defaults/assets/fgmod.sh
index d48856d..3910580 100755
--- a/defaults/assets/fgmod.sh
+++ b/defaults/assets/fgmod.sh
@@ -19,6 +19,10 @@ fgmod_path="$HOME/fgmod"
dll_name="${DLL:-dxgi.dll}"
preserve_ini="${PRESERVE_INI:-true}"
+if [[ ! -d "$fgmod_path" ]]; then
+ error_exit "OptiScaler bundle not found at $fgmod_path. Install OptiScaler first."
+fi
+
# === Resolve Game Path ===
if [[ "$#" -lt 1 ]]; then
error_exit "Usage: $0 program [program_arguments...]"
diff --git a/main.py b/main.py
index 5b6b8e8..6151201 100644
--- a/main.py
+++ b/main.py
@@ -1,7 +1,6 @@
import decky
import os
import subprocess
-import json
import shutil
import re
from pathlib import Path
@@ -70,7 +69,7 @@ class Plugin:
def _create_renamed_copies(self, source_file, renames_dir):
"""Create renamed copies of the OptiScaler.dll file"""
try:
- renames_dir.mkdir(exist_ok=True)
+ renames_dir.mkdir(parents=True, exist_ok=True)
rename_files = [
"dxgi.dll",
@@ -124,7 +123,7 @@ class Plugin:
"""Modify OptiScaler.ini to set FGType=nukems, Fsr4Update=true, and ASI plugin settings"""
try:
if ini_file.exists():
- with open(ini_file, 'r') as f:
+ with open(ini_file, 'r', encoding='utf-8', errors='replace') as f:
content = f.read()
# Replace FGType=auto with FGType=nukems
@@ -139,7 +138,7 @@ class Plugin:
# Replace Path=auto with Path=plugins
updated_content = re.sub(r'Path\s*=\s*auto', 'Path=plugins', updated_content)
- with open(ini_file, 'w') as f:
+ with open(ini_file, 'w', encoding='utf-8') as f:
f.write(updated_content)
decky.logger.info("Modified OptiScaler.ini to set FGType=nukems, Fsr4Update=true, LoadAsiPlugins=true, Path=plugins")
@@ -262,12 +261,14 @@ class Plugin:
# Create renamed copies of OptiScaler.dll
source_file = extract_path / "OptiScaler.dll"
renames_dir = extract_path / "renames"
- self._create_renamed_copies(source_file, renames_dir)
+ if not self._create_renamed_copies(source_file, renames_dir):
+ decky.logger.warning("Renamed copies were not created successfully")
decky.logger.info("Copying launcher scripts")
# Copy launcher scripts from assets
assets_dir = Path(decky.DECKY_PLUGIN_DIR) / "assets"
- self._copy_launcher_scripts(assets_dir, extract_path)
+ if not self._copy_launcher_scripts(assets_dir, extract_path):
+ decky.logger.warning("Launcher scripts were not copied successfully")
decky.logger.info("Setting up ASI plugins directory")
# Create plugins directory and copy OptiPatcher ASI file
@@ -318,7 +319,7 @@ class Plugin:
# Create version file
version_file = extract_path / "version.txt"
try:
- with open(version_file, 'w') as f:
+ with open(version_file, 'w', encoding='utf-8') as f:
f.write(version)
decky.logger.info(f"Created version file: {version}")
except Exception as e:
@@ -635,7 +636,7 @@ class Plugin:
game_info = {"appid": "", "name": ""}
try:
- with open(appmanifest, "r", encoding="utf-8") as file:
+ with open(appmanifest, "r", encoding="utf-8", errors="replace") as file:
for line in file:
if '"appid"' in line:
game_info["appid"] = line.split('"appid"')[1].strip().strip('"')
@@ -643,8 +644,6 @@ class Plugin:
game_info["name"] = line.split('"name"')[1].strip().strip('"')
except UnicodeDecodeError as e:
decky.logger.error(f"Skipping {appmanifest} due to encoding issue: {e}")
- finally:
- pass # Ensures loop continues even if an error occurs
if game_info["appid"] and game_info["name"]:
games.append(game_info)
diff --git a/src/components/CustomPathOverride.tsx b/src/components/CustomPathOverride.tsx
index ffc4b1f..3b1fb7e 100644
--- a/src/components/CustomPathOverride.tsx
+++ b/src/components/CustomPathOverride.tsx
@@ -158,7 +158,7 @@ export const ManualPatchControls = ({ isAvailable, onManualModeChange }: ManualP
if (!selectedPath) return;
const setBusy = action === "patch" ? setIsPatching : setIsUnpatching;
- setLastOperation(action);
+ setLastOperation(action);
setBusy(true);
setOperationResult(null);
@@ -300,4 +300,4 @@ export const ManualPatchControls = ({ isAvailable, onManualModeChange }: ManualP
)}
</>
);
-}; \ No newline at end of file
+};
diff --git a/src/components/InstalledGamesSection.tsx b/src/components/InstalledGamesSection.tsx
index 71278d7..fb65e81 100644
--- a/src/components/InstalledGamesSection.tsx
+++ b/src/components/InstalledGamesSection.tsx
@@ -26,7 +26,7 @@ export function InstalledGamesSection() {
.sort((a, b) => a.name.toLowerCase().localeCompare(b.name.toLowerCase()));
setGames(sortedGames);
} else if (response) {
- logError('fetchGames: ' + JSON.stringify(response));
+ void logError('fetchGames: ' + JSON.stringify(response));
console.error('fetchGames: ' + JSON.stringify(response));
}
};
@@ -51,7 +51,7 @@ export function InstalledGamesSection() {
await SteamClient.Apps.SetAppLaunchOptions(selectedGame.appid, '~/fgmod/fgmod %COMMAND%');
setResult(`✓ Frame generation enabled for ${selectedGame.name}. Launch the game, enable DLSS in graphics settings, then press Insert to access OptiScaler options.`);
} catch (error) {
- logError('handlePatchClick: ' + String(error));
+ void logError('handlePatchClick: ' + String(error));
setResult(error instanceof Error ? `Error: ${error.message}` : 'Error enabling frame generation');
}
}}
@@ -66,7 +66,7 @@ export function InstalledGamesSection() {
await SteamClient.Apps.SetAppLaunchOptions(selectedGame.appid, '~/fgmod/fgmod-uninstaller.sh %COMMAND%');
setResult(`✓ Frame generation will be disabled on next launch of ${selectedGame.name}.`);
} catch (error) {
- logError('handleUnpatchClick: ' + String(error));
+ void logError('handleUnpatchClick: ' + String(error));
setResult(error instanceof Error ? `Error: ${error.message}` : 'Error disabling frame generation');
}
};
diff --git a/src/utils/constants.ts b/src/utils/constants.ts
index 1f583c0..afc996e 100644
--- a/src/utils/constants.ts
+++ b/src/utils/constants.ts
@@ -1,16 +1,3 @@
-// Common types for the application
-
-export interface ResultType {
- status: string;
- message?: string;
- output?: string;
-}
-
-export interface GameType {
- appid: number;
- name: string;
-}
-
// Common style definitions
export const STYLES = {
resultBox: {
diff --git a/src/utils/index.ts b/src/utils/index.ts
index d969cb6..d90787c 100644
--- a/src/utils/index.ts
+++ b/src/utils/index.ts
@@ -23,7 +23,7 @@ export const safeAsyncOperation = async <T,>(
try {
return await operation();
} catch (e) {
- logError(`${errorContext}: ${String(e)}`);
+ void logError(`${errorContext}: ${String(e)}`);
console.error(e);
return undefined;
}