Skip to content

Commit

Permalink
Disable options when patches are present
Browse files Browse the repository at this point in the history
To prevent inconsistent patch states by mix and matching options, mainly
the scale and filters.
  • Loading branch information
lah7 committed Jul 16, 2024
1 parent 8b55f35 commit 298e502
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions sims2_4k_ui_patcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,27 +250,30 @@ def __init__(self, *args, **kwargs):
if self.tk.call("tk", "windowingsystem") == 'win32':
self.iconbitmap(get_resource("assets/icon.ico"))

# Try the default paths
for path in DEFAULT_PATHS:
if os.path.exists(path):
self.input_dir.insert(0, path)
self.game_install_dir = path
self.refresh_patch_state()
break

# A list of controls that should be disabled when in progress
self.controls = [
self.input_dir,
self.btn_browse,
# A list of controls for selecting options
self.options = [
self.scale_label,
self.scale_option,
self.filter_label,
self.filter_option,
self.compress_option,
self.btn_patch,
]

# A list of controls that should be disabled when in progress
self.controls = [
self.input_dir,
self.btn_browse,
self.btn_patch,
] + self.options

# Show time!
for path in DEFAULT_PATHS:
if os.path.exists(path):
self.input_dir.insert(0, path)
self.game_install_dir = path
self.refresh_patch_state()
break

self.update()
self._check_for_updates()

Expand Down Expand Up @@ -305,7 +308,6 @@ def create_options(self):

self.options_label = self.widgets.make_label(self.frame_options, "Options", colour=self.widgets.colour_fg_alt)
self.options_label.grid(row=0, column=0, padx=8, pady=2, columnspan=2, sticky=tk.W)
self.options = []

self.scale_label = self.widgets.make_label(self.frame_options, "Scale:")
self.scale_option = self.widgets.make_combo(self.frame_options, list(LABELS_UI_SCALE.keys()))
Expand Down Expand Up @@ -511,6 +513,10 @@ def refresh_patch_state(self):
any_outdated = any(file.patch_outdated for file in self.game_files)
partially_patched = not all_patched and any(file.patched for file in self.game_files)

for widget in self.options:
# Disable options when files are patched, to avoid inconsistencies
self.widgets.set_enabled(widget, count_patched == 0)

if all_patched and all_backed_up:
self.set_status_primary("Patched", 2)
self.set_status_secondary(f"{count_patched} files patched")
Expand Down

0 comments on commit 298e502

Please sign in to comment.