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,11 +1,13 @@
import os
import threading
from pkgutil import get_data
from typing import Dict, Any
import bsdiff4
import Utils
import settings
import typing
from typing import NamedTuple, Union, Dict, Any
from BaseClasses import Item, Location, Region, Entrance, MultiWorld, ItemClassification, Tutorial
from .ItemPool import generate_itempool, starting_weapons, dangerous_weapon_locations
from .Items import item_table, item_prices, item_game_ids
@@ -18,6 +20,28 @@ from worlds.AutoWorld import World, WebWorld
from worlds.generic.Rules import add_rule
class TLoZSettings(settings.Group):
class RomFile(settings.UserFilePath):
"""File name of the Zelda 1"""
description = "The Legend of Zelda (U) ROM File"
copy_to = "Legend of Zelda, The (U) (PRG0) [!].nes"
md5s = [TLoZDeltaPatch.hash]
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 .nes file with
"""
class DisplayMsgs(settings.Bool):
"""Display message inside of Bizhawk"""
rom_file: RomFile = RomFile(RomFile.copy_to)
rom_start: typing.Union[RomStart, bool] = True
display_msgs: typing.Union[DisplayMsgs, bool] = True
class TLoZWeb(WebWorld):
theme = "stone"
setup = Tutorial(
@@ -40,6 +64,7 @@ class TLoZWorld(World):
every time.
"""
option_definitions = tloz_options
settings: typing.ClassVar[TLoZSettings]
game = "The Legend of Zelda"
topology_present = False
data_version = 1