try to get languages more in sync in the scripts.
This commit is contained in:
parent
b866b308a0
commit
fe803f174e
|
|
@ -74,35 +74,38 @@ e_name_data = Path(f"YGO_2020/main/howto_db/howtoplay_{language_code}.bin").read
|
||||||
language_code = 'J'
|
language_code = 'J'
|
||||||
j_name_data = Path(f"YGO_2020/main/howto_db/howtoplay_{language_code}.bin").read_bytes() # Get all the bytes
|
j_name_data = Path(f"YGO_2020/main/howto_db/howtoplay_{language_code}.bin").read_bytes() # Get all the bytes
|
||||||
|
|
||||||
language_code = 'J'
|
|
||||||
script_data = Path(f"YGO_2020/main/scriptdata_{language_code}.bin").read_bytes() # Get all the bytes
|
|
||||||
|
|
||||||
|
scripts = {}
|
||||||
|
|
||||||
offset = struct.unpack("<Q", script_data[0:8])[0] # 11914
|
def getScriptData():
|
||||||
titlecount = struct.unpack("<I", script_data[8:12])[0] # 307
|
offset = struct.unpack("<Q", script_data[0:8])[0] # 11914
|
||||||
scriptblockcount = struct.unpack("<I", script_data[12:16])[0] # 7340
|
titlecount = struct.unpack("<I", script_data[8:12])[0] # 307
|
||||||
|
scriptblockcount = struct.unpack("<I", script_data[12:16])[0] # 7340
|
||||||
|
|
||||||
titleStartPos = list()
|
titleStartPos = list()
|
||||||
titleEndPos = list()
|
titleEndPos = list()
|
||||||
titleOffset = list()
|
titleOffset = list()
|
||||||
for p in range(titlecount):
|
for p in range(titlecount):
|
||||||
i = p * 16
|
i = p * 16
|
||||||
titleStartPos.append(struct.unpack("<I", script_data[i:i+4])[0])
|
titleStartPos.append(struct.unpack("<I", script_data[i:i+4])[0])
|
||||||
titleEndPos.append(struct.unpack("<I", script_data[i+4:i+8])[0])
|
titleEndPos.append(struct.unpack("<I", script_data[i+4:i+8])[0])
|
||||||
titleOffset.append(struct.unpack("<Q", script_data[i+8:i+16])[0])
|
titleOffset.append(struct.unpack("<Q", script_data[i+8:i+16])[0])
|
||||||
## 307 items? Is that good
|
## 307 items? Is that good
|
||||||
|
|
||||||
script_titles = list()
|
script_titles = list()
|
||||||
for o in range(len(titleOffset)):
|
for o in range(len(titleOffset)):
|
||||||
start = titleOffset[o]
|
start = titleOffset[o]
|
||||||
end = read_until_space(start,script_data)
|
end = read_until_space(start,script_data)
|
||||||
script_titles.append(script_data[start:end].decode("utf-8"))
|
script_titles.append(script_data[start:end].decode("utf-8"))
|
||||||
print( script_data[start:end].decode("utf-8") )
|
print( script_data[start:end].decode("utf-8") )
|
||||||
|
|
||||||
## Script Data extraction!
|
## Script Data extraction!
|
||||||
scripts = {}
|
for p in range(titlecount):
|
||||||
for p in range(titlecount):
|
#scripts[script_titles[p]] = {"title":script_titles[p], "blocks" : list()}
|
||||||
scripts[p] = {"title":script_titles[p], "blocks" : list()}
|
if script_titles[p] == '':
|
||||||
|
continue
|
||||||
|
if scripts.get(script_titles[p]) == None:
|
||||||
|
scripts[script_titles[p]] = {}
|
||||||
script_block = {}
|
script_block = {}
|
||||||
blockCount = titleEndPos[p] - titleStartPos[p] #+1
|
blockCount = titleEndPos[p] - titleStartPos[p] #+1
|
||||||
#start = offset + titleOffset[p] + titleStartPos[p]
|
#start = offset + titleOffset[p] + titleStartPos[p]
|
||||||
|
|
@ -111,6 +114,7 @@ for p in range(titlecount):
|
||||||
start_char = struct.unpack("<Q", script_data[seeker:seeker+8])[0]
|
start_char = struct.unpack("<Q", script_data[seeker:seeker+8])[0]
|
||||||
end = read_until_space(start_char, script_data)
|
end = read_until_space(start_char, script_data)
|
||||||
script_block['character'] = script_data[start_char:end].decode('utf-8')
|
script_block['character'] = script_data[start_char:end].decode('utf-8')
|
||||||
|
index = f"{j}_{language_code}_{script_block['character']}"
|
||||||
|
|
||||||
seeker = seeker + 8
|
seeker = seeker + 8
|
||||||
start_arg1 = struct.unpack("<Q", script_data[seeker:seeker+8])[0]
|
start_arg1 = struct.unpack("<Q", script_data[seeker:seeker+8])[0]
|
||||||
|
|
@ -127,10 +131,26 @@ for p in range(titlecount):
|
||||||
end = read_until_space(start_text, script_data) ## These strings seem to always start with /0x00
|
end = read_until_space(start_text, script_data) ## These strings seem to always start with /0x00
|
||||||
script_block['text'] = script_data[start_text:end].decode('utf-8')
|
script_block['text'] = script_data[start_text:end].decode('utf-8')
|
||||||
|
|
||||||
scripts[p]['blocks'].append(script_block.copy())
|
if script_block['text'] != '':
|
||||||
|
if scripts[script_titles[p]].get(index) == None:
|
||||||
|
scripts[script_titles[p]][index] = {}
|
||||||
|
scripts[script_titles[p]][index]['arg1'] = script_block['arg1']
|
||||||
|
scripts[script_titles[p]][index]['arg2'] = script_block['arg2']
|
||||||
|
scripts[script_titles[p]][index]['text'] = script_block['text']
|
||||||
|
|
||||||
|
#scripts[p]['blocks'].append(script_block.copy())
|
||||||
print(script_block)
|
print(script_block)
|
||||||
|
|
||||||
with open(f"scripts_dump_{language_code}.json", "w", encoding="utf-8") as outfile:
|
language_code = 'J'
|
||||||
|
script_data = Path(f"YGO_2020/main/scriptdata_{language_code}.bin").read_bytes() # Get all the bytes
|
||||||
|
getScriptData()
|
||||||
|
language_code = 'E'
|
||||||
|
script_data = Path(f"YGO_2020/main/scriptdata_{language_code}.bin").read_bytes() # Get all the bytes
|
||||||
|
getScriptData()
|
||||||
|
|
||||||
|
print('again?')
|
||||||
|
|
||||||
|
with open(f"scripts_dump.json", "w", encoding="utf-8") as outfile:
|
||||||
json.dump(scripts, outfile, ensure_ascii=False, indent=2)
|
json.dump(scripts, outfile, ensure_ascii=False, indent=2)
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user