summaryrefslogtreecommitdiff
path: root/defaults
diff options
context:
space:
mode:
Diffstat (limited to 'defaults')
-rwxr-xr-xdefaults/assets/fgmod-uninstaller.sh95
-rwxr-xr-xdefaults/assets/fgmod.sh130
-rwxr-xr-xdefaults/assets/prepare.sh47
3 files changed, 120 insertions, 152 deletions
diff --git a/defaults/assets/fgmod-uninstaller.sh b/defaults/assets/fgmod-uninstaller.sh
index dd5f198..93f279f 100755
--- a/defaults/assets/fgmod-uninstaller.sh
+++ b/defaults/assets/fgmod-uninstaller.sh
@@ -1,15 +1,16 @@
#!/usr/bin/env bash
-set -x # Enable debugging
-exec > >(tee -i /tmp/prepare.log) 2>&1 # Log output and errors
+set -x
+exec > >(tee -i /tmp/fgmod-uninstaller.log) 2>&1
error_exit() {
- echo "$1"
+ echo "โŒ $1"
if [[ -n $STEAM_ZENITY ]]; then
$STEAM_ZENITY --error --text "$1"
else
- zenity --error --text "$1"
+ zenity --error --text "$1" || echo "Zenity failed to display error"
fi
+ logger -t fgmod-uninstaller "โŒ ERROR: $1"
exit 1
}
@@ -18,10 +19,8 @@ if [ "$#" -lt 1 ]; then
exit 1
fi
-game_path=""
-mod_path="/usr/share/fgmod"
-
-# Locate the game folder based on the first argument
+# === Resolve Game Path ===
+exe_folder_path=""
if [[ "$1" == *.exe ]]; then
exe_folder_path=$(dirname "$1")
else
@@ -44,9 +43,7 @@ else
fi
# Fallback to STEAM_COMPAT_INSTALL_PATH when no path was found
-if [[ ! -d $exe_folder_path ]] && [[ -n ${STEAM_COMPAT_INSTALL_PATH} ]]; then
- exe_folder_path=${STEAM_COMPAT_INSTALL_PATH}
-fi
+[[ -z "$exe_folder_path" && -n "$STEAM_COMPAT_INSTALL_PATH" ]] && exe_folder_path="$STEAM_COMPAT_INSTALL_PATH"
# Check for Unreal Engine game paths
if [[ -d "$exe_folder_path/Engine" ]]; then
@@ -55,51 +52,65 @@ if [[ -d "$exe_folder_path/Engine" ]]; then
fi
# Verify the game folder exists
-if [[ ! -d $exe_folder_path ]]; then
- error_exit "Unable to locate the game folder. Ensure the game is installed and the path is correct."
-fi
+[[ ! -d "$exe_folder_path" ]] && error_exit "Unable to locate the game folder: $exe_folder_path"
# Avoid operating on the uninstaller's own directory
script_dir=$(dirname "$(realpath "$0")")
-if [[ "$(realpath "$exe_folder_path")" == "$script_dir" ]]; then
- error_exit "The target directory matches the script's directory. Aborting to prevent accidental deletion."
-fi
+[[ "$(realpath "$exe_folder_path")" == "$script_dir" ]] && error_exit "The target directory matches the script's directory. Aborting to prevent accidental deletion."
# Change to the game directory
cd "$exe_folder_path" || error_exit "Failed to change directory to $exe_folder_path"
# Verify current directory before proceeding
-if [[ "$(pwd)" != "$exe_folder_path" ]]; then
- error_exit "Unexpected working directory: $(pwd)"
-fi
-
-# Log the resolved exe_folder_path for debugging
-echo "Resolved exe_folder_path: $exe_folder_path" >> /tmp/fgmod-uninstaller.log
-
-# Perform uninstallation
-rm -f "dlss-enabler.dll" "dxgi.dll" "nvngx-wrapper.dll" "_nvngx.dll"
-rm -f "dlssg_to_fsr3_amd_is_better.dll" "dlssg_to_fsr3_amd_is_better-3.0.dll"
-rm -f "dlss-enabler-upscaler.dll" "nvngx.ini"
-rm -f "d3dcompiler_47.dll" "amd_fidelityfx_dx12.dll" "amd_fidelityfx_vk.dll"
-rm -f "nvapi64.dll" "fakenvapi.ini" "OptiScaler.log"
-rm -f "dlss-enabler.log" "dlssg_to_fsr3.log" "fakenvapi.log"
-
-# Restore original DLLs if they exist
-mv -f "libxess.dll.b" "libxess.dll" 2>/dev/null # keeping this for legacy patched games to successfully revert changes with newer builds of plugin
-mv -f "d3dcompiler_47.dll.b" "d3dcompiler_47.dll" 2>/dev/null
-mv -f "amd_fidelityfx_dx12.dll.b" "amd_fidelityfx_dx12.dll" 2>/dev/null
-mv -f "amd_fidelityfx_vk.dll.b" "amd_fidelityfx_vk.dll" 2>/dev/null
+[[ "$(pwd)" != "$exe_folder_path" ]] && error_exit "Unexpected working directory: $(pwd)"
+
+logger -t fgmod-uninstaller "๐ŸŸข Uninstalling from: $exe_folder_path"
+
+# === Remove OptiScaler Files ===
+echo "๐Ÿงน Removing OptiScaler files..."
+rm -f "OptiScaler.dll" "dxgi.dll" "winmm.dll" "dbghelp.dll" "version.dll" "wininet.dll" "winhttp.dll" "OptiScaler.asi"
+rm -f "OptiScaler.ini" "OptiScaler.log"
+
+# === Remove Nukem FG Mod Files ===
+echo "๐Ÿงน Removing Nukem FG Mod files..."
+rm -f "dlssg_to_fsr3_amd_is_better.dll" "dlssg_to_fsr3.ini" "dlssg_to_fsr3.log"
+rm -f "nvapi64.dll" "fakenvapi.ini" "fakenvapi.log"
+rm -f "amdxcffx64.dll"
+
+# === Remove Supporting Libraries ===
+echo "๐Ÿงน Removing supporting libraries..."
+rm -f "libxess.dll" "nvngx.dll" "nvngx.ini"
+
+# === Remove Legacy Files ===
+echo "๐Ÿงน Removing legacy files..."
+rm -f "dlss-enabler.dll" "dlss-enabler-upscaler.dll" "dlss-enabler.log"
+rm -f "nvngx-wrapper.dll" "_nvngx.dll"
+rm -f "dlssg_to_fsr3_amd_is_better-3.0.dll"
+
+# === Restore Original DLLs ===
+echo "๐Ÿ”„ Restoring original DLLs..."
+original_dlls=("d3dcompiler_47.dll" "amd_fidelityfx_dx12.dll" "amd_fidelityfx_vk.dll" "nvapi64.dll" "amdxcffx64.dll" "libxess.dll")
+for dll in "${original_dlls[@]}"; do
+ if [[ -f "${dll}.b" ]]; then
+ mv "${dll}.b" "$dll"
+ echo "โœ… Restored original $dll"
+ logger -t fgmod-uninstaller "โœ… Restored original $dll"
+ fi
+done
-# Self-remove uninstaller (now optional for safety)
-echo "Uninstaller self-removal skipped for safety. Remove manually if needed."
+# === Self-remove uninstaller ===
+echo "๐Ÿ—‘๏ธ Removing uninstaller..."
+rm -f "fgmod-uninstaller.sh"
-echo "fgmod removed from this game."
+echo "โœ… fgmod removed from this game successfully!"
+logger -t fgmod-uninstaller "โœ… fgmod removed from $exe_folder_path"
+# === Execute original command if provided ===
if [[ $# -gt 1 ]]; then
- echo "Launching the game..."
+ echo "๐Ÿš€ Launching the game..."
export SteamDeck=0
export WINEDLLOVERRIDES="${WINEDLLOVERRIDES},dxgi=n,b"
exec "$@"
else
- echo "Uninstallation complete. No game specified to run."
+ echo "โœ… Uninstallation complete. No game specified to run."
fi \ No newline at end of file
diff --git a/defaults/assets/fgmod.sh b/defaults/assets/fgmod.sh
index 026d546..134ded0 100755
--- a/defaults/assets/fgmod.sh
+++ b/defaults/assets/fgmod.sh
@@ -1,42 +1,41 @@
#!/usr/bin/env bash
-set -x # Enable debugging
-exec > >(tee -i /tmp/prepare.log) 2>&1 # Log output and errors
+set -x
+exec > >(tee -i /tmp/fgmod-install.log) 2>&1
error_exit() {
- echo "$1"
+ echo "โŒ $1"
if [[ -n $STEAM_ZENITY ]]; then
$STEAM_ZENITY --error --text "$1"
else
- zenity --error --text "$1"
+ zenity --error --text "$1" || echo "Zenity failed to display error"
fi
+ logger -t fgmod "โŒ ERROR: $1"
exit 1
}
-mod_path="/usr/share/fgmod"
+# === CONFIG ===
+fgmod_path="$HOME/fgmod"
+dll_name="${DLL:-dxgi.dll}"
+preserve_ini="${PRESERVE_INI:-true}"
-if [ "$#" -lt 1 ]; then
- echo "Usage: $0 program [program_arguments...]"
- exit 1
+# === Resolve Game Path ===
+if [[ "$#" -lt 1 ]]; then
+ error_exit "Usage: $0 program [program_arguments...]"
fi
-# One arg means the command is ran standalone
+exe_folder_path=""
if [[ $# -eq 1 ]]; then
- if [[ "$1" == *.exe ]]; then
- exe_folder_path=$(dirname "$1")
- else
- exe_folder_path=$1
- fi
+ [[ "$1" == *.exe ]] && exe_folder_path=$(dirname "$1") || exe_folder_path="$1"
else
for arg in "$@"; do
if [[ "$arg" == *.exe ]]; then
- # Special cases, only FG-supported games
[[ "$arg" == *"Cyberpunk 2077"* ]] && arg=${arg//REDprelauncher.exe/bin/x64/Cyberpunk2077.exe}
[[ "$arg" == *"Witcher 3"* ]] && arg=${arg//REDprelauncher.exe/bin/x64_dx12/witcher3.exe}
[[ "$arg" == *"HITMAN 3"* ]] && arg=${arg//Launcher.exe/Retail/HITMAN3.exe}
[[ "$arg" == *"HITMAN World of Assassination"* ]] && arg=${arg//Launcher.exe/Retail/HITMAN3.exe}
- [[ "$arg" == *"SYNCED"* ]] && arg=${arg//Launcher\/sop_launcher.exe/SYNCED.exe} # UE with a launcher
- [[ "$arg" == *"2KLauncher"* ]] && arg=${arg//2KLauncher\/LauncherPatcher.exe/DoesntMatter.exe} # 2K launcher games
+ [[ "$arg" == *"SYNCED"* ]] && arg=${arg//Launcher\/sop_launcher.exe/SYNCED.exe}
+ [[ "$arg" == *"2KLauncher"* ]] && arg=${arg//2KLauncher\/LauncherPatcher.exe/DoesntMatter.exe}
[[ "$arg" == *"Warhammer 40,000 DARKTIDE"* ]] && arg=${arg//launcher\/Launcher.exe/binaries/Darktide.exe}
[[ "$arg" == *"Warhammer Vermintide 2"* ]] && arg=${arg//launcher\/Launcher.exe/binaries_dx12/vermintide2_dx12.exe}
[[ "$arg" == *"Satisfactory"* ]] && arg=${arg//FactoryGameSteam.exe/Engine/Binaries/Win64/FactoryGameSteam-Win64-Shipping.exe}
@@ -46,65 +45,70 @@ else
done
fi
-# Fallback to STEAM_COMPAT_INSTALL_PATH when no path was found
-if [[ ! -d $exe_folder_path ]] && [[ -n ${STEAM_COMPAT_INSTALL_PATH} ]]; then
- echo "Trying the path from STEAM_COMPAT_INSTALL_PATH"
- exe_folder_path=${STEAM_COMPAT_INSTALL_PATH}
-fi
+[[ -z "$exe_folder_path" && -n "$STEAM_COMPAT_INSTALL_PATH" ]] && exe_folder_path="$STEAM_COMPAT_INSTALL_PATH"
-# Check for UE games
if [[ -d "$exe_folder_path/Engine" ]]; then
- ue_exe_path=$(find "$exe_folder_path" -maxdepth 4 -mindepth 4 -path "*Binaries/Win64/*.exe" -not -path "*/Engine/*" | head -1)
- exe_folder_path=$(dirname "$ue_exe_path")
+ ue_exe=$(find "$exe_folder_path" -maxdepth 4 -mindepth 4 -path "*Binaries/Win64/*.exe" -not -path "*/Engine/*" | head -1)
+ exe_folder_path=$(dirname "$ue_exe")
fi
-if [[ -d $exe_folder_path ]]; then
- if [[ ! -w $exe_folder_path ]]; then
- error_exit "No write permission to the game folder!"
- fi
+[[ ! -d "$exe_folder_path" ]] && error_exit "โŒ Could not resolve game directory!"
+[[ ! -w "$exe_folder_path" ]] && error_exit "๐Ÿ›‘ No write permission to the game folder!"
- original_dlls=("d3dcompiler_47.dll" "amd_fidelityfx_dx12.dll" "amd_fidelityfx_vk.dll")
+logger -t fgmod "๐ŸŸข Target directory: $exe_folder_path"
+logger -t fgmod "๐Ÿงฉ Using DLL name: $dll_name"
+logger -t fgmod "๐Ÿ“„ Preserve INI: $preserve_ini"
- # Assume that the mod is not installed when dlss-enabler.dll is not present
- if [[ ! -f "$exe_folder_path/dlss-enabler.dll" ]]; then
- [[ -f "$exe_folder_path/dxgi.dll" ]] && error_exit 'dxgi.dll is already present in the game folder!\nThis script uses dxgi.dll to load required files.\nRemove the mod using dxgi.dll or install DLSS Enabler manually.'
- for dll in "${original_dlls[@]}"; do
- if [[ ! -f "$exe_folder_path/${dll}.b" ]]; then
- mv -f "$exe_folder_path/$dll" "$exe_folder_path/${dll}.b" 2>/dev/null
- fi
- done
- fi
+# === Cleanup Old Injectors ===
+rm -f "$exe_folder_path"/{dxgi.dll,winmm.dll,nvngx.dll,_nvngx.dll,nvngx-wrapper.dll,dlss-enabler.dll,OptiScaler.dll}
- cp -f "$mod_path/fgmod-uninstaller.sh" "$exe_folder_path" ||
- error_exit "Couldn't copy the uninstaller!"
+# === Optional: Backup Original DLLs ===
+original_dlls=("d3dcompiler_47.dll" "amd_fidelityfx_dx12.dll" "amd_fidelityfx_vk.dll" "nvapi64.dll" "amdxcffx64.dll")
+for dll in "${original_dlls[@]}"; do
+ [[ -f "$exe_folder_path/$dll" && ! -f "$exe_folder_path/$dll.b" ]] && mv -f "$exe_folder_path/$dll" "$exe_folder_path/$dll.b"
+done
- cp -f "$mod_path/dlss-enabler.dll" "$exe_folder_path" &&
- cp -f "$mod_path/dxgi.dll" "$exe_folder_path" &&
- cp -f "$mod_path/nvngx-wrapper.dll" "$exe_folder_path" ||
- error_exit "Couldn't copy DLSS Enabler files!"
+# === Core Install ===
+if [[ -f "$fgmod_path/renames/$dll_name" ]]; then
+ echo "โœ… Using pre-renamed $dll_name"
+ cp "$fgmod_path/renames/$dll_name" "$exe_folder_path/$dll_name" || error_exit "โŒ Failed to copy $dll_name"
+else
+ echo "โš ๏ธ Pre-renamed $dll_name not found, falling back to OptiScaler.dll"
+ cp "$fgmod_path/OptiScaler.dll" "$exe_folder_path/$dll_name" || error_exit "โŒ Failed to copy OptiScaler.dll as $dll_name"
+fi
- # File is not preset on Nvidia installs so will fail on some setups on purpose
- cp -f "$mod_path/nvapi64.dll" "$exe_folder_path" 2>/dev/null
+# === OptiScaler.ini Handling ===
+if [[ "$preserve_ini" == "true" && -f "$exe_folder_path/OptiScaler.ini" ]]; then
+ echo "๐Ÿ“„ Preserving existing OptiScaler.ini (user settings retained)"
+ logger -t fgmod "๐Ÿ“„ Existing OptiScaler.ini preserved in $exe_folder_path"
+else
+ echo "๐Ÿ“„ Installing OptiScaler.ini from plugin defaults"
+ cp "$fgmod_path/OptiScaler.ini" "$exe_folder_path/OptiScaler.ini" || error_exit "โŒ Failed to copy OptiScaler.ini"
+ logger -t fgmod "๐Ÿ“„ OptiScaler.ini installed to $exe_folder_path"
+fi
- cp -f "$mod_path/_nvngx.dll" "$exe_folder_path" ||
- error_exit "Couldn't copy _nvngx.dll!"
+# === Supporting Libraries ===
+cp -f "$fgmod_path/libxess.dll" "$exe_folder_path/" || true
+cp -f "$fgmod_path/amd_fidelityfx_dx12.dll" "$exe_folder_path/" || true
+cp -f "$fgmod_path/amd_fidelityfx_vk.dll" "$exe_folder_path/" || true
+cp -f "$fgmod_path/nvngx.dll" "$exe_folder_path/" || true
- cp -f "$mod_path/dlssg_to_fsr3_amd_is_better.dll" "$exe_folder_path" &&
- cp -f "$mod_path/dlssg_to_fsr3_amd_is_better-3.0.dll" "$exe_folder_path" ||
- error_exit "Couldn't copy dlssg-to-fsr3!"
+# === Nukem FG Mod Files (now in fgmod directory) ===
+cp -f "$fgmod_path/dlssg_to_fsr3_amd_is_better.dll" "$exe_folder_path/" || true
+cp -f "$fgmod_path/dlssg_to_fsr3.ini" "$exe_folder_path/" || true
+cp -f "$fgmod_path/nvapi64.dll" "$exe_folder_path/" || true
+cp -f "$fgmod_path/fakenvapi.ini" "$exe_folder_path/" || true
+cp -f "$fgmod_path/amdxcffx64.dll" "$exe_folder_path/" || true
- cp -f "$mod_path/dlss-enabler-upscaler.dll" "$exe_folder_path" &&
- cp -f "$mod_path/amd_fidelityfx_dx12.dll" "$exe_folder_path" &&
- cp -f "$mod_path/amd_fidelityfx_vk.dll" "$exe_folder_path" &&
- cp -f "$mod_path/d3dcompiler_47.dll" "$exe_folder_path" ||
- error_exit "Couldn't copy Optiscaler files!"
+# === Additional Support Files ===
+cp -f "$fgmod_path/d3dcompiler_47.dll" "$exe_folder_path/" || true
- cp -n "$mod_path/nvngx.ini" "$exe_folder_path"
- cp -n "$mod_path/fakenvapi.ini" "$exe_folder_path"
-else
- error_exit "Path doesn't exist!"
-fi
+echo "โœ… Installation completed successfully!"
+echo "๐Ÿ“„ For Steam, add this to the launch options: \"$fgmod_path/fgmod\" %COMMAND%"
+echo "๐Ÿ“„ For Heroic, add this as a new wrapper: \"$fgmod_path/fgmod\""
+logger -t fgmod "๐ŸŸข Installation completed successfully for $exe_folder_path"
+# === Execute original command ===
if [[ $# -gt 1 ]]; then
# Log to both file and system journal
logger -t fgmod "=================="
@@ -119,7 +123,7 @@ if [[ $# -gt 1 ]]; then
# Execute the original command
export SteamDeck=0
export WINEDLLOVERRIDES="$WINEDLLOVERRIDES,dxgi=n,b"
- "$@"
+ exec "$@"
else
echo "Done!"
echo "----------------------------------------"
diff --git a/defaults/assets/prepare.sh b/defaults/assets/prepare.sh
deleted file mode 100755
index 65f92e1..0000000
--- a/defaults/assets/prepare.sh
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/usr/bin/env bash
-
-set -x # Enable debugging
-exec > >(tee -i /tmp/prepare.log) 2>&1 # Log output and errors
-
-mod_path="$HOME/fgmod"
-bin_path="$(dirname "$(realpath "$0")")/../bin"
-assets_path="$(dirname "$(realpath "$0")")"
-
-standalone=1
-
-if [[ -d "$mod_path" ]] && [[ ! $mod_path == . ]]; then
- rm -r "$mod_path"
-fi
-
-mkdir -p "$mod_path"
-cd "$mod_path" || exit 1
-
-# Copy all files from bin directory into the current directory
-cp "$bin_path"/* .
-
-# # Unzip assets.zip so that all files are in the modpath root, then remove the zip file
-# unzip -j -o assets.zip && rm assets.zip
-
-# Copy fgmod.sh and fgmod-uninstaller.sh from defaults/assets
-# cp "$assets_path/fgmod.sh" "$mod_path/fgmod" || exit 1
-# cp "$assets_path/fgmod-uninstaller.sh" "$mod_path" || exit 1
-
-# Update paths in scripts
-sed -i 's|mod_path="/usr/share/fgmod"|mod_path="'"$mod_path"'"|g' fgmod
-chmod +x fgmod
-
-sed -i 's|mod_path="/usr/share/fgmod"|mod_path="'"$mod_path"'"|g' fgmod-uninstaller.sh
-chmod +x fgmod-uninstaller.sh
-
-echo ""
-
-# Flatpak compatibility
-if flatpak list | grep "com.valvesoftware.Steam" 1>/dev/null; then
- echo "Flatpak version of Steam detected, adding access to fgmod's folder"
- echo "Please restart Steam!"
- flatpak override --user --filesystem="$mod_path" com.valvesoftware.Steam
-fi
-
-echo "For Steam, add this to the launch options: \"$mod_path/fgmod\" %COMMAND%"
-echo "For Heroic, add this as a new wrapper: \"$mod_path/fgmod\""
-echo "All done!" \ No newline at end of file