Dan Albert bce6a170b8
Improve UI for flight properties.
Use the new data from pydcs to improve the properties UI:

* Use human readable names
* Use appropriate control types
* Limit min and max values as appropriate for each property
* Show labels

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3090.
2023-10-01 19:28:52 +02:00

22 lines
737 B
Python

from PySide6.QtWidgets import QCheckBox
from dcs.unitpropertydescription import UnitPropertyDescription
from game.ato import Flight
from .missingpropertydataerror import MissingPropertyDataError
class PropertyCheckBox(QCheckBox):
def __init__(self, flight: Flight, prop: UnitPropertyDescription) -> None:
super().__init__()
self.flight = flight
self.prop = prop
if prop.default is None:
raise MissingPropertyDataError("default cannot be None")
self.setChecked(self.flight.props.get(self.prop.identifier, self.prop.default))
self.toggled.connect(self.on_toggle)
def on_toggle(self, checked: bool) -> None:
self.flight.props[self.prop.identifier] = checked