Skip to content

Commit

Permalink
Added a WIP GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
bamhm182 committed May 8, 2019
1 parent b0e5808 commit 7376cb2
Show file tree
Hide file tree
Showing 14 changed files with 257 additions and 107 deletions.
175 changes: 125 additions & 50 deletions .idea/workspace.xml

Large diffs are not rendered by default.

119 changes: 71 additions & 48 deletions FinTrinity.py
Original file line number Diff line number Diff line change
@@ -1,50 +1,73 @@
import sys
import shutil
import Utils
from User import User
from Game import Game

try:
apps_path = Utils.read_hkcu(r"Software\codestation\qcma", 'appsPath') + '/PGAME'
account = Utils.read_hkcu(r"Software\codestation\qcma", 'lastAccountId')
username = Utils.read_hkcu(r"Software\codestation\qcma", 'lastOnlineId')
user = User()
game = Game()

if username and account:
user.set_id(account)
user.set_name(username)
user.set_path(apps_path)
game = user.games[0]

if input(f"{game.title} ({game.id}) found for {user.name} ({user.id}). Continue? (yes/no): ")[0] != "y":
sys.exit("Aborted by User")

working_dir = Utils.make_dir(f"{Utils.get_home()}/Desktop/FinTrinity{Utils.get_timestamp()}")
hack_dir = Utils.make_dir(working_dir / f"{game.id}.hacked")
decrypt_dir = working_dir / f"{game.id}.decrypted"
backup_dir = working_dir / f"{game.id}.backup"
print(f"Created Working Directory: {working_dir}")

# Backup Game
shutil.copytree(game.path, backup_dir)
shutil.copytree(game.path, decrypt_dir)

# Download Dependencies
print(f"Downloading and Extracting Dependencies")
Utils.download('https://github.com/TheOfficialFloW/Trinity/releases/download/v1.0/PBOOT.PBP', working_dir)
Utils.download('https://github.com/yifanlu/psvimgtools/releases/download/v0.1/psvimgtools-0.1-win64.zip',
working_dir)
Utils.extract(f'{working_dir}/psvimgtools-0.1-win64.zip', decrypt_dir)

# Hack
print(f"Applying Trinity Hack:\n\n\n")
Utils.decrypt_game(user.decrypt_key, decrypt_dir, working_dir / "PBOOT.PBP", game.id)
Utils.encrypt_game(user.decrypt_key, decrypt_dir, hack_dir)
Utils.replace_folder(hack_dir, game.path)

print(f"\n\n\nTrinity Applied. Please refresh your QCMA database and transfer your game back to your Vita.")
except SystemExit:
pass
finally:
input("[PRESS ENTER TO CLOSE]")
from classes import Utils
from classes.User import User
from classes.Game import Game


class FinTrinity:
def __init__(self):
self.apps_path = ""
self.working_dir = ""
self.hack_dir = ""
self.decrypt_dir = ""
self.backup_dir = ""
self.user = User()
self.game = Game()

def read_registry(self):
self.apps_path = Utils.read_hkcu(r"Software\codestation\qcma", 'appsPath') + '/PGAME'
account = Utils.read_hkcu(r"Software\codestation\qcma", 'lastAccountId')
username = Utils.read_hkcu(r"Software\codestation\qcma", 'lastOnlineId')

if username and account:
self.user.set_id(account)
self.user.set_name(username)
self.user.set_path(self.apps_path)
self.game = self.user.games[0]

def confirm_find(self):
ans = input(
f"{self.game.title} ({self.game.id}) found for {self.user.name} ({self.user.id}). Continue? (yes/no): ")
if ans[0] != "y" and ans[0] != "Y":
sys.exit("Aborted by User")

def setup_dirs(self):
self.working_dir = Utils.make_dir(f"{Utils.get_home()}/Desktop/FinTrinity{Utils.get_timestamp()}")
self.hack_dir = Utils.make_dir(self.working_dir / f"{self.game.id}.hacked")
self.decrypt_dir = self.working_dir / f"{self.game.id}.decrypted"
self.backup_dir = self.working_dir / f"{self.game.id}.backup"
print(f"Created Working Directory: {self.working_dir}")

def backup_game(self):
shutil.copytree(self.game.path, self.backup_dir)
shutil.copytree(self.game.path, self.decrypt_dir)

def download_dependencies(self):
print(f"Downloading and Extracting Dependencies")
Utils.download('https://github.com/TheOfficialFloW/Trinity/releases/download/v1.0/PBOOT.PBP', self.working_dir)
Utils.download('https://github.com/yifanlu/psvimgtools/releases/download/v0.1/psvimgtools-0.1-win64.zip',
self.working_dir)
Utils.extract(f'{self.working_dir}/psvimgtools-0.1-win64.zip', self.decrypt_dir)

def hack(self):
print(f"Applying Trinity Hack:\n\n\n")
Utils.decrypt_game(self.user.decrypt_key, self.decrypt_dir, self.working_dir / "PBOOT.PBP", self.game.id)
Utils.encrypt_game(self.user.decrypt_key, self.decrypt_dir, self.hack_dir)
Utils.replace_folder(self.hack_dir, self.game.path)
print(f"\n\n\nTrinity Applied. Please refresh your QCMA database and transfer your game back to your Vita.")


if __name__ == "__main__":
try:
fin = FinTrinity()
fin.read_registry()
fin.confirm_find()
fin.setup_dirs()
fin.backup_game()
fin.download_dependencies()
fin.hack()
except SystemExit:
pass
finally:
input("[PRESS ENTER TO CLOSE]")
49 changes: 49 additions & 0 deletions GUI.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
from tkinter import *
from FinTrinity import FinTrinity
from time import sleep

class GUI:
def __init__(self):
self.fin = FinTrinity()
self.fin.read_registry()

self.window = Tk()
self.window.title("FinTrinity")
self.window.minsize(250, 0)

lbl_info = Label(self.window, text="I was able to find this game!\nPlease confirm it is correct.")
lbl_info.pack(pady=10)

lbl_username = Label(self.window, text=f"{self.fin.user.name} ({self.fin.user.id})")
lbl_username.pack()

lbl_game = Label(self.window, text=f"{self.fin.game.title} ({self.fin.game.id})")
lbl_game.pack()

canvas_game = Canvas(self.window, width=144, height=80)
canvas_game.pack()
img = PhotoImage(file=self.fin.game.image)
canvas_game.create_image(0, 0, anchor=NW, image=img)

self.txt_btn_confirm = StringVar()
self.txt_btn_confirm.set("Confirm")

btn_confirm = Button(self.window, textvariable=self.txt_btn_confirm, command=self.click_confirm)
btn_confirm.pack(pady=10)

self.window.mainloop()

def click_confirm(self):
if self.txt_btn_confirm.get() == "Confirm":
self.txt_btn_confirm.set("Patching...")
self.window.update()
self.fin.setup_dirs()
self.fin.backup_game()
self.fin.download_dependencies()
self.fin.hack()
self.txt_btn_confirm.set("Finished!")
lbl_refresh = Label(self.window, text="Please refresh your QCMA database!")
lbl_refresh.pack(pady=10)


gui = GUI()
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@ If you do use this, PLEASE make a backup of your game folder first.
This is currently only for Windows. I have tested it with Windows 10 and the latest version of QCMA (v0.4.1)

To use it, you will need to have [python 3.7.3](https://www.python.org/downloads/) installed and in your path. If you
download it and run through the installer, you should be good to go. Make sure you select to add it to your path as it
is not default. After you have python 3.7 installed, you should be able to download this git repository as a zip and
double click on FinTrinity.py.
download it and run through the installer, you should be good to go. Once you have that installed,
[download the zip](https://github.com/bamhm182/FinTrinity/archive/master.zip) of this repository and double click on
either FinTrinity.py or GUI.py


# Testing
# Screenshots
![GUI Screenshot 1](resources/gui-1.jpg)
![GUI Screenshot 2](resources/gui-2.jpg)
![CLI Screenshot](resources/cli.jpg)

If it works for you, please let me know. If you're interested in helping me figure out how to make it work for macOS and
Linux, let me know.

Thanks!
# TODO
* Prettier GUI
* Ability to select from a list of games in the GUI
* macOS and Linux support
Binary file added __pycache__/FinTrinity.cpython-37.pyc
Binary file not shown.
File renamed without changes.
2 changes: 1 addition & 1 deletion User.py → classes/User.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from urllib import request
from re import findall
import os
from Game import Game
from classes.Game import Game


class User:
Expand Down
File renamed without changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added resources/cli.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/gui-1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/gui-2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7376cb2

Please sign in to comment.