fixing path issues

This commit is contained in:
Stewie
2022-04-30 14:06:21 -04:00
parent c374307fce
commit 2deff24916
4 changed files with 18 additions and 21 deletions

View File

@@ -28,10 +28,10 @@ class ToolsTOR(ToolsTales):
datBinNew = '../Data/Tales-Of-Rebirth/Disc/New/DAT.BIN'
elfOriginal = '../Data/Tales-Of-Rebirth/Disc/Original/SLPS_254.50'
elfNew = '../Data/Tales-Of-Rebirth/Disc/New/SLPS_254.50'
storyPathArchives= '../Tales-Of-Rebirth/Data/TOR/Story/New/' #Story XML files will be extracted here
storyPathXML = '../Tales-Of-Rebirth/Data/TOR/Story/XML/' #SCPK will be repacked here
skitPathArchives = '../Tales-Of-Rebirth/Data/TOR/Skits/' #Skits XML files will be extracted here
datPathExtract = '../Data/Tales-Of-Rebirth/DAT/'
story_XML_new = '../Tales-Of-Rebirth/Data/Data/TOR/Story/' #Story XML files will be extracted here
story_XML_patch = '../Data/Tales-Of-Rebirth/Story/' #Story XML files will be extracted here
skit_XML_patch = '../Data/Tales-Of-Rebirth/Skits/' #Skits XML files will be extracted here
dat_archive_extract = '../Data/Tales-Of-Rebirth/DAT/'
def __init__(self, tbl):
@@ -51,11 +51,11 @@ class ToolsTOR(ToolsTales):
# Extract the story files
def extract_All_Story_Files(self,debug=False):
self.mkdir( self.storyPathXML)
listFiles = [self.datPathExtract + 'SCPK/' + ele for ele in os.listdir( os.path.join(self.datPathExtract, "SCPK"))]
self.mkdir( self.story_XML_patch + "XML")
listFiles = [self.dat_archive_extract + 'SCPK/' + ele for ele in os.listdir( os.path.join(self.dat_archive_extract, "SCPK"))]
for scpkFile in listFiles:
self.extract_TheirSce_XML(scpkFile,debug)
self.extract_TheirSce_XML(scpkFile)
def get_theirsce_from_scpk(self, scpk, scpkFileName, debug=False)->bytes:
header = scpk.read(4)
@@ -82,10 +82,7 @@ class ToolsTOR(ToolsTales):
c_type = struct.unpack("<b", data[:1])[0]
if data_decompressed[:8] == b"THEIRSCE":
if debug:
with open("Debug/{}.theirsce".format( self.get_file_name(scpkFileName)), "wb") as f:
f.write(data)
return io.BytesIO(data_decompressed)
return None
@@ -95,7 +92,7 @@ class ToolsTOR(ToolsTales):
# Extract THEIRSCE to XML
def extract_TheirSce_XML(self, scpkFileName,debug=False):
def extract_TheirSce_XML(self, scpkFileName):
#Create the XML file
root = etree.Element('SceneText')
@@ -107,9 +104,9 @@ class ToolsTOR(ToolsTales):
with open(scpkFileName, "rb") as scpk:
theirsce = self.get_theirsce_from_scpk(scpk,scpkFileName,True)
if (scpkFileName.endswith(".scpk") and debug):
with open("Debug/{}d.theirsce".format( self.get_file_name(scpkFileName)), "wb") as f:
f.write(theirsce.read())
#if (scpkFileName.endswith(".scpk") and debug):
# with open("Debug/{}d.theirsce".format( self.get_file_name(scpkFileName)), "wb") as f:
# f.write(theirsce.read())
theirsce.seek(0)
#Validate the header
@@ -128,7 +125,7 @@ class ToolsTOR(ToolsTales):
theirsce.seek(pointer_block, 0) #Go the the start of the pointer section
pointers_offset, texts_offset = self.extract_Story_Pointers(theirsce, strings_offset, fsize)
text_list = [self.bytesToText(theirsce, ele)[0] for ele in texts_offset]
text_list = [self.bytes_to_text(theirsce, ele)[0] for ele in texts_offset]
#Remove duplicates
@@ -137,14 +134,14 @@ class ToolsTOR(ToolsTales):
#Build the XML Structure with the information
file_path = self.storyPathXML + self.get_file_name(scpkFileName)
file_path = self.story_XML_patch +"XML/"+ self.get_file_name(scpkFileName)
root = self.create_Node_XML(file_path, list_informations, "SceneText")
#Write the XML file
txt=etree.tostring(root, encoding="UTF-8", pretty_print=True)
with open(os.path.join( self.storyPathXML, self.get_file_name(scpkFileName)+".xml"), "wb") as xmlFile:
with open(os.path.join( self.story_XML_patch,"XML", self.get_file_name(scpkFileName)+".xml"), "wb") as xmlFile:
xmlFile.write(txt)
def getNewTheirsce(self, theirsce, scpkFileName):
@@ -158,7 +155,7 @@ class ToolsTOR(ToolsTales):
print(strings_offset)
#Read the XML for the corresponding THEIRSCE
file = self.storyPathXML+ self.get_file_name(scpkFileName)+'.xml'
file = self.story_XML_patch +"XML/"+ self.get_file_name(scpkFileName)+'.xml'
print("XML : {}".format(self.get_file_name(scpkFileName)+'.xml'))
tree = etree.parse(file)
root = tree.getroot()
@@ -183,7 +180,7 @@ class ToolsTOR(ToolsTales):
#Convert the text values to bytes using TBL, TAGS, COLORS, ...
bytesEntry = self.textToBytes(final_text)
bytesEntry = self.text_to_bytes(final_text)
#Write to the file
theirsce.write(bytesEntry + b'\x00')

View File

@@ -18,7 +18,7 @@ def generate_xdelta_patch(repo_name, xdelta_name="Tales-Of-Rebirth_Patch_New.xde
print("Create xdelta patch")
original_path = "../Data/{}/Disc/Original/{}.iso".format(repo_name, repo_name)
new_path = "../Data/{}/Disc/New/{}.iso".format(repo_name, repo_name)
subprocess.run(["xdelta", "-s", original_path, new_path, xdelta_name])
subprocess.run(["xdelta", "-f", "-s", original_path, new_path, xdelta_name])

Binary file not shown.