all repos — m12-patcher @ cfe07ba4b9c6d81b80cc98d91d4b0197b2f94676

first commit
Marco Andronaco andronacomarco@gmail.com
Tue, 05 Jul 2022 16:47:38 +0200
commit

cfe07ba4b9c6d81b80cc98d91d4b0197b2f94676

4 files changed, 431 insertions(+), 0 deletions(-)

jump to
A .gitignore

@@ -0,0 +1,4 @@

+__pycache__ +tools +venv +*.gba
A Gui.py

@@ -0,0 +1,95 @@

+#!/usr/bin/python3 +import tkinter as tk +from tkinter.filedialog import askopenfilename +import pathlib, pygubu + +PROJECT_PATH = pathlib.Path(__file__).parent +PROJECT_UI = PROJECT_PATH / "patcher.ui" + +presets = { + "Scelte consigliate": { + 'font': 1, + 'sprites': 3, + 'places': 6, + 'palette': 8, + 'skip_m1': 1 + }, + "EB Beginnings (US)": { + 'font': 1, + 'sprites': 4, + 'places': 6, + 'palette': 8, + 'skip_m1': 1 + }, + "Mother 1 (JP)": { + 'font': 1, + 'sprites': 5, + 'places': 7, + 'palette': 8, + 'skip_m1': 1 + }, + "Mother 1+2": { + 'font': 1, + 'sprites': 4, + 'places': 7, + 'palette': 9, + 'skip_m1': 0 + } +} + +class PatcherApp: + def __init__(self, master=None): + self.builder = builder = pygubu.Builder() + builder.add_resource_path(PROJECT_PATH) + builder.add_from_file(PROJECT_UI) + # Main widget + self.mainwindow = builder.get_object("main_frame", master) + + self.browse_path = None + self.preset = None + self.font = None + self.places = None + self.sprites = None + self.palette = None + self.skip_m1 = None + builder.import_variables( + self, + [ + "browse_path", + "preset", + "font", + "places", + "sprites", + "palette", + "skip_m1", + ], + ) + self.font.set(1) + self.sprites.set(3) + self.places.set(6) + self.palette.set(8) + self.skip_m1.set(1) + + builder.connect_callbacks(self) + + def run(self): + self.mainwindow.mainloop() + + def on_browse_button(self): + fn = askopenfilename(filetypes=[('ROM giapponese di Mother 1+2', '*.gba'), ('Tutti i file', '*')]) + self.browse_path.set(fn) + + def on_change_preset(self, option): + new_vars = presets[option] + + for key in new_vars.keys(): + getattr(self, key).set(new_vars[key]) + + def on_apply_button(self): + pass + + +if __name__ == "__main__": + root = tk.Tk() + app = PatcherApp(root) + app.run()
A patcher.py

@@ -0,0 +1,34 @@

+#!/usr/bin/python3 +import tkinter as tk +import os +from hashlib import md5 +from Gui import PatcherApp + +m12_md5 = 'f41e36204356974c94fabf7d144dd32a' +tools_path = os.path.join('.', 'tools') +alt_path = os.path.join(tools_path, 'alt') + +def check_rom(filename): + with open(filename, 'rb') as f: + file_hash = md5() + while chunk := f.read(8192): + file_hash.update(chunk) + + return file_hash.hexdigest() == m12_md5 + +if __name__ == "__main__": + + if not os.path.isdir(alt_path): + print('\nErrore: รจ necessario estrarre l\'archivio.') + exit() + + baserom = None + for file in os.listdir('.'): + if file.endswith('.gba'): + filename = os.path.join('.', file) + if(check_rom(filename)): + baserom = filename + + root = tk.Tk() + app = PatcherApp(root) + app.run()
A patcher.ui

@@ -0,0 +1,298 @@

+<?xml version='1.0' encoding='utf-8'?> +<interface version="1.2"> + <object class="ttk.Frame" id="main_frame"> + <property name="height">200</property> + <property name="width">200</property> + <layout manager="pack"> + <property name="side">top</property> + </layout> + <child> + <object class="ttk.Labelframe" id="browse_frame"> + <property name="height">200</property> + <property name="text" translatable="yes"> Selezione della ROM </property> + <property name="width">200</property> + <layout manager="grid"> + <property name="column">0</property> + <property name="ipadx">2</property> + <property name="ipady">5</property> + <property name="padx">5</property> + <property name="pady">5</property> + <property name="row">0</property> + <property name="sticky">ew</property> + </layout> + <child> + <object class="ttk.Entry" id="browse_entry"> + <property name="justify">left</property> + <property name="textvariable">string:browse_path</property> + <property name="width">23</property> + <layout manager="pack"> + <property name="fill">x</property> + <property name="padx">3</property> + <property name="pady">5</property> + <property name="side">left</property> + </layout> + </object> + </child> + <child> + <object class="ttk.Button" id="browse_button"> + <property name="command" type="command" cbtype="simple">on_browse_button</property> + <property name="text" translatable="yes">...</property> + <property name="width">2</property> + <layout manager="pack"> + <property name="ipadx">2</property> + <property name="padx">5</property> + <property name="side">right</property> + </layout> + </object> + </child> + </object> + </child> + <child> + <object class="ttk.Labelframe" id="preset_frame"> + <property name="height">200</property> + <property name="text" translatable="yes"> Preset </property> + <property name="width">200</property> + <layout manager="grid"> + <property name="column">1</property> + <property name="ipadx">2</property> + <property name="ipady">2</property> + <property name="padx">5</property> + <property name="pady">5</property> + <property name="row">0</property> + <property name="sticky">ew</property> + </layout> + <child> + <object class="tk.OptionMenu" id="preset_menu"> + <property name="command" type="command" cbtype="simple">on_change_preset</property> + <property name="value">Scelte consigliate</property> + <property name="values">Scelte consigliate,EB Beginnings (US),Mother 1 (JP),Mother 1+2</property> + <property name="variable">string:preset</property> + <layout manager="pack"> + <property name="fill">x</property> + <property name="side">top</property> + </layout> + </object> + </child> + </object> + </child> + <child> + <object class="ttk.Labelframe" id="font_frame"> + <property name="height">200</property> + <property name="text" translatable="yes"> Font </property> + <property name="width">200</property> + <layout manager="grid"> + <property name="column">0</property> + <property name="ipadx">2</property> + <property name="ipady">2</property> + <property name="padx">5</property> + <property name="pady">5</property> + <property name="row">1</property> + <property name="sticky">ew</property> + </layout> + <child> + <object class="ttk.Radiobutton" id="font_serif"> + <property name="text" translatable="yes">Serif (originale)</property> + <property name="value">1</property> + <property name="variable">int:font</property> + <layout manager="pack"> + <property name="anchor">w</property> + <property name="side">top</property> + </layout> + </object> + </child> + <child> + <object class="ttk.Radiobutton" id="font_sans"> + <property name="text" translatable="yes">Sans serif (alternativa di Tomato)</property> + <property name="value">2</property> + <property name="variable">int:font</property> + <layout manager="pack"> + <property name="anchor">w</property> + <property name="side">top</property> + </layout> + </object> + </child> + </object> + </child> + <child> + <object class="ttk.Labelframe" id="places_frame"> + <property name="height">200</property> + <property name="text" translatable="yes"> Nomi dei luoghi </property> + <property name="width">200</property> + <layout manager="grid"> + <property name="column">1</property> + <property name="ipadx">2</property> + <property name="ipady">2</property> + <property name="padx">5</property> + <property name="pady">5</property> + <property name="row">1</property> + <property name="sticky">ew</property> + </layout> + <child> + <object class="ttk.Radiobutton" id="places_us"> + <property name="text" translatable="yes">Americani</property> + <property name="value">6</property> + <property name="variable">int:places</property> + <layout manager="pack"> + <property name="anchor">w</property> + <property name="side">top</property> + </layout> + </object> + </child> + <child> + <object class="ttk.Radiobutton" id="places_jp"> + <property name="text" translatable="yes">Giapponesi</property> + <property name="value">7</property> + <property name="variable">int:places</property> + <layout manager="pack"> + <property name="anchor">w</property> + <property name="side">top</property> + </layout> + </object> + </child> + </object> + </child> + <child> + <object class="ttk.Labelframe" id="sprites_frame"> + <property name="height">200</property> + <property name="text" translatable="yes"> Sprite e tileset </property> + <property name="width">200</property> + <layout manager="grid"> + <property name="column">1</property> + <property name="ipadx">2</property> + <property name="ipady">2</property> + <property name="padx">5</property> + <property name="pady">5</property> + <property name="row">2</property> + <property name="sticky">ew</property> + </layout> + <child> + <object class="ttk.Radiobutton" id="sprites_mix"> + <property name="text" translatable="yes">Misti (aggiornati non censurati)</property> + <property name="value">3</property> + <property name="variable">int:sprites</property> + <layout manager="pack"> + <property name="anchor">w</property> + <property name="side">top</property> + </layout> + </object> + </child> + <child> + <object class="ttk.Radiobutton" id="sprites_us"> + <property name="text" translatable="yes">Aggiornati e censurati (EBB, M1+2)</property> + <property name="value">4</property> + <property name="variable">int:sprites</property> + <layout manager="pack"> + <property name="anchor">w</property> + <property name="side">top</property> + </layout> + </object> + </child> + <child> + <object class="ttk.Radiobutton" id="sprites_jp"> + <property name="text" translatable="yes">Originali (M1)</property> + <property name="value">5</property> + <property name="variable">int:sprites</property> + <layout manager="pack"> + <property name="anchor">w</property> + <property name="side">top</property> + </layout> + </object> + </child> + </object> + </child> + <child> + <object class="ttk.Labelframe" id="palette_frame"> + <property name="height">200</property> + <property name="text" translatable="yes"> Palette dei colori </property> + <property name="width">200</property> + <layout manager="grid"> + <property name="column">0</property> + <property name="ipadx">2</property> + <property name="ipady">2</property> + <property name="padx">5</property> + <property name="pady">5</property> + <property name="row">2</property> + <property name="sticky">ew</property> + </layout> + <child> + <object class="ttk.Radiobutton" id="palette_nes"> + <property name="text" translatable="yes">NES</property> + <property name="value">8</property> + <property name="variable">int:palette</property> + <layout manager="pack"> + <property name="anchor">w</property> + <property name="side">top</property> + </layout> + </object> + </child> + <child> + <object class="ttk.Radiobutton" id="palette_gba"> + <property name="text" translatable="yes">GBA</property> + <property name="value">9</property> + <property name="variable">int:palette</property> + <layout manager="pack"> + <property name="anchor">w</property> + <property name="side">top</property> + </layout> + </object> + </child> + <child> + <object class="ttk.Radiobutton" id="palette_vc"> + <property name="text" translatable="yes">Virtual Console Wii e Wii U</property> + <property name="value">11</property> + <property name="variable">int:palette</property> + <layout manager="pack"> + <property name="anchor">w</property> + <property name="side">top</property> + </layout> + </object> + </child> + </object> + </child> + <child> + <object class="ttk.Labelframe" id="other_frame"> + <property name="height">200</property> + <property name="text" translatable="yes"> Altri miglioramenti </property> + <property name="width">200</property> + <layout manager="grid"> + <property name="column">0</property> + <property name="columnspan">2</property> + <property name="ipadx">2</property> + <property name="ipady">2</property> + <property name="padx">5</property> + <property name="pady">5</property> + <property name="row">3</property> + <property name="sticky">ew</property> + </layout> + <child> + <object class="ttk.Checkbutton" id="skip_m1_check"> + <property name="offvalue">0</property> + <property name="onvalue">1</property> + <property name="text" translatable="yes">Avvia automaticamente Mother 1</property> + <property name="variable">int:skip_m1</property> + <layout manager="pack"> + <property name="anchor">w</property> + <property name="side">top</property> + </layout> + </object> + </child> + </object> + </child> + <child> + <object class="ttk.Button" id="apply_button"> + <property name="command" type="command" cbtype="simple">on_apply_button</property> + <property name="text" translatable="yes">Applica!</property> + <layout manager="grid"> + <property name="column">0</property> + <property name="columnspan">2</property> + <property name="ipadx">2</property> + <property name="ipady">2</property> + <property name="padx">5</property> + <property name="pady">5</property> + <property name="row">4</property> + <property name="sticky">ew</property> + </layout> + </object> + </child> + </object> +</interface>