Ref:
https://github.com/peace-and-protection/Peace-and-Protection/issues/52Hello!
I've done some experiments and my preliminary findings with automating the conversion from
option dbu to
option map in the peace and protection script are great!
Basically I'm iterating over all the remote script files, finding the dialog declarations and changing:
1. option dbu to option map;
2. change size -1 -1 w h to new values of w and h, where w gets multiplied by 1.336 and h by 1.228571;
3. change x y w h for all elements to new values, where x and w get multiplied by 1.336 and y and h get multiplied by 1.228571
I've download the new PowerShell (7.3.4) from here
https://github.com/PowerShell/PowerShell/releases/tag/v7.3.4(The one-liner doesn't work on ps5 that comes with windows 10)
For Peace and Protection users:
I open up a PowerShell 7 prompt and navigate to %appdata% :
Change directory to mIRC\script:
Run the following ps7 one-liner:
gci -Name *.mrc -Exclude alias* | % { (gc $_ -Raw) -ireplace '(?s)(?<all>dialog(?: -l)? \S+ \{.*?\})', {return $($_.Groups['all'].Value) -ireplace 'option dbu', 'option map' -replace '(?<one>\d+) (?<two>\d+) (?<three>\d+) (?<four>\d+)', {return $([string][System.Math]::Floor([int]$_.Groups['one'].Value*1.336) + " " + [System.Math]::Floor([int]$_.Groups['two'].Value*1.228571) + " " + [System.Math]::Floor([int]$_.Groups['three'].Value*1.336) + " " + [System.Math]::Floor([int]$_.Groups['four'].Value*1.228571))} -ireplace 'size -1 -1 (?<width>\d+) (?<height>\d+)', {return $([string]"size -1 -1 " + [System.Math]::Floor([int]$_.Groups['width'].Value*1.336) + " " + [System.Math]::Floor([int]$_.Groups['height'].Value*1.228571))} } | Out-File $_ }
If you have trouble copying the code, I posted this snippet in an issue on our GitHub repo
here and it has a copy button in the code block!
This snippet can hopefully be used - with some modification - to convert other scripts as well. If you want to reach out for help with the PowerShell one-liner, you can find me on Ouims' super #mircscripting channel on SwiftIRC!
Cheers!