Changes red base info to show defenses first, and adds an attack option
This commit is contained in:
Walter 2020-11-02 19:00:50 -06:00 committed by Dan Albert
parent ac05c7cfaa
commit cdb16cc591
6 changed files with 26 additions and 15 deletions

View File

@ -34,12 +34,13 @@ class Dialog:
cls.game_model = game_model cls.game_model = game_model
@classmethod @classmethod
def open_new_package_dialog(cls, mission_target: MissionTarget): def open_new_package_dialog(cls, mission_target: MissionTarget, parent=None):
"""Opens the dialog to create a new package with the given target.""" """Opens the dialog to create a new package with the given target."""
cls.new_package_dialog = QNewPackageDialog( cls.new_package_dialog = QNewPackageDialog(
cls.game_model, cls.game_model,
cls.game_model.ato_model, cls.game_model.ato_model,
mission_target mission_target,
parent=parent
) )
cls.new_package_dialog.show() cls.new_package_dialog.show()

View File

@ -16,11 +16,11 @@ class QBaseMenuTabs(QTabWidget):
if cp: if cp:
if not cp.captured: if not cp.captured:
self.intel = QIntelInfo(cp, game_model.game)
self.addTab(self.intel, "Intel")
if not cp.is_carrier: if not cp.is_carrier:
self.base_defenses_hq = QBaseDefensesHQ(cp, game_model.game) self.base_defenses_hq = QBaseDefensesHQ(cp, game_model.game)
self.addTab(self.base_defenses_hq, "Base Defenses") self.addTab(self.base_defenses_hq, "Base Defenses")
self.intel = QIntelInfo(cp, game_model.game)
self.addTab(self.intel, "Intel")
else: else:
if cp.has_runway(): if cp.has_runway():
self.airfield_command = QAirfieldCommand(cp, game_model) self.airfield_command = QAirfieldCommand(cp, game_model)

View File

@ -1,6 +1,7 @@
from PySide2.QtCore import Qt from PySide2.QtCore import Qt
from PySide2.QtWidgets import QGridLayout, QLabel, QGroupBox, QPushButton, QVBoxLayout from PySide2.QtWidgets import QGridLayout, QLabel, QGroupBox, QPushButton, QVBoxLayout
from qt_ui.dialogs import Dialog
from qt_ui.uiconstants import VEHICLES_ICONS from qt_ui.uiconstants import VEHICLES_ICONS
from qt_ui.windows.groundobject.QGroundObjectMenu import QGroundObjectMenu from qt_ui.windows.groundobject.QGroundObjectMenu import QGroundObjectMenu
from theater import ControlPoint, TheaterGroundObject from theater import ControlPoint, TheaterGroundObject
@ -23,12 +24,17 @@ class QBaseDefenseGroupInfo(QGroupBox):
def init_ui(self): def init_ui(self):
self.buildLayout() self.buildLayout()
self.main_layout.addLayout(self.unit_layout)
if not self.cp.captured:
attack_button = QPushButton("Attack")
attack_button.setProperty("style", "btn-danger")
attack_button.setMaximumWidth(180)
attack_button.clicked.connect(self.onAttack)
self.main_layout.addWidget(attack_button, 0, Qt.AlignLeft)
manage_button = QPushButton("Manage") manage_button = QPushButton("Manage")
manage_button.setProperty("style", "btn-success") manage_button.setProperty("style", "btn-success")
manage_button.setMaximumWidth(180) manage_button.setMaximumWidth(180)
manage_button.clicked.connect(self.onManage) manage_button.clicked.connect(self.onManage)
self.main_layout.addLayout(self.unit_layout)
self.main_layout.addWidget(manage_button, 0, Qt.AlignLeft) self.main_layout.addWidget(manage_button, 0, Qt.AlignLeft)
self.setLayout(self.main_layout) self.setLayout(self.main_layout)
@ -66,6 +72,9 @@ class QBaseDefenseGroupInfo(QGroupBox):
self.setLayout(self.main_layout) self.setLayout(self.main_layout)
def onAttack(self):
Dialog.open_new_package_dialog(self.ground_object, parent=self.window())
def onManage(self): def onManage(self):
self.edition_menu = QGroundObjectMenu(self.window(), self.ground_object, self.buildings, self.cp, self.game) self.edition_menu = QGroundObjectMenu(self.window(), self.ground_object, self.buildings, self.cp, self.game)

View File

@ -15,8 +15,8 @@ from qt_ui.windows.mission.flight.QFlightPlanner import QFlightPlanner
class QEditFlightDialog(QDialog): class QEditFlightDialog(QDialog):
"""Dialog window for editing flight plans and loadouts.""" """Dialog window for editing flight plans and loadouts."""
def __init__(self, game_model: GameModel, package: Package, flight: Flight) -> None: def __init__(self, game_model: GameModel, package: Package, flight: Flight, parent=None) -> None:
super().__init__() super().__init__(parent=parent)
self.game_model = game_model self.game_model = game_model

View File

@ -36,8 +36,8 @@ class QPackageDialog(QDialog):
#: Emitted when a change is made to the package. #: Emitted when a change is made to the package.
package_changed = Signal() package_changed = Signal()
def __init__(self, game_model: GameModel, model: PackageModel) -> None: def __init__(self, game_model: GameModel, model: PackageModel, parent=None) -> None:
super().__init__() super().__init__(parent)
self.game_model = game_model self.game_model = game_model
self.package_model = model self.package_model = model
self.add_flight_dialog: Optional[QFlightCreator] = None self.add_flight_dialog: Optional[QFlightCreator] = None
@ -156,7 +156,8 @@ class QPackageDialog(QDialog):
def on_add_flight(self) -> None: def on_add_flight(self) -> None:
"""Opens the new flight dialog.""" """Opens the new flight dialog."""
self.add_flight_dialog = QFlightCreator(self.game, self.add_flight_dialog = QFlightCreator(self.game,
self.package_model.package) self.package_model.package,
parent=self.window())
self.add_flight_dialog.created.connect(self.add_flight) self.add_flight_dialog.created.connect(self.add_flight)
self.add_flight_dialog.show() self.add_flight_dialog.show()
@ -189,8 +190,8 @@ class QNewPackageDialog(QPackageDialog):
""" """
def __init__(self, game_model: GameModel, model: AtoModel, def __init__(self, game_model: GameModel, model: AtoModel,
target: MissionTarget) -> None: target: MissionTarget, parent=None) -> None:
super().__init__(game_model, PackageModel(Package(target))) super().__init__(game_model, PackageModel(Package(target)), parent=parent)
self.ato_model = model self.ato_model = model
self.save_button = QPushButton("Save") self.save_button = QPushButton("Save")

View File

@ -23,8 +23,8 @@ from theater import ControlPoint
class QFlightCreator(QDialog): class QFlightCreator(QDialog):
created = Signal(Flight) created = Signal(Flight)
def __init__(self, game: Game, package: Package) -> None: def __init__(self, game: Game, package: Package, parent=None) -> None:
super().__init__() super().__init__(parent=parent)
self.game = game self.game = game
self.package = package self.package = package