#!/bin/zsh # Restart the original game in a fresh 800x600 Wine desktop with the virtual cursor hook, # then wait until its window exists and the title screen has settled. export WINEPREFIX="$HOME/.wine-choc3" WINEDEBUG=-all MVK_CONFIG_LOG_LEVEL=0 W="$HOME/Applications/Wine Devel.app/Contents/Resources/wine/bin" HERE=${0:A:h} "$W/wineserver" -k; sleep 1 # fresh profile unless KEEP_PROFILE=1 [ -z "$KEEP_PROFILE" ] && rm -rf "$HOME/.wine-choc3/drive_c/users/$USER/AppData/Roaming/PlayFirst/chocolatier-decadence-design" launch() { ( "$W/wine" explorer '/desktop=Choc3,800x600' 'C:\Games\launch.exe' >/dev/null 2>&1 & ); } wait_window() { for i in {1..30}; do swift "$HERE/wins.swift" 2>/dev/null | grep -q 'Chocolatier: Decadence' && return 0; sleep 1; done; return 1; } launch # the first start after wiping the profile can crash; the second one works wait_window || { "$W/wineserver" -k; sleep 1; launch; wait_window; } sleep "${1:-12}"