Export txt version of kneeboard pages

This commit is contained in:
Raffson 2023-05-01 17:52:19 +02:00
parent b4b19d3ad5
commit 199467f31b
No known key found for this signature in database
GPG Key ID: B0402B2C9B764D99
2 changed files with 11 additions and 0 deletions

View File

@ -10,6 +10,7 @@
* **[Modding]** Support for A-7E Corsair II (presumed latest available version)
* **[Squadrons]** Added many new squadron's by Adecarcer
* **[Plugins]** Updated 'expl_table' in Splash Damage script.
* **[Mission Generation]** Also save kneeboards in txt-format, found under "kneeboards" within Retribution's installation folder after pressing take-off.
## Fixes
* **[New Game Wizard]** Settings would not persist when going back to a previous page.

View File

@ -89,6 +89,7 @@ class KneeboardPageWriter:
self.x = page_margin
self.y = page_margin
self.line_spacing = line_spacing
self.text_buffer: List[str] = []
@property
def position(self) -> Tuple[int, int]:
@ -117,6 +118,13 @@ class KneeboardPageWriter:
self.draw.text(self.position, text, font=font, fill=fill)
width, height = self.draw.textsize(text, font=font)
self.y += height + self.line_spacing
self.text_buffer.append(text)
def flush_text_buffer(self) -> None:
self.text_buffer = []
def get_text_string(self) -> str:
return "\n".join(x for x in self.text_buffer)
def title(self, title: str) -> None:
self.text(title, font=self.title_font, fill=self.foreground_fill)
@ -139,6 +147,8 @@ class KneeboardPageWriter:
def write(self, path: Path) -> None:
self.image.save(path)
print(path.with_suffix(".txt"))
path.with_suffix(".txt").write_text(self.get_text_string())
@staticmethod
def wrap_line(inputstr: str, max_length: int) -> str: