Core: Add settings API ("auto settings") for host.yaml (#1871)

* Add settings API ("auto settings") for host.yaml

* settings: no BOM when saving

* settings: fix saving / groups resetting themselves

* settings: fix AutoWorldRegister import

Co-authored-by: el-u <109771707+el-u@users.noreply.github.com>

* Lufia2: settings: clean up imports

* settings: more consistent class naming

* Docs: update world api for settings api refactor

* settings: fix access from World instance

* settings: update migration timeline

* Docs: Apply suggestions from code review

Co-authored-by: Zach Parks <zach@alliware.com>

* Settings: correctly resolve .exe in UserPath and LocalPath

---------

Co-authored-by: el-u <109771707+el-u@users.noreply.github.com>
Co-authored-by: Zach Parks <zach@alliware.com>
This commit is contained in:
black-sliver
2023-07-05 22:39:35 +02:00
committed by GitHub
parent d8a8997684
commit 827444f5a4
34 changed files with 1455 additions and 412 deletions

View File

@@ -1,6 +1,7 @@
import logging
import os
import random
import settings
import threading
import typing
@@ -29,6 +30,16 @@ lttp_logger = logging.getLogger("A Link to the Past")
extras_list = sum(difficulties['normal'].extras[0:5], [])
class ALTTPSettings(settings.Group):
class RomFile(settings.SNESRomPath):
"""File name of the v1.0 J rom"""
description = "ALTTP v1.0 J ROM File"
copy_to = "Zelda no Densetsu - Kamigami no Triforce (Japan).sfc"
md5s = [LttPDeltaPatch.hash]
rom_file: RomFile = RomFile(RomFile.copy_to)
class ALTTPWeb(WebWorld):
setup_en = Tutorial(
"Multiworld Setup Tutorial",
@@ -123,6 +134,8 @@ class ALTTPWorld(World):
"""
game = "A Link to the Past"
option_definitions = alttp_options
settings_key = "lttp_options"
settings: typing.ClassVar[ALTTPSettings]
topology_present = True
item_name_groups = item_name_groups
location_name_groups = {
@@ -219,9 +232,16 @@ class ALTTPWorld(World):
create_items = generate_itempool
enemizer_path: str = Utils.get_options()["generator"]["enemizer_path"] \
if os.path.isabs(Utils.get_options()["generator"]["enemizer_path"]) \
else Utils.local_path(Utils.get_options()["generator"]["enemizer_path"])
_enemizer_path: typing.ClassVar[typing.Optional[str]] = None
@property
def enemizer_path(self) -> str:
# TODO: directly use settings
cls = self.__class__
if cls._enemizer_path is None:
cls._enemizer_path = settings.get_settings().generator.enemizer_path
assert isinstance(cls._enemizer_path, str)
return cls._enemizer_path
# custom instance vars
dungeon_local_item_names: typing.Set[str]