import os import sys import hashlib import zipfile import shutil import tkinter as tk from tkinter import filedialog, messagebox, ttk from PIL import Image, ImageTk EXPECTED_HASH = "D554FCC8EBBF78D40734020A52F91900C489C979DE5B83143829801266774C46" def get_resource_path(relative_path): if hasattr(sys, '_MEIPASS'): return os.path.join(sys._MEIPASS, relative_path) return os.path.join(os.path.abspath("."), relative_path) class PatcherApp: def __init__(self, root): self.root = root self.root.title("TheHouse2Vita-Patcher-v1.0") self.root.geometry("640x520") self.root.resizable(False, False) self.root.configure(bg="#0f0f12") # Set Window Icon icon_path = get_resource_path(os.path.join("patcher_assets", "icon.png")) if not os.path.exists(icon_path): icon_path = os.path.abspath("assets/Patcher/icon.png") if os.path.exists(icon_path): try: icon_img = ImageTk.PhotoImage(Image.open(icon_path)) self.root.iconphoto(True, icon_img) except Exception: pass self.selected_apk = "" # Style configuration style = ttk.Style() style.theme_use("clam") style.configure("TProgressbar", thickness=14, troughcolor="#222228", background="#dc2626") # Header Frame with Branding header_frame = tk.Frame(root, bg="#0f0f12") header_frame.pack(fill="x", pady=(18, 10)) # Logos Frame logos_frame = tk.Frame(header_frame, bg="#0f0f12") logos_frame.pack() # Load Game Logos th1_path = get_resource_path(os.path.join("patcher_assets", "TheHouse.png")) if not os.path.exists(th1_path): th1_path = os.path.abspath("assets/Patcher/TheHouse.png") th2_path = get_resource_path(os.path.join("patcher_assets", "TheHouse2.png")) if not os.path.exists(th2_path): th2_path = os.path.abspath("assets/Patcher/TheHouse2.png") self.img_th1 = None self.img_th2 = None if os.path.exists(th1_path): try: img1 = Image.open(th1_path) img1.thumbnail((140, 60)) self.img_th1 = ImageTk.PhotoImage(img1) lbl_img1 = tk.Label(logos_frame, image=self.img_th1, bg="#0f0f12") lbl_img1.pack(side="left", padx=15) except Exception: pass if os.path.exists(th2_path): try: img2 = Image.open(th2_path) img2.thumbnail((160, 60)) self.img_th2 = ImageTk.PhotoImage(img2) lbl_img2 = tk.Label(logos_frame, image=self.img_th2, bg="#0f0f12") lbl_img2.pack(side="left", padx=15) except Exception: pass # Text Header title_label = tk.Label( header_frame, text="The House 1 and 2", font=("Segoe UI", 18, "bold"), fg="#ef4444", bg="#0f0f12" ) title_label.pack(pady=(6, 0)) subtitle_label = tk.Label( header_frame, text="PS Vita", font=("Segoe UI", 11, "bold"), fg="#9ca3af", bg="#0f0f12" ) subtitle_label.pack(pady=(0, 10)) # Main Content Box card = tk.Frame(root, bg="#1e1e24", bd=1, relief="solid") card.pack(padx=22, pady=0, fill="both", expand=True) # Step 1: Select APK apk_header = tk.Label( card, text="1. Select game.apk (Original Game Jolt APK):", font=("Segoe UI", 9, "bold"), fg="#f4f4f5", bg="#1e1e24" ) apk_header.pack(anchor="w", padx=15, pady=(15, 4)) apk_frame = tk.Frame(card, bg="#1e1e24") apk_frame.pack(fill="x", padx=15, pady=0) self.apk_entry = tk.Entry( apk_frame, font=("Segoe UI", 9), bg="#0f0f12", fg="#a1a1aa", insertbackground="white", bd=1, relief="solid" ) self.apk_entry.pack(side="left", fill="x", expand=True, ipady=4, padx=(0, 8)) browse_btn = tk.Button( apk_frame, text="Browse...", font=("Segoe UI", 9, "bold"), bg="#3f3f46", fg="white", activebackground="#52525b", activeforeground="white", bd=0, padx=12, pady=3, command=self.browse_apk ) browse_btn.pack(side="right") # Status Hash Label self.status_label = tk.Label( card, text="Waiting for APK file selection...", font=("Segoe UI", 8), fg="#71717a", bg="#1e1e24" ) self.status_label.pack(anchor="w", padx=15, pady=(4, 12)) # Step 2: Output Destination out_header = tk.Label( card, text="2. Output Destination:", font=("Segoe UI", 9, "bold"), fg="#f4f4f5", bg="#1e1e24" ) out_header.pack(anchor="w", padx=15, pady=(0, 4)) out_frame = tk.Frame(card, bg="#1e1e24") out_frame.pack(fill="x", padx=15, pady=0) self.out_entry = tk.Entry( out_frame, font=("Segoe UI", 9), bg="#0f0f12", fg="#f4f4f5", insertbackground="white", bd=1, relief="solid" ) self.out_entry.insert(0, os.path.abspath("thehouse2")) self.out_entry.pack(side="left", fill="x", expand=True, ipady=4, padx=(0, 8)) out_btn = tk.Button( out_frame, text="Browse...", font=("Segoe UI", 9, "bold"), bg="#3f3f46", fg="white", activebackground="#52525b", activeforeground="white", bd=0, padx=12, pady=3, command=self.browse_output ) out_btn.pack(side="right") # Progress bar self.progress = ttk.Progressbar(card, style="TProgressbar", mode="determinate") self.progress.pack(fill="x", padx=15, pady=(16, 10)) # Action Button self.generate_btn = tk.Button( card, text="GENERATE DATA FOLDER", font=("Segoe UI", 10, "bold"), bg="#dc2626", fg="white", activebackground="#b91c1c", activeforeground="white", bd=0, pady=8, command=self.generate_data ) self.generate_btn.pack(fill="x", padx=15, pady=(0, 15)) def browse_apk(self): filename = filedialog.askopenfilename( title="Select game.apk", filetypes=[("APK Files", "*.apk"), ("All Files", "*.*")] ) if filename: self.selected_apk = filename self.apk_entry.delete(0, tk.END) self.apk_entry.insert(0, filename) self.validate_apk(filename) def validate_apk(self, path): if not os.path.exists(path): self.status_label.config(text="File not found.", fg="#ef4444") return False self.status_label.config(text="Computing SHA-256 hash...", fg="#f59e0b") self.root.update_idletasks() sha256 = hashlib.sha256() with open(path, "rb") as f: while chunk := f.read(65536): sha256.update(chunk) actual_hash = sha256.hexdigest().upper() if actual_hash == EXPECTED_HASH: self.status_label.config(text="✓ Compatible Original APK (SHA-256 OK)", fg="#22c55e") return True else: self.status_label.config( text=f"⚠ Incompatible Hash: {actual_hash[:12]}...", fg="#ef4444" ) return False def browse_output(self): folder = filedialog.askdirectory(title="Select output folder for thehouse2") if folder: out_path = os.path.join(folder, "thehouse2") self.out_entry.delete(0, tk.END) self.out_entry.insert(0, out_path) def generate_data(self): apk_path = self.apk_entry.get().strip() out_path = self.out_entry.get().strip() if not apk_path or not os.path.exists(apk_path): messagebox.showerror("Error", "Please select a valid APK file.") return if not self.validate_apk(apk_path): if not messagebox.askyesno( "Compatibility Warning", "The selected APK hash does not match the tested Game Jolt version.\n\nDo you want to proceed anyway?" ): return try: self.progress["value"] = 10 self.generate_btn.config(state="disabled", text="PROCESSING...") self.root.update_idletasks() os.makedirs(out_path, exist_ok=True) # Step 1: Copy game.apk self.progress["value"] = 25 dest_apk = os.path.join(out_path, "game.apk") shutil.copy2(apk_path, dest_apk) self.root.update_idletasks() # Step 2: Extract libcocos2dcpp.so and full assets folder from APK self.progress["value"] = 50 so_extracted = False with zipfile.ZipFile(apk_path, "r") as z: members = z.namelist() so_entry = "lib/armeabi/libcocos2dcpp.so" for member in members: if member == so_entry: z.extract(member, path=out_path) extracted_so = os.path.join(out_path, "lib", "armeabi", "libcocos2dcpp.so") target_so = os.path.join(out_path, "libcocos2dcpp.so") if os.path.exists(extracted_so): shutil.move(extracted_so, target_so) shutil.rmtree(os.path.join(out_path, "lib"), ignore_errors=True) so_extracted = True elif member.startswith("assets/"): z.extract(member, path=out_path) if not so_extracted: raise Exception("lib/armeabi/libcocos2dcpp.so not found in APK.") # Step 3: Apply embedded patch assets (converted OpenAL OGG audio & fixed BG_IntroScene.png) self.progress["value"] = 85 self.root.update_idletasks() patch_assets = get_resource_path("patcher_assets") assets_dir = os.path.join(out_path, "assets") if os.path.exists(patch_assets): # Copy Sound OGGs sound_src = os.path.join(patch_assets, "Sound") sound_dst = os.path.join(assets_dir, "Sound") if os.path.exists(sound_src): os.makedirs(sound_dst, exist_ok=True) for item in os.listdir(sound_src): s_item = os.path.join(sound_src, item) d_item = os.path.join(sound_dst, item) shutil.copy2(s_item, d_item) # Copy BG_IntroScene.png bg_intro_src = os.path.join(patch_assets, "BG_IntroScene.png") bg_intro_dst = os.path.join(assets_dir, "Background", "BG_IntroScene.png") if os.path.exists(bg_intro_src): os.makedirs(os.path.dirname(bg_intro_dst), exist_ok=True) shutil.copy2(bg_intro_src, bg_intro_dst) self.progress["value"] = 100 self.root.update_idletasks() messagebox.showinfo( "Success!", f"Data folder 'thehouse2' (with game.apk, libcocos2dcpp.so, and full assets) generated successfully at:\n{out_path}\n\n" "INSTRUCTIONS FOR PLAYSTATION VITA:\n" "1. Install 'TheHouse1And2-v1.0.vpk' using VitaShell.\n" "2. Copy the entire 'thehouse2' folder to 'ux0:data/' on your PS Vita.\n\n" "Enjoy the game!" ) except Exception as e: messagebox.showerror("Extraction Error", f"An error occurred while generating data:\n{str(e)}") finally: self.progress["value"] = 0 self.generate_btn.config(state="normal", text="GENERATE DATA FOLDER") def main(): root = tk.Tk() app = PatcherApp(root) root.mainloop() if __name__ == "__main__": main()