diff --git a/scripts/Windows/Software/osu!/Manage.ps1 b/scripts/Windows/Software/osu!/Manage.ps1 index d3ad1af7..3024a636 100644 --- a/scripts/Windows/Software/osu!/Manage.ps1 +++ b/scripts/Windows/Software/osu!/Manage.ps1 @@ -5,10 +5,41 @@ param( . "$PSScriptRoot/../../../Common/Scripts/Software.ps1"; -Start-SoftwareInstaller @PSBoundParameters ` - -Installer { - Install-ChocoPackage osu; - Remove-DesktopIcon "*osu*"; - }; +& { + param($Parameters) + . "$PSScriptRoot/../../Scripts/Restoration.ps1"; + Export-ModuleMember -Function @(); -# ToDo: Add restoration + $getInstallPath = { + return "$((Get-KnownFolder -SpecialFolder ProgramFilesX86).Path)/osu!"; + } + + Start-SoftwareInstaller @Parameters ` + -Installer { + Install-ChocoPackage osu; + Remove-DesktopIcon "*osu*"; + } ` + -Backup { + Add-BackupArtifacts -Source (& $getInstallPath) -Path "osu!" ` + -Include @( + "Screenshots", + "Skins", + "Songs", + "osu!.cfg", + "scores.db" + ); + } ` + -Configurator { + Expand-BackupArtifacts -Path "osu!" -Target (& $getInstallPath); + } ` + -UserBackup { + param([hashtable] $Arguments) + $name = $Arguments.Name; + Add-BackupArtifacts -Source "$(& $getInstallPath)/osu!.$name.cfg" -User $name -Path "osu!/osu!.cfg"; + } ` + -UserConfigurator { + param([hashtable] $Arguments) + $name = $Arguments.Name; + Expand-BackupArtifacts -User $name -Path "osu!/osu!.cfg" -Target "$(& $getInstallPath)/osu!.$name.cfg"; + }; +} $PSBoundParameters; diff --git a/scripts/Windows/Software/osu!lazer/Manage.ps1 b/scripts/Windows/Software/osu!lazer/Manage.ps1 index 5853c4c9..d2f7a727 100644 --- a/scripts/Windows/Software/osu!lazer/Manage.ps1 +++ b/scripts/Windows/Software/osu!lazer/Manage.ps1 @@ -3,29 +3,45 @@ param( [hashtable] $Arguments ) -. "$PSScriptRoot/../../../Common/Scripts/Software.ps1"; -. "$PSScriptRoot/../../../Common/Scripts/System.ps1"; +& { + param($Parameters) + . "$PSScriptRoot/../../Scripts/Restoration.ps1"; + . "$PSScriptRoot/../../../Common/Scripts/Software.ps1"; + . "$PSScriptRoot/../../../Common/Scripts/System.ps1"; + $path = "$env:AppData/osu"; -Start-SoftwareInstaller @PSBoundParameters ` - -UserConfigurator { - $file = "osu!lazer.exe"; - $processName = "osu!"; - $dir = New-TemporaryDirectory; + Start-SoftwareInstaller @Parameters ` + -UserBackup { + param([hashtable] $Arguments) + Add-BackupArtifacts -User $Arguments.Name -Source $path -Path "osu!lazer" ` + -Include @( + "files", + "rulesets", + "screenshots", + "framework.ini", + "game.ini", + "input.json" + ); + } ` + -UserConfigurator { + $file = "osu!lazer.exe"; + $processName = "osu!"; + $dir = New-TemporaryDirectory; - Push-Location $dir; - Invoke-WebRequest "https://github.com/ppy/osu/releases/latest/download/install.exe" -OutFile $file; - Start-Process -FilePath $file; + Push-Location $dir; + Invoke-WebRequest "https://github.com/ppy/osu/releases/latest/download/install.exe" -OutFile $file; + Start-Process -FilePath $file; - while (-not (Get-Process -ErrorAction SilentlyContinue $processName)) { - Start-Sleep 1; - } + while (-not (Get-Process -ErrorAction SilentlyContinue $processName)) { + Start-Sleep 1; + } - Start-Sleep 10; - Get-Process $processName | Stop-Process -Force; - Pop-Location; - Remove-Item -Recurse $dir; + Start-Sleep 10; + Get-Process $processName | Stop-Process -Force; + Pop-Location; + Remove-Item -Recurse $dir; - Remove-DesktopIcon "*osu*"; - }; - -# ToDo: Add restoration + Remove-DesktopIcon "*osu*"; + Expand-BackupArtifacts -User $Arguments.Name -Path "osu!lazer" -Target $path; + }; +} $PSBoundParameters;