diff --git a/.includes/bottle.sh b/.includes/bottle.sh index 07d2496..20293a0 100644 --- a/.includes/bottle.sh +++ b/.includes/bottle.sh @@ -95,8 +95,21 @@ install_wine_bottle() { # Modern wine is unified - no separate wine32/wine64 executables export WINE="wine" export WINESERVER="wineserver" - # Arguments to the function are dependancies to be installed. - # Get location of mono and gecko. + + # Check if bottle already exists and is properly initialized + local bottleExists=false + if [[ -d "$WINEPREFIX" ]] && [[ -f "$WINEPREFIX/system.reg" ]] && [[ -f "$WINEPREFIX/user.reg" ]]; then + bottleExists=true + echo "Using existing wine${architecture} bottle at $WINEPREFIX" + fi + + # Only do basic setup if bottle doesn't exist + if [[ "$bottleExists" == false ]]; then + echo -n "Creating new wine${architecture} bottle - Using " + wine --version + DISPLAY="" wineboot -u | agm_progressbox "Wine Setup" "Initializing wine bottle..." + + # Install mono and gecko only for new bottles monoPath="$(find /usr/share/wine/ -maxdepth 1 -type d -name mono 2> /dev/null)" geckoPath="$(find /usr/share/wine/ -maxdepth 1 -type d -name "gecko" 2> /dev/null)" if [[ -z "$monoPath" ]]; then @@ -107,28 +120,35 @@ install_wine_bottle() { download 'http://dl.winehq.org/wine/wine-gecko/2.40/wine_gecko-2.40-x86.msi' geckoPath="${cache}/wine_gecko-2.40-x86.msi" fi - echo -n "Using " - wine --version - DISPLAY="" wineboot -u | agm_progressbox "Wine Setup" "Initializing wine bottle..." - wine msiexec /i z:"$monoPath" /quiet | agm_progressbox "Wine Setup" "Installing .NET Framework..." - wine msiexec /i z:"$geckoPath" /quiet | agm_progressbox "Wine Setup" "Installing Web Browser support..." - if [[ "${*}" =~ (speechsdk|sapi) ]]; then - install_rhvoice - fi - if [[ "${WINEARCH}" == "win64" ]]; then - download "https://github.com/RastislavKish/nvda2speechd/releases/download/v0.1/nvda2speechd" - fi - if [[ "${WINEARCH}" == "win64" ]] && [[ ! -f "${XDG_DATA_HOME:-$HOME/.local/share}/audiogame-manager/nvda2speechd" ]]; then - cp "${cache}/nvda2speechd" "${XDG_DATA_HOME:-$HOME/.local/share}/audiogame-manager/nvda2speechd" - chmod +x "${XDG_DATA_HOME:-$HOME/.local/share}/audiogame-manager/nvda2speechd" - fi - winetricks -q isolate_home "$@" "${winVer:-win7}" ${winetricksSettings} | agm_progressbox "Wine Setup" "Installing wine dependencies..." - - # Set default voice for speech-enabled games - if [[ ${#defaultVoice} -ge 2 ]] && [[ "$*" =~ (speechsdk|sapi) ]]; then - echo "Setting default voice for wine${architecture}." - "${0%/*}/speech/set-voice.sh" -b "wine${architecture}" -r "${defaultRate:-7}" -v "${defaultVoice}" - fi + wine msiexec /i z:"$monoPath" /quiet | agm_progressbox "Wine Setup" "Installing .NET Framework..." + wine msiexec /i z:"$geckoPath" /quiet | agm_progressbox "Wine Setup" "Installing Web Browser support..." + fi + + # Install RHVoice only if needed and not already installed + if [[ "${*}" =~ (speechsdk|sapi) ]]; then + install_rhvoice + fi + + # Setup nvda2speechd for wine64 bottles (only once) + if [[ "${WINEARCH}" == "win64" ]]; then + download "https://github.com/RastislavKish/nvda2speechd/releases/download/v0.1/nvda2speechd" + if [[ ! -f "${XDG_DATA_HOME:-$HOME/.local/share}/audiogame-manager/nvda2speechd" ]]; then + cp "${cache}/nvda2speechd" "${XDG_DATA_HOME:-$HOME/.local/share}/audiogame-manager/nvda2speechd" + chmod +x "${XDG_DATA_HOME:-$HOME/.local/share}/audiogame-manager/nvda2speechd" + fi + fi + + # Install winetricks dependencies - this is more complex to optimize + # For now, let winetricks handle checking if packages are already installed + if [[ $# -gt 0 ]] || [[ -n "${winVer}" ]] || [[ -n "${winetricksSettings}" ]]; then + winetricks -q isolate_home "$@" "${winVer:-win7}" ${winetricksSettings} | agm_progressbox "Wine Setup" "Installing wine dependencies..." + fi + + # Set default voice for speech-enabled games (only if not already set) + if [[ ${#defaultVoice} -ge 2 ]] && [[ "$*" =~ (speechsdk|sapi) ]]; then + echo "Setting default voice for wine${architecture}." + "${0%/*}/speech/set-voice.sh" -b "wine${architecture}" -r "${defaultRate:-7}" -v "${defaultVoice}" + fi } add_launcher() {