mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
fix 588 - long waypoint descriptor in kneeboard generation
This commit is contained in:
parent
1539d9c7ed
commit
7d0b738918
@ -94,6 +94,23 @@ class KneeboardPageWriter:
|
|||||||
def write(self, path: Path) -> None:
|
def write(self, path: Path) -> None:
|
||||||
self.image.save(path)
|
self.image.save(path)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def wrap_line(inputstr: str, max_length: int) -> str:
|
||||||
|
if len(inputstr) <= max_length:
|
||||||
|
return inputstr
|
||||||
|
tokens = inputstr.split(" ")
|
||||||
|
output = ""
|
||||||
|
segments = []
|
||||||
|
for token in tokens:
|
||||||
|
combo = output + " " + token
|
||||||
|
if len(combo) > max_length:
|
||||||
|
combo = output + "\n" + token
|
||||||
|
segments.append(combo)
|
||||||
|
output = ""
|
||||||
|
else:
|
||||||
|
output = combo
|
||||||
|
return "".join(segments + [output]).strip()
|
||||||
|
|
||||||
|
|
||||||
class KneeboardPage:
|
class KneeboardPage:
|
||||||
"""Base class for all kneeboard pages."""
|
"""Base class for all kneeboard pages."""
|
||||||
@ -110,6 +127,9 @@ class NumberedWaypoint:
|
|||||||
|
|
||||||
|
|
||||||
class FlightPlanBuilder:
|
class FlightPlanBuilder:
|
||||||
|
|
||||||
|
WAYPOINT_DESC_MAX_LEN = 25
|
||||||
|
|
||||||
def __init__(self, start_time: datetime.datetime) -> None:
|
def __init__(self, start_time: datetime.datetime) -> None:
|
||||||
self.start_time = start_time
|
self.start_time = start_time
|
||||||
self.rows: List[List[str]] = []
|
self.rows: List[List[str]] = []
|
||||||
@ -151,7 +171,9 @@ class FlightPlanBuilder:
|
|||||||
def add_waypoint_row(self, waypoint: NumberedWaypoint) -> None:
|
def add_waypoint_row(self, waypoint: NumberedWaypoint) -> None:
|
||||||
self.rows.append([
|
self.rows.append([
|
||||||
str(waypoint.number),
|
str(waypoint.number),
|
||||||
waypoint.waypoint.pretty_name,
|
KneeboardPageWriter.wrap_line(
|
||||||
|
waypoint.waypoint.pretty_name,
|
||||||
|
FlightPlanBuilder.WAYPOINT_DESC_MAX_LEN),
|
||||||
str(int(waypoint.waypoint.alt.feet)),
|
str(int(waypoint.waypoint.alt.feet)),
|
||||||
self._waypoint_distance(waypoint.waypoint),
|
self._waypoint_distance(waypoint.waypoint),
|
||||||
self._ground_speed(waypoint.waypoint),
|
self._ground_speed(waypoint.waypoint),
|
||||||
@ -258,11 +280,9 @@ class BriefingPage(KneeboardPage):
|
|||||||
str(tanker.tacan),
|
str(tanker.tacan),
|
||||||
self.format_frequency(tanker.freq),
|
self.format_frequency(tanker.freq),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
writer.table(comm_ladder, headers=["Callsign","Task", "Type", "TACAN", "FREQ"])
|
writer.table(comm_ladder, headers=["Callsign","Task", "Type", "TACAN", "FREQ"])
|
||||||
|
|
||||||
|
|
||||||
writer.heading("JTAC")
|
writer.heading("JTAC")
|
||||||
jtacs = []
|
jtacs = []
|
||||||
for jtac in self.jtacs:
|
for jtac in self.jtacs:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user