diff --git a/RepoFunctions.py b/RepoFunctions.py index 32de3ef..a6c1529 100644 --- a/RepoFunctions.py +++ b/RepoFunctions.py @@ -26,6 +26,6 @@ def refresh_repo(repo_name): base_path = os.path.join(os.getcwd(), "..", repo_name) print("Repo to refresh: {}".format(base_path)) listFile = subprocess.run( - ["git", "pull", repo_name], + ["git", "pull"], cwd=base_path ) diff --git a/ToolsTOR.py b/ToolsTOR.py index 6ec56b2..8ec51f7 100644 --- a/ToolsTOR.py +++ b/ToolsTOR.py @@ -24,14 +24,14 @@ class ToolsTOR(ToolsTales): #Path to used - datBinOriginal = '../Data/TOR/Disc/Original/DAT.BIN' - datBinNew = '../Data/TOR/Disc/New/DAT.BIN' - elfOriginal = '../Data/TOR/Disc/Original/SLPS_254.50' - elfNew = '../Data/TOR/Disc/New/SLPS_254.50' + datBinOriginal = '../Data/Tales-Of-Rebirth/Disc/Original/DAT.BIN' + 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/TOR/DAT/' + datPathExtract = '../Data/Tales-Of-Rebirth/DAT/' def __init__(self, tbl): diff --git a/ToolsTales.py b/ToolsTales.py index ffa6acd..ca20ba5 100644 --- a/ToolsTales.py +++ b/ToolsTales.py @@ -31,7 +31,7 @@ class ToolsTales: self.repo_name = repo_name self.basePath = os.getcwd() - with open("../{}/Data/Misc/{}".format(repo_name, tblFile), encoding="utf-8") as f: + with open("../{}/Data/{}/Misc/{}".format(repo_name, gameName, tblFile), encoding="utf-8") as f: jsonRaw = json.load(f) 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()} @@ -45,7 +45,7 @@ class ToolsTales: self.icolors = dict([[i, j] for j, i in self.jsonTblTags['COLOR'].items()]) - with open("../{}/Data/Menu/MenuFiles.json".format(repo_name)) as f: + with open("../{}/Data/{}/Menu/MenuFiles.json".format(repo_name, gameName)) as f: self.menu_files_json = json.load(f) @@ -635,11 +635,12 @@ class ToolsTales: # ############################# - def insert_Menu_File(self, menu_file_path): + def pack_Menu_File(self, menu_file_path): #Load all the banks for insertion and load XML new_text_offsets = dict() + file_node = [ele for ele in self.menu_files_json if ele['File_Extract'] == menu_file_path][0] xml_file_name = "../{}/Data/{}/Menu/XML/".format(self.repo_name, self.gameName) + self.get_file_name(menu_file_path)+'.xml' @@ -652,7 +653,7 @@ class ToolsTales: #Copy the original file - new_file_path = "../Data/TOR/Menu/New/{}".format(os.path.basename(file_node['File_Original'])) + new_file_path = "../Data/{}/Menu/New/{}".format(self.repo_name, os.path.basename(file_node['File_Original'])) shutil.copy( file_node['File_Extract'], new_file_path) #Open the new file with r+b diff --git a/ToolsTales_Executable.py b/ToolsTales_Executable.py index 6981932..6176bbf 100644 --- a/ToolsTales_Executable.py +++ b/ToolsTales_Executable.py @@ -9,15 +9,37 @@ import requests import subprocess import ApacheAutomate import RepoFunctions +from pydrive.auth import GoogleAuth +from pydrive.drive import GoogleDrive SCRIPT_VERSION = "0.3" +GoogleAuth.DEFAULT_SETTINGS['client_config_file'] = "../client_secrets.json" -def generate_xdelta_patch(original_path, new_path, xdelta_name="Tales-Of-Rebirth_Patch_New.xdelta"): - +def generate_xdelta_patch(repo_name, xdelta_name="Tales-Of-Rebirth_Patch_New.xdelta"): + + 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]) - +def upload_xdelta(xdelta_name, folder_name): + + gauth = GoogleAuth() + drive = GoogleDrive(gauth) + + xdelta_name = r"G:\TalesHacking\PythonLib_Playground\Data\Tales-Of-Rebirth\Disc\New\Tales-Of-Rebirth_patch.xdelta" + + folder_id = '1txy2BI8tTFDPT9vmIbFELW2qmxC_ZjW0' + + gfile = drive.CreateFile({'parents': [{'id': folder_id}]}) + + + file_name = os.path.basename(xdelta_name) + gfile['title'] = file_name + + gfile.SetContentFile(xdelta_name) + gfile.Upload() # Upload the file. def get_directory_path(path): return os.path.dirname(os.path.abspath(path)) @@ -200,13 +222,11 @@ if __name__ == "__main__": if args.file == "SLPS": #SLPS - tales_instance.insert_Menu_File("../Data/TOR/Disc/Original/SLPS_254.50") + tales_instance.pack_Menu_File("../Data/Tales-Of-Rebirth/Disc/Original/SLPS_254.50") ApacheAutomate.apache_job(['SLPS_254.50'], "Tales-Of-Rebirth") - print("new SLPS is found inside Data/{}/Menu/New".format(game_name)) - #Other files for menu stuff - + generate_xdelta_patch("Tales-Of-Rebirth", "../Data/Tales-Of-Rebirth/Disc/New/Tales-Of-Rebirth_patch.xdelta") if args.action == "unpack": if args.file == "Main": diff --git a/__pycache__/RepoFunctions.cpython-38.pyc b/__pycache__/RepoFunctions.cpython-38.pyc new file mode 100644 index 0000000..e583c23 Binary files /dev/null and b/__pycache__/RepoFunctions.cpython-38.pyc differ diff --git a/__pycache__/ToolsTOR.cpython-38.pyc b/__pycache__/ToolsTOR.cpython-38.pyc index a730327..99015d0 100644 Binary files a/__pycache__/ToolsTOR.cpython-38.pyc and b/__pycache__/ToolsTOR.cpython-38.pyc differ diff --git a/__pycache__/ToolsTales.cpython-38.pyc b/__pycache__/ToolsTales.cpython-38.pyc index b095f3f..e9116b5 100644 Binary files a/__pycache__/ToolsTales.cpython-38.pyc and b/__pycache__/ToolsTales.cpython-38.pyc differ