-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSoulsOufitManager.py
753 lines (633 loc) · 28.8 KB
/
SoulsOufitManager.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
import tkinter as tk
from tkinter import filedialog
from tkinter import messagebox
import os
import json
import shutil
import time
from ChecklistBox import ScrollableChecklist
from DS3ModelMaskPatcher import DS3ModelMaskPatcher
from DS3PartInfo import DS3PartInfo
from DS3PartUtil import DS3PartUtil
from DS3PartUtil import EquipModelCategory
from DS3PartUtil import EquipModelGender
from DS3PartListbox import DS3PartListbox
class SoulsOutfitManager:
"""Main class of SoulsOutfitManager"""
supportedGameEXENames = [
'DarkSoulsIII.exe',
]
programDataFileName = 'SoulsOutfitManager_Data.json'
partNamesFileName = 'part_names.json'
assetsDirectory = 'assets'
modsDirectory = 'mods'
def __init__(self):
self.__ds3PartUtil = None
self.__window = None
self.__gameDirectory = ''
self.__moddedParts = []
self.__gameParts = {}
self.__replacedParts = []
self.__widgets = {}
self.__selectedModdedPart = None
self.__modelMaskPresets = {}
self.__modelMaskPatchedParts = {}
self.__wasLastAttachedToDS3 = False
def __getSelectedModdedPart(self):
return self.__selectedModdedPart
def __selectModdedPart(self, __selectedModdedPart):
self.__selectedModdedPart = __selectedModdedPart
def __getModelMaskPresetFile(self, part):
return part.getEquipModelCategory() + '_' + str(part.getEquipModelId()) + '.modelmaskpreset.json'
def __loadDS3PartUtil(self):
self.__ds3PartUtil = DS3PartUtil(SoulsOutfitManager.assetsDirectory + os.path.sep + SoulsOutfitManager.partNamesFileName)
def __initUI(self):
self.__window = tk.Tk()
self.__window.configure(bg='#1e1e1e')
self.__window.geometry('1300x550')
self.__window.title('SoulsOutfitManager')
self.__window.iconbitmap('assets' + os.path.sep + 'gundyr_chest.ico')
self.gameDirVariable = tk.StringVar()
self.__widgets['game_dir_browse_button'] = tk.Button(
self.__window,
bg='#333333',
fg='#c3c3c3',
text='Browse',
width=8,
height=1,
relief=tk.RAISED,
command=SoulsOutfitManager.openBrowseForGameDirectory)
self.__widgets['game_dir_browse_button'].grid(
row=0,
column=0,
padx=5,
pady=5)
self.__widgets['game_dir_entry'] = tk.Entry(
self.__window,
bg='#333333',
fg='#c3c3c3',
width=100)
self.__widgets['game_dir_entry'].grid(
row=0,
column=1,
columnspan=4,
padx=5,
pady=5)
self.__widgets['modded_part_list_label'] = tk.Label(
self.__window,
bg='#333333',
fg='#c3c3c3',
text='Your Prepared Mods',
relief=tk.RIDGE,
padx=3,
pady=3)
self.__widgets['modded_part_list_label'].grid(
row=1,
column=0,
padx=1,
pady=5)
self.__widgets['modded_part_list_search_box'] = tk.Entry(
self.__window,
bg='#333333',
fg='#c3c3c3',
width=50)
self.__widgets['modded_part_list_search_box'].grid(
row=2,
column=0,
padx=5,
pady=0)
self.__widgets['modded_part_list_search_box'].bind('<KeyRelease>',
SoulsOutfitManager.moddedPartsSearchUpdate)
self.__widgets['modded_part_list'] = DS3PartListbox(
self.__window,
bg='#333333',
fg='#c3c3c3',
width=50,
height=25,
relief=tk.SUNKEN,
bd=5)
self.__widgets['modded_part_list'].grid(
row=3,
column=0,
padx=5,
pady=5)
self.__widgets['modded_part_list'].bind('<<ListboxSelect>>',
SoulsOutfitManager.selectModdedPart)
self.__widgets['game_part_list_label'] = tk.Label(
self.__window,
bg='#333333',
fg='#c3c3c3',
text='Parts in your Game',
relief=tk.RIDGE,
padx=3,
pady=3)
self.__widgets['game_part_list_label'].grid(
row=1,
column=1,
padx=5,
pady=5)
self.__widgets['game_part_list_search_box'] = tk.Entry(
self.__window,
bg='#333333',
fg='#c3c3c3',
width=50)
self.__widgets['game_part_list_search_box'].grid(
row=2,
column=1,
padx=5,
pady=0)
self.__widgets['game_part_list_search_box'].bind('<KeyRelease>',
SoulsOutfitManager.gamePartsSearchUpdate)
self.__widgets['game_part_list'] = DS3PartListbox(
self.__window,
bg='#333333',
fg='#c3c3c3',
width=50,
height=25,
relief=tk.SUNKEN,
bd=3)
self.__widgets['game_part_list'].grid(
row=3,
column=1,
padx=5,
pady=5)
self.__widgets['game_part_list'].bind('<Double-Button-1>',
SoulsOutfitManager.tryReplaceGamePart)
self.__widgets['game_part_list'].bind('<Delete>',
SoulsOutfitManager.tryDeleteGamePart)
self.__widgets['replaced_part_list_label'] = tk.Label(
self.__window,
bg='#333333',
fg='#c3c3c3',
text='Installed Modded Parts',
relief=tk.RIDGE,
padx=3,
pady=3)
self.__widgets['replaced_part_list_label'].grid(
row=1,
column=2,
padx=5,
pady=5)
self.__widgets['replaced_part_list_search_box'] = tk.Entry(
self.__window,
bg='#333333',
fg='#c3c3c3',
width=50)
self.__widgets['replaced_part_list_search_box'].grid(
row=2,
column=2,
padx=5,
pady=0)
self.__widgets['replaced_part_list_search_box'].bind('<KeyRelease>',
SoulsOutfitManager.replacedPartsSearchUpdate)
self.__widgets['replaced_part_list'] = DS3PartListbox(
self.__window,
bg='#333333',
fg='#c3c3c3',
width=50,
height=25,
relief=tk.SUNKEN,
bd=3)
self.__widgets['replaced_part_list'].grid(
row=3,
column=2,
padx=5,
pady=5)
self.__widgets['replaced_part_list'].bind('<BackSpace>',
SoulsOutfitManager.tryRestorePart)
self.__widgets['replaced_part_list'].bind('<<ListboxSelect>>',
SoulsOutfitManager.tryOpenModelMaskEditor)
self.__widgets['refresh_button'] = tk.Button(
self.__window,
bg='#333333',
fg='#c3c3c3',
text='Refresh Files',
width=14,
height=1,
relief=tk.RAISED,
command=SoulsOutfitManager.refresh)
self.__widgets['refresh_button'].grid(
row=0,
column=4,
padx=5,
pady=5,
sticky='W')
self.__widgets['model_mask_save_button'] = tk.Button(
self.__window,
bg='#333333',
fg='#c3c3c3',
text='Save Model\nMask Changes',
width=16,
height=2,
relief=tk.RAISED,
command=SoulsOutfitManager.saveModelMaskChanges)
self.__widgets['model_mask_save_button'].grid(
row=1,
column=4,
padx=5,
pady=5,
sticky='W')
self.__widgets['model_mask_editor_label'] = tk.Label(
self.__window,
bg='#333333',
fg='#c3c3c3',
text='Edit Model Masks',
relief=tk.RIDGE,
padx=3,
pady=3)
self.__widgets['model_mask_editor_label'].grid(
row=2,
column=3,
padx=5,
pady=5)
self.__widgets['model_mask_editor'] = ScrollableChecklist(
self.__window,
bg='#333333',
width=150,
height=410,
relief=tk.SUNKEN,
bd=3)
self.__widgets['model_mask_editor'].grid(
row=3,
column=3,
padx=5,
pady=5)
def __tryLoadProgramData(self):
try:
return json.load(open(SoulsOutfitManager.programDataFileName))
except FileNotFoundError as error:
json.dump({}, open(SoulsOutfitManager.programDataFileName, 'w'))
try:
return json.load(open(SoulsOutfitManager.programDataFileName))
except FileNotFoundError as error:
print(error)
messagebox.showerror('SoulsOutfitManager Python Error', str(error)
+ '\n\nUnable to create program data file.')
exit()
def __saveProgramData(self, programData):
json.dump(programData, open(SoulsOutfitManager.programDataFileName, 'w'))
def __loadPartLists(self):
self.__moddedParts = []
self.__gameParts = []
self.__replacedParts = []
gameDirectory = soulsOutfitManager_global.getWidgets()['game_dir_entry'].get()
if os.path.isdir(gameDirectory) and os.path.isdir(gameDirectory + os.path.sep + 'parts'):
partsDir = gameDirectory + os.path.sep + 'parts'
for entry in os.scandir(partsDir):
if not entry.is_file() or len(os.path.splitext(entry.name)) != 2:
continue
elif os.path.splitext(entry.name)[1] == '.dcx':
self.__gameParts.append(DS3PartInfo(self.__ds3PartUtil, partsDir, entry.name))
elif os.path.splitext(entry.name)[1] == '.sombak':
part = DS3PartInfo(self.__ds3PartUtil, partsDir, entry.name)
self.__replacedParts.append(part)
self.__loadModelMaskPresetFile(part)
if os.path.isdir(SoulsOutfitManager.modsDirectory):
for entry in os.scandir(SoulsOutfitManager.modsDirectory):
if not entry.is_file() or len(os.path.splitext(entry.name)) != 2 or not os.path.splitext(entry.name)[1] == '.dcx':
continue
self.__moddedParts.append(DS3PartInfo(self.__ds3PartUtil, SoulsOutfitManager.modsDirectory, entry.name))
def __updateUIModdedPartList(self):
self.__widgets['modded_part_list'].delete(0, self.__widgets['modded_part_list'].size())
searchTerm = self.__widgets['modded_part_list_search_box'].get()
for moddedPart in self.__moddedParts:
partFile = os.path.splitext(moddedPart.getPartFile())[0]
if searchTerm == '' or searchTerm.lower() in partFile.lower():
self.__widgets['modded_part_list'].insert(0, partFile, moddedPart)
def __updateUIGamePartList(self):
self.__widgets['game_part_list'].delete(0, self.__widgets['game_part_list'].size())
searchTerm = self.__widgets['game_part_list_search_box'].get()
replacedPartFiles = []
for replacedPart in self.__replacedParts:
replacedPartFiles.append(replacedPart.getPartFile())
for gamePart in self.__gameParts:
if gamePart.getPartFile() + '.sombak' in replacedPartFiles:
continue
partName = gamePart.getPartName()
if partName != 'Unknown' and (searchTerm == '' or searchTerm.lower() in partName.lower()):
self.__widgets['game_part_list'].insert(0, partName, gamePart)
def __updateUIReplacedPartList(self):
self.__widgets['replaced_part_list'].delete(0, self.__widgets['replaced_part_list'].size())
searchTerm = soulsOutfitManager_global.__widgets['replaced_part_list_search_box'].get()
for replacedPart in self.__replacedParts:
partName = replacedPart.getPartName()
if partName != 'Unknown' and (searchTerm == '' or searchTerm.lower() in partName.lower()):
self.__widgets['replaced_part_list'].insert(0, partName, replacedPart)
def __replaceGamePart(self, moddedPart, gamePart):
gameDirectory = soulsOutfitManager_global.__widgets['game_dir_entry'].get()
moddedPartPath = moddedPart.getDirectory() + os.path.sep + moddedPart.getPartFile()
gamePartPath = gamePart.getDirectory() + os.path.sep + gamePart.getPartFile()
if not os.path.isfile(moddedPartPath):
messagebox.showerror('SoulsOutfitManager Python Error',
'Unable to replace game part with modded part: \n\n'
+ 'File \"'
+ moddedPart
+ '\" does not exist.\n\n'
+ 'You may have deleted or moved the file. Please refresh.')
return
if not os.path.isfile(gamePartPath):
messagebox.showerror('SoulsOutfitManager Python Error',
'Unable to replace game part with modded part: \n\n'
+ 'File \"'
+ gamePart
+ '\" does not exist.\n\n'
+ 'You may have deleted or moved the file. Please refresh.')
return
try:
shutil.copyfile(gamePartPath,
gamePartPath + '.sombak')
shutil.copyfile(moddedPartPath,
gamePartPath)
except FileNotFoundError as error:
print(error)
messagebox.showerror('SoulsOutfitManager Python Error',
str(error)
+ '\n\nUnable to replace game part with modded part. \n\n'
+ 'You may have deleted or moved the files. Please refresh.')
return
self.__loadPartLists()
self.__updateUIModdedPartList()
self.__updateUIReplacedPartList()
self.__updateUIGamePartList()
def __deleteGamePart(self, gamePart):
gameDirectory = soulsOutfitManager_global.__widgets['game_dir_entry'].get()
gamePartPath = gamePart.getDirectory() + os.path.sep + gamePart.getPartFile()
if not os.path.isfile(gamePartPath):
messagebox.showerror('SoulsOutfitManager Python Error',
+ 'Unable to delete game part. \n\n'
+ 'You may have deleted or moved the file. Please refresh.')
return
try:
if not os.path.isfile(gamePartPath + '.sombak'):
os.rename(gamePartPath,
gamePartPath + '.sombak')
except FileNotFoundError as error:
print(error)
messagebox.showerror('SoulsOutfitManager Python Error',
str(error)
+ '\n\nUnable to delete game part. \n\n'
+ 'You may have deleted or moved the file. Please refresh.')
return
self.__loadPartLists()
self.__updateUIModdedPartList()
self.__updateUIReplacedPartList()
self.__updateUIGamePartList()
def __restoreReplacedPart(self, replacedPart):
gameDirectory = soulsOutfitManager_global.__widgets['game_dir_entry'].get()
replacedPartBackupPath = replacedPart.getDirectory() + os.path.sep + replacedPart.getPartFile()
replacedPartPath = replacedPartBackupPath[:-7]
if not os.path.isfile(replacedPartBackupPath):
messagebox.showerror('SoulsOutfitManager Python Error',
'Unable to restore part \"'
+ replacedPart.getPartFile()
+ '\"\n\nYou may have deleted or moved the file. Please refresh.')
return
try:
if os.path.isfile(replacedPartPath):
os.remove(replacedPartPath)
os.rename(replacedPartBackupPath,
replacedPartPath)
except FileNotFoundError as error:
print(error)
messagebox.showerror('SoulsOutfitManager Python Error',
'Unable to restore part \"'
+ replacedPart.getPartFile()
+ '\"\n\nYou may have deleted or moved the file. Please refresh.')
return
self.__loadPartLists()
self.__updateUIModdedPartList()
self.__updateUIReplacedPartList()
self.__updateUIGamePartList()
def __applyModelMaskPresetToGame(self, part, preset):
presetFile = os.path.splitext(self.__getModelMaskPresetFile(part))[0]
if not presetFile.endswith('.modelmaskpreset'):
return
split = presetFile.split('.')
if not len(split) == 2:
return
equipInfoSplit = split[0].split('_')
if not len(equipInfoSplit) == 2:
return
self.__modelMaskPatchedParts[part.getPartFile()] = True
bodyPart = equipInfoSplit[0]
modelId = int(equipInfoSplit[1])
for offset in preset:
paramId = modelMaskPatcher.getParamIdByEquipModelIdAndEquipModelCategory(modelId, bodyPart)
modelMaskPatcher.writeModelMask(paramId, int(offset), int(preset[offset]['hidden']))
def __createModelMaskPresetFile(self, part):
if not os.path.isdir(SoulsOutfitManager.modsDirectory):
return
template = json.load(open(SoulsOutfitManager.assetsDirectory + os.path.sep + 'template.modelmaskpreset.json'))
preset = {}
paramId = modelMaskPatcher.getParamIdByEquipModelIdAndEquipModelCategory(part.getEquipModelId(), part.getEquipModelCategory())
for i in range(97):
maskElement = { 'description' : '', 'hidden' : False }
if str(i) in template:
maskElement['description'] = 'Hide ' + template[str(i)]['description']
else:
maskElement['description'] = 'Hide ' + str(i)
maskElement['hidden'] = modelMaskPatcher.readModelMask(paramId, i)
preset[str(i)] = maskElement
with open(SoulsOutfitManager.modsDirectory + os.path.sep + self.__getModelMaskPresetFile(part), 'w') as file:
json.dump(preset, file, ensure_ascii=False, indent=2)
def __saveModelMaskPreset(self, part):
if not os.path.isdir(SoulsOutfitManager.modsDirectory):
return
template = json.load(open(SoulsOutfitManager.assetsDirectory + os.path.sep + 'template.modelmaskpreset.json'))
preset = {}
paramId = modelMaskPatcher.getParamIdByEquipModelIdAndEquipModelCategory(part.getEquipModelId(), part.getEquipModelCategory())
presetFile = self.__getModelMaskPresetFile(part)
with open(SoulsOutfitManager.modsDirectory + os.path.sep + presetFile, 'w') as file:
json.dump(self.__modelMaskPresets[part.getPartFile()], file, ensure_ascii=False, indent=2)
def __registerModelMaskPresetEdit(self, part, items):
self.__modelMaskPatchedParts[part.getPartFile()] = False
for i in range(97):
if int(items[i]) == 1:
self.__modelMaskPresets[part.getPartFile()][str(i)]['hidden'] = True
else:
self.__modelMaskPresets[part.getPartFile()][str(i)]['hidden'] = False
def __loadModelMaskPresetFile(self, part):
presetPath = SoulsOutfitManager.modsDirectory + os.path.sep + self.__getModelMaskPresetFile(part)
if not os.path.isfile(presetPath):
return
preset = json.load(open(presetPath))
self.__modelMaskPresets[part.getPartFile()] = preset
def __loadPresetIntoModelMaksEditorUI(self, preset):
self.__widgets['model_mask_editor'].setItems(preset, SoulsOutfitManager.tryUpdateModelMaskPreset)
def __emptyModelMasksEditorUI(self):
self.__widgets['model_mask_editor'].setItems({}, SoulsOutfitManager.tryUpdateModelMaskPreset)
def __tryLoadModelMaskPresetIntoEditor(self, part):
equipModelCategory = part.getEquipModelCategory()
if equipModelCategory == EquipModelCategory.WEAPON.value:
self.__emptyModelMasksEditorUI()
return
if modelMaskPatcher.isAttached() and modelMaskPatcher.isParamsDefined() and not os.path.isfile(SoulsOutfitManager.modsDirectory
+ os.path.sep
+ self.__getModelMaskPresetFile(part)):
self.__createModelMaskPresetFile(part)
self.__loadModelMaskPresetFile(part)
if part.getPartFile() in self.__modelMaskPresets:
preset = self.__modelMaskPresets[part.getPartFile()]
self.__loadPresetIntoModelMaksEditorUI(preset)
else:
self.__emptyModelMasksEditorUI()
def start(self):
self.__loadDS3PartUtil()
self.__initUI()
programDataFile = self.__tryLoadProgramData()
if 'gameDirectory' in programDataFile and any(os.path.isfile(programDataFile['gameDirectory'] + os.path.sep + EXEName) for EXEName in SoulsOutfitManager.supportedGameEXENames):
currentText = self.__widgets['game_dir_entry'].get()
self.__widgets['game_dir_entry'].delete(0, len(currentText))
self.__widgets['game_dir_entry'].insert(0, programDataFile['gameDirectory'])
self.__loadPartLists()
self.__updateUIModdedPartList()
self.__updateUIReplacedPartList()
self.__updateUIGamePartList()
self.__window.after(0, SoulsOutfitManager.ds3PatchLoop)
self.__window.mainloop()
def getWidgets(self):
return self.__widgets
@staticmethod
def selectModdedPart(event):
selection = soulsOutfitManager_global.getWidgets()['modded_part_list'].curselection()
part = None
if len(selection) == 1:
part = soulsOutfitManager_global.getWidgets()['modded_part_list'].getDS3PartInfo(selection[0])
if part != None:
soulsOutfitManager_global.__selectModdedPart(part)
@staticmethod
def tryReplaceGamePart(event):
selection = soulsOutfitManager_global.getWidgets()['game_part_list'].curselection()
part = None
if len(selection) == 1:
part = soulsOutfitManager_global.getWidgets()['game_part_list'].getDS3PartInfo(selection[0])
if part != None:
moddedPart = soulsOutfitManager_global.__getSelectedModdedPart()
if moddedPart == None:
return
result = messagebox.askokcancel('Replace game part with modded part?',
'Are you sure you want to replace \"'
+ str(part.getPartName()) + '\" with \"'
+ str(moddedPart.getPartFile()) + '\"?'
+ '\nA backup will be created for you.')
if result:
soulsOutfitManager_global.__replaceGamePart(moddedPart, part)
@staticmethod
def tryDeleteGamePart(event):
selection = soulsOutfitManager_global.getWidgets()['game_part_list'].curselection()
part = None
if len(selection) == 1:
part = soulsOutfitManager_global.getWidgets()['game_part_list'].getDS3PartInfo(selection[0])
if part != None:
result = messagebox.askokcancel('Replace this game part with nothing?',
'Are you you want to replace \"'
+ part.getPartName()
+ '\" with nothing?'
+ '\nA backup will be created for you.')
if result:
soulsOutfitManager_global.__deleteGamePart(part)
@staticmethod
def tryOpenModelMaskEditor(event):
selection = soulsOutfitManager_global.getWidgets()['replaced_part_list'].curselection()
part = None
if len(selection) == 1:
part = soulsOutfitManager_global.getWidgets()['replaced_part_list'].getDS3PartInfo(selection[0])
if part != None:
soulsOutfitManager_global.__tryLoadModelMaskPresetIntoEditor(part)
@staticmethod
def tryUpdateModelMaskPreset():
selection = soulsOutfitManager_global.getWidgets()['replaced_part_list'].curselection()
part = None
if len(selection) == 1:
part = soulsOutfitManager_global.getWidgets()['replaced_part_list'].getDS3PartInfo(selection[0])
if part != None:
soulsOutfitManager_global.__registerModelMaskPresetEdit(
part,
soulsOutfitManager_global.getWidgets()['model_mask_editor'].getItemCheckStates())
@staticmethod
def saveModelMaskChanges():
selection = soulsOutfitManager_global.getWidgets()['replaced_part_list'].curselection()
part = None
if len(selection) == 1:
part = soulsOutfitManager_global.getWidgets()['replaced_part_list'].getDS3PartInfo(selection[0])
if part != None:
soulsOutfitManager_global.__saveModelMaskPreset(part)
@staticmethod
def tryRestorePart(event):
selection = soulsOutfitManager_global.getWidgets()['replaced_part_list'].curselection()
part = None
if len(selection) == 1:
part = soulsOutfitManager_global.getWidgets()['replaced_part_list'].getDS3PartInfo(selection[0])
if part != None:
result = messagebox.askokcancel('Restore this backup?',
'Are you sure you want to restore this part to it\'s original?'
+ '\nAny file currently replacing it will be deleted.')
if result:
soulsOutfitManager_global.__restoreReplacedPart(part)
@staticmethod
def openBrowseForGameDirectory():
directory = filedialog.askdirectory(mustexist=True)
if any(os.path.isfile(directory + os.path.sep + EXEName) for EXEName in SoulsOutfitManager.supportedGameEXENames):
programDataFile = soulsOutfitManager_global.__tryLoadProgramData()
programDataFile['gameDirectory'] = directory
soulsOutfitManager_global.__saveProgramData(programDataFile)
currentText = soulsOutfitManager_global.getWidgets()['game_dir_entry'].get()
soulsOutfitManager_global.getWidgets()['game_dir_entry'].delete(0, len(currentText))
soulsOutfitManager_global.getWidgets()['game_dir_entry'].insert(0, directory)
soulsOutfitManager_global.__loadPartLists()
soulsOutfitManager_global.__updateUIModdedPartList()
soulsOutfitManager_global.__updateUIReplacedPartList()
soulsOutfitManager_global.__updateUIGamePartList()
elif len(directory) != 0:
messagebox.showerror('Invalid Directory Given',
'Could not find a valid EXE in the specified directory.'
+ '\nYou should select the directory containing the game EXE eg. steamapps\common\DARK SOULS III\Game')
@staticmethod
def refresh():
soulsOutfitManager_global.__loadPartLists()
soulsOutfitManager_global.__updateUIModdedPartList()
soulsOutfitManager_global.__updateUIReplacedPartList()
soulsOutfitManager_global.__updateUIGamePartList()
modelMaskPatcher.attach()
@staticmethod
def moddedPartsSearchUpdate(event):
soulsOutfitManager_global.__updateUIModdedPartList()
@staticmethod
def gamePartsSearchUpdate(event):
soulsOutfitManager_global.__updateUIGamePartList()
@staticmethod
def replacedPartsSearchUpdate(event):
soulsOutfitManager_global.__updateUIReplacedPartList()
def checkDS3Patch(self):
if not modelMaskPatcher.isAttached() or not modelMaskPatcher.isParamsDefined():
for partName in self.__modelMaskPatchedParts:
self.__modelMaskPatchedParts[partName] = False
self.__wasLastAttachedToDS3 = False
modelMaskPatcher.undefineParams()
modelMaskPatcher.attach()
if not modelMaskPatcher.isAttached() or not modelMaskPatcher.isParamsDefined():
return
for replacedPart in self.__replacedParts:
partFile = replacedPart.getPartFile()
if not partFile in self.__modelMaskPatchedParts:
continue
if not self.__modelMaskPatchedParts[partFile]:
self.__applyModelMaskPresetToGame(replacedPart,
self.__modelMaskPresets[partFile])
if not self.__wasLastAttachedToDS3:
selection = self.getWidgets()['replaced_part_list'].curselection()
part = None
if len(selection) == 1:
part = self.getWidgets()['replaced_part_list'].getDS3PartInfo(selection[0])
if part != None:
self.__tryLoadModelMaskPresetIntoEditor(part)
self.__wasLastAttachedToDS3 = True
@staticmethod
def ds3PatchLoop():
soulsOutfitManager_global.checkDS3Patch()
soulsOutfitManager_global.__window.after(3000, SoulsOutfitManager.ds3PatchLoop)
global soulsOutfitManager_global
global modelMaskPatcher
soulsOutfitManager_global = SoulsOutfitManager()
modelMaskPatcher = DS3ModelMaskPatcher()
soulsOutfitManager_global.start()