34
34
import tkFileDialog as filedialog
35
35
36
36
collapseWhiteSpaceRegex = re .compile (r"[\s\b]+" )
37
- def _TKAskGameExe (subMod ):
37
+ def _TKAskPath (subMod ):
38
38
# TODO: on 2.7 you can use .withdraw on the root window, but on python 3 it prevents the filedialog from showing!
39
39
# TODO: for now, put up with the root window showing when choosing path manually
40
40
root = Tk ()
@@ -46,8 +46,6 @@ def _TKAskGameExe(subMod):
46
46
47
47
# returns empty string if user didn't select any file or folder. If a file is selected, convert it to the parent folder
48
48
installFolder = filedialog .askopenfilename (filetypes = fileList )
49
- if os .path .isfile (installFolder ):
50
- installFolder = os .path .normpath (os .path .join (installFolder , os .pardir ))
51
49
52
50
root .destroy ()
53
51
@@ -271,12 +269,19 @@ def __init__(self, allSubModConfigs):
271
269
self .messageBuffer = []
272
270
self .threadHandle = None
273
271
274
- def try_start_install (self , subMod , installPath ):
272
+ # TODO: this function should return an error message describing why the install couldn't be started
273
+ def try_start_install (self , subMod , installPath , pathIsManual ):
275
274
import higurashiInstaller
276
275
import uminekoInstaller
277
276
import threading
278
277
279
- fullInstallConfigs = gameScanner .scanForFullInstallConfigs ([subMod ], possiblePaths = [installPath ])
278
+ # if the path was user selected, do some extra processing on the path
279
+ if pathIsManual :
280
+ fullInstallConfigs , errorMessage = gameScanner .scanUserSelectedPath ([subMod ], installPath )
281
+ print (errorMessage )
282
+ else :
283
+ fullInstallConfigs = gameScanner .scanForFullInstallConfigs ([subMod ], possiblePaths = [installPath ])
284
+
280
285
if not fullInstallConfigs :
281
286
return False
282
287
@@ -359,11 +364,14 @@ def getGamePathsHandler(requestData):
359
364
def startInstallHandler (requestData ):
360
365
id = requestData ['id' ]
361
366
subMod = self .idToSubMod [id ]
367
+ pathIsManual = False
362
368
installPath = requestData .get ('installPath' , None )
369
+
363
370
if installPath is None :
364
- installPath = _TKAskGameExe (subMod )
371
+ pathIsManual = True
372
+ installPath = _TKAskPath (subMod )
365
373
366
- return { 'installStarted' : self .try_start_install (subMod , installPath ) }
374
+ return { 'installStarted' : self .try_start_install (subMod , installPath , pathIsManual ) }
367
375
368
376
# requestData: Not necessary - will be ignored
369
377
# responseData: Returns a list of dictionaries. Each dictionary may have different fields depending on the
0 commit comments