Updated default snippets
parent
2cb7013120
commit
aed9935b16
|
@ -1 +1 @@
|
||||||
Copy-Item -Path "$InstallDir\<Source Path>" -Destination "$InstallDir\<Destination Path>" -Recurse
|
Copy-Item -Path "$InstallDirectory\<Source Path>" -Destination "$InstallDirectory\<Destination Path>" -Recurse
|
|
@ -1 +1 @@
|
||||||
New-Item -ItemType Directory -Force -Path "$InstallDir\<Path>"
|
New-Item -ItemType Directory -Force -Path "$InstallDirectory\<Path>"
|
|
@ -1,2 +1,2 @@
|
||||||
# Writes byte[] to a file at an offset
|
# Writes byte[] to a file at an offset
|
||||||
Patch-Binary -FilePath "$InstallDir\<File Path>" -Offset 0x00 -Data $bytes
|
Patch-Binary -FilePath "$InstallDirectory\<File Path>" -Offset 0x00 -Data $bytes
|
|
@ -1 +1 @@
|
||||||
Remove-Item "$InstallDir\<DirectoryPath>" -Recurse -ErrorAction Ignore
|
Remove-Item "$InstallDirectory\<DirectoryPath>" -Recurse -ErrorAction Ignore
|
|
@ -1 +1 @@
|
||||||
Rename-Item -Path "$InstallDir\<FilePath>" -NewName "$InstallDir\<NewName>"
|
Rename-Item -Path "$InstallDirectory\<FilePath>" -NewName "$InstallDirectory\<NewName>"
|
|
@ -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\<File Path>"
|
|
|
@ -1,2 +0,0 @@
|
||||||
# Takes an input byte[] and separates it with 0x00 between each character
|
|
||||||
$bytes = Separate-AsciiBytes -Data $bytes
|
|
|
@ -9,4 +9,4 @@
|
||||||
# WIN7RTM
|
# WIN7RTM
|
||||||
# WIN8RTM
|
# WIN8RTM
|
||||||
# See: https://ss64.com/nt/syntax-compatibility.html
|
# See: https://ss64.com/nt/syntax-compatibility.html
|
||||||
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" -Name "$InstallDir\<Executable>" -Value "~ WINXPSP2 HIGHDPIAWARE" -Force
|
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" -Name "$InstallDirectory\<Executable>" -Value "~ WINXPSP2 HIGHDPIAWARE" -Force
|
|
@ -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
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Trim a string down to a specified amount of characters
|
# Trim a string down to a specified amount of characters
|
||||||
if ($NewName.Length -gt 10) {
|
if ($NewPlayerAlias.Length -gt 10) {
|
||||||
$NewName = $NewName.Substring(0, 10);
|
$NewPlayerAlias = $NewPlayerAlias.Substring(0, 10);
|
||||||
}
|
}
|
|
@ -1,2 +1,2 @@
|
||||||
# Write contents of a string to a file
|
# Write contents of a string to a file
|
||||||
Set-Content "$InstallDir\<File Path>" "Hello world!"
|
Set-Content "$InstallDirectory\<File Path>" "Hello world!"
|
|
@ -0,0 +1,2 @@
|
||||||
|
# Bounds accessible via $Resolution.Height, $Resolution.Width
|
||||||
|
$Resolution = Convert-AspectRatio -Width 1280 -Height 800 -AspectRatio (4 / 3)
|
|
@ -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
|
|
@ -0,0 +1 @@
|
||||||
|
Edit-PatchBinary -FilePath "$InstallDirectory\<File Path>" -Offset 0x00 -Data $bytes
|
|
@ -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
|
|
|
@ -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
|
|
||||||
}
|
|
|
@ -0,0 +1 @@
|
||||||
|
$manifest = Get-GameManifest "C:\\Games\\<Game Directory>"
|
|
@ -0,0 +1,2 @@
|
||||||
|
# Bounds are accessible by $Resolution.Width and $Resolution.Height
|
||||||
|
$Resolution = Get-PrimaryDisplay
|
|
@ -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)
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
function Separate-AsciiBytes([byte[]]$Data)
|
|
||||||
{
|
|
||||||
$array = @()
|
|
||||||
|
|
||||||
foreach ($byte in $Data)
|
|
||||||
{
|
|
||||||
$array += $byte
|
|
||||||
$array += 0x00
|
|
||||||
}
|
|
||||||
|
|
||||||
return $array
|
|
||||||
}
|
|
|
@ -1,5 +1,2 @@
|
||||||
function Write-ReplaceContentInFile([string]$Regex, [string]$Replacement, [string]$FilePath)
|
# 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\<File Path>"
|
||||||
$content = (Get-Content $FilePath) -replace $Regex, $Replacement
|
|
||||||
[IO.File]::WriteAllLines($FilePath, $content)
|
|
||||||
}
|
|
|
@ -0,0 +1 @@
|
||||||
|
$AllocatedKey
|
|
@ -0,0 +1 @@
|
||||||
|
$DefaultInstallDirectory
|
|
@ -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
|
|
|
@ -0,0 +1 @@
|
||||||
|
$OldPlayerAlias
|
|
@ -0,0 +1 @@
|
||||||
|
$GameManifest
|
|
@ -1 +0,0 @@
|
||||||
$InstallDir = $PSScriptRoot
|
|
|
@ -0,0 +1 @@
|
||||||
|
$ServerAddress
|
Loading…
Reference in New Issue