Added a documentation button that will hopefully load the game's documentation in w3m. This is the first attempt but it seems to be working pretty well so far.

This commit is contained in:
Storm Dragon 2021-04-27 20:32:08 -04:00
parent 55caa9b843
commit ab1e89fd6b

View File

@ -197,6 +197,11 @@ checklist() {
else else
errorList+=("Warning: unix2dos is not installed. Some games need a configuration file in dos format before they will run.") errorList+=("Warning: unix2dos is not installed. Some games need a configuration file in dos format before they will run.")
fi fi
if command -v w3m &> /dev/null ; then
echo "W3m is installed."
else
errorList+=("Warning: w3m is not installed. W3m is used to view game documentation.")
fi
if command -v xclip &> /dev/null ; then if command -v xclip &> /dev/null ; then
echo "Xclip is installed." echo "Xclip is installed."
else else
@ -266,6 +271,43 @@ help() {
exit 0 exit 0
} }
documentation() {
if [[ "$2" == "Become a Patron" ]]; then
return
fi
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."
fi
export WINEPREFIX="$1"
echo "Loading documentation, please wait..."
# Try to find documentation based on common naming conventions.
local gamePath="$(winepath -u "$2" 2> /dev/null)"
gamePath="${gamePath%/*}"
local gameDoc="$(find "$gamePath" -type f -iname 'user_manual.html')"
if [[ -z "$gameDoc" ]]; then
gameDoc="$(find "$gamePath" -type f -iname 'manual.html')"
fi
if [[ -z "$gameDoc" ]]; then
gameDoc="$(find "$gamePath" -type f -iname 'readme.html')"
fi
if [[ -z "$gameDoc" ]]; then
gameDoc="$(find "$gamePath" -type f -iname 'manual.txt')"
fi
if [[ -z "$gameDoc" ]]; then
gameDoc="$(find "$gamePath" -type f -iname 'readme.txt')"
fi
# Display documentation if available.
if [[ -n "$gameDoc" ]]; then
w3m "$gameDoc"
else
echo "No documentation found."
fi
exit 0
}
install_wine_bottle() { install_wine_bottle() {
# 32 bit installations work best and are the default here, if you need to override it, do it in the game specific installation steps. # 32 bit installations work best and are the default here, if you need to override it, do it in the game specific installation steps.
export WINEARCH="${WINEARCH:-win32}" export WINEARCH="${WINEARCH:-win32}"
@ -421,10 +463,18 @@ game_launcher() {
done done
menuList+=("Donate" "Donate") menuList+=("Donate" "Donate")
menuList+=("Become a Patron" "Become a Patron") menuList+=("Become a Patron" "Become a Patron")
local game="$(dialog --backtitle "Audio Game Launcher" \ game="$(dialog --backtitle "Audio Game Launcher" \
--clear \ --clear \
--extra-button \
--extra-label "Documentation" \
--no-tags \ --no-tags \
--menu "Please select a game to play" 0 0 0 "${menuList[@]}" --stdout)" --menu "Please select a game to play" 0 0 0 "${menuList[@]}" --stdout)"
local menuCode=$?
if [[ $menuCode -eq 1 ]]; then
exit 0
elif [[ $menuCode -eq 3 ]]; then
documentation "${HOME}/.local/wine/${game%|*}" "$(echo "$game" | cut -d '|' -f2)"
fi
else else
local game="$(grep "^${1}|" "${configFile}" 2> /dev/null)" local game="$(grep "^${1}|" "${configFile}" 2> /dev/null)"
game="${game%|*}" game="${game%|*}"