mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
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.
22 lines
737 B
Python
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
|