-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathicon_lister.py
244 lines (201 loc) · 9.64 KB
/
icon_lister.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
import os
import sys
pr_repo = sys.argv[1]
minimap_icons_path = os.path.join(pr_repo, "menu/HUD/Texture/Ingame/Vehicles/Icons/Minimap")
menuIcons_path = os.path.join(pr_repo, "menu/HUD/Texture/Ingame/Vehicles/Icons/Hud/MenuIcons")
vehicles_path = "objects/vehicles/"
vehicles_subfolders = ["Air", "civilian", "Land", "Sea"]
factions = ["arg", "cf", "ch", "fr", "gb", "ger", "idf", "mec", "nl", "nva", "pl", "ru", "us", "civ", "fsa", "gb82", "mil", "boat"]
prefix1 = "ObjectTemplate.vehicleHud.miniMapIcon Ingame\\Vehicles\\Icons\\Minimap\\"
prefix2 = "ObjectTemplate.vehicleHud.typeIcon Ingame\\Vehicles\\Icons\\Hud\\MenuIcons\\"
prefixName = "ObjectTemplate.vehicleHud.hudName "
pre1 = "mini_"
pre2 = "menuIcon_"
icons_list = []
menuIcons_list = []
for f in os.listdir(minimap_icons_path):
if not os.path.isdir(f) and f[-len(".tga"):] == ".tga":
icons_list.append(f.lower())
for f in os.listdir(menuIcons_path):
if not os.path.isdir(f) and f[-len(".tga"):] == ".tga":
menuIcons_list.append(f.lower())
icons_map = {}
names_map = {}
missing_icons = {}
missing_menuIcons = {}
inconsistent_icons = []
inconsistent_menuIcons = []
inconsistent_names = []
wrong_menuIcons = []
base_vehicles = {}
bf2_vehicles = []
prsp_vehicles = []
sp_vehicles = []
bf2 = "_bf2"
prsp = "_prsp"
sp = "_sp"
for icon in icons_list:
icons_map[icon] = []
for f1 in vehicles_subfolders:
cur_path = os.path.join(pr_repo, vehicles_path + f1)
for f2 in os.listdir(cur_path):
if f2[0:2] in factions or f2[0:3] in factions or f2[0:4] in factions:
vehicle = os.path.join(pr_repo, vehicles_path + f1 + "/" + f2)
if os.path.isdir(vehicle):
for tweak in os.listdir(vehicle):
#print(tweak)
#print(" {}".format(tweak[-len(".tweak"):]))
if tweak[-len(".tweak"):] == ".tweak":
p = os.path.join(pr_repo, vehicles_path + f1 + "/" + f2 + "/" + tweak)
with open(p) as f:
veh = tweak[:-len(".tweak")]
icon = None
menuIcon = None
name = None
consistentMini = True
for line in f.readlines():
if line.lower()[:len(prefix1)] == prefix1.lower():
icon2 = line[len(prefix1):].rstrip()
if icon == None:
icon = icon2
else:
if icon[-len(".tga"):] != ".tga":
print("!!!!!!! {} {}".format(veh, icon2))
if icon != icon2 and veh not in inconsistent_icons:
inconsistent_icons.append(veh)
consistentMini = False
elif line.lower()[:len(prefix2)] == prefix2.lower():
menuIcon2 = line[len(prefix2):].rstrip()
if menuIcon == None:
menuIcon = menuIcon2
else:
if menuIcon[-len(".tga"):] != ".tga":
print("!!!!!!! {} {}".format(veh, menuIcon2))
if menuIcon != menuIcon2 and veh not in inconsistent_menuIcons:
inconsistent_menuIcons.append(veh)
elif line.lower()[:len(prefixName)] == prefixName.lower():
name2 = line[len(prefixName):].rstrip()
if name == None:
name = name2
else:
if name != name2 and veh not in inconsistent_names:
inconsistent_names.append(veh)
if icon == None:
print("No mini_ icon found for: {}".format(veh))
elif icon.lower() not in icons_list:
if icon not in missing_icons:
missing_icons[icon] = []
if veh not in missing_icons[icon]:
missing_icons[icon].append(veh)
elif veh not in icons_map[icon]:
icons_map[icon].append(veh)
if menuIcon == None:
print("No menuIcon_ icon found for: {}".format(veh))
elif menuIcon.lower() not in menuIcons_list:
if menuIcon not in missing_menuIcons:
missing_menuIcons[menuIcon] = []
if veh not in missing_menuIcons[menuIcon]:
missing_menuIcons[menuIcon].append(veh)
if icon == None and menuIcon == None:
pass
elif icon == None or menuIcon == None:
print("Some icon not found for {}: minimap: {} // hud: {}".format(veh, icon, menuIcon))
elif consistentMini and icon[len(pre1):] != menuIcon[len(pre2):]:
wrong_menuIcons.append((veh, icon, menuIcon, p))
if veh[-len(bf2):] == bf2:
bf2_vehicles.append((veh, icon, menuIcon))
elif veh[-len(prsp):] == prsp:
prsp_vehicles.append((veh, icon, menuIcon))
elif veh[-len(sp):] == sp:
sp_vehicles.append((veh, icon, menuIcon))
else:
base_vehicles[veh] = (veh, icon, menuIcon)
if name is not None:
names_map[veh] = name
if __name__ == "__main__":
print()
print()
print("Check if _bf2 vehicles use the same icons as base...")
for veh, icon, menuIcon in bf2_vehicles:
veh2 = veh[:-len(bf2)]
if veh2 in base_vehicles:
_, icon2, menuIcon2 = base_vehicles[veh2]
if icon != icon2:
print(" Different mini_ icons for {} and {}: {} != {}".format(veh2, veh, icon2, icon))
if menuIcon != menuIcon2:
print(" Different mini_ icons for {} and {}: {} != {}".format(veh2, veh, menuIcon2, menuIcon))
else:
print(" Base {} not found for {}!".format(veh2, veh))
print("Done!")
print()
print()
print("Check if _prsp vehicles use the same icons as base...")
for veh, icon, menuIcon in prsp_vehicles:
veh2 = veh[:-len(prsp)]
if veh2 in base_vehicles:
_, icon2, menuIcon2 = base_vehicles[veh2]
if icon != icon2:
print(" Different menuIcon_ icons for {} and {}: {} != {}".format(veh2, veh, icon2, icon))
if menuIcon != menuIcon2:
print(" Different menuIcon_ icons for {} and {}: {} != {}".format(veh2, veh, menuIcon2, menuIcon))
else:
print(" Base {} not found for {}!".format(veh2, veh))
print("Done!")
print()
print()
print("Check if _sp vehicles use the same icons as base...")
for veh, icon, menuIcon in sp_vehicles:
veh2 = veh[:-len(sp)]
if veh2 in base_vehicles:
_, icon2, menuIcon2 = base_vehicles[veh2]
if icon != icon2:
print(" Different menuIcon_ icons for {} and {}: {} != {}".format(veh2, veh, icon2, icon))
if menuIcon != menuIcon2:
print(" Different menuIcon_ icons for {} and {}: {} != {}".format(veh2, veh, menuIcon2, menuIcon))
else:
print(" Base {} not found for {}!".format(veh2, veh))
print("Done!")
print()
print()
print("Unknown mini_ icons (total: {}):".format(len(missing_icons)))
for k, v in missing_icons.items():
print(k)
for v2 in v:
print(" {}".format(v2))
print()
print()
print("Unknown menuIcon_ icons (total: {}):".format(len(missing_menuIcons)))
for k, v in missing_menuIcons.items():
print(k)
for v2 in v:
print(" {}".format(v2))
print()
print()
print("Inconsistent mini_ icons (total: {}):".format(len(inconsistent_icons)))
for v in inconsistent_icons:
print(" {}".format(v))
print()
print()
print("Inconsistent menuIcon_ icons (total: {}):".format(len(inconsistent_menuIcons)))
for v in inconsistent_menuIcons:
print(" {}".format(v))
print()
print()
print("Vehicles with different mini_ and menuIcon_ icons (total: {}):".format(len(wrong_menuIcons)))
for veh, icon, menuIcon, path in wrong_menuIcons:
print(" {}: {} != {}".format(veh, icon, menuIcon))
#print()
#print()
#print("Known Icons + Vehicles:")
#for k, v in icons_map.items():
#if len(v) > 0:
#print(" {}".format(k))
#for v2 in v:
#if v2[-len(bf2):] != bf2 and v2[-len(prsp):] != prsp and v2[-len(sp):] != sp:
#print(" {}".format(v2))
print()
print()
print("Unused Icons:")
for k, v in icons_map.items():
if len(v) == 0:
print(" {}".format(k))