mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Allow edit of flight's custom name
This commit is contained in:
parent
e36d51a7c2
commit
f4d75a2c6f
@ -336,7 +336,7 @@ class BriefingPage(KneeboardPage):
|
||||
|
||||
def write(self, path: Path) -> None:
|
||||
writer = KneeboardPageWriter(dark_theme=self.dark_kneeboard)
|
||||
if self.flight.custom_name is not None:
|
||||
if self.flight.custom_name:
|
||||
custom_name_title = ' ("{}")'.format(self.flight.custom_name)
|
||||
else:
|
||||
custom_name_title = ""
|
||||
@ -500,7 +500,7 @@ class SupportPage(KneeboardPage):
|
||||
|
||||
def write(self, path: Path) -> None:
|
||||
writer = KneeboardPageWriter(dark_theme=self.dark_kneeboard)
|
||||
if self.flight.custom_name is not None:
|
||||
if self.flight.custom_name:
|
||||
custom_name_title = ' ("{}")'.format(self.flight.custom_name)
|
||||
else:
|
||||
custom_name_title = ""
|
||||
@ -611,7 +611,7 @@ class SeadTaskPage(KneeboardPage):
|
||||
|
||||
def write(self, path: Path) -> None:
|
||||
writer = KneeboardPageWriter(dark_theme=self.dark_kneeboard)
|
||||
if self.flight.custom_name is not None:
|
||||
if self.flight.custom_name:
|
||||
custom_name_title = ' ("{}")'.format(self.flight.custom_name)
|
||||
else:
|
||||
custom_name_title = ""
|
||||
@ -653,7 +653,7 @@ class StrikeTaskPage(KneeboardPage):
|
||||
|
||||
def write(self, path: Path) -> None:
|
||||
writer = KneeboardPageWriter(dark_theme=self.dark_kneeboard)
|
||||
if self.flight.custom_name is not None:
|
||||
if self.flight.custom_name:
|
||||
custom_name_title = ' ("{}")'.format(self.flight.custom_name)
|
||||
else:
|
||||
custom_name_title = ""
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
from PySide2.QtWidgets import QGroupBox, QHBoxLayout, QLabel
|
||||
from typing import Optional
|
||||
|
||||
from PySide2.QtWidgets import QGroupBox, QVBoxLayout, QLineEdit, QLabel, QMessageBox
|
||||
from game.ato.flight import Flight
|
||||
|
||||
|
||||
@ -9,7 +10,22 @@ class QFlightCustomName(QGroupBox):
|
||||
|
||||
self.flight = flight
|
||||
|
||||
self.layout = QHBoxLayout()
|
||||
self.custom_name_label = QLabel(f"Custom Name: {flight.custom_name}")
|
||||
self.layout = QVBoxLayout()
|
||||
self.custom_name_label = QLabel(f"Custom Name:")
|
||||
self.custom_name_input = QLineEdit(flight.custom_name)
|
||||
self.custom_name_input.textChanged.connect(self.on_change)
|
||||
self.layout.addWidget(self.custom_name_label)
|
||||
self.layout.addWidget(self.custom_name_input)
|
||||
self.setLayout(self.layout)
|
||||
|
||||
def on_change(self) -> None:
|
||||
error = self.verify_form()
|
||||
if error is not None:
|
||||
QMessageBox.critical(self, "Could not edit flight", error)
|
||||
return
|
||||
self.flight.custom_name = self.custom_name_input.text()
|
||||
|
||||
def verify_form(self) -> Optional[str]:
|
||||
if "|" in self.custom_name_input.text():
|
||||
return f"Cannot include | in flight name"
|
||||
return None
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user