Remove "base defenses" UI features.

There's no such thing any more. There are just objectives that are
closer to the CP than the others.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1130
This commit is contained in:
Dan Albert 2021-05-30 21:06:35 -07:00
parent a5336bbe56
commit 6616359baf
6 changed files with 4 additions and 205 deletions

View File

@ -411,14 +411,10 @@ class CoastalSiteGroundObject(TheaterGroundObject):
)
class BaseDefenseGroundObject(TheaterGroundObject):
"""Base type for all base defenses."""
# TODO: Differentiate types.
# This type gets used both for AA sites (SAM, AAA, or SHORAD). These should each
# be split into their own types.
class SamGroundObject(BaseDefenseGroundObject):
class SamGroundObject(TheaterGroundObject):
def __init__(
self,
name: str,
@ -496,7 +492,7 @@ class SamGroundObject(BaseDefenseGroundObject):
return max(max_tel_range, max_telar_range, max_non_radar)
class VehicleGroupGroundObject(BaseDefenseGroundObject):
class VehicleGroupGroundObject(TheaterGroundObject):
def __init__(
self,
name: str,
@ -518,7 +514,7 @@ class VehicleGroupGroundObject(BaseDefenseGroundObject):
)
class EwrGroundObject(BaseDefenseGroundObject):
class EwrGroundObject(TheaterGroundObject):
def __init__(
self,
name: str,

View File

@ -312,10 +312,6 @@ class NameGenerator:
db.unit_type_name(unit_type),
)
@staticmethod
def next_basedefense_name():
return "basedefense_aa|0|0|"
@classmethod
def next_awacs_name(cls, country: Country):
cls.number += 1

View File

@ -4,7 +4,6 @@ from game.theater import ControlPoint, OffMapSpawn, Fob
from qt_ui.models import GameModel
from qt_ui.windows.basemenu.DepartingConvoysMenu import DepartingConvoysMenu
from qt_ui.windows.basemenu.airfield.QAirfieldCommand import QAirfieldCommand
from qt_ui.windows.basemenu.base_defenses.QBaseDefensesHQ import QBaseDefensesHQ
from qt_ui.windows.basemenu.ground_forces.QGroundForcesHQ import QGroundForcesHQ
from qt_ui.windows.basemenu.intel.QIntelInfo import QIntelInfo
@ -14,9 +13,6 @@ class QBaseMenuTabs(QTabWidget):
super(QBaseMenuTabs, self).__init__()
if not cp.captured:
if not cp.is_carrier and not isinstance(cp, OffMapSpawn):
self.base_defenses_hq = QBaseDefensesHQ(cp, game_model.game)
self.addTab(self.base_defenses_hq, "Base Defenses")
self.intel = QIntelInfo(cp, game_model.game)
self.addTab(self.intel, "Intel")
@ -30,17 +26,9 @@ class QBaseMenuTabs(QTabWidget):
if cp.helipads:
self.airfield_command = QAirfieldCommand(cp, game_model)
self.addTab(self.airfield_command, "Heliport")
self.base_defenses_hq = QBaseDefensesHQ(cp, game_model.game)
self.addTab(self.base_defenses_hq, "Base Defenses")
else:
self.airfield_command = QAirfieldCommand(cp, game_model)
self.addTab(self.airfield_command, "Airfield Command")
if cp.is_carrier:
self.base_defenses_hq = QBaseDefensesHQ(cp, game_model.game)
self.addTab(self.base_defenses_hq, "Fleet")
elif not isinstance(cp, OffMapSpawn):
if not isinstance(cp, OffMapSpawn):
self.ground_forces_hq = QGroundForcesHQ(cp, game_model)
self.addTab(self.ground_forces_hq, "Ground Forces HQ")
self.base_defenses_hq = QBaseDefensesHQ(cp, game_model.game)
self.addTab(self.base_defenses_hq, "Base Defenses")

View File

@ -1,106 +0,0 @@
from PySide2.QtCore import Qt
from PySide2.QtWidgets import (
QGridLayout,
QGroupBox,
QLabel,
QPushButton,
QVBoxLayout,
)
from game.theater import ControlPoint, TheaterGroundObject
from qt_ui.dialogs import Dialog
from qt_ui.uiconstants import VEHICLES_ICONS
from qt_ui.windows.groundobject.QGroundObjectMenu import QGroundObjectMenu
from game import db
from dcs import vehicles
class QBaseDefenseGroupInfo(QGroupBox):
def __init__(self, cp: ControlPoint, ground_object: TheaterGroundObject, game):
super(QBaseDefenseGroupInfo, self).__init__("Group : " + ground_object.obj_name)
self.ground_object = ground_object
self.cp = cp
self.game = game
self.buildings = game.theater.find_ground_objects_by_obj_name(
self.ground_object.obj_name
)
self.main_layout = QVBoxLayout()
self.unit_layout = QGridLayout()
self.init_ui()
def init_ui(self):
self.buildLayout()
self.main_layout.addLayout(self.unit_layout)
if not self.cp.captured and not self.ground_object.is_dead:
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)
if self.cp.captured:
manage_button = QPushButton("Manage")
manage_button.setProperty("style", "btn-success")
manage_button.setMaximumWidth(180)
manage_button.clicked.connect(self.onManage)
self.main_layout.addWidget(manage_button, 0, Qt.AlignLeft)
self.setLayout(self.main_layout)
def buildLayout(self):
unit_dict = {}
for i in range(self.unit_layout.rowCount()):
for j in range(self.unit_layout.columnCount()):
item = self.unit_layout.itemAtPosition(i, j)
if item is not None and item.widget() is not None:
item.widget().setParent(None)
print("Remove " + str(i) + ", " + str(j))
for g in self.ground_object.groups:
for u in g.units:
if u.type in unit_dict.keys():
unit_dict[u.type] = unit_dict[u.type] + 1
else:
unit_dict[u.type] = 1
i = 0
for k, v in unit_dict.items():
icon = QLabel()
if k in VEHICLES_ICONS.keys():
icon.setPixmap(VEHICLES_ICONS[k])
else:
icon.setText("<b>" + k[:8] + "</b>")
icon.setProperty("style", "icon-armor")
self.unit_layout.addWidget(icon, i, 0)
unit_display_name = k
unit_type = vehicles.vehicle_map.get(k)
if unit_type is not None:
unit_display_name = db.unit_get_expanded_info(
self.game.enemy_country, unit_type, "name"
)
self.unit_layout.addWidget(
QLabel(str(v) + " x " + "<strong>" + unit_display_name + "</strong>"),
i,
1,
)
i = i + 1
if len(unit_dict.items()) == 0:
self.unit_layout.addWidget(QLabel("/"), 0, 0)
self.setLayout(self.main_layout)
def onAttack(self):
Dialog.open_new_package_dialog(self.ground_object, parent=self.window())
def onManage(self):
self.edition_menu = QGroundObjectMenu(
self.window(), self.ground_object, self.buildings, self.cp, self.game
)
self.edition_menu.show()
self.edition_menu.changed.connect(self.onEdition)
def onEdition(self):
self.buildLayout()

View File

@ -1,19 +0,0 @@
from PySide2.QtWidgets import QFrame, QGridLayout
from game import Game
from game.theater import ControlPoint
from qt_ui.windows.basemenu.base_defenses.QBaseInformation import QBaseInformation
class QBaseDefensesHQ(QFrame):
def __init__(self, cp: ControlPoint, game: Game):
super(QBaseDefensesHQ, self).__init__()
self.cp = cp
self.game = game
self.init_ui()
def init_ui(self):
airport = self.game.theater.terrain.airport_by_id(self.cp.id)
layout = QGridLayout()
layout.addWidget(QBaseInformation(self.cp, airport, self.game))
self.setLayout(layout)

View File

@ -1,56 +0,0 @@
from PySide2.QtGui import Qt
from PySide2.QtWidgets import (
QFrame,
QGridLayout,
QScrollArea,
QVBoxLayout,
QWidget,
)
from game.theater import Airport, ControlPoint, Fob
from game.theater.theatergroundobject import BuildingGroundObject
from qt_ui.windows.basemenu.base_defenses.QBaseDefenseGroupInfo import (
QBaseDefenseGroupInfo,
)
class QBaseInformation(QFrame):
def __init__(self, cp: ControlPoint, airport: Airport, game):
super(QBaseInformation, self).__init__()
self.cp = cp
self.airport = airport
self.game = game
self.setMinimumWidth(500)
self.init_ui()
def init_ui(self):
self.mainLayout = QVBoxLayout()
scroll_content = QWidget()
task_box_layout = QGridLayout()
scroll_content.setLayout(task_box_layout)
for g in self.cp.ground_objects:
# Airbase groups are the objects that are hidden on the map because
# they're shown in the base menu.
if not g.airbase_group:
continue
# Of these, we need to ignore the FOB structure itself since that's
# not supposed to be targetable.
if isinstance(self.cp, Fob) and isinstance(g, BuildingGroundObject):
continue
group_info = QBaseDefenseGroupInfo(self.cp, g, self.game)
task_box_layout.addWidget(group_info)
scroll_content.setLayout(task_box_layout)
scroll = QScrollArea()
scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
scroll.setWidgetResizable(True)
scroll.setWidget(scroll_content)
self.mainLayout.addWidget(scroll)
self.setLayout(self.mainLayout)