audiogame-manager/game-scripts/crazy-party-update.sh

74 lines
3.8 KiB
Bash
Raw Permalink Normal View History

#!/usr/bin/env bash
#
# âe contents of this file are subject to the Common Public Attribution
# License Version 1.0 (the âcenseâ you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
# https://opensource.org/licenses/CPAL-1.0. The License is based on the Mozilla Public License Version
# 1.1 but Sections 14 and 15 have been added to cover use of software over a
# computer network and provide for limited attribution for the Original
# Developer. In addition, Exhibit A has been modified to be consistent with
# Exhibit B.
#
# Software distributed under the License is distributed on an â ISâasis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is audiogame manager.
#
# The Original Developer is not the Initial Developer and is . If
# left blank, the Original Developer is the Initial Developer.
#
# The Initial Developer of the Original Code is Billy "Storm Dragon" Wolfe. All portions of
# the code written by Billy Wolfe are Copyright (c) 2020. All Rights
# Reserved.
#
# Contributor Michael Taboada.
#
# Attribution Copyright Notice: Audiogame manager copyright 2020 Storm Dragon. All rights reserved.
#
# Attribution Phrase (not exceeding 10 words): A Stormux project
#
# Attribution URL: https://stormgames.wolfe.casa
#
# Graphic Image as provided in the Covered Code, if any.
#
# Display of Attribution Information is required in Larger
# Works which are defined in the CPAL as a work which combines Covered Code
# or portions thereof with code not governed by the terms of the CPAL.
newVersion=82
WINEPREFIX="${XDG_DATA_HOME:-$HOME/.local}/wine/crazy-party"
oldVersion=$(find ~/.local/wine/crazy-party -type d -name 'Crazy-Party-beta*' | tr -cd '[:digit:]')
cache="${XDG_CACHE_HOME:-$HOME/.cache}/audiogame-manager"
configFile="${XDG_CONFIG_HOME:-$HOME/.config}/storm-games/audiogame-manager/games.conf"
if [[ $oldVersion -le 78 ]]; then
echo "Crazy party has to be reinstalled because it is now a 64 bit application."
echo "Please run audiogame-manager -r to remove the old version."
echo "You can then install it again with audiogame-manager -i"
echo "Don't forget to make a backup of your save.bin file, custom card decks, and custom game lists."
find "${WINEPREFIX}/drive_c/Program Files" -type f -name 'save.bin' 2> /dev/null
find "${WINEPREFIX}/drive_c/Program Files" -type d -name 'deck' 2> /dev/null
find "${WINEPREFIX}/drive_c/Program Files" -type d -name 'game' 2> /dev/null
fi
if [[ $oldVersion -eq $newVersion ]]; then
echo "Crazy Party is up to date."
exit 0
fi
url="http://pragmapragma.free.fr/crazy-party/Crazy-Party-beta${newVersion}.zip"
(rm -v "${cache}/Crazy-Party-beta${oldVersion}.zip"
wget -O "${cache}/Crazy-Party-beta${newVersion}.zip" "$url" || { echo "Could not download file."; exit 1; }
unzip -DDod "${WINEPREFIX}/drive_c/Program Files" "${cache}/Crazy-Party-beta${newVersion}.zip"
find "${WINEPREFIX}" -type f -name 'Tolk.dll' -exec cp -v "${cache}/Tolk.dll" "{}" \;
find "${WINEPREFIX}" -type f -name 'nvdaControllerClient64.dll' -exec cp -v "${cache}/nvda2speechd64.dll" "{}" \;
sed -i "s/Crazy-Party-beta${oldVersion}/Crazy-Party-beta${newVersion}/" "$configFile"
cp -v "${WINEPREFIX}/drive_c/Program Files/Crazy-Party-beta${oldVersion}/save.bin" "$HOME/.local/wine/crazy-party/drive_c/Program Files/Crazy-Party-beta${newVersion}/"
cp -ruv "${WINEPREFIX}/drive_c/Program Files/Crazy-Party-beta${oldVersion}/"* "$HOME/.local/wine/crazy-party/drive_c/Program Files/Crazy-Party-beta${newVersion}/" 2> /dev/null
rm -rf "${WINEPREFIX}/drive_c/Program Files/Crazy-Party-beta${oldVersion}/") | dialog --progressbox "updating Crazy Party, please wait..." -1 -1
exit 0