mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Weather and exact time of day information is helpful during mission planning, so generate it at the start of the turn rather than at takeoff time. Another advantage aside from planning is that we can now use the wind information to set carrier headings and takeoff runways appropriately.
51 lines
1.6 KiB
Python
51 lines
1.6 KiB
Python
import datetime
|
|
|
|
from PySide2.QtWidgets import QLabel, QHBoxLayout, QGroupBox, QVBoxLayout
|
|
|
|
from game.weather import Conditions, TimeOfDay
|
|
import qt_ui.uiconstants as CONST
|
|
|
|
|
|
class QTurnCounter(QGroupBox):
|
|
"""
|
|
UI Component to display current turn and time info
|
|
"""
|
|
|
|
def __init__(self):
|
|
super(QTurnCounter, self).__init__("Turn")
|
|
|
|
self.icons = {
|
|
TimeOfDay.Dawn: CONST.ICONS["Dawn"],
|
|
TimeOfDay.Day: CONST.ICONS["Day"],
|
|
TimeOfDay.Dusk: CONST.ICONS["Dusk"],
|
|
TimeOfDay.Night: CONST.ICONS["Night"],
|
|
}
|
|
|
|
self.layout = QHBoxLayout()
|
|
self.setLayout(self.layout)
|
|
|
|
self.daytime_icon = QLabel()
|
|
self.daytime_icon.setPixmap(self.icons[TimeOfDay.Dawn])
|
|
self.layout.addWidget(self.daytime_icon)
|
|
|
|
self.time_column = QVBoxLayout()
|
|
self.layout.addLayout(self.time_column)
|
|
|
|
self.date_display = QLabel()
|
|
self.time_column.addWidget(self.date_display)
|
|
|
|
self.time_display = QLabel()
|
|
self.time_column.addWidget(self.time_display)
|
|
|
|
def setCurrentTurn(self, turn: int, conditions: Conditions) -> None:
|
|
"""Sets the turn information display.
|
|
|
|
:arg turn Current turn number.
|
|
:arg conditions Current time and weather conditions.
|
|
"""
|
|
self.daytime_icon.setPixmap(self.icons[conditions.time_of_day])
|
|
self.date_display.setText(conditions.start_time.strftime("%d %b %Y"))
|
|
self.time_display.setText(
|
|
conditions.start_time.strftime("%H:%M:%S Local"))
|
|
self.setTitle("Turn " + str(turn + 1))
|