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

@@ -2,6 +2,8 @@ import logging
import threading
import copy
import functools
import settings
import typing
from typing import Optional, List, AbstractSet, Union # remove when 3.8 support is dropped
from collections import Counter, deque
from string import printable
@@ -66,6 +68,28 @@ class OOTCollectionState(metaclass=AutoLogicRegister):
return ret
class OOTSettings(settings.Group):
class RomFile(settings.UserFilePath):
"""File name of the OoT v1.0 ROM"""
description = "Ocarina of Time ROM File"
copy_to = "The Legend of Zelda - Ocarina of Time.z64"
md5s = [
"5bd1fe107bf8106b2ab6650abecd54d6", # normal
"6697768a7a7df2dd27a692a2638ea90b", # byte-swapped
"05f0f3ebacbc8df9243b6148ffe4792f", # decompressed
]
class RomStart(str):
"""
Set this to false to never autostart a rom (such as after patching),
true for operating system default program
Alternatively, a path to a program to open the .z64 file with
"""
rom_file: RomFile = RomFile(RomFile.copy_to)
rom_start: typing.Union[RomStart, bool] = True
class OOTWeb(WebWorld):
setup = Tutorial(
"Multiworld Setup Tutorial",
@@ -105,6 +129,7 @@ class OOTWorld(World):
"""
game: str = "Ocarina of Time"
option_definitions: dict = oot_options
settings: typing.ClassVar[OOTSettings]
topology_present: bool = True
item_name_to_id = {item_name: oot_data_to_ap_id(data, False) for item_name, data in item_table.items() if
data[2] is not None and item_name not in {