-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDS3PartUtil.py
96 lines (73 loc) · 2.97 KB
/
DS3PartUtil.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
import json
from tkinter import messagebox
from enum import Enum
class EquipModelCategory(Enum):
HEAD = 'hd'
BODY = 'bd'
ARMS = 'am'
LEGS = 'lg'
WEAPON = 'wp'
class EquipModelGender(Enum):
MALE = 'm'
FEMALE = 'f'
ALL = 'a'
class DS3PartUtil:
def __init__(self, partNamesLayoutFile):
try:
self.__partNames = json.load(open(partNamesLayoutFile))
except FileNotFoundError as error:
print(error)
messagebox.showerror('SoulsOutfitManager Error', str(error)
+ "\n\nPlease assure you don't move SoulsOutfitManager outside the same folder where \"assets\" is contained.")
exit()
def getPartNameFromPartFile(self, partFile):
name = 'Unknown'
if len(partFile.split('.')) == 0:
return name
partNameSections = partFile.split('.')[0].split('_')
for partNameKey in self.__partNames:
if len(partNameKey.split('.')) == 0:
continue
itrPartNameSections = partNameKey.split('.')[0].split('_')
if len(partNameSections) >= 3 and len(itrPartNameSections) == 2 and itrPartNameSections[0].lower() == partNameSections[0].lower() and itrPartNameSections[1] == partNameSections[2]:
name = self.__partNames[partNameKey]
if partNameSections[1] == 'm':
name += ' [Male]'
elif partNameSections[1] == 'f':
name += ' [Female]'
if len(partNameSections) == 4 and partNameSections[3] == 'l':
name += ' [Lower Detail]'
return name
def getEquipModelIdFromPartFile(self, partFile):
if len(partFile.split('.')) < 1:
return None
equipModelId = partFile.split('.')[0]
if len(equipModelId.split('_')) > 2:
try:
return int(equipModelId.split('_')[2])
except ValueError:
return None
else:
return None
def getEquipModelGenderFromPartFile(self, partFile):
if len(partFile.split('.')) < 1:
return None
equipModelId = partFile.split('.')[0]
if len(equipModelId.split('_')) > 2:
for equipModelGender in EquipModelGender:
if equipModelGender.value == equipModelId.split('_')[1].lower():
return equipModelGender.value
return None
else:
return None
def getEquipModelCategoryFromPartFile(self, partFile):
if len(partFile.split('.')) < 1:
return None
equipModelId = partFile.split('.')[0]
if len(equipModelId.split('_')) > 2:
for equipModelCategory in EquipModelCategory:
if equipModelCategory.value == equipModelId.split('_')[0].lower():
return equipModelCategory.value
return None
else:
return None