You've already forked PythonLib
mirror of
https://github.com/lifebottle/PythonLib.git
synced 2026-02-13 15:25:50 -08:00
Remove Section and Duplicate
This commit is contained in:
BIN
10247.scpk
BIN
10247.scpk
Binary file not shown.
20
ToolsTOR.py
20
ToolsTOR.py
@@ -40,7 +40,7 @@ class ToolsTOR(ToolsTales):
|
||||
|
||||
#byteCode
|
||||
self.story_byte_code = b"\xF8"
|
||||
self.list_status_insertion = ['Done']
|
||||
self.list_status_insertion = ['Done', 'Proofreading']
|
||||
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@ class ToolsTOR(ToolsTales):
|
||||
for scpk_file in listFiles:
|
||||
|
||||
self.extract_TheirSce_XML(scpk_file)
|
||||
self.id = 1
|
||||
|
||||
def get_theirsce_from_scpk(self, scpk, scpk_file_name, debug=False)->bytes:
|
||||
header = scpk.read(4)
|
||||
@@ -130,13 +131,14 @@ class ToolsTOR(ToolsTales):
|
||||
|
||||
|
||||
#Remove duplicates
|
||||
list_informations = self.remove_duplicates(["Story"] * len(pointers_offset), pointers_offset, text_list)
|
||||
#list_informations = self.remove_duplicates(["Story"] * len(pointers_offset), pointers_offset, text_list)
|
||||
|
||||
list_informations = ( ['Story', pointers_offset[i], text_list[i]] for i in range(len(text_list)))
|
||||
#Build the XML Structure with the information
|
||||
|
||||
|
||||
file_path = self.story_XML_patch +"XML/"+ self.get_file_name(scpk_file_name)
|
||||
root = self.create_Node_XML(file_path, list_informations, "SceneText")
|
||||
root = self.create_Node_XML(file_path, list_informations, "Story", "SceneText")
|
||||
|
||||
|
||||
#Write the XML file
|
||||
@@ -173,11 +175,12 @@ class ToolsTOR(ToolsTales):
|
||||
#Grab strings_offset for pointers
|
||||
theirsce.read(12)
|
||||
strings_offset = struct.unpack("<L", theirsce.read(4))[0]
|
||||
print(strings_offset)
|
||||
|
||||
|
||||
#Read the XML for the corresponding THEIRSCE
|
||||
file = self.story_XML_new +"XML/"+ self.get_file_name(scpk_file_name)+'.xml'
|
||||
print("XML : {}".format(self.get_file_name(scpk_file_name)+'.xml'))
|
||||
#print("XML : {}".format(self.get_file_name(scpk_file_name)+'.xml'))
|
||||
|
||||
tree = etree.parse(file)
|
||||
root = tree.getroot()
|
||||
|
||||
@@ -355,8 +358,7 @@ class ToolsTOR(ToolsTales):
|
||||
buffer = 0
|
||||
|
||||
|
||||
story_file_list = [self.get_file_name(ele) for ele in os.listdir( self.story_XML_patch +"New")]
|
||||
print(story_file_list)
|
||||
|
||||
output_dat_path = self.dat_bin_new
|
||||
with open(output_dat_path, "wb") as output_dat:
|
||||
|
||||
@@ -379,7 +381,7 @@ class ToolsTOR(ToolsTales):
|
||||
size = 0
|
||||
remainder = 0
|
||||
current = int(re.search(self.VALID_FILE_NAME, file).group(1))
|
||||
|
||||
|
||||
if current != previous + 1:
|
||||
while previous < current - 1:
|
||||
remainders.append(remainder)
|
||||
@@ -390,7 +392,7 @@ class ToolsTOR(ToolsTales):
|
||||
file_name = self.get_file_name(file)
|
||||
|
||||
if ".scpk" in file:
|
||||
|
||||
print(file)
|
||||
data = self.pack_Story_File(file_name+".scpk")
|
||||
|
||||
else:
|
||||
|
||||
@@ -43,7 +43,7 @@ class ToolsTales:
|
||||
self.itags = dict([[i, j] for j, i in self.jsonTblTags['TAGS'].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()])
|
||||
|
||||
self.id = 1
|
||||
|
||||
with open("../{}/Data/{}/Menu/MenuFiles.json".format(repo_name, gameName)) as f:
|
||||
self.menu_files_json = json.load(f)
|
||||
@@ -559,7 +559,7 @@ class ToolsTales:
|
||||
for line in splitLineBreak:
|
||||
string_hex = re.split(self.HEX_TAG, line)
|
||||
string_hex = [sh for sh in string_hex if sh]
|
||||
|
||||
#print(string_hex)
|
||||
for s in string_hex:
|
||||
if re.match(self.HEX_TAG, s):
|
||||
bytesFinal += struct.pack("B", int(s[1:3], 16))
|
||||
@@ -576,8 +576,8 @@ class ToolsTales:
|
||||
bytesFinal += struct.pack("<I", int(split[1][:-1], 16))
|
||||
elif split[0][1:4] == "Unk":
|
||||
bytesFinal += struct.pack("B", int(split[0][4:], 16))
|
||||
for i in [split[1][i:i+2] for i in range(0, len(split[1]) - 2, 2)]:
|
||||
bytesFinal += struct.pack("B", int(i, 16))
|
||||
for j in [split[1][j:j+2] for j in range(0, len(split[1]) - 2, 2)]:
|
||||
bytesFinal += struct.pack("B", int(j, 16))
|
||||
bytesFinal += struct.pack("B", 0x80)
|
||||
else:
|
||||
bytesFinal += struct.pack("B", int(split[0][1:], 16))
|
||||
@@ -593,8 +593,10 @@ class ToolsTales:
|
||||
if c2 in self.itable.keys():
|
||||
bytesFinal += self.itable[c2]
|
||||
else:
|
||||
|
||||
bytesFinal += c2.encode("cp932")
|
||||
|
||||
i=i+1
|
||||
if (nb >=2 and i<nb):
|
||||
bytesFinal += b'\x01'
|
||||
|
||||
@@ -605,7 +607,7 @@ class ToolsTales:
|
||||
#Return the bytes for that specific text
|
||||
bytes_from_text = self.text_to_bytes(japanese_text)
|
||||
|
||||
def create_Entry(self, strings_node, section, pointer_offset, text):
|
||||
def create_Entry(self, strings_node, pointer_offset, text):
|
||||
|
||||
#Add it to the XML node
|
||||
entry_node = etree.SubElement(strings_node, "Entry")
|
||||
@@ -613,6 +615,9 @@ class ToolsTales:
|
||||
etree.SubElement(entry_node,"JapaneseText").text = text
|
||||
etree.SubElement(entry_node,"EnglishText").text = ''
|
||||
etree.SubElement(entry_node,"Notes").text = ''
|
||||
etree.SubElement(entry_node,"Id").text = str(self.id)
|
||||
|
||||
self.id = self.id + 1
|
||||
|
||||
if text == '':
|
||||
statusText = 'Done'
|
||||
@@ -621,22 +626,15 @@ class ToolsTales:
|
||||
etree.SubElement(entry_node,"Status").text = statusText
|
||||
|
||||
|
||||
def create_Node_XML(self, fileName, list_informations, parent):
|
||||
def create_Node_XML(self, fileName, list_informations, section, parent):
|
||||
|
||||
root = etree.Element(parent)
|
||||
strings_node = etree.SubElement(root, 'Strings')
|
||||
etree.SubElement(strings_node, 'Section').text = section
|
||||
|
||||
|
||||
|
||||
sections = set([item[0] for item in list_informations])
|
||||
|
||||
for section in sections:
|
||||
strings_node = etree.SubElement(root, 'Strings')
|
||||
etree.SubElement(strings_node, "Section").text = section
|
||||
list_section = [ele for ele in list_informations if ele[0] == section]
|
||||
|
||||
|
||||
for s, pointers_offset, text in list_section:
|
||||
self.create_Entry( strings_node, s, pointers_offset, text)
|
||||
for s, pointers_offset, text in list_informations:
|
||||
self.create_Entry( strings_node, pointers_offset, text)
|
||||
|
||||
return root
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user