mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
35 lines
753 B
Python
35 lines
753 B
Python
from dataclasses import dataclass, field
|
|
from typing import Any, Optional
|
|
|
|
from .optiondescription import OptionDescription, SETTING_DESCRIPTION_KEY
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class BoundedFloatOption(OptionDescription):
|
|
min: float
|
|
max: float
|
|
divisor: int
|
|
|
|
|
|
def bounded_float_option(
|
|
text: str,
|
|
page: str,
|
|
section: str,
|
|
default: float,
|
|
min: float,
|
|
max: float,
|
|
divisor: int,
|
|
detail: Optional[str] = None,
|
|
tooltip: Optional[str] = None,
|
|
**kwargs: Any,
|
|
) -> float:
|
|
return field(
|
|
metadata={
|
|
SETTING_DESCRIPTION_KEY: BoundedFloatOption(
|
|
page, section, text, detail, tooltip, min, max, divisor
|
|
)
|
|
},
|
|
default=default,
|
|
**kwargs,
|
|
)
|