Skip to content

Instantly share code, notes, and snippets.

@chemputer
Created May 25, 2023 15:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chemputer/8b5be65c84c45925d65c20cc1f8a944e to your computer and use it in GitHub Desktop.
Save chemputer/8b5be65c84c45925d65c20cc1f8a944e to your computer and use it in GitHub Desktop.
A Powershell and Python3 script that creates PNG files for all of the maps in the game, and creates a ZIP file full of them.

Make PNG files of all the maps in the game as well as a ZIP file of all the maps

Setup Guide

Make sure that Python 3 is installed (I used 3.11, ymmv) and make sure to install Pillow via python3 -m pip install pillow Change the $root variable in the powershell file to the folder immediately above where your installation of World of Warships is. Make sure that wowsunpack.exe is in the World of Warships folder. You may already have it, but if not, it is available here. Here is a page about it and the GUI tool created for it: https://forum.worldofwarships.eu/topic/113847-all-wows-unpack-tool-unpack-game-client-resources/

Place the minimap.ps1 file and the imageOverlay.py file from this gist in your World of Warships folder.

Run the minimap.ps1 file. Look in the folder /World of Warships/res_unpack/ for the minimaps.zip file.

Success!

#!/usr/bin/python3
from PIL import Image
import sys
path = sys.argv[1]
layer1 = Image.open(str(path)+"\minimap_water.png").convert("RGBA")
layer2 = Image.open(str(path)+"\minimap.png").convert("RGBA")
final1 = Image.new("RGBA", layer1.size)
final1.paste(layer1, (0,0), layer1)
final1.paste(layer2, (0,0), layer2)
final1.save(str(path)+"\Complete_Minimap.png",format="PNG")
# change this to the folder directly above \World of Warships\
$root = "E:\Steam\steamapps\common\"
$items = Get-ChildItem -Path "$root\World of Warships\bin" -Directory -Exclude "clientrunner"
[int]$highestNumberTillNow = 0
$highestitem = ""
$secondHighest = ""
foreach ($item in $items){
[String]$test= $item.Name
[int]$number = $test
if ($number -gt $highestNumberTillNow){
$secondHighest = $highestNumberTillNow
$highestNumberTillNow = $number
$highestitem = $item
}
}
write-host $highestitem
$lastFolder = Split-Path $highestitem -Leaf
# for demo, just output the FullName property of the folders found
if (test-path "$root\World of Warships\bin\$lastFolder\res_mods\*"){
.\wowsunpack.exe -l -x bin\$lastFolder\idx -p ..\..\..\res_packages --include spaces/*.png -o res_unpack
}elseif( (test-path "$root\World of Warships\bin\$secondHighest\res_mods\*") -and (test-path "$root\World of Warships\bin\$secondHighest\idx")){
.\wowsunpack.exe -l -x bin\$secondHighest\idx -p ..\..\..\res_packages --include spaces/*.png -o res_unpack
} else {
throw 'There is not a folder that is in use (i.e. has mods in the mod folder and an idx folder) to use!'
}
Set-Location "$root\World of Warships\res_unpack"
foreach ($d in (get-childitem -Directory "$root\World of Warships\res_unpack\spaces")){
$n = $d.Name
$fd = "$root\World of Warships\res_unpack\Spaces\$n"
if(!(([string]$n -like '*dock*') -or ([string]$n -like '*shipyard*') -or ([string]$n -like '*Exterior*') -or -not (Test-Path $fd/Minimap.png))){ {
python3 imageOverlay.py $fd
$mmap = ".\Spaces\$n\Complete_Minimap.png"
if (Test-Path $mmap){
Copy-Item $mmap "$root\World of Warships\res_unpack\minimaps\$n.png"
Write-Host $n
}Else{
Write-Host "$n is missing"
}}}Else{
Write-Host "Skipping " $n
}
}
Get-ChildItem -Path "$root\World of Warships\res_unpack\minimaps" -Recurse | Compress-Archive -CompressionLevel Optimal -DestinationPath "$root\World of Warships\res_unpack\Minimaps.zip" -Force
Set-Location "$root\World of Warships\"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment