From 3c693d9184a8b529204f565822b60ec1fd890010 Mon Sep 17 00:00:00 2001 From: shupershuff <63577525+shupershuff@users.noreply.github.com> Date: Mon, 26 Aug 2024 01:27:52 +1200 Subject: [PATCH] Update D2Loader.ps1 --- D2Loader.ps1 | 124 +++++++++++++++++++++++++-------------------------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/D2Loader.ps1 b/D2Loader.ps1 index 9333dc4..ae62325 100644 --- a/D2Loader.ps1 +++ b/D2Loader.ps1 @@ -434,7 +434,7 @@ Function InitialiseCurrentStats { $StatsCSVRecoveryAttempt = 2 } if ($StatsCSVImportSuccess -eq $False -or $StatsCSVRecoveryAttempt -eq 2){ - Write-Host "`n Stats.csv is corrupted or empty." -foregroundcolor red + Write-Host;Write-Host " Stats.csv is corrupted or empty." -foregroundcolor red Write-Host " Replace with data from stats.backup.csv or delete stats.csv`n" -foregroundcolor red PressTheAnyKeyToExit } @@ -459,7 +459,7 @@ Function CheckForUpdates { $ReleaseInfo = ($Releases | Sort-Object id -desc)[0] #find release with the highest ID. $Script:LatestVersion = [version[]]$ReleaseInfo.Name.Trim('v') if ($Script:LatestVersion -gt $Script:CurrentVersion){ #If a newer version exists, prompt user about update details and ask if they want to update. - Write-Host "`n Update available! See Github for latest version and info" -foregroundcolor Yellow -nonewline + Write-Host;Write-Host " Update available! See Github for latest version and info" -foregroundcolor Yellow -nonewline if ([version]$CurrentVersion -in (($Releases.name.Trim('v') | ForEach-Object { [version]$_ } | Sort-Object -desc)[2..$releases.count])){ Write-Host ".`n There have been several releases since your version." -foregroundcolor Yellow Write-Host " Checkout Github releases for fixes/features added. " -foregroundcolor Yellow @@ -478,11 +478,11 @@ Function CheckForUpdates { $UpdateResponseValid = $True } Else { - Write-Host "`n Invalid response. Choose $X[38;2;255;165;000;22mY$X[0m $X[38;2;231;072;086;22mor$X[0m $X[38;2;255;165;000;22mN$X[0m.`n" -ForegroundColor red + Write-Host;Write-Host " Invalid response. Choose $X[38;2;255;165;000;22mY$X[0m $X[38;2;231;072;086;22mor$X[0m $X[38;2;255;165;000;22mN$X[0m.`n" -ForegroundColor red } } Until ($UpdateResponseValid -eq $True) if ($ShouldUpdate -eq "y" -or $ShouldUpdate -eq "yes"){#if user wants to update script, download .zip of latest release, extract to temporary folder and replace old D2Loader.ps1 with new D2Loader.ps1 - Write-Host "`n Updating... :)" -foregroundcolor green + Write-Host;Write-Host " Updating... :)" -foregroundcolor green try { New-Item -ItemType Directory -Path ($Script:WorkingDirectory + "\UpdateTemp\") -ErrorAction stop | Out-Null #create temporary folder to download zip to and extract } @@ -512,7 +512,7 @@ Function CheckForUpdates { $CurrentStats | Export-Csv -Path "$Script:WorkingDirectory\Stats.csv" -NoTypeInformation #update stats.csv with the new time played. } Catch { - Write-Host "`n Couldn't check for updates. GitHub API limit may have been reached..." -foregroundcolor Yellow + Write-Host;Write-Host " Couldn't check for updates. GitHub API limit may have been reached..." -foregroundcolor Yellow Start-Sleep -milliseconds 3500 } } @@ -547,7 +547,7 @@ Function ImportXML { #Import Config XML Write-Verbose "Config imported successfully." } Catch { - Write-Host "`n Config.xml Was not able to be imported. This could be due to a typo or a special character such as `'&`' being incorrectly used." -foregroundcolor red + Write-Host;Write-Host " Config.xml Was not able to be imported. This could be due to a typo or a special character such as `'&`' being incorrectly used." -foregroundcolor red Write-Host " The error message below will show which line in the config.xml is invalid:" -foregroundcolor red Write-Host (" " + $PSitem.exception.message + "`n") -foregroundcolor red PressTheAnyKeyToExit @@ -579,11 +579,11 @@ Function ValidationAndSetup { $NewXML = $NewXML -replace $Pattern, "-->;;" $NewXML = $NewXML -replace ";;","`r`n" $NewXML | Set-Content -Path "$Script:WorkingDirectory\Config.xml" - Write-Host "`n Corrected the description for GamePath in config.xml." -foregroundcolor Green + Write-Host;Write-Host " Corrected the description for GamePath in config.xml." -foregroundcolor Green Start-Sleep -milliseconds 1500 } if ($Null -ne $Script:Config.CommandLineArguments){#remove this config option as arguments are now stored in accounts.csv so that different arguments can be set for each account - Write-Host "`n Config option 'CommandLineArguments' is being moved to accounts.csv" -foregroundcolor Yellow + Write-Host;Write-Host " Config option 'CommandLineArguments' is being moved to accounts.csv" -foregroundcolor Yellow Write-Host " This is to enable different CMD arguments per account." -foregroundcolor Yellow $XML = Get-Content "$Script:WorkingDirectory\Config.xml" $Pattern = ";;\t;;\t.*?;;" @@ -596,7 +596,7 @@ Function ValidationAndSetup { Start-Sleep -milliseconds 1500 } if ($Null -eq $Script:Config.ManualSettingSwitcherEnabled){#not to be confused with the AutoSettingSwitcher. - Write-Host "`n Config option 'ManualSettingSwitcherEnabled' missing from config.xml" -foregroundcolor Yellow + Write-Host;Write-Host " Config option 'ManualSettingSwitcherEnabled' missing from config.xml" -foregroundcolor Yellow Write-Host " This is due to the config.xml recently being updated." -foregroundcolor Yellow Write-Host " This is an optional config option to allow you to manually select which " -foregroundcolor Yellow Write-Host " config file you want to use for each account when launching." -foregroundcolor Yellow @@ -614,7 +614,7 @@ Function ValidationAndSetup { PressTheAnyKey } if ($Null -eq $Script:Config.TrackAccountUseTime){ - Write-Host "`n Config option 'TrackAccountUseTime' missing from config.xml" -foregroundcolor Yellow + Write-Host;Write-Host " Config option 'TrackAccountUseTime' missing from config.xml" -foregroundcolor Yellow Write-Host " This is due to the config.xml recently being updated." -foregroundcolor Yellow Write-Host " This is an optional config option to track time played per account." -foregroundcolor Yellow Write-Host " Added this missing option into .xml file :)`n" -foregroundcolor green @@ -629,7 +629,7 @@ Function ValidationAndSetup { PressTheAnyKey } if ($Null -eq $Script:Config.ConvertPlainTextSecrets){ - Write-Host "`n Renaming ConvertPlainTextPasswords to ConvertPlainTextSecrets in config.xml" -foregroundcolor Yellow + Write-Host;Write-Host " Renaming ConvertPlainTextPasswords to ConvertPlainTextSecrets in config.xml" -foregroundcolor Yellow $XML = Get-Content "$Script:WorkingDirectory\Config.xml" $Pattern = "" $Replacement = "" @@ -644,7 +644,7 @@ Function ValidationAndSetup { PressTheAnyKey } if ($Null -ne $Script:Config.EnableBatchFeature){ # remove from config.xml. Not needed anymore as script checks accounts.csv to see if batches are used. - Write-Host "`n Config option 'EnableBatchFeature' is no longer needed." -foregroundcolor Yellow + Write-Host;Write-Host " Config option 'EnableBatchFeature' is no longer needed." -foregroundcolor Yellow Write-Host " Removed this option from config.xml file :)`n" -foregroundcolor green $XML = Get-Content "$Script:WorkingDirectory\Config.xml" $Pattern = ";;\t