@@ -2,16 +2,18 @@ class IconFile extends CopyableBuildFile {
22 requestMessage := " Select an icon file or an exe to extract the icon from"
33 selectFilter := " Icons (*.ico; *.exe; *.ocx; *.dll; *.cpl)"
44
5- __New (app, config, launcherDir, key, filePath := "", autoBuild := true ) {
5+ __New (app, config, launcherDir, key, filePath := "" ) {
66 sourcePath := config.HasKey (" iconSrc" ) ? config.iconSrc : ""
7- base.__New (app, config, launcherDir, key, " .ico" , filePath, autoBuild, sourcePath)
7+ base.__New (app, config, launcherDir, key, " .ico" , filePath, sourcePath)
88 }
99
1010 Cleanup () {
1111 base.Cleanup()
1212
1313 iconsDir := this.tempDir . " \icons"
1414 FileRemoveDir , %iconsDir%, true
15+
16+ return true
1517 }
1618
1719 Locate () {
@@ -21,7 +23,11 @@ class IconFile extends CopyableBuildFile {
2123 SplitPath , path,,, fileExt
2224
2325 if (fileExt ! = " ico" ) {
24- path := this.ExtractGameIcon(path)
26+ path := this.ExtractIcon(path)
27+
28+ if (path == "" ) {
29+ this.Locate()
30+ }
2531 }
2632 }
2733
@@ -30,36 +36,40 @@ class IconFile extends CopyableBuildFile {
3036
3137 ExtractIcon (path ) {
3238 iconsDir := this.tempDir . " \icons"
33- iconsCount := 0
39+
3440 iconFilePath := ""
41+ iconsExtPath := this.appDir . " \Vendor\IconsExt\iconsext.exe"
3542
3643 FileCreateDir , %iconsDir%
37- RunWait , %appDir%\Vendor\IconsExt\iconsext.exe / save " %path%" " %iconsDir%" - icons,, Hide
44+ RunWait , %iconsExtPath% / save " %path%" " %iconsDir%" - icons,, Hide
3845
46+ iconsCount := 0
3947 glob := iconsDir . " \*.ico"
4048 Loop , %glob% {
4149 iconsCount := A_Index
4250 iconFilePath := A_LoopFilePath
4351 }
4452
4553 if (iconsCount == 0 ) {
46- MsgBox , No icons count be extracted from %exeFile%.
47- this.Cleanup()
48- ExitApp , - 1
49- }
50-
51- if (iconsCount > 1 ) {
54+ MsgBox , No icons could be extracted from %exeFile%. Please try another file.
5255 iconFilePath := ""
53- FileSelectFile , iconFilePath,, %iconsDir%, Select the correct icon from the extracted files, Icons (* .ico)
56+ this.Cleanup()
57+ } else {
58+ if (iconsCount > 1 ) {
59+ iconFilePath := ""
60+ FileSelectFile , iconFilePath,, %iconsDir%, Select the correct icon from the extracted files, Icons (* .ico)
5461
55- if (iconFilePath == "" ) {
56- MsgBox , " Canceled icon selection."
57- this.Cleanup()
58- ExitApp , - 1
62+ if (iconFilePath == "" ) {
63+ MsgBox , " Canceled icon selection. Please try again ."
64+ this.Cleanup()
65+ }
5966 }
6067 }
6168
62- this.sourcePath := iconFilePath
63- return this.sourcePath
69+ if (iconFilePath ! = "" ) {
70+ this.sourcePath := iconFilePath
71+ }
72+
73+ return iconFilePath
6474 }
6575}
0 commit comments