Skip to content

Commit

Permalink
Merge 'Store settings versioning names to avoid breaking plandomizers…
Browse files Browse the repository at this point in the history
… when renaming a setting' (#1839)

# Conflicts:
#	Plandomizer.py
#	Settings.py
#	SettingsList.py
  • Loading branch information
fenhl committed Sep 30, 2024
2 parents 2ab2a22 + 3845386 commit 1adaaeb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
6 changes: 5 additions & 1 deletion Plandomizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from Location import Location, LocationIterator, LocationFactory
from LocationList import location_groups, location_table
from Search import Search
from SettingsList import build_close_match, validate_settings
from SettingsList import build_close_match, validate_settings, settings_versioning
from Spoiler import Spoiler, HASH_ICONS, PASSWORD_NOTES
from version import __version__

Expand Down Expand Up @@ -1176,6 +1176,10 @@ def __init__(self, settings: Settings, src_dict: Optional[dict[str, Any]] = None

self.settings.update(update_dict['_settings'])
if 'settings' in self.src_dict:
for setting in self.src_dict['settings']:
for setting_version in settings_versioning:
if setting == setting_version.old_name:
self.src_dict['settings'][setting_version.new_name] = self.src_dict['settings'].pop(setting_version.old_name)
validate_settings(self.src_dict['settings'])
self.src_dict['_settings'] = self.src_dict['settings']
del self.src_dict['settings']
Expand Down
6 changes: 5 additions & 1 deletion Settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import StartingItems
from version import __version__
from Utils import local_path, data_path
from SettingsList import SettingInfos, validate_settings
from SettingsList import SettingInfos, validate_settings, settings_versioning
from Plandomizer import Distribution

LEGACY_STARTING_ITEM_SETTINGS: dict[str, dict[str, StartingItems.Entry]] = {
Expand Down Expand Up @@ -76,6 +76,10 @@ class Settings(SettingInfos):
def __init__(self, settings_dict: dict[str, Any], strict: bool = False) -> None:
super().__init__()
self.numeric_seed: Optional[int] = None
for setting in settings_dict:
for setting_version in settings_versioning:
if setting == setting_version.old_name:
settings_dict[setting_version.new_name] = settings_dict.pop(setting_version.old_name)
if settings_dict.get('compress_rom', None):
# Old compress_rom setting is set, so set the individual output settings using it.
settings_dict['create_patch_file'] = settings_dict['compress_rom'] == 'Patch' or settings_dict.get('create_patch_file', False)
Expand Down
12 changes: 12 additions & 0 deletions SettingsList.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@
if TYPE_CHECKING:
from Entrance import Entrance

# Old/New name of a setting
class Setting_Info_Versioning:
def __init__(self, old_name, new_name):
self.old_name = old_name # old name of the setting
self.new_name = new_name # new name of the setting

settings_versioning = [
Setting_Info_Versioning(
old_name = '',
new_name = '',
),
]

class SettingInfos:
# Internal & Non-GUI Settings
Expand Down
2 changes: 1 addition & 1 deletion version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '8.2.2'
__version__ = '8.2.3'

# This is a supplemental version number for branches based off of main dev.
supplementary_version = 0
Expand Down

0 comments on commit 1adaaeb

Please sign in to comment.