mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-22 23:48:08 -05:00
128 lines
4.5 KiB
AppleScript
Executable file
128 lines
4.5 KiB
AppleScript
Executable file
#!/usr/bin/env osascript
|
|
|
|
on ExitWithMessage(message)
|
|
display dialog message
|
|
do shell script "sudo rm -rf \"" & binPath & "\""
|
|
error number -128
|
|
end ExitWithMessage
|
|
|
|
set installerChoices to {"Install Geode", "Uninstall Geode"}
|
|
|
|
set installerAnswer to choose from list installerChoices with title "Geode" with prompt "What do you want to do?" default items "Install Geode"
|
|
|
|
if installerAnswer is false then
|
|
ExitWithMessage ("Prompt cancelled.")
|
|
else
|
|
set installerAnswer to installerAnswer's item 1
|
|
end if
|
|
|
|
set tmpPath to POSIX path of "/tmp/"
|
|
set binPath to (tmpPath & "geode-install/")
|
|
|
|
tell application "System Events"
|
|
try
|
|
set libraryPath to POSIX path of (path to home folder from user domain)
|
|
set steamPath to (libraryPath & "/Library/Application Support/Steam/steamapps/common/Geometry Dash/")
|
|
|
|
display dialog "Steam path: " & steamPath
|
|
|
|
if exists folder steamPath then
|
|
set gdPath to (the POSIX path of (choose file with prompt "Please choose the Geometry Dash application to install Geode to:" of type {"app"} default location steamPath))
|
|
else
|
|
set gdPath to (the POSIX path of (choose file with prompt "Please choose the Geometry Dash application to install Geode to:" of type {"app"}))
|
|
end if
|
|
|
|
set gdPath to (gdPath & "/")
|
|
|
|
on error
|
|
ExitWithMessage ("Prompt cancelled.")
|
|
end try
|
|
|
|
set execPath to (gdPath & "Contents/MacOS/Geometry Dash")
|
|
set frameworkPath to (gdPath & "Contents/Frameworks/")
|
|
set fmodPath to "libfmod.dylib"
|
|
set fmodOriginalPath to "restore_fmod.dylib"
|
|
set geodePath to "Geode.dylib"
|
|
set bootstrapperPath to "GeodeBootstrapper.dylib"
|
|
set resourcesPath to "resources/"
|
|
set newGeodePath to "Contents/geode/"
|
|
set newResourcesPath to (newGeodePath & "resources/geode.loader/")
|
|
|
|
try
|
|
if not exists file execPath then
|
|
ExitWithMessage ("Not a valid Geometry Dash installation (executable missing): " & gdPath)
|
|
end if
|
|
|
|
if not exists file (frameworkPath & fmodPath) then
|
|
ExitWithMessage ("Not a valid Geometry Dash installation (fmod missing): " & gdPath)
|
|
end if
|
|
on error
|
|
ExitWithMessage ("Not a valid Geometry Dash installation: " & gdPath)
|
|
end try
|
|
end tell
|
|
|
|
|
|
|
|
|
|
|
|
if installerAnswer is "Install Geode" then
|
|
|
|
try
|
|
do shell script "mv -n \"" & (frameworkPath & fmodPath) & "\" \"" & (frameworkPath & fmodOriginalPath) & "\""
|
|
on error
|
|
ExitWithMessage ("Saving original fmod failed: " & (frameworkPath & fmodPath))
|
|
end try
|
|
|
|
try
|
|
do shell script "mv \"" & (binPath & geodePath) & "\" \"" & (frameworkPath & geodePath) & "\""
|
|
do shell script "mv \"" & (binPath & bootstrapperPath) & "\" \"" & (frameworkPath & bootstrapperPath) & "\""
|
|
do shell script "mv \"" & (binPath & fmodPath) & "\" \"" & (frameworkPath & fmodPath) & "\""
|
|
do shell script "INSTALLER_USER=$(stat -f '%Su' $HOME) && chown -R $INSTALLER_USER \"" & frameworkPath & "\""
|
|
on error
|
|
ExitWithMessage ("Moving libraries failed: " & frameworkPath)
|
|
end try
|
|
|
|
try
|
|
do shell script "mkdir -p \"" & (gdPath & newResourcesPath) & "\""
|
|
do shell script "mv \"" & (binPath & resourcesPath) & "\"* \"" & (gdPath & newResourcesPath) & "\""
|
|
do shell script "INSTALLER_USER=$(stat -f '%Su' $HOME) && chown -R $INSTALLER_USER \"" & (gdPath & newGeodePath) & "\""
|
|
on error
|
|
ExitWithMessage ("Moving resources failed: " & (gdPath & newResourcesPath))
|
|
end try
|
|
|
|
try
|
|
do shell script "sudo xattr -dr com.apple.quarantine \"" & gdPath & "\""
|
|
on error
|
|
|
|
end try
|
|
|
|
else if installerAnswer is "Uninstall Geode" then
|
|
|
|
try
|
|
do shell script "rm \"" & (frameworkPath & geodePath) & "\""
|
|
do shell script "rm \"" & (frameworkPath & bootstrapperPath) & "\""
|
|
do shell script "rm \"" & (frameworkPath & fmodPath) & "\""
|
|
on error
|
|
ExitWithMessage ("Removing libraries failed: " & frameworkPath)
|
|
end try
|
|
|
|
try
|
|
do shell script "mv \"" & (frameworkPath & fmodOriginalPath) & "\" \"" & (frameworkPath & fmodPath) & "\""
|
|
on error
|
|
ExitWithMessage ("Restoring original fmod failed: " & (frameworkPath & fmodPath))
|
|
end try
|
|
|
|
try
|
|
do shell script "rm -r \"" & (gdPath & newGeodePath) & "\""
|
|
on error
|
|
ExitWithMessage ("Removing geode folder failed: " & (gdPath & newGeodePath))
|
|
end try
|
|
|
|
end if
|
|
|
|
try
|
|
do shell script "sudo rm -rf \"" & binPath & "\""
|
|
on error
|
|
|
|
end try
|
|
|