You've already forked PythonLib
mirror of
https://github.com/lifebottle/PythonLib.git
synced 2026-02-13 15:25:50 -08:00
Extracting 00016_0000d
This commit is contained in:
@@ -11,8 +11,56 @@ import os
|
||||
import lxml.etree as etree
|
||||
|
||||
|
||||
tool = ToolsTODDC.ToolsTODDC("toddc.tbl")
|
||||
tool = ToolsTODDC.ToolsTODDC("TBL_All.json")
|
||||
|
||||
ele = tool.menu_files_json[0]
|
||||
tool.extract_Menu_File(ele)
|
||||
|
||||
repo_name = "Tales-Of-Destiny-DC"
|
||||
tblFile = "TBL_ALL.json"
|
||||
with open("../{}/Data/Misc/{}".format(repo_name, tblFile), encoding="utf-8") as f:
|
||||
jsonRaw = json.load(f)
|
||||
jsonTblTags ={ k1:{ int(k2) if (k2 != "TBL") else int(k2):v2 for k2,v2 in jsonRaw[k1].items()} for k1,v1 in jsonRaw.items()}
|
||||
#jsonTblTags = {k2:v2 for k2,v2 in jsonRaw[k1].items()} for k1,v1 in jsonRaw.items()}
|
||||
|
||||
|
||||
TAGS = jsonTblTags['TAGS']
|
||||
|
||||
with open("../Data/Tales-Of-Destiny-DC/Menu/New/00016/00016_0000d.unknown", "rb") as fileRead:
|
||||
|
||||
|
||||
fileRead.seek(0x3C87D)
|
||||
b = fileRead.read(1)
|
||||
|
||||
b = ord(b)
|
||||
finalText=""
|
||||
if (b >= 0x99 and b <= 0x9F) or (b >= 0xE0 and b <= 0xEB):
|
||||
c = (b << 8) + ord(fileRead.read(1))
|
||||
|
||||
# if str(c) not in json_data.keys():
|
||||
# json_data[str(c)] = char_index[decode(c)]
|
||||
try:
|
||||
finalText += (jsonTblTags['TBL'][str(c)])
|
||||
except KeyError:
|
||||
b_u = (c >> 8) & 0xff
|
||||
b_l = c & 0xff
|
||||
finalText += ("{%02X}" % b_u)
|
||||
finalText += ("{%02X}" % b_l)
|
||||
elif b == 0x1:
|
||||
finalText += ("\n")
|
||||
elif b in (0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xB, 0xC, 0xD, 0xE, 0xF):
|
||||
b2 = struct.unpack("<L", fileRead.read(4))[0]
|
||||
if b in TAGS:
|
||||
tag_name = TAGS.get(b)
|
||||
|
||||
tag_param = None
|
||||
tag_search = tag_name.upper()
|
||||
if (tag_search in jsonTblTags.keys()):
|
||||
tags2 = jsonTblTags[tag_search]
|
||||
tag_param = tags2.get(b2, None)
|
||||
if tag_param != None:
|
||||
finalText += tag_param
|
||||
else:
|
||||
finalText += ("<%s:%08X>" % (tag_name, b2))
|
||||
else:
|
||||
finalText += "<%02X:%08X>" % (b, b2)
|
||||
@@ -20,29 +20,6 @@ class ToolsTODDC(ToolsTales):
|
||||
|
||||
def __init__(self, tbl):
|
||||
|
||||
self.gameName = "TODDC"
|
||||
self.repo_name = "Tales-of-Destiny-DC"
|
||||
self.basePath = os.getcwd()
|
||||
|
||||
|
||||
with open("../Tales-of-Destiny-DC/Data/Misc/toddc.tbl", encoding="utf-8") as f:
|
||||
data = f.readlines()
|
||||
hex_list = [bytes.fromhex(str(ele.split("=",1)[0])) for ele in data]
|
||||
self.itable = dict([[ele.split("=",1)[1].replace("\n",""), bytes.fromhex(ele.split("=",1)[0])] for ele in data])
|
||||
|
||||
|
||||
|
||||
#with open("../{}/Data/{}/Misc/{}".format(repo_name, gameName, tblFile)) as f:
|
||||
# jsonRaw = json.load(f)
|
||||
# self.jsonTblTags ={ k1:{ int(k2,16) if (k1 != "TBL") else k2:v2 for k2,v2 in jsonRaw[k1].items()} for k1,v1 in jsonRaw.items()}
|
||||
|
||||
#self.itable = dict([[i, struct.pack(">H", int(j))] for j, i in self.jsonTblTags['TBL'].items()])
|
||||
#self.itags = dict([[i, j] for j, i in self.jsonTblTags['TAGS'].items()])
|
||||
#self.inames = dict([[i, j] for j, i in self.jsonTblTags['NAMES'].items()])
|
||||
#self.icolors = dict([[i, j] for j, i in self.jsonTblTags['COLORS'].items()])
|
||||
|
||||
|
||||
with open("../{}/Data/Menu/MenuFiles.json".format(self.repo_name, self.gameName)) as f:
|
||||
self.menu_files_json = json.load(f)
|
||||
super().__init__("TODDC", tbl, "Tales-of-Destiny-DC")
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -31,17 +31,21 @@ class ToolsTales:
|
||||
self.repo_name = repo_name
|
||||
self.basePath = os.getcwd()
|
||||
|
||||
with open("../{}/Data/{}/Misc/{}".format(repo_name, gameName, tblFile)) as f:
|
||||
with open("../{}/Data/Misc/{}".format(repo_name, tblFile), encoding="utf-8") as f:
|
||||
jsonRaw = json.load(f)
|
||||
self.jsonTblTags ={ k1:{ int(k2,16) if (k1 != "TBL") else k2:v2 for k2,v2 in jsonRaw[k1].items()} for k1,v1 in jsonRaw.items()}
|
||||
if self.repo_name == "Tales-of-Destiny-DC":
|
||||
self.jsonTblTags ={ k1:{ int(k2) if (k1 != "TBL") else k2:v2 for k2,v2 in jsonRaw[k1].items()} for k1,v1 in jsonRaw.items()}
|
||||
else:
|
||||
self.jsonTblTags ={ k1:{ int(k2,16) if (k1 != "TBL") else k2:v2 for k2,v2 in jsonRaw[k1].items()} for k1,v1 in jsonRaw.items()}
|
||||
|
||||
|
||||
self.itable = dict([[i, struct.pack(">H", int(j))] for j, i in self.jsonTblTags['TBL'].items()])
|
||||
self.itags = dict([[i, j] for j, i in self.jsonTblTags['TAGS'].items()])
|
||||
self.inames = dict([[i, j] for j, i in self.jsonTblTags['NAMES'].items()])
|
||||
self.icolors = dict([[i, j] for j, i in self.jsonTblTags['COLORS'].items()])
|
||||
self.inames = dict([[i, j] for j, i in self.jsonTblTags['NAME'].items()])
|
||||
self.icolors = dict([[i, j] for j, i in self.jsonTblTags['COLOR'].items()])
|
||||
|
||||
|
||||
with open("../{}/Data/{}/Menu/MenuFiles.json".format(repo_name, gameName)) as f:
|
||||
with open("../{}/Data/Menu/MenuFiles.json".format(repo_name)) as f:
|
||||
self.menu_files_json = json.load(f)
|
||||
|
||||
|
||||
@@ -469,7 +473,7 @@ class ToolsTales:
|
||||
tag_name = TAGS.get(b)
|
||||
|
||||
tag_param = None
|
||||
tag_search = tag_name.upper()+'S'
|
||||
tag_search = tag_name.upper()
|
||||
if (tag_search in self.jsonTblTags.keys()):
|
||||
tags2 = self.jsonTblTags[tag_search]
|
||||
tag_param = tags2.get(b2, None)
|
||||
@@ -913,7 +917,7 @@ class ToolsTales:
|
||||
|
||||
#Write to XML file
|
||||
txt=etree.tostring(root, encoding="UTF-8", pretty_print=True)
|
||||
with open(file_definition['File_XML'].replace("/{}".format(self.repo_name),""), "wb") as xmlFile:
|
||||
with open(file_definition['File_XML'].replace("/{}".format(self.repo_name),"").replace("/Data","/Data/{}".format(self.repo_name)), "wb") as xmlFile:
|
||||
xmlFile.write(txt)
|
||||
|
||||
|
||||
@@ -922,7 +926,7 @@ class ToolsTales:
|
||||
|
||||
|
||||
print("Extracting Menu Files")
|
||||
self.mkdir("../Data/{}/Menu/New".format(self.gameName))
|
||||
self.mkdir("../Data/{}/Menu/New".format(self.repo_name))
|
||||
|
||||
#Prepare the menu files (Unpack PAK files and use comptoe)
|
||||
files_to_prepare = list(dict.fromkeys([ele['File_Original'] for ele in self.menu_files_json]))
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user