all repos — m12-patcher @ 3473a55360ab7a11cb56040fa2fdae97e4fc73af

more scalable code
Marco Andronaco andronacomarco@gmail.com
Wed, 06 Jul 2022 16:43:00 +0200
commit

3473a55360ab7a11cb56040fa2fdae97e4fc73af

parent

e3c37d39bb278f21f24f2661ccddd39d5175ca23

4 files changed, 35 insertions(+), 77 deletions(-)

jump to
M Constants.pyConstants.py

@@ -28,32 +28,32 @@ PATH_TOOLS = os.path.join('.', 'tools')

PATH_ALT = os.path.join(PATH_TOOLS, 'alt') PRESETS = { - "Scelte consigliate": { + "Scelte consigliate": { # default preset 'font': 'fonts_og', 'sprites': 'sprites_mix', 'places': 'places_us', - 'palette': 'palette_nes', + 'nes_palette': 'nes_palette_yes', 'skip_m1': 'skip_m1_yes' }, "EB Beginnings (US)": { 'font': 'fonts_og', 'sprites': 'sprites_us', 'places': 'places_us', - 'palette': 'palette_nes', + 'nes_palette': 'nes_palette_yes', 'skip_m1': 'skip_m1_yes' }, "Mother 1 (JP)": { 'font': 'fonts_og', 'sprites': 'sprites_jp', 'places': 'places_jp', - 'palette': 'palette_nes', + 'nes_palette': 'nes_palette_yes', 'skip_m1': 'skip_m1_yes' }, "Mother 1+2": { 'font': 'fonts_og', 'sprites': 'sprites_us', 'places': 'places_jp', - 'palette': 'palette_gba', + 'nes_palette': 'nes_palette_no', 'skip_m1': 'skip_m1_no' } }

@@ -85,10 +85,8 @@ 'places_jp':

['m1_main_text_jp.txt', 'm1_gfx_map_jp.bin'], - 'palette_nes': 'nes.ips', - 'palette_gba': None, - 'palette_ncm': 'ncm.ips', - 'palette_vc': 'vc.ips', + 'nes_palette_yes': 'nes.ips', + 'nes_palette_no': None, 'skip_m1_yes': 'skipm1.ips', 'skip_m1_no': None }

@@ -108,6 +106,9 @@ 'm1_main_text.txt',

'm1_gfx_map.bin' ] } + +DEF_PRESET = next(iter(PRESETS.items())) +DEF_PATCHES = DEF_PRESET[1].keys() - DEF_FILENAMES.keys() OS_SUFFIX = ( '.exe' if platform.startswith('win32') else
M Functions.pyFunctions.py

@@ -43,20 +43,19 @@ def set_progress(app, percent, message):

app.progress.set(percent) app.status_text.set(message) +def read_options(app, output, keys): + for key in keys: + new_option = getattr(app, key).get() + output[key] = Constants.ALT_FILENAMES[new_option] + def start_patching(app): set_progress(app, 20, Constants.STATUS_MD5) delete_list = [] - sel_filenames = { - 'font': Constants.ALT_FILENAMES[app.font.get()], - 'sprites': Constants.ALT_FILENAMES[app.sprites.get()], - 'places': Constants.ALT_FILENAMES[app.places.get()] - } - - sel_patches = { - 'palette': Constants.ALT_FILENAMES[app.palette.get()], - 'skip_m1': Constants.ALT_FILENAMES[app.skip_m1.get()] - } + #sel_filenames = {} + #sel_patches = {} + read_options(app, sel_filenames, Constants.DEF_FILENAMES.keys()) + read_options(app, sel_patches, Constants.DEF_PATCHES) for key in sel_filenames.keys(): sel_list = sel_filenames[key]
M patcher.pypatcher.py

@@ -21,30 +21,30 @@ self.apply_button = builder.get_object("apply_button")

self.browse_path = None self.preset = None + self.progress = None + self.status_text = None self.font = None self.places = None self.sprites = None - self.palette = None + self.nes_palette = None self.skip_m1 = None - self.progress = None - self.status_text = None builder.import_variables( self, [ "browse_path", "preset", + "progress", + "status_text", "font", "places", "sprites", - "palette", + "nes_palette", "skip_m1", - "progress", - "status_text", ], ) self.preset.trace('w', self.on_change_preset) - self.preset.set(next(iter(Constants.PRESETS.keys()))) + self.preset.set(Constants.DEF_PRESET[0]) self.status_text.set(Constants.STATUS_START) baserom = None
M patcher.uipatcher.ui

@@ -169,7 +169,7 @@ <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="column">0</property> <property name="ipadx">2</property> <property name="ipady">2</property> <property name="padx">5</property>

@@ -219,12 +219,12 @@ </child>

</object> </child> <child> - <object class="ttk.Labelframe" id="palette_frame"> + <object class="ttk.Labelframe" id="other_frame"> <property name="height">200</property> - <property name="text" translatable="yes"> Palette dei colori </property> + <property name="text" translatable="yes"> Altri miglioramenti </property> <property name="width">200</property> <layout manager="grid"> - <property name="column">0</property> + <property name="column">1</property> <property name="ipadx">2</property> <property name="ipady">2</property> <property name="padx">5</property>

@@ -233,36 +233,11 @@ <property name="row">2</property>

<property name="sticky">new</property> </layout> <child> - <object class="ttk.Radiobutton" id="palette_nes"> - <property name="text" translatable="yes">NES</property> - <property name="value">palette_nes</property> - <property name="variable">string:palette</property> - <layout manager="pack"> - <property name="anchor">w</property> - <property name="padx">5</property> - <property name="pady">1</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">palette_gba</property> - <property name="variable">string:palette</property> - <layout manager="pack"> - <property name="anchor">w</property> - <property name="padx">5</property> - <property name="pady">1</property> - <property name="side">top</property> - </layout> - </object> - </child> - <child> - <object class="ttk.Radiobutton" id="palette_ncm"> - <property name="text" translatable="yes">Nintendo Classic Mini - NES</property> - <property name="value">palette_ncm</property> - <property name="variable">string:palette</property> + <object class="ttk.Checkbutton" id="nes_palette_check"> + <property name="offvalue">nes_palette_no</property> + <property name="onvalue">nes_palette_yes</property> + <property name="text" translatable="yes">Palette NES</property> + <property name="variable">string:nes_palette</property> <layout manager="pack"> <property name="anchor">w</property> <property name="padx">5</property>

@@ -271,23 +246,6 @@ <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">skip_m1_no</property>