-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathcaptureItemHints.py
More file actions
70 lines (57 loc) · 1.68 KB
/
captureItemHints.py
File metadata and controls
70 lines (57 loc) · 1.68 KB
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
import bcsv
import msbt
import json
import sarc
import sys
import zstandard
from specs import *
messages_path = sys.argv[1]
bcsv_path = sys.argv[2]
def fixup(name):
bits = []
for bit in name.parse():
if isinstance(bit, str):
bits.append(bit)
return ''.join(bits)
item_names = {}
# MESSAGES
data = open(messages_path + '/String_EUen.sarc.zs', 'rb').read()
data = zstandard.ZstdDecompressor().decompress(data)
msgArc = sarc.SARC(data)
outfitGroup = {}
for name in sorted(msgArc.list_files()):
if 'STR_ItemName' in name:
m = msbt.MSBT()
m.load(msgArc.get_file_data(name))
for label, msg in m.data.items():
if not label.endswith('_pl'):
item_id = int(label[label.rfind('_') + 1:], 10)
item_names[item_id] = fixup(msg)
if 'STR_OutfitGroupColor' in name:
m = msbt.MSBT()
m.load(msgArc.get_file_data(name))
for label, msg in m.data.items():
key = label[:label.rfind('_')]
item_id = int(label[label.rfind('_') + 1:], 10)
try:
outfitGroup[key].append((item_id, fixup(msg)))
except KeyError:
outfitGroup[key] = [(item_id, fixup(msg))]
if 'STR_OutfitGroupName' in name:
m = msbt.MSBT()
m.load(msgArc.get_file_data(name))
key2 = name[name.rfind('_')+1:name.rfind('.')]
for label, msg in m.data.items():
key1 = label
name = fixup(msg)
for iid, col in outfitGroup[f'{key1}_{key2}']:
item_names[iid] = f'{col} {name}'
output = {}
f = bcsv.File(ItemParam)
f.load(open(bcsv_path + '/ItemParam.bcsv', 'rb').read())
for row in f.rows:
if row.UniqueID in item_names:
output[row.UniqueID] = f'{row.Label} ({item_names[row.UniqueID]})'
else:
output[row.UniqueID] = row.Label
json.dump(output, open('item_hints.json', 'w'), indent=4, sort_keys=True)