2023-07-12 20:37:31 +00:00
|
|
|
#!/bin/pwsh
|
2024-03-24 15:54:36 +00:00
|
|
|
. "$PSScriptRoot/../../Scripts/KnownFolders.ps1";
|
2024-08-07 19:05:32 +00:00
|
|
|
. "$PSScriptRoot/../../../Common/Scripts/Context.ps1";
|
2023-06-07 18:02:31 +00:00
|
|
|
|
2023-06-08 00:28:33 +00:00
|
|
|
$null = New-Module {
|
2023-07-02 14:07:47 +00:00
|
|
|
$path = "$((Get-KnownFolder -SpecialFolder ProgramFilesX86).Path)/osu!";
|
2023-06-08 00:28:33 +00:00
|
|
|
$softwareName = "osu!";
|
|
|
|
$genericConfigName = "osu!.User.cfg";
|
|
|
|
|
2023-06-30 10:19:54 +00:00
|
|
|
function Backup-Osu([Context] $context) {
|
2023-06-30 12:23:20 +00:00
|
|
|
Write-Host "Backing up osu!";
|
2023-06-08 00:28:33 +00:00
|
|
|
$archive = $context.SoftwareArchive($softwareName);
|
2023-06-30 12:23:20 +00:00
|
|
|
Write-Information "Backing up important files";
|
2023-06-08 00:28:33 +00:00
|
|
|
$context.Backup($path, $archive, @("-i@`"$PSScriptRoot/include.txt`""));
|
2023-06-30 12:23:20 +00:00
|
|
|
Write-Information "Renaming user configuration to $genericConfigName";
|
2023-06-08 00:28:33 +00:00
|
|
|
& 7z rn "$archive" "osu!.$env:USERNAME.cfg" $genericConfigName;
|
|
|
|
}
|
2023-07-02 12:42:17 +00:00
|
|
|
|
|
|
|
function Restore-Osu([Context] $context) {
|
|
|
|
Write-Host "Restoring osu!";
|
|
|
|
Write-Information "Installing osu!";
|
|
|
|
choco install -y osu;
|
2023-07-16 10:32:46 +00:00
|
|
|
$context.RemoveDesktopIcon("*osu*");
|
2023-07-02 12:42:17 +00:00
|
|
|
Write-Information "Restoring files";
|
2024-03-24 17:17:18 +00:00
|
|
|
$context.Restore($context.SoftwareArchive($softwareName), $path, @("-aos"));
|
2023-07-02 12:42:17 +00:00
|
|
|
$configName = "osu!.$env:USERNAME.cfg";
|
|
|
|
Write-Information "Renaming user configuration to $configName";
|
|
|
|
Push-Location $path;
|
2023-07-02 16:46:06 +00:00
|
|
|
|
|
|
|
if ((Test-Path $genericConfigName)) {
|
|
|
|
Rename-Item $genericConfigName $configName;
|
|
|
|
}
|
|
|
|
|
2023-07-02 16:45:38 +00:00
|
|
|
Pop-Location;
|
2023-07-02 12:42:17 +00:00
|
|
|
}
|
2023-06-07 18:02:31 +00:00
|
|
|
}
|