Skip to content

Commit

Permalink
Implement #1984: Set "save settings to palette" to match the selected…
Browse files Browse the repository at this point in the history
… palette.
  • Loading branch information
TeamSpen210 committed Oct 11, 2023
1 parent fd439b3 commit ff7f56e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* Moved various palette-related buttons, to group them with the other palette options.
* A VPK file can be now placed into `vpk_override` to have it be combined with the built VPK.
* Added a warning screen to the developer tab of the options window, indicating that some of these options can temporarily break BEE if changed.
* #1984: The "save settings to palette" will now change to match the selected palette. This means clicking "save" won't accidentally delete saved settings.

### UCP-Relevant Changes:
* Terminology change: "Condition Flags" have been renamed to "Condition Tests" - I think that sounds a bit better.
Expand Down
27 changes: 18 additions & 9 deletions src/app/paletteUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ async def event_remove(self, dialogs: Dialogs) -> None:
):
pal.delete_from_disk()
del self.palettes[pal.uuid]
self.select_palette(UUID_PORTAL2)
self.select_palette(UUID_PORTAL2, False)
self.update_state()
background_run(self.set_items, self.selected)

Expand Down Expand Up @@ -373,7 +373,7 @@ async def event_save_as(self, dialogs: Dialogs) -> None:

pal.save()
self.palettes[pal.uuid] = pal
self.select_palette(pal.uuid)
self.select_palette(pal.uuid, False)
self.update_state()

async def event_rename(self, dialogs: Dialogs) -> None:
Expand All @@ -387,13 +387,22 @@ async def event_rename(self, dialogs: Dialogs) -> None:
self.selected.name = TransToken.untranslated(name)
self.update_state()

def select_palette(self, uuid: UUID) -> None:
"""Select a new palette. This does not update items/settings!"""
if uuid in self.palettes:
def select_palette(self, uuid: UUID, set_save_settings: bool) -> None:
"""Select a new palette.
This does not update items/settings! It does override the "save settings" checkbox
to match the palette optionally, though.
"""
try:
pal = self.palettes[uuid]
except KeyError:
LOGGER.warning('Unknown UUID {}!', uuid.hex)
else:
self.selected_uuid = uuid
if set_save_settings and not pal.readonly:
# Propagate the save-settings option to the palette, so saving does the same thing.
self.var_save_settings.set(pal.settings is not None)
self._store_configuration()
else:
LOGGER.warning('Unknown UUID {}!', uuid.hex)

async def event_change_group(self, dialogs: Dialogs) -> None:
"""Change the group of a palette."""
Expand All @@ -412,7 +421,7 @@ async def event_change_group(self, dialogs: Dialogs) -> None:
async def event_select_menu(self) -> None:
"""Called when the menu buttons are clicked."""
uuid_hex = self.var_pal_select.get()
self.select_palette(UUID(hex=uuid_hex))
self.select_palette(UUID(hex=uuid_hex), True)
await self.set_items(self.selected)
self.update_state()

Expand All @@ -423,7 +432,7 @@ async def event_select_tree(self) -> None:
except IndexError: # No selection, exit.
return
self.var_pal_select.set(uuid_hex)
self.select_palette(UUID(hex=uuid_hex))
self.select_palette(UUID(hex=uuid_hex), True)
await self.set_items(self.selected)
self.update_state()

Expand Down

0 comments on commit ff7f56e

Please sign in to comment.