Skip to content

Commit cf07c55

Browse files
committed
added crazy autoit editor extraction scripts
1 parent 25b430e commit cf07c55

File tree

7 files changed

+204
-0
lines changed

7 files changed

+204
-0
lines changed

sc2editor/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Crazy AutoIT script that attempts to automatically render out a full idle animation of every unit in SC2 in the editor!
2+
3+
I've used this to create the animated gifs and also extracted frames from it for cooler/larger unit icons.
4+
5+
You'll need autoit/windows for it: http://www.autoitscript.com and change the script up a little, there are hardcoded paths in there and whatnot.
6+
7+
Then, if you have that running, you can use the shell/rb scripts to generate animated gifs/etc from the created videos.
8+

sc2editor/all.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
for k in videos/*y4m; do
4+
filename=$(basename "$k")
5+
extension="${filename##*.}"
6+
filename="${filename%.*}"
7+
8+
./to_seq.sh videos/$filename.y4m $filename
9+
done

sc2editor/generate_icon.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
echo "Generating final icons.."
2+
3+
unit=$(dirname "$1")
4+
filename=$(basename "$1")
5+
extension="${filename##*.}"
6+
filename="${filename%.*}"
7+
8+
# generate a 2 color "alpha map" of sorts
9+
convert $1 -blur 0x30 -unsharp 0x20 -colorspace Gray +dither -colors 2 -threshold 70% _$unit.png
10+
11+
# this was a try to just get the edges
12+
# convert test2.png -negate -morphology EdgeIn Diamond -negate test3.png
13+
# convert test2.png -morphology EdgeIn Diamond -negate test3.png
14+
15+
# autotrace the 2-color map to svg
16+
autotrace -output-format svg -output-file _tmp.svg -line-threshold 3 _$unit.png
17+
18+
# blur it back into an image
19+
#convert _tmp.svg -blur 5x4.5 _shadow.png
20+
convert _tmp.svg -blur 5x10.5 _shadow.png
21+
22+
# use it as a "drop shadow"
23+
convert _shadow.png $1 -resize 76x76 -compose over -composite -gravity center -extent 76x76 -fill transparent +repage final/$unit.png
24+
25+
rm _tmp.svg
26+
rm _shadow.png
27+
rm _$unit.png

sc2editor/sc2.au3

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
; prep before running this:
2+
; also: rebind rotate model keys to , and . (left, right)
3+
; also: set viewport to "Portrait" in scene editor
4+
5+
; window configuration before launch:
6+
; - messages window closed (ctrl+shift+m)
7+
; - cutscene editor panes shown (f11)
8+
9+
; need to use 32bit, because the editor is a 32bit process..
10+
#AutoIt3Wrapper_UseX64=n
11+
12+
Opt("WinTitleMatchMode", 4) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
13+
Opt("MouseCoordMode", 0)
14+
Opt("PixelCoordMode", 0)
15+
16+
$title_terrain = "[REGEXPTITLE:Terrain.*StarCraft II Editor]"
17+
$title_data = "[REGEXPTITLE:Data.*StarCraft II Editor]"
18+
$title_cseditor = "[REGEXPTITLE:Cutscene Editor.*StarCraft II Editor]"
19+
20+
; Run("e:\sc2\StarCraft\ II\ Editor.exe")
21+
WinActivate($title_terrain)
22+
WinWaitActive($title_terrain)
23+
24+
; activate messages window
25+
Send("^+m")
26+
; then hide it away
27+
WinActivate($title_terrain)
28+
WinWaitActive($title_terrain)
29+
30+
Dim $i
31+
;Dim $units = StringSplit("Zergling,Baneling,Banshee", ",")
32+
;Dim $units = StringSplit("Probe,Zealot,Stalker,Sentry,Observer,Immortal,Colossus,Phoenix,Carrier,Mothership", ",")
33+
Dim $units = StringSplit("Archon,Carrier,Colossus,Dark Templar,High Templar,Immortal,Interceptor,Mothership,Observer,Phoenix,Probe,Sentry,Stalker,Void Ray,Warp Prism (Transport Mode),Zealot", ",")
34+
Dim $unit_count = UBound($units)
35+
36+
For $i = 1 to $unit_count - 1
37+
; open data
38+
Send("{F7}")
39+
WinWaitActive($title_data)
40+
41+
; open search
42+
; Send("^f")
43+
; WinWaitActive("Find")
44+
45+
; nope.. click the search inside the control instead
46+
; ControlSetText($title_data, "", "[ID:18]", $units[$i])
47+
; ControlFocus($title_data, "", "[ID:18]")
48+
; Send("{ENTER}")
49+
50+
; Oh god, I don't even have to use the search..
51+
ControlFocus($title_data, "", "[ID:1023]")
52+
ControlListView($title_data, "", "[ID:1023]", "SelectClear")
53+
$idx = ControlListView($title_data, "", "[ID:1023]", "FindItem", $units[$i], 0)
54+
ControlListView($title_data, "", "[ID:1023]", "Select", $idx)
55+
56+
; activate the list and press POS1 then Ctrl+P because I can't be arsed
57+
; to read the docs on how to control the list.
58+
; ControlFocus($title_data, "", "[ID:1023]")
59+
; Send("{HOME}")
60+
Send("^p")
61+
62+
; wait for cutscene editor to open
63+
Local $hWnd = WinWaitActive($title_cseditor)
64+
65+
; send shift+f, zoom to fit
66+
Send("+f")
67+
Sleep(50)
68+
; send ] to rotate 45° to the right
69+
Send(".")
70+
Sleep(50)
71+
72+
; then, crazy stuff.. right click on the animation element
73+
; and select "reset animation duration", because we can't fucking assign
74+
; a hotkey to that that works.
75+
; ControlClick($title_cseditor, "", "[ID:66]", "menu", 1, 100, 1)
76+
; n/m, shift+f10 does the trick ("menu key") .. holy shit, this is a fickle bitch
77+
; ControlFocus($title_cseditor, "", "[ID:66]")
78+
; ControlClick($title_cseditor, "", "[ID:66]", "left", 1, 5, 5)
79+
; Now ..I don't know ..color matching I guess
80+
81+
;MsgBox(0, "", PixelGetColor(948, 683))
82+
;Exit
83+
84+
;$pos = PixelSearch(200, 200, 1000, 1000, 6724095, 20, 2, $hWnd)
85+
;MsgBox(0, "", $pos[0] & $pos[1])
86+
;MouseClick("menu", $pos[0], $pos[1], 1)
87+
88+
ControlClick($title_cseditor, "", "[ID:66]", "right", 1, 200, 25)
89+
Sleep(50)
90+
Send("{DOWN}")
91+
Sleep(50)
92+
Send("{DOWN}")
93+
Sleep(50)
94+
Send("{ENTER}")
95+
Sleep(50)
96+
97+
; send f11 for huge view (hide all panes)
98+
Send("{F11}")
99+
Sleep(50)
100+
101+
; send alt+f11 then enter to record video
102+
Send("!{F11}")
103+
WinWaitActive("Record New Video")
104+
;ControlSend("Record New Video", "", "[ID:20]", "{SPACE}")
105+
106+
;Exit
107+
108+
Send("{ENTER}")
109+
; Sleep(100) ; no idea why, pressing enter immediately won't work
110+
; ControlClick("Record New Video", "", "[CLASS:Button; INSTANCE:5]")
111+
112+
; ControlFocus($title, "Search", "[CLASS:SysTabControl32; INSTANCE:3]")
113+
; sleep 10 seconds.. is there any animation that runs longer?
114+
Sleep(10000)
115+
116+
; f11 again to reactivate all panes
117+
Send("{F11}")
118+
FileCopy("c:\\Users\\mr\\Documents\\StarCraft II\\Videos\\Video.y4m", "f:\\_v\\" & $units[$i] & ".y4m")
119+
Next
120+
121+
; hide messages again once we're done
122+
Send("^+m")
123+
124+
MsgBox(0, "", "done!")

sc2editor/to_seq.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
mkdir -p $2
3+
ffmpeg -i $1 -r 10 -an -f image2 -pix_fmt rgba "$2/%05d.png"
4+
cd $2
5+
# removes transparent color and produces transparent png
6+
../trans_png.sh
7+
# converts nicely into smaller transparent gif
8+
../trans_gif.sh
9+
cd ..
10+
# ffmpeg -i "$2/%05d.png" -an -f image2 -pix_fmt rgba $2.gif
11+
12+
# make an animated gif!
13+
gifsicle --delay 1 --optimize --loop --colors 256 --crop-transparency -D 2 $2/tr*gif > final/$2.gif
14+
15+
# and create the "icons" from the first still
16+
./generate_icon.sh "$2/tr_00001.png"

sc2editor/trans_gif.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
rm *diff*
4+
5+
for k in tr_*.png; do
6+
k="${k%.*}"
7+
echo "k: $k"
8+
convert $k.png -resize 76x76 -gravity center -extent 76x76 -fill transparent -unsharp 0x1 +repage $k.gif
9+
#convert $k.png -resize 150x -unsharp 0x1 $k.gif
10+
done

sc2editor/trans_png.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
rm *diff*
4+
5+
for k in *.png; do
6+
#k="${k%.*}"
7+
echo "k: $k"
8+
#convert $k -fuzz 10% -transparent "#28667D" -gravity Center -crop 90%x90%+0+0 tr_$k
9+
convert $k -fuzz 10% -transparent "#4CAFD2" -gravity Center -crop 90%x90%+0+0 -trim +repage tr_$k
10+
done

0 commit comments

Comments
 (0)