mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Feb 2015
Posts: 138
kap Offline OP
Vogon poet
OP Offline
Vogon poet
Joined: Feb 2015
Posts: 138
Ref: https://github.com/peace-and-protection/Peace-and-Protection/issues/52

Hello!

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% :
Code
cd $env:APPDATA
Change directory to mIRC\script:
Code
cd mIRC\script
Run the following ps7 one-liner:
Code
 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!


GNU Terry Pratchett - Looking for a mIRC help channel -> Check #mircscripting @ irc.swiftirc.net
Joined: Feb 2015
Posts: 138
kap Offline OP
Vogon poet
OP Offline
Vogon poet
Joined: Feb 2015
Posts: 138
Click on the Ref link for the github issue in order to get the latest PS one-liner to make PnP 4.22.9 use option map!


GNU Terry Pratchett - Looking for a mIRC help channel -> Check #mircscripting @ irc.swiftirc.net
Joined: Feb 2023
Posts: 47
Ameglian cow
Offline
Ameglian cow
Joined: Feb 2023
Posts: 47
Hello kap!

for some reason after the last Windows 11 update to build 25982 all my dialogs "shrank" and I had to migrate from option dbu to option map.

I used your ps7 script and it worked just fine. I just changed both multipliers to *1.1 because 1.336 and 1.228571 made the dialogs far too big.

Multiplying by 1.1 worked perfectly fine for me.

Thank you for sharing this script! 😽


Link Copied to Clipboard