#!/bin/bash
# Bot Manager window (/bots, 2026-09-29): install the staged DLL and UI files into one client folder
# (default: Trevor's desktop client). Backups: *.bak-bots (made once, never overwritten).
# Run on the desktop:  bash install_desktop.sh [client_dir]     (after copying this folder there)
# The game may be running: files are swapped by rename, restart the game to load them.
# The Bigg patcher puts the shipped files back if it runs before promotion; re-run this afterwards.
set -euo pipefail
here="$(cd "$(dirname "$0")" && pwd)"
dst="${1:-/home/tj/Desktop/everquest_rof2_tanks}"
for f in dinput8.dll uifiles/default/EQUI.xml uifiles/default/EQUI_Inventory.xml uifiles/default/HJ_BotWnd.xml; do
    src="$here/$(basename "$f")"
    if [ -f "$dst/$f" ] && [ ! -f "$dst/$f.bak-bots" ]; then cp -p "$dst/$f" "$dst/$f.bak-bots"; fi
    cp "$src" "$dst/$f.new" && mv -f "$dst/$f.new" "$dst/$f"   # rename: a running client keeps its mapped copy
    echo "installed $f"
done
