Documentation and launching much nicer now when using the yad interface.

This commit is contained in:
Storm Dragon
2026-01-09 12:24:08 -05:00
parent 1c1046c43b
commit a4f0dcae36
3 changed files with 254 additions and 66 deletions

View File

@@ -5,16 +5,21 @@ documentation() {
if [[ "$2" == "Donate" ]]; then
return
fi
if ! command -v w3m &> /dev/null ; then
echo "This feature of audiogame-manager requires w3m. Please install it before continuing."
exit 1
fi
get_bottle "$1"
echo "Loading documentation, please wait..."
# Extract architecture from first parameter (format: "win64|path")
local wineArch="${1%%|*}"
get_bottle "$wineArch"
echo "Loading documentation, please wait..."
# Try to find documentation based on common naming conventions.
local gamePath="$(winepath -u "$2" 2> /dev/null)"
local gamePath
gamePath="$(winepath -u "$2" 2> /dev/null)"
gamePath="${gamePath%/*}"
local gameDoc="$(find "$gamePath" -type f -iname 'user_manual.htm*' -or -iname 'user manual.htm*' -or -iname '*user guide.htm*' | head -1)"
local gameDoc=""
local isUrl="false"
gameDoc="$(find "$gamePath" -type f -iname 'user_manual.htm*' -or -iname 'user manual.htm*' -or -iname '*user guide.htm*' | head -1)"
# Game name specific docs, add the name to the for loop.
if [[ -z "$gameDoc" ]]; then
for i in "troopanum.txt" "superdeekout.txt" scw.html ; do
@@ -46,12 +51,47 @@ echo "Loading documentation, please wait..."
gameDoc="$(find "$gamePath" -type f -iname '*.url' -exec grep -i 'url=' {} \; | grep -iv 'score' | head -1)"
gameDoc="${gameDoc#*=}"
gameDoc="${gameDoc//[[:cntrl:]]/}"
[[ -n "$gameDoc" ]] && isUrl="true"
fi
# Display documentation if available.
# Display documentation if available
if [[ -n "$gameDoc" ]]; then
w3m "$gameDoc"
if [[ "$isUrl" == "true" ]]; then
# URL extracted from .url file - open in browser
open_url "$gameDoc"
elif [[ "$dialogType" == "yad" ]]; then
# GUI mode: use appropriate viewer
if [[ "${gameDoc,,}" =~ \.(html?)$ ]]; then
# HTML files: use xdg-open for default browser
xdg-open "$gameDoc" 2>/dev/null &
else
# Text files: use yad text-info for accessibility
yad --text-info \
--title="Game Documentation" \
--filename="$gameDoc" \
--width=800 \
--height=600 \
--button="Close:0"
fi
else
# Console mode: use w3m or fallback
if command -v w3m &> /dev/null; then
w3m "$gameDoc"
elif [[ "${gameDoc,,}" =~ \.(html?)$ ]]; then
echo "Install w3m to view HTML documentation in console mode."
echo "Documentation location: $gameDoc"
read -rp "Press Enter to continue..."
else
less "$gameDoc"
fi
fi
else
echo "No documentation found."
if [[ "$dialogType" == "yad" ]]; then
agm_msgbox "Documentation" "" "No documentation found for this game."
else
echo "No documentation found."
read -rp "Press Enter to continue..."
fi
fi
exit 0
}