sonolus.script.options¶
EmptyOptions
¶
An option set with no options, used as the default when an engine declares none.
OptionCategory
dataclass
¶
A category of engine options.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | None
|
The name of the category. If unset, the attribute name in the decorated options class is used. |
None
|
title
|
AnyText | None
|
The display title of the category, as a plain string or an
|
None
|
options(cls: type[T]) -> T | Options
¶
Decorator to define options.
Note
A replay_fallback_option_names class attribute is excluded from the options list and is instead
forwarded as replayFallbackOptionNames in the built engine configuration.
If the class declares any OptionCategory attributes, every
option must specify a category.
Usage
@options
class Options:
gameplay = OptionCategory(title='Gameplay')
slider_option: float = slider_option(
name='Slider Option',
category=gameplay,
standard=True,
advanced=False,
default=0.5,
min=0,
max=1,
step=0.1,
unit='unit',
scope='scope',
)
toggle_option: bool = toggle_option(
name='Toggle Option',
category=gameplay,
standard=True,
advanced=False,
default=True,
scope='scope',
)
select_option: int = select_option(
name='Select Option',
category=gameplay,
standard=True,
advanced=False,
default='value',
values=['value'],
scope='scope',
)
select_option(*, name: str | None = None, category: str | OptionCategory | None = None, title: AnyText | None = None, description: AnyText | None = None, standard: bool = False, advanced: bool = False, default: AnyText | int, values: list[AnyText], scope: str | None = None) -> Any
¶
Define a select option.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | None
|
The name of the option. |
None
|
category
|
str | OptionCategory | None
|
A category declared on the options class, specified by its object or name. |
None
|
title
|
AnyText | None
|
The display title of the option, as a plain string or an
|
None
|
description
|
AnyText | None
|
The description of the option, as a plain string or an
|
None
|
standard
|
bool
|
Whether the option is standard. |
False
|
advanced
|
bool
|
Whether the option is advanced. |
False
|
default
|
AnyText | int
|
The default value of the option, given as an entry of |
required |
values
|
list[AnyText]
|
The values of the option, each a plain string or an
|
required |
scope
|
str | None
|
The scope of the option. |
None
|
slider_option(*, name: str | None = None, category: str | OptionCategory | None = None, title: AnyText | None = None, description: AnyText | None = None, standard: bool = False, advanced: bool = False, default: float, min: float, max: float, step: float, unit: AnyText | None = None, scope: str | None = None) -> Any
¶
Define a slider option.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | None
|
The name of the option. |
None
|
category
|
str | OptionCategory | None
|
A category declared on the options class, specified by its object or name. |
None
|
title
|
AnyText | None
|
The display title of the option, as a plain string or an
|
None
|
description
|
AnyText | None
|
The description of the option, as a plain string or an
|
None
|
standard
|
bool
|
Whether the option is standard. |
False
|
advanced
|
bool
|
Whether the option is advanced. |
False
|
default
|
float
|
The default value of the option. |
required |
min
|
float
|
The minimum value of the option. |
required |
max
|
float
|
The maximum value of the option. |
required |
step
|
float
|
The step value of the option. |
required |
unit
|
AnyText | None
|
The unit of the option, as a plain string or an
|
None
|
scope
|
str | None
|
The scope of the option. |
None
|
toggle_option(*, name: str | None = None, category: str | OptionCategory | None = None, title: AnyText | None = None, description: AnyText | None = None, standard: bool = False, advanced: bool = False, default: bool, scope: str | None = None) -> Any
¶
Define a toggle option.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | None
|
The name of the option. |
None
|
category
|
str | OptionCategory | None
|
A category declared on the options class, specified by its object or name. |
None
|
title
|
AnyText | None
|
The display title of the option, as a plain string or an
|
None
|
description
|
AnyText | None
|
The description of the option, as a plain string or an
|
None
|
standard
|
bool
|
Whether the option is standard. |
False
|
advanced
|
bool
|
Whether the option is advanced. |
False
|
default
|
bool
|
The default value of the option. |
required |
scope
|
str | None
|
The scope of the option. |
None
|