@@ -42,7 +42,7 @@ let dirDialogOptions = {
42
42
properties : [ 'openDirectory' ]
43
43
}
44
44
45
- let fileDialogOptions = {
45
+ let imgDialogOptions = {
46
46
title : "Select your addon's icon" ,
47
47
buttonLabel : "Select icon" ,
48
48
filters :[
@@ -51,6 +51,16 @@ let fileDialogOptions = {
51
51
properties : [ 'openFile' ]
52
52
}
53
53
54
+ let fileDialogOptions = {
55
+ title : "Select your GMA file" ,
56
+ buttonLabel : "Select GMA" ,
57
+ filters :[
58
+ { name : 'Garry\'s Mod Addon File' , extensions : [ 'gma' ] }
59
+ ] ,
60
+ properties : [ 'openFile' ]
61
+ }
62
+
63
+
54
64
55
65
56
66
// Make links open in enternal browser
@@ -176,53 +186,91 @@ $(document).ready(() => {
176
186
dialog . showOpenDialog ( win , dirDialogOptions ) . then ( result => {
177
187
var filePath = result . filePaths [ 0 ]
178
188
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' ) ;
189
+ if ( filePath != null ) {
190
+ ipcRenderer . send ( 'checkIfDirectoryExists' , filePath + "\\bin\\gmad.exe" ) ;
191
+ ipcRenderer . send ( 'checkIfDirectoryExists' , filePath + "\\bin\\gmpublish.exe" ) ;
192
+ if ( desName == "GarrysMod" ) {
193
+ $ ( '#status_of_dir' ) . css ( 'color' , 'lightgreen' ) ;
194
+ $ ( '#status_of_dir' ) . text ( 'Found gmad.exe and gmpublish.exe!' ) ;
195
+ $ ( '#dir_prompt_next button' ) . css ( 'background-color' , '#56bd56' ) ;
196
+ $ ( '#dir_prompt_next button' ) . prop ( 'disabled' , false ) ;
197
+ $ ( '#dir_prompt_next button' ) . css ( 'cursor' , 'pointer' ) ;
198
+ $ ( '#checkmarkNote' ) . fadeIn ( ( ) => {
199
+ $ ( '#checkmarkNote' ) . delay ( 1000 ) . fadeOut ( ) ;
200
+ } )
201
+ settings . set ( 'gmodDirectory' , filePath ) ;
202
+ ipcRenderer . send ( 'getAddonInfo' ) ;
203
+ } else {
204
+ $ ( '#status_of_dir' ) . css ( 'color' , 'red' ) ;
205
+ $ ( '#status_of_dir' ) . text ( "Can't find gmad.exe or gmpublish.exe!" ) ;
206
+ console . log ( filePath ) ;
207
+ $ ( '#dir_prompt_next button' ) . prop ( 'disabled' , true ) ;
208
+ $ ( '#dir_prompt_next button' ) . css ( 'cursor' , 'not-allowed' ) ;
209
+ }
198
210
}
199
211
} ) . catch ( err => {
200
212
console . log ( "dialog error" )
201
213
} ) ;
202
- } )
214
+ } ) ;
215
+
216
+ $ ( "#gmaFileSelection" ) . click ( ( ) => {
217
+ dialog . showOpenDialog ( win , fileDialogOptions ) . then ( r => {
218
+ let addonGMA = r . filePaths [ 0 ] ;
219
+ addonPath = r . filePaths [ 0 ] ;
220
+ if ( addonGMA != null ) {
221
+ ipcRenderer . send ( 'checkIfDirectoryExists' , addonGMA ) ;
222
+ var n = addonGMA . lastIndexOf ( '\\' ) ;
223
+ var result = addonGMA . substring ( n + 1 , addonGMA . length ) ;
224
+ $ ( "#currentGMAFile" ) . text ( result ) ;
225
+ $ ( "#addon_extract_next button" ) . prop ( 'disabled' , false ) ;
226
+ $ ( '#addon_extract_next button' ) . css ( 'background-color' , '#56bd56' ) ;
227
+ $ ( '#addon_extract_next button' ) . css ( 'cursor' , 'pointer' ) ;
228
+ }
229
+ } ) . catch ( err => { } ) ;
230
+ } ) ;
231
+
232
+ $ ( "#addon_extract_next button" ) . click ( ( ) => {
233
+ $ ( "#extract_addon_select" ) . fadeOut ( ( ) => {
234
+ $ ( "#extracting_addon" ) . fadeIn ( ( ) => {
235
+ ipcRenderer . send ( 'extractAddon' , addonPath ) ;
236
+ } ) ;
237
+ } ) ;
238
+ } ) ;
239
+
240
+ ipcRenderer . on ( 'finishExtraction' , ( e ) => {
241
+ $ ( '#extracting_addon' ) . fadeOut ( ( ) => {
242
+ win . setBounds ( { height : 225 } )
243
+ // $('#extractedGMALocation').attr('href', 'steam://url/CommunityFilePage/' + newAddonID)
244
+ $ ( '#extraction_done' ) . fadeIn ( )
245
+ } ) ;
246
+ } ) ;
203
247
204
248
// If directory exists (and is writable/readable) allow user to procede
205
249
$ ( '#addon_dir_folder' ) . click ( ( ) => {
206
250
dialog . showOpenDialog ( win , dirDialogOptions ) . then ( result => {
207
251
if ( ! result . canceled ) {
208
252
currentNewAddon = result . filePaths [ 0 ] ;
209
- ipcRenderer . send ( 'checkIfDirectoryExists' , currentNewAddon ) ;
210
- var n = currentNewAddon . lastIndexOf ( '\\' ) ;
211
- var result = currentNewAddon . substring ( n + 1 ) ;
212
- $ ( '#addonDir b' ) . text ( result ) ;
213
- $ ( '#addonDirCheck' ) . css ( 'background-color' , '#56bd56' ) ;
214
- $ ( '#addonDirCheck' ) . prop ( 'disabled' , false ) ;
215
- $ ( '#addonDirCheck' ) . css ( 'cursor' , 'pointer' ) ;
253
+ if ( currentNewAddon != null ) {
254
+ ipcRenderer . send ( 'checkIfDirectoryExists' , currentNewAddon ) ;
255
+ var n = currentNewAddon . lastIndexOf ( '\\' ) ;
256
+ var result = currentNewAddon . substring ( n + 1 ) ;
257
+ $ ( '#addonDir b' ) . text ( result ) ;
258
+ $ ( '#addonDirCheck' ) . css ( 'background-color' , '#56bd56' ) ;
259
+ $ ( '#addonDirCheck' ) . prop ( 'disabled' , false ) ;
260
+ $ ( '#addonDirCheck' ) . css ( 'cursor' , 'pointer' ) ;
261
+ }
216
262
}
217
263
} ) . catch ( err => {
218
264
console . log ( "dialog error" )
219
265
} ) ;
220
266
} ) ;
221
267
222
268
$ ( '#addon_icon' ) . click ( ( ) => {
223
- dialog . showOpenDialog ( win , fileDialogOptions ) . then ( result => {
269
+ dialog . showOpenDialog ( win , imgDialogOptions ) . then ( result => {
224
270
addonIcon = result . filePaths [ 0 ] ;
225
- ipcRenderer . send ( 'checkIfDirectoryExists' , addonIcon ) ;
271
+ if ( addonIcon != null ) {
272
+ ipcRenderer . send ( 'checkIfDirectoryExists' , addonIcon ) ;
273
+ }
226
274
var jpegCheck = addonIcon . substring ( addonIcon . length - 4 ) ;
227
275
var sizeOf = require ( 'image-size' ) ;
228
276
var dimensions = sizeOf ( addonIcon ) ;
@@ -296,7 +344,7 @@ $(document).ready(() => {
296
344
} )
297
345
298
346
$ ( '.removeBackOption' ) . click ( ( ) => {
299
- // $('#back_button_addon_creation ').fadeOut();
347
+ // $('#extraction_back ').fadeOut();
300
348
} )
301
349
302
350
// General function for transitioning between div tags (with a shitty name)
0 commit comments