Add button to rename pilots in air wing

This commit is contained in:
Raffson 2023-01-01 00:43:58 +01:00
parent 192741af36
commit ee1fc53dd3
No known key found for this signature in database
GPG Key ID: B0402B2C9B764D99
2 changed files with 20 additions and 0 deletions

View File

@ -5,6 +5,7 @@
* **[Mission Generation]** Add option to switch ATFLIR to LITENING automatically for ground based F-18C flights * **[Mission Generation]** Add option to switch ATFLIR to LITENING automatically for ground based F-18C flights
* **[Cheat Menu]** Option to instantly transfer squadrons across bases. * **[Cheat Menu]** Option to instantly transfer squadrons across bases.
* **[UI]** Add selectable units in faction overview during campaign generation. * **[UI]** Add selectable units in faction overview during campaign generation.
* **[UI]** Add button to rename pilots in Air Wing's Squadron dialog.
## Fixes ## Fixes
* **[UI]** Removed deprecated options * **[UI]** Removed deprecated options

View File

@ -12,6 +12,8 @@ from PySide2.QtWidgets import (
QListView, QListView,
QPushButton, QPushButton,
QVBoxLayout, QVBoxLayout,
QInputDialog,
QLineEdit,
) )
from game.ato.flightplans.custom import CustomFlightPlan from game.ato.flightplans.custom import CustomFlightPlan
@ -178,6 +180,11 @@ class SquadronDialog(QDialog):
button_panel.addStretch() button_panel.addStretch()
layout.addLayout(button_panel) layout.addLayout(button_panel)
self.rename_button = QPushButton("Rename pilot")
self.rename_button.setProperty("style", "start-button")
self.rename_button.clicked.connect(self.rename_pilot)
button_panel.addWidget(self.rename_button, alignment=Qt.AlignRight)
self.toggle_ai_button = QPushButton() self.toggle_ai_button = QPushButton()
self.reset_ai_toggle_state(self.pilot_list.currentIndex()) self.reset_ai_toggle_state(self.pilot_list.currentIndex())
self.toggle_ai_button.setProperty("style", "start-button") self.toggle_ai_button.setProperty("style", "start-button")
@ -231,6 +238,18 @@ class SquadronDialog(QDialog):
return True return True
return False return False
def rename_pilot(self) -> None:
index = self.pilot_list.currentIndex()
if not index.isValid():
logging.error("Cannot toggle player/AI: no pilot is selected")
return
p = self.squadron_model.pilot_at_index(index)
text, ok = QInputDialog.getText(
self, "Rename pilot", "New name: ", QLineEdit.EchoMode.Normal
)
if ok:
p.name = text
def toggle_ai(self) -> None: def toggle_ai(self) -> None:
index = self.pilot_list.currentIndex() index = self.pilot_list.currentIndex()
if not index.isValid(): if not index.isValid():