Show player waypoint timing in the briefing.

Fixes https://github.com/Khopa/dcs_liberation/issues/536

(cherry picked from commit d5276c9d4a70fb0434b2ba8c870c6ef6320b070c)
This commit is contained in:
Dan Albert 2020-12-12 13:41:51 -08:00
parent 4c0fc5a407
commit f62c2fbabb
4 changed files with 22 additions and 6 deletions

View File

@ -5,6 +5,7 @@ from __future__ import annotations
import os
from dataclasses import dataclass
from datetime import timedelta
from typing import Dict, List, TYPE_CHECKING
from dcs.mission import Mission
@ -14,6 +15,7 @@ from game.theater import ControlPoint, FrontLine
from .aircraft import FlightData
from .airsupportgen import AwacsInfo, TankerInfo
from .armor import JtacInfo
from .flights.flight import FlightWaypoint
from .ground_forces.combat_stance import CombatStance
from .radios import RadioFrequency
from .runways import RunwayData
@ -118,6 +120,16 @@ class MissionInfoGenerator:
raise NotImplementedError
def format_waypoint_time(waypoint: FlightWaypoint, depart_prefix: str) -> str:
if waypoint.tot is not None:
time = timedelta(seconds=int(waypoint.tot.total_seconds()))
return f"T+{time} "
elif waypoint.departure_time is not None:
time = timedelta(seconds=int(waypoint.departure_time.total_seconds()))
return f"{depart_prefix} T+{time} "
return ""
class BriefingGenerator(MissionInfoGenerator):
def __init__(self, mission: Mission, game: Game):
@ -133,6 +145,7 @@ class BriefingGenerator(MissionInfoGenerator):
trim_blocks=True,
lstrip_blocks=True,
)
env.filters["waypoint_timing"] = format_waypoint_time
self.template = env.get_template("briefingtemplate_EN.j2")
def generate(self) -> None:

View File

@ -66,8 +66,9 @@ DCS Liberation 第 {{ game.turn }} 回合
====================
{% for flight in flights if flight.client_units %}
--------------------------------------------------
{{ flight.flight_type }} {{ flight.units[0].type }} x {{ flight.size }}, {{ flight.package.target.name}}
{% for waypoint in flight.waypoints %}{{ loop.index0 }} -- {{waypoint.name}} : {{ waypoint.description}}
{{ flight.flight_type }} {{ flight.units[0].type }} x {{flight.size}}, departing in {{ flight.departure_delay }}, {{ flight.package.target.name}}
{% for waypoint in flight.waypoints %}
{{ loop.index0 }} {{waypoint|waypoint_timing("Depart ")}}-- {{waypoint.name}} : {{ waypoint.description}}
{% endfor %}
--------------------------------------------------{% endfor %}

View File

@ -66,8 +66,9 @@ Your flights:
====================
{% for flight in flights if flight.client_units %}
--------------------------------------------------
{{ flight.flight_type }} {{ flight.units[0].type }} x {{ flight.size }}, {{ flight.package.target.name}}
{% for waypoint in flight.waypoints %}{{ loop.index0 }} -- {{waypoint.name}} : {{ waypoint.description}}
{{ flight.flight_type }} {{ flight.units[0].type }} x {{ flight.size }}, departing in {{ flight.departure_delay }}, {{ flight.package.target.name}}
{% for waypoint in flight.waypoints %}
{{ loop.index0 }} {{waypoint|waypoint_timing("Depart ")}}-- {{waypoint.name}} : {{ waypoint.description}}
{% endfor %}
--------------------------------------------------{% endfor %}

View File

@ -66,8 +66,9 @@ Vols :
==========
{% for flight in flights if flight.client_units %}
--------------------------------------------------
{{ flight.flight_type }} {{ flight.units[0].type }} x {{ flight.size }}, {{ flight.package.target.name}}
{% for waypoint in flight.waypoints %}{{ loop.index0 }} -- {{waypoint.name}} : {{ waypoint.description}}
{{ flight.flight_type }} {{ flight.units[0].type }} x {{flight.size}}, départ dans {{ flight.departure_delay }}, {{ flight.package.target.name}}
{% for waypoint in flight.waypoints %}
{{ loop.index0 }} {{waypoint|waypoint_timing("Départ dans ")}}-- {{waypoint.name}} : {{ waypoint.description}}
{% endfor %}
--------------------------------------------------{% endfor %}