try to get languages more in sync in the scripts.
This commit is contained in:
parent
b866b308a0
commit
fe803f174e
|
|
@ -74,10 +74,10 @@ 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 = {}
|
||||||
|
|
||||||
|
def getScriptData():
|
||||||
offset = struct.unpack("<Q", script_data[0:8])[0] # 11914
|
offset = struct.unpack("<Q", script_data[0:8])[0] # 11914
|
||||||
titlecount = struct.unpack("<I", script_data[8:12])[0] # 307
|
titlecount = struct.unpack("<I", script_data[8:12])[0] # 307
|
||||||
scriptblockcount = struct.unpack("<I", script_data[12:16])[0] # 7340
|
scriptblockcount = struct.unpack("<I", script_data[12:16])[0] # 7340
|
||||||
|
|
@ -100,9 +100,12 @@ for o in range(len(titleOffset)):
|
||||||
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[p] = {"title":script_titles[p], "blocks" : list()}
|
#scripts[script_titles[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