mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Generate settings pages automatically.
This adds metadata to settings fields that can be used to automatically generate the settings window. For now I have replaced the Difficulty page. Will follow up to replace the others.
This commit is contained in:
22
game/settings/booleanoption.py
Normal file
22
game/settings/booleanoption.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Any, Optional
|
||||
|
||||
from .optiondescription import OptionDescription, SETTING_DESCRIPTION_KEY
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class BooleanOption(OptionDescription):
|
||||
pass
|
||||
|
||||
|
||||
def boolean_option(
|
||||
text: str,
|
||||
page: str,
|
||||
section: str,
|
||||
detail: Optional[str] = None,
|
||||
**kwargs: Any,
|
||||
) -> bool:
|
||||
return field(
|
||||
metadata={SETTING_DESCRIPTION_KEY: BooleanOption(page, section, text, detail)},
|
||||
**kwargs,
|
||||
)
|
||||
Reference in New Issue
Block a user