diff --git a/LANCommander/Snippets/Examples/Copy Directory.ps1 b/LANCommander/Snippets/Examples/Copy Directory.ps1 index 26c82d5..02c366f 100644 --- a/LANCommander/Snippets/Examples/Copy Directory.ps1 +++ b/LANCommander/Snippets/Examples/Copy Directory.ps1 @@ -1 +1 @@ -Copy-Item -Path "$InstallDir\" -Destination "$InstallDir\" -Recurse \ No newline at end of file +Copy-Item -Path "$InstallDirectory\" -Destination "$InstallDirectory\" -Recurse \ No newline at end of file diff --git a/LANCommander/Snippets/Examples/Create Directory.ps1 b/LANCommander/Snippets/Examples/Create Directory.ps1 index b5d5d4c..b65e50d 100644 --- a/LANCommander/Snippets/Examples/Create Directory.ps1 +++ b/LANCommander/Snippets/Examples/Create Directory.ps1 @@ -1 +1 @@ -New-Item -ItemType Directory -Force -Path "$InstallDir\" \ No newline at end of file +New-Item -ItemType Directory -Force -Path "$InstallDirectory\" \ No newline at end of file diff --git a/LANCommander/Snippets/Examples/Patch Binary.ps1 b/LANCommander/Snippets/Examples/Patch Binary.ps1 index 5019bf2..b3568ad 100644 --- a/LANCommander/Snippets/Examples/Patch Binary.ps1 +++ b/LANCommander/Snippets/Examples/Patch Binary.ps1 @@ -1,2 +1,2 @@ # Writes byte[] to a file at an offset -Patch-Binary -FilePath "$InstallDir\" -Offset 0x00 -Data $bytes \ No newline at end of file +Patch-Binary -FilePath "$InstallDirectory\" -Offset 0x00 -Data $bytes \ No newline at end of file diff --git a/LANCommander/Snippets/Examples/Remove Directory.ps1 b/LANCommander/Snippets/Examples/Remove Directory.ps1 index 5df8909..8425c7b 100644 --- a/LANCommander/Snippets/Examples/Remove Directory.ps1 +++ b/LANCommander/Snippets/Examples/Remove Directory.ps1 @@ -1 +1 @@ -Remove-Item "$InstallDir\" -Recurse -ErrorAction Ignore \ No newline at end of file +Remove-Item "$InstallDirectory\" -Recurse -ErrorAction Ignore \ No newline at end of file diff --git a/LANCommander/Snippets/Examples/Rename File.ps1 b/LANCommander/Snippets/Examples/Rename File.ps1 index b315277..9042ba1 100644 --- a/LANCommander/Snippets/Examples/Rename File.ps1 +++ b/LANCommander/Snippets/Examples/Rename File.ps1 @@ -1 +1 @@ -Rename-Item -Path "$InstallDir\" -NewName "$InstallDir\" \ No newline at end of file +Rename-Item -Path "$InstallDirectory\" -NewName "$InstallDirectory\" \ No newline at end of file diff --git a/LANCommander/Snippets/Examples/Replace Content In File.ps1 b/LANCommander/Snippets/Examples/Replace Content In File.ps1 deleted file mode 100644 index c28c8bf..0000000 --- a/LANCommander/Snippets/Examples/Replace Content In File.ps1 +++ /dev/null @@ -1,2 +0,0 @@ -# Use regex to replace text within a file. Quotes are escaped by double quoting ("") -Write-ReplaceContentInFile -Regex '^game.setPlayerName "(.+)"' -Replacement "game.setPlayerName ""$NewName""" -FilePath "$InstallDir\" \ No newline at end of file diff --git a/LANCommander/Snippets/Examples/Separate ASCII Bytes.ps1 b/LANCommander/Snippets/Examples/Separate ASCII Bytes.ps1 deleted file mode 100644 index 2ea805a..0000000 --- a/LANCommander/Snippets/Examples/Separate ASCII Bytes.ps1 +++ /dev/null @@ -1,2 +0,0 @@ -# Takes an input byte[] and separates it with 0x00 between each character -$bytes = Separate-AsciiBytes -Data $bytes \ No newline at end of file diff --git a/LANCommander/Snippets/Examples/Set Compatibility Mode.ps1 b/LANCommander/Snippets/Examples/Set Compatibility Mode.ps1 index b9e130d..0ebf256 100644 --- a/LANCommander/Snippets/Examples/Set Compatibility Mode.ps1 +++ b/LANCommander/Snippets/Examples/Set Compatibility Mode.ps1 @@ -9,4 +9,4 @@ # WIN7RTM # WIN8RTM # See: https://ss64.com/nt/syntax-compatibility.html -New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" -Name "$InstallDir\" -Value "~ WINXPSP2 HIGHDPIAWARE" -Force \ No newline at end of file +New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" -Name "$InstallDirectory\" -Value "~ WINXPSP2 HIGHDPIAWARE" -Force \ No newline at end of file diff --git a/LANCommander/Snippets/Examples/String to ASCII Bytes.ps1 b/LANCommander/Snippets/Examples/String to ASCII Bytes.ps1 deleted file mode 100644 index d40c156..0000000 --- a/LANCommander/Snippets/Examples/String to ASCII Bytes.ps1 +++ /dev/null @@ -1,2 +0,0 @@ -# Convert an input string to ASCII-encoded byte[]. Shorter strings will pad out to 12 bytes, longer strings will be trimmed. -$bytes = Get-AsciiBytes -InputString "Hello world!" -MaxLength 12 \ No newline at end of file diff --git a/LANCommander/Snippets/Examples/Trim String.ps1 b/LANCommander/Snippets/Examples/Trim String.ps1 index b4d7b94..2a72e13 100644 --- a/LANCommander/Snippets/Examples/Trim String.ps1 +++ b/LANCommander/Snippets/Examples/Trim String.ps1 @@ -1,4 +1,4 @@ # Trim a string down to a specified amount of characters -if ($NewName.Length -gt 10) { - $NewName = $NewName.Substring(0, 10); +if ($NewPlayerAlias.Length -gt 10) { + $NewPlayerAlias = $NewPlayerAlias.Substring(0, 10); } \ No newline at end of file diff --git a/LANCommander/Snippets/Examples/Write to File.ps1 b/LANCommander/Snippets/Examples/Write to File.ps1 index e2e2bbf..8dbb621 100644 --- a/LANCommander/Snippets/Examples/Write to File.ps1 +++ b/LANCommander/Snippets/Examples/Write to File.ps1 @@ -1,2 +1,2 @@ # Write contents of a string to a file -Set-Content "$InstallDir\" "Hello world!" \ No newline at end of file +Set-Content "$InstallDirectory\" "Hello world!" \ No newline at end of file diff --git a/LANCommander/Snippets/Functions/Convert-AspectRatio.ps1 b/LANCommander/Snippets/Functions/Convert-AspectRatio.ps1 new file mode 100644 index 0000000..5faeb50 --- /dev/null +++ b/LANCommander/Snippets/Functions/Convert-AspectRatio.ps1 @@ -0,0 +1,2 @@ +# Bounds accessible via $Resolution.Height, $Resolution.Width +$Resolution = Convert-AspectRatio -Width 1280 -Height 800 -AspectRatio (4 / 3) \ No newline at end of file diff --git a/LANCommander/Snippets/Functions/ConvertTo-StringBytes.ps1 b/LANCommander/Snippets/Functions/ConvertTo-StringBytes.ps1 new file mode 100644 index 0000000..18e775b --- /dev/null +++ b/LANCommander/Snippets/Functions/ConvertTo-StringBytes.ps1 @@ -0,0 +1,2 @@ +# Converts a string to a UTF16-encoded byte array. This looks like ASCII characters separated by 0x00 in most cases. +$bytes = ConvertTo-StringBytes -Input "Hello World!" -Utf16 1 -MaxLength 12 \ No newline at end of file diff --git a/LANCommander/Snippets/Functions/Edit-PatchBinary.ps1 b/LANCommander/Snippets/Functions/Edit-PatchBinary.ps1 new file mode 100644 index 0000000..e35312d --- /dev/null +++ b/LANCommander/Snippets/Functions/Edit-PatchBinary.ps1 @@ -0,0 +1 @@ +Edit-PatchBinary -FilePath "$InstallDirectory\" -Offset 0x00 -Data $bytes \ No newline at end of file diff --git a/LANCommander/Snippets/Functions/Get-43Resolution.ps1 b/LANCommander/Snippets/Functions/Get-43Resolution.ps1 deleted file mode 100644 index 7c45514..0000000 --- a/LANCommander/Snippets/Functions/Get-43Resolution.ps1 +++ /dev/null @@ -1,14 +0,0 @@ -function Get-43Resolution([int]$Width, [int]$Height) { - $ratio = 4 / 3 - - if (($Width -gt $Height) -or ($Width -eq $Height)) { - return @{ Width = [math]::Round($ratio * $Height); Height = $Height } - } - - if ($Width -lt $Height) { - return @{ Width = $Width; Height = [math]::Round($Width / $ratio) } - } -} - -# Accessible via $Resolution.Height, $Resolution.Width -$Resolution = Get-43Resolution -Width 1280 -Height 800 \ No newline at end of file diff --git a/LANCommander/Snippets/Functions/Get-AsciiBytes.ps1 b/LANCommander/Snippets/Functions/Get-AsciiBytes.ps1 deleted file mode 100644 index 9696eb2..0000000 --- a/LANCommander/Snippets/Functions/Get-AsciiBytes.ps1 +++ /dev/null @@ -1,30 +0,0 @@ -function Get-AsciiBytes([string]$InputString, [int]$MaxLength) -{ - if ($InputString.Length -gt $MaxLength) - { - $InputString = $InputString.Substring(0, $MaxLength) - } - - $bytes = [System.Text.Encoding]::ASCII.GetBytes($InputString) - $array = @() - $count = 0 - - $extraPadding = $MaxLength - $bytes.Length - - foreach ($byte in $bytes) - { - if ($count -lt $MaxLength) - { - $array += $byte - $count++ - } - } - - # Pad the end with 0x00 to meet our max length - for ($i = $count; $i -lt $MaxLength; $i++) - { - $array += 0x00 - } - - return $array -} \ No newline at end of file diff --git a/LANCommander/Snippets/Functions/Get-GameManifest.ps1 b/LANCommander/Snippets/Functions/Get-GameManifest.ps1 new file mode 100644 index 0000000..5fa659b --- /dev/null +++ b/LANCommander/Snippets/Functions/Get-GameManifest.ps1 @@ -0,0 +1 @@ +$manifest = Get-GameManifest "C:\\Games\\" \ No newline at end of file diff --git a/LANCommander/Snippets/Functions/Get-PrimaryDisplay.ps1 b/LANCommander/Snippets/Functions/Get-PrimaryDisplay.ps1 new file mode 100644 index 0000000..db37f87 --- /dev/null +++ b/LANCommander/Snippets/Functions/Get-PrimaryDisplay.ps1 @@ -0,0 +1,2 @@ +# Bounds are accessible by $Resolution.Width and $Resolution.Height +$Resolution = Get-PrimaryDisplay \ No newline at end of file diff --git a/LANCommander/Snippets/Functions/Patch-Binary.ps1 b/LANCommander/Snippets/Functions/Patch-Binary.ps1 deleted file mode 100644 index 80be124..0000000 --- a/LANCommander/Snippets/Functions/Patch-Binary.ps1 +++ /dev/null @@ -1,11 +0,0 @@ -function Patch-Binary([byte[]]$Data, [int]$Offset, [string]$FilePath) -{ - $bytes = [System.IO.File]::ReadAllBytes($FilePath) - - for ($i = 0; $i -lt $Data.Length; $i++) - { - $bytes[$Offset + $i] = $Data[$i] - } - - [System.IO.File]::WriteAllBytes($FilePath, $bytes) -} \ No newline at end of file diff --git a/LANCommander/Snippets/Functions/Separate-AsciiBytes.ps1 b/LANCommander/Snippets/Functions/Separate-AsciiBytes.ps1 deleted file mode 100644 index d8c86f1..0000000 --- a/LANCommander/Snippets/Functions/Separate-AsciiBytes.ps1 +++ /dev/null @@ -1,12 +0,0 @@ -function Separate-AsciiBytes([byte[]]$Data) -{ - $array = @() - - foreach ($byte in $Data) - { - $array += $byte - $array += 0x00 - } - - return $array -} \ No newline at end of file diff --git a/LANCommander/Snippets/Functions/Write-ReplaceContentInFile.ps1 b/LANCommander/Snippets/Functions/Write-ReplaceContentInFile.ps1 index b50e3b3..c28c8bf 100644 --- a/LANCommander/Snippets/Functions/Write-ReplaceContentInFile.ps1 +++ b/LANCommander/Snippets/Functions/Write-ReplaceContentInFile.ps1 @@ -1,5 +1,2 @@ -function Write-ReplaceContentInFile([string]$Regex, [string]$Replacement, [string]$FilePath) -{ - $content = (Get-Content $FilePath) -replace $Regex, $Replacement - [IO.File]::WriteAllLines($FilePath, $content) -} \ No newline at end of file +# Use regex to replace text within a file. Quotes are escaped by double quoting ("") +Write-ReplaceContentInFile -Regex '^game.setPlayerName "(.+)"' -Replacement "game.setPlayerName ""$NewName""" -FilePath "$InstallDir\" \ No newline at end of file diff --git a/LANCommander/Snippets/Variables/Allocated Key.ps1 b/LANCommander/Snippets/Variables/Allocated Key.ps1 new file mode 100644 index 0000000..0fb4572 --- /dev/null +++ b/LANCommander/Snippets/Variables/Allocated Key.ps1 @@ -0,0 +1 @@ +$AllocatedKey \ No newline at end of file diff --git a/LANCommander/Snippets/Variables/Default Install Directory.ps1 b/LANCommander/Snippets/Variables/Default Install Directory.ps1 new file mode 100644 index 0000000..3f6de2c --- /dev/null +++ b/LANCommander/Snippets/Variables/Default Install Directory.ps1 @@ -0,0 +1 @@ +$DefaultInstallDirectory \ No newline at end of file diff --git a/LANCommander/Snippets/Variables/Display.ps1 b/LANCommander/Snippets/Variables/Display.ps1 deleted file mode 100644 index eca1e0e..0000000 --- a/LANCommander/Snippets/Variables/Display.ps1 +++ /dev/null @@ -1,3 +0,0 @@ -# Accessible via $Display.Width and $Display.Height -Add-Type -AssemblyName System.Windows.Forms -$Display = ([System.Windows.Forms.Screen]::AllScreens | Where-Object Primary).Bounds \ No newline at end of file diff --git a/LANCommander/Snippets/Variables/Game Install Directory.ps1 b/LANCommander/Snippets/Variables/Game Install Directory.ps1 new file mode 100644 index 0000000..ac9ce15 --- /dev/null +++ b/LANCommander/Snippets/Variables/Game Install Directory.ps1 @@ -0,0 +1 @@ +$OldPlayerAlias \ No newline at end of file diff --git a/LANCommander/Snippets/Variables/Game Manifest.ps1 b/LANCommander/Snippets/Variables/Game Manifest.ps1 new file mode 100644 index 0000000..d839b38 --- /dev/null +++ b/LANCommander/Snippets/Variables/Game Manifest.ps1 @@ -0,0 +1 @@ +$GameManifest \ No newline at end of file diff --git a/LANCommander/Snippets/Variables/InstallDir.ps1 b/LANCommander/Snippets/Variables/InstallDir.ps1 deleted file mode 100644 index 262b772..0000000 --- a/LANCommander/Snippets/Variables/InstallDir.ps1 +++ /dev/null @@ -1 +0,0 @@ -$InstallDir = $PSScriptRoot \ No newline at end of file diff --git a/LANCommander/Snippets/Variables/NewName.ps1 b/LANCommander/Snippets/Variables/New Player Alias.ps1 similarity index 100% rename from LANCommander/Snippets/Variables/NewName.ps1 rename to LANCommander/Snippets/Variables/New Player Alias.ps1 diff --git a/LANCommander/Snippets/Variables/OldName.ps1 b/LANCommander/Snippets/Variables/Old Player Alias.ps1 similarity index 100% rename from LANCommander/Snippets/Variables/OldName.ps1 rename to LANCommander/Snippets/Variables/Old Player Alias.ps1 diff --git a/LANCommander/Snippets/Variables/Server Address.ps1 b/LANCommander/Snippets/Variables/Server Address.ps1 new file mode 100644 index 0000000..e244bae --- /dev/null +++ b/LANCommander/Snippets/Variables/Server Address.ps1 @@ -0,0 +1 @@ +$ServerAddress \ No newline at end of file