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

@@ -3,6 +3,8 @@ import copy
import itertools
import math
import os
import settings
import typing
from enum import IntFlag
from typing import Any, ClassVar, Dict, List, Optional, Set, Tuple
@@ -31,6 +33,42 @@ from worlds.LauncherComponents import Component, components, SuffixIdentifier
components.append(Component('Adventure Client', 'AdventureClient', file_identifier=SuffixIdentifier('.apadvn')))
class AdventureSettings(settings.Group):
class RomFile(settings.UserFilePath):
"""
File name of the standard NTSC Adventure rom.
The licensed "The 80 Classic Games" CD-ROM contains this.
It may also have a .a26 extension
"""
copy_to = "ADVNTURE.BIN"
description = "Adventure ROM File"
md5s = [AdventureDeltaPatch.hash]
class RomStart(str):
"""
Set this to false to never autostart a rom (such as after patching)
True for operating system default program for '.a26'
Alternatively, a path to a program to open the .a26 file with (generally EmuHawk for multiworld)
"""
class RomArgs(str):
"""
Optional, additional args passed into rom_start before the .bin file
For example, this can be used to autoload the connector script in BizHawk
(see BizHawk --lua= option)
Windows example:
rom_args: "--lua=C:/ProgramData/Archipelago/data/lua/connector_adventure.lua"
"""
class DisplayMsgs(settings.Bool):
"""Set this to true to display item received messages in EmuHawk"""
rom_file: RomFile = RomFile(RomFile.copy_to)
rom_start: typing.Union[RomStart, bool] = True
rom_args: Optional[RomArgs] = " "
display_msgs: typing.Union[DisplayMsgs, bool] = True
class AdventureWeb(WebWorld):
theme = "dirt"
@@ -53,7 +91,6 @@ class AdventureWeb(WebWorld):
)
tutorials = [setup, setup_fr]
def get_item_position_data_start(table_index: int):
@@ -73,6 +110,7 @@ class AdventureWorld(World):
web: ClassVar[WebWorld] = AdventureWeb()
option_definitions: ClassVar[Dict[str, AssembleOptions]] = adventure_option_definitions
settings: ClassVar[AdventureSettings]
item_name_to_id: ClassVar[Dict[str, int]] = {name: data.id for name, data in item_table.items()}
location_name_to_id: ClassVar[Dict[str, int]] = {name: data.location_id for name, data in location_table.items()}
data_version: ClassVar[int] = 1