@@ -42,6 +42,17 @@ let dirDialogOptions = {
42
42
properties : [ 'openDirectory' ]
43
43
}
44
44
45
+ let fileDialogOptions = {
46
+ title : "Select your addon's icon" ,
47
+ buttonLabel : "Select icon" ,
48
+ filters :[
49
+ { name : 'Image' , extensions : [ 'jpeg' , 'jpg' ] }
50
+ ] ,
51
+ properties : [ 'openFile' ]
52
+ }
53
+
54
+
55
+
45
56
// Make links open in enternal browser
46
57
$ ( document ) . on ( "click" , "a[href^='http']" , function ( event ) {
47
58
event . preventDefault ( ) ;
@@ -67,12 +78,33 @@ $(document).ready(() => {
67
78
dataType : "json"
68
79
} ) . done ( ( data ) => {
69
80
if ( data . tag_name != currentAppVersion ) {
70
- var open = confirm ( "Update " + data . tag_name + " available." ) ;
71
- if ( open ) {
72
- shell . openExternal ( "https://github.com/Leeous/gmod-addon-tool/releases" ) ;
73
- }
81
+ newUpdate ( data . tag_name ) ;
82
+ // var open = confirm("Update " + data.tag_name + " available.");
83
+ // if (open) {
84
+ // shell.openExternal("https://github.com/Leeous/gmod-addon-tool/releases");
85
+ // }
74
86
}
75
87
} )
88
+
89
+ function newUpdate ( ver ) {
90
+ if ( settings . get ( 'remindUpdate' ) == null || settings . get ( 'remindUpdate' ) ) {
91
+ dialog . showMessageBox ( win , {
92
+ type : "info" ,
93
+ buttons : [ 'Cancel' , 'Open' ] ,
94
+ message : "Update " + ver + " is available for download." ,
95
+ title : "New update available!" ,
96
+ checkboxLabel : "Don't remind me again" ,
97
+ } ) . then ( response => {
98
+ if ( response . response == 1 ) {
99
+ shell . openExternal ( "https://github.com/Leeous/gmod-addon-tool/releases" ) ;
100
+ }
101
+ if ( response . checkboxChecked ) {
102
+ console . log ( "Will no longer remind user about updates." )
103
+ settings . set ( 'remindUpdate' , false ) ;
104
+ }
105
+ } ) . catch ( err => { } ) ;
106
+ }
107
+ }
76
108
77
109
function getAddonInfoFromSteam ( message ) {
78
110
arrayOfAddonIds = message ;
@@ -128,37 +160,45 @@ $(document).ready(() => {
128
160
remote . getCurrentWindow ( ) . minimize ( ) ;
129
161
} )
130
162
131
- // Used to "fake click" the input[type="file"]
132
- $ ( '.fake_select' ) . click ( ( event ) => {
133
- var fakeButton = event . target ;
134
- var realButton = $ ( fakeButton ) . data ( 'buttonclick' ) ;
135
- $ ( realButton ) . click ( ) ;
163
+ $ ( '#helpApp' ) . click ( ( ) => {
164
+ alert ( 'no' )
136
165
} )
137
166
167
+ // Used to "fake click" the input[type="file"]
168
+ // $('.fake_select').click((event) => {
169
+ // var fakeButton = event.target;
170
+ // var realButton = $(fakeButton).data('buttonclick');
171
+ // $(realButton).click();
172
+ // })
173
+
138
174
// Validate that we have read/write access to the users Garrysmod directory so we can use gmad & gmpublish
139
- $ ( '#gmod_dir_folder' ) . change ( ( ) => {
140
- var filePath = document . getElementById ( "gmod_dir_folder" ) . files [ 0 ] . path ;
141
- var desName = filePath . substring ( filePath . length - 9 , filePath . length ) ;
142
- ipcRenderer . send ( 'checkIfDirectoryExists' , filePath + "\\bin\\gmad.exe" ) ;
143
- ipcRenderer . send ( 'checkIfDirectoryExists' , filePath + "\\bin\\gmpublish.exe" ) ;
144
- if ( desName == "GarrysMod" ) {
145
- $ ( '#status_of_dir' ) . css ( 'color' , 'lightgreen' ) ;
146
- $ ( '#status_of_dir' ) . text ( 'Found gmad.exe and gmpublish.exe!' ) ;
147
- $ ( '#dir_prompt_next button' ) . css ( 'background-color' , '#56bd56' ) ;
148
- $ ( '#dir_prompt_next button' ) . prop ( 'disabled' , false ) ;
149
- $ ( '#dir_prompt_next button' ) . css ( 'cursor' , 'pointer' ) ;
150
- $ ( '#checkmarkNote' ) . fadeIn ( ( ) => {
151
- $ ( '#checkmarkNote' ) . delay ( 1000 ) . fadeOut ( ) ;
152
- } )
153
- settings . set ( 'gmodDirectory' , filePath ) ;
154
- ipcRenderer . send ( 'getAddonInfo' ) ;
155
- } else {
156
- $ ( '#status_of_dir' ) . css ( 'color' , 'red' ) ;
157
- $ ( '#status_of_dir' ) . text ( "Can't find gmad.exe or gmpublish.exe!" ) ;
158
- console . log ( filePath ) ;
159
- $ ( '#dir_prompt_next button' ) . prop ( 'disabled' , true ) ;
160
- $ ( '#dir_prompt_next button' ) . css ( 'cursor' , 'not-allowed' ) ;
161
- }
175
+ $ ( '#gmod_dir_folder' ) . click ( ( ) => {
176
+ dialog . showOpenDialog ( win , dirDialogOptions ) . then ( result => {
177
+ var filePath = result . filePaths [ 0 ]
178
+ var desName = filePath . substring ( filePath . length - 9 , filePath . length ) ;
179
+ ipcRenderer . send ( 'checkIfDirectoryExists' , filePath + "\\bin\\gmad.exe" ) ;
180
+ ipcRenderer . send ( 'checkIfDirectoryExists' , filePath + "\\bin\\gmpublish.exe" ) ;
181
+ if ( desName == "GarrysMod" ) {
182
+ $ ( '#status_of_dir' ) . css ( 'color' , 'lightgreen' ) ;
183
+ $ ( '#status_of_dir' ) . text ( 'Found gmad.exe and gmpublish.exe!' ) ;
184
+ $ ( '#dir_prompt_next button' ) . css ( 'background-color' , '#56bd56' ) ;
185
+ $ ( '#dir_prompt_next button' ) . prop ( 'disabled' , false ) ;
186
+ $ ( '#dir_prompt_next button' ) . css ( 'cursor' , 'pointer' ) ;
187
+ $ ( '#checkmarkNote' ) . fadeIn ( ( ) => {
188
+ $ ( '#checkmarkNote' ) . delay ( 1000 ) . fadeOut ( ) ;
189
+ } )
190
+ settings . set ( 'gmodDirectory' , filePath ) ;
191
+ ipcRenderer . send ( 'getAddonInfo' ) ;
192
+ } else {
193
+ $ ( '#status_of_dir' ) . css ( 'color' , 'red' ) ;
194
+ $ ( '#status_of_dir' ) . text ( "Can't find gmad.exe or gmpublish.exe!" ) ;
195
+ console . log ( filePath ) ;
196
+ $ ( '#dir_prompt_next button' ) . prop ( 'disabled' , true ) ;
197
+ $ ( '#dir_prompt_next button' ) . css ( 'cursor' , 'not-allowed' ) ;
198
+ }
199
+ } ) . catch ( err => {
200
+ console . log ( "dialog error" )
201
+ } ) ;
162
202
} )
163
203
164
204
// If directory exists (and is writable/readable) allow user to procede
@@ -179,27 +219,30 @@ $(document).ready(() => {
179
219
} ) ;
180
220
} ) ;
181
221
182
- $ ( '#addon_icon' ) . change ( ( ) => {
183
- addonIcon = document . getElementById ( "addon_icon" ) . files [ 0 ] . path ;
184
- sizeIsOkay = true ;
185
- ipcRenderer . send ( 'checkIfDirectoryExists' , addonIcon ) ;
186
- var jpegCheck = addonIcon . substring ( addonIcon . length - 4 ) ;
187
- var sizeOf = require ( 'image-size' ) ;
188
- var dimensions = sizeOf ( addonIcon ) ;
189
- if ( jpegCheck == "jpeg" || jpegCheck == ".jpg" ) {
190
- if ( dimensions . height == 512 && dimensions . width == 512 ) {
191
- $ ( '#addonIconCheck' ) . css ( 'background-color' , '#56bd56' ) ;
192
- $ ( '#addonIconCheck' ) . prop ( 'disabled' , false ) ;
193
- $ ( '#addonIconCheck' ) . css ( 'cursor' , 'pointer' ) ;
222
+ $ ( '#addon_icon' ) . click ( ( ) => {
223
+ dialog . showOpenDialog ( win , fileDialogOptions ) . then ( result => {
224
+ addonIcon = result . filePaths [ 0 ] ;
225
+ ipcRenderer . send ( 'checkIfDirectoryExists' , addonIcon ) ;
226
+ var jpegCheck = addonIcon . substring ( addonIcon . length - 4 ) ;
227
+ var sizeOf = require ( 'image-size' ) ;
228
+ var dimensions = sizeOf ( addonIcon ) ;
229
+ if ( jpegCheck == "jpeg" || jpegCheck == ".jpg" ) {
230
+ if ( dimensions . height == 512 && dimensions . width == 512 ) {
231
+ $ ( '#addonIconCheck' ) . css ( 'background-color' , '#56bd56' ) ;
232
+ $ ( '#addonIconCheck' ) . prop ( 'disabled' , false ) ;
233
+ $ ( '#addonIconCheck' ) . css ( 'cursor' , 'pointer' ) ;
234
+ } else {
235
+ alert ( "Image must be 512x512." )
236
+ }
194
237
} else {
195
- alert ( "Image must be 512x512." )
238
+ $ ( '#addonIconCheck' ) . css ( 'background-color' , '#0f0f0f' ) ;
239
+ $ ( '#addonIconCheck' ) . prop ( 'disabled' , true ) ;
240
+ $ ( '#addonIconCheck' ) . css ( 'cursor' , 'not-allowed' ) ;
241
+ alert ( "Doesn't seem like a JPEG image." ) ;
196
242
}
197
- } else {
198
- $ ( '#addonIconCheck' ) . css ( 'background-color' , '#0f0f0f' ) ;
199
- $ ( '#addonIconCheck' ) . prop ( 'disabled' , true ) ;
200
- $ ( '#addonIconCheck' ) . css ( 'cursor' , 'not-allowed' ) ;
201
- alert ( "Doesn't seem like a JPEG image." ) ;
202
- }
243
+ } ) . catch ( err => {
244
+
245
+ } ) ;
203
246
} )
204
247
205
248
$ ( '#dir_prompt_next button' ) . click ( ( ) => {
0 commit comments