-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1978dca
commit 9f5e280
Showing
2 changed files
with
160 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
from functions import * | ||
|
||
start() | ||
game_path = input("Please enter your game path (ex: D:\SteamLibrary\steamapps\common\Atelier Sophie 2): ") | ||
game_path.replace("\\", "/") | ||
|
||
main_path = os.path.dirname(os.path.abspath(__file__)) | ||
gust_pak = main_path + "/gust_pak.exe" | ||
gust_ebm = main_path + "/gust_ebm.exe" | ||
pack_path = game_path + "/Data/PACK01/PACK01.PAK" | ||
|
||
move_file(game_path + "/Data/PACK01.PAK", pack_path) | ||
|
||
subprocess.run([gust_pak, pack_path]) | ||
|
||
path = game_path + "/Data/PACK01/event/event_en" | ||
|
||
sub_folders = get_subfolder_paths(path) | ||
|
||
for folder in sub_folders: | ||
folder_name = get_last_folder_name(folder) | ||
ebm_folder = get_files_with_extension(folder, ".ebm") | ||
for file in ebm_folder: | ||
print(Fore.GREEN + file + Fore.RESET) | ||
subprocess.run([gust_ebm, file]) | ||
remove_files_with_extension(folder, ".ebm") | ||
json_files = get_files_with_extension(folder, ".json") | ||
for json_file in json_files: | ||
move_file(json_file, folder + "/JSON/" + os.path.basename(json_file)) | ||
need_translation = get_files_with_extension(folder + "/JSON", ".json") | ||
for js_file in need_translation: | ||
with open(js_file, "r", encoding="utf-8") as file: | ||
file_contents = file.read() | ||
replaced_json = re.sub(r'0x([0-9a-fA-F]+)', replace_hex_values, file_contents) | ||
decoded_json = json.loads(replaced_json) | ||
json_file_name = os.path.basename(js_file).replace(".json", ".txt") | ||
translated_text = read_file_to_list(main_path + "/MOD/" + folder_name + "/" + json_file_name) | ||
for i, linea in enumerate(translated_text): | ||
decoded_json['messages'][i]['msg_string'] = linea.strip() | ||
with open(path + "/" + folder_name + "/JSON/" + os.path.basename(js_file), "w", encoding="utf-8") as file: | ||
MATCH_ALL_XYZ = r'(?<![a-zA-Z\"])(?![\"])(\b\d+)' | ||
file.write(re.sub(MATCH_ALL_XYZ, replace_decimal_values, json.dumps(decoded_json, ensure_ascii=False))) | ||
move_file(path + "/" + folder_name + "/JSON/" + os.path.basename(js_file), path + "/" + folder_name + "/" + os.path.basename(js_file)) | ||
ebm_folder = get_files_with_extension(folder, ".json") | ||
for file in ebm_folder: | ||
print(Fore.GREEN + file + Fore.RESET) | ||
subprocess.run([gust_ebm, file]) | ||
remove_files_with_extension(folder, ".json") | ||
|
||
print(Fore.YELLOW + "Starting Repack!" + Fore.RESET) | ||
pack_json = game_path + "/Data/PACK01/PACK01.json" | ||
subprocess.run([gust_pak, pack_json]) | ||
move_file(pack_path, game_path + "/Data/PACK01.PAK") | ||
move_file(game_path + "/Data/PACK01/PACK01.pak.bak", game_path + "/Data/PACK01.PAK.bak") | ||
print(Fore.GREEN + "\nDone, enjoy :D\n" + Fore.RESET) | ||
print(Fore.YELLOW + "If you ever wanna revert rename PACK01.PAK.bak to PACK01.PAK\n" + Fore.RESET) | ||
exit = input("Press enter to exit.") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
# This file stores functions used on Atelier Transaltor. | ||
|
||
import json | ||
import re | ||
import subprocess | ||
import shutil | ||
import os | ||
import colorama | ||
from colorama import Fore, Style | ||
colorama.init() | ||
|
||
|
||
def start(): | ||
text1 = """ | ||
________ ___ ___ ___ ___ ___ _____ | ||
|\ __ \ |\ \ |\ \|\ \ |\ \ / /|/ __ \ | ||
\ \ \|\ \ \ \ \ \ \ \\\\\ \ \ \ \ / / /\/_|\ \ | ||
\ \ __ \ \ \ \ \ \ \\\\\ \ \ \ \/ / /\|/ \ \ \ | ||
\ \ \ \ \ __\ \ \____ __\ \ \\\\\ \ \ \ / / \ \ \ | ||
\ \__\ \__\\\\__\ \_______\\\\__\ \_______\ \ \__/ / \ \__\\ | ||
\|__|\|__\|__|\|_______\|__|\|_______| \|__|/ \|__| | ||
""" | ||
text2 = """ | ||
-------------------------------------------- | ||
By Ferripro & MisterGunXD | ||
-------------------------------------------- | ||
""" | ||
print(Fore.RESET + text1) | ||
print(text2) | ||
|
||
def get_files_with_extension(folder_path, extension): | ||
for root, dirs, files in os.walk(folder_path): | ||
for file_name in files: | ||
if file_name.endswith(extension): | ||
file_path = os.path.join(root, file_name) | ||
yield file_path | ||
|
||
def replace_hex_values(match): | ||
hex_value = match.group(1) | ||
return str(int(hex_value, 16)) | ||
|
||
def replace_decimal_values(match): | ||
decimal_value = match.group(1) | ||
return hex(int(decimal_value)) | ||
|
||
def get_subfolder_paths(folder_path): | ||
subfolder_paths = [] | ||
for entry in os.listdir(folder_path): | ||
full_path = os.path.join(folder_path, entry) | ||
if os.path.isdir(full_path): | ||
subfolder_paths.append(full_path) | ||
return subfolder_paths | ||
|
||
def get_last_folder_name(path): | ||
normalized_path = os.path.normpath(path) | ||
directories = normalized_path.split(os.sep) | ||
last_folder_name = directories[-1] | ||
|
||
return last_folder_name | ||
|
||
def read_file_to_list(file_path): | ||
content_list = [] | ||
|
||
try: | ||
with open(file_path, 'r', encoding="utf-8") as file: | ||
for line in file: | ||
content_list.append(line.strip()) | ||
|
||
except FileNotFoundError: | ||
print("File not found. Please check the file path and try again.") | ||
except Exception as e: | ||
print(f"An error occurred while reading the file: {e}") | ||
|
||
return content_list | ||
|
||
def remove_files_with_extension(directory_path, file_extension): | ||
try: | ||
for root, dirs, files in os.walk(directory_path): | ||
for file in files: | ||
if file.lower().endswith(file_extension.lower()): | ||
file_path = os.path.join(root, file) | ||
os.remove(file_path) | ||
print(f"Deleted file: {file_path}") | ||
|
||
except FileNotFoundError: | ||
print("Directory not found. Please check the directory path and try again.") | ||
except Exception as e: | ||
print(f"An error occurred while removing files: {e}") | ||
|
||
def move_file(source, destination): | ||
try: | ||
destination_folder = os.path.dirname(destination) | ||
os.makedirs(destination_folder, exist_ok=True) | ||
shutil.move(source, destination) | ||
print(f"File '{source}' moved to '{destination}' successfully.") | ||
except FileNotFoundError: | ||
print(f"File '{source}' not found.") | ||
except shutil.Error as e: | ||
print(f"An error occurred while moving the file: {str(e)}") | ||
except Exception as e: | ||
print(f"An unexpected error occurred: {str(e)}") |