Polishing, Bug Fixes, Slight improvements to flight generator for BARCAP.

This commit is contained in:
Khopa
2020-05-29 03:05:27 +02:00
parent fc64e57495
commit 8afdf5ef65
21 changed files with 194 additions and 123 deletions

View File

@@ -81,7 +81,7 @@ class QTopPanel(QFrame):
self.budgetBox.setGame(self.game)
self.factionsInfos.setGame(self.game)
if not len(self.game.planners.keys()) == len(self.game.theater.controlpoints):
if self.game and self.game.turn == 0:
self.proceedButton.setEnabled(False)
else:
self.proceedButton.setEnabled(True)

View File

@@ -1,45 +0,0 @@
from PySide2.QtWidgets import QGridLayout, QLabel, QGroupBox, QVBoxLayout
from game import db
from qt_ui.uiconstants import AIRCRAFT_ICONS, VEHICLES_ICONS
from theater import ControlPoint, Airport
class QBaseInformation(QGroupBox):
def __init__(self, cp:ControlPoint, airport:Airport):
super(QBaseInformation, self).__init__("Base defenses")
self.cp = cp
self.airport = airport
self.setMinimumWidth(500)
self.init_ui()
def init_ui(self):
self.layout = QGridLayout()
unit_dict = {}
for g in self.cp.ground_objects:
if g.airbase_group:
for group in g.groups:
for u in group.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[:6]+"</b>")
icon.setProperty("style", "icon-plane")
self.layout.addWidget(icon, i, 0)
self.layout.addWidget(QLabel(str(v) + " x " + k), i, 1)
i = i + 1
stretch = QVBoxLayout()
stretch.addStretch()
self.layout.addLayout(stretch, len(unit_dict) + 1, 0)
self.setLayout(self.layout)

View File

@@ -76,24 +76,13 @@ class QLiberationMap(QGraphicsView):
scene.addItem(QMapControlPoint(self, pos[0] - CONST.CP_SIZE / 2, pos[1] - CONST.CP_SIZE / 2, CONST.CP_SIZE,
CONST.CP_SIZE, cp, self.game))
if cp.captured:
pen = QPen(brush=CONST.COLORS["blue"])
brush = CONST.COLORS["blue_transparent"]
flight_path_pen = QPen(brush=CONST.COLORS["blue"])
flight_path_pen.setColor(CONST.COLORS["blue"])
flight_path_pen.setWidth(1)
flight_path_pen.setStyle(Qt.DashDotLine)
else:
pen = QPen(brush=CONST.COLORS["red"])
brush = CONST.COLORS["red_transparent"]
flight_path_pen = QPen(brush=CONST.COLORS["bright_red"])
flight_path_pen.setColor(CONST.COLORS["bright_red"])
flight_path_pen.setWidth(1)
flight_path_pen.setStyle(Qt.DashDotLine)
for ground_object in cp.ground_objects:
go_pos = self._transform_point(ground_object.position)
@@ -119,6 +108,24 @@ class QLiberationMap(QGraphicsView):
self.scene_create_lines_for_cp(cp)
for cp in self.game.theater.controlpoints:
if cp.captured:
pen = QPen(brush=CONST.COLORS["blue"])
brush = CONST.COLORS["blue_transparent"]
flight_path_pen = QPen(brush=CONST.COLORS["blue"])
flight_path_pen.setColor(CONST.COLORS["blue"])
flight_path_pen.setWidth(1)
flight_path_pen.setStyle(Qt.DashDotLine)
else:
pen = QPen(brush=CONST.COLORS["red"])
brush = CONST.COLORS["red_transparent"]
flight_path_pen = QPen(brush=CONST.COLORS["bright_red"])
flight_path_pen.setColor(CONST.COLORS["bright_red"])
flight_path_pen.setWidth(1)
flight_path_pen.setStyle(Qt.DashDotLine)
pos = self._transform_point(cp.position)
if self.get_display_rule("flight_paths"):
if cp.id in self.game.planners.keys():

View File

@@ -210,16 +210,16 @@ class TheaterConfiguration(QtWidgets.QWizardPage):
terrainCaucasusSmall.setIcon(QtGui.QIcon(CONST.ICONS["Terrain_Caucasus"]))
terrainCaucasusSmallInverted = QtWidgets.QRadioButton("Caucasus - Western Georgia Inverted [RECOMMENDED]")
terrainCaucasusSmallInverted.setIcon(QtGui.QIcon(CONST.ICONS["Terrain_Caucasus"]))
terrainCaucasus = QtWidgets.QRadioButton("Caucasus - Full map")
terrainCaucasus = QtWidgets.QRadioButton("Caucasus - Full map [NOT TESTED]")
terrainCaucasus.setIcon(QtGui.QIcon(CONST.ICONS["Terrain_Caucasus"]))
terrainPg = QtWidgets.QRadioButton("Persian Gulf - Full Map")
terrainPg = QtWidgets.QRadioButton("Persian Gulf - Full Map [NOT TESTED]")
terrainPg.setIcon(QtGui.QIcon(CONST.ICONS["Terrain_Persian_Gulf"]))
terrainIran = QtWidgets.QRadioButton("Persian Gulf - Invasion of Iran [RECOMMENDED]")
terrainIran.setIcon(QtGui.QIcon(CONST.ICONS["Terrain_Persian_Gulf"]))
terrainEmirates = QtWidgets.QRadioButton("Persian Gulf - Emirates [RECOMMENDED]")
terrainEmirates.setIcon(QtGui.QIcon(CONST.ICONS["Terrain_Persian_Gulf"]))
terrainNttr = QtWidgets.QRadioButton("Nevada - Full")
terrainNttr = QtWidgets.QRadioButton("Nevada - North Nevada [RECOMMENDED]")
terrainNttr.setIcon(QtGui.QIcon(CONST.ICONS["Terrain_Nevada"]))
terrainNormandy = QtWidgets.QRadioButton("Normandy [Alpha]")
terrainNormandy.setIcon(QtGui.QIcon(CONST.ICONS["Terrain_Normandy"]))
@@ -282,6 +282,7 @@ class MiscOptions(QtWidgets.QWizardPage):
sams.setChecked(True)
midGame = QtWidgets.QCheckBox()
multiplier = QtWidgets.QSpinBox()
multiplier.setEnabled(False)
multiplier.setMinimum(1)
multiplier.setMaximum(5)
@@ -290,11 +291,11 @@ class MiscOptions(QtWidgets.QWizardPage):
self.registerField('multiplier', multiplier)
layout = QtWidgets.QGridLayout()
layout.addWidget(QtWidgets.QLabel("With SAM Systems :"), 0, 0)
layout.addWidget(sams, 0, 1)
#layout.addWidget(QtWidgets.QLabel("With SAM Systems :"), 0, 0)
#layout.addWidget(sams, 0, 1)
layout.addWidget(QtWidgets.QLabel("Start at mid game"), 1, 0)
layout.addWidget(midGame, 1, 1)
layout.addWidget(QtWidgets.QLabel("Ennemy forces multiplier"), 2, 0)
layout.addWidget(QtWidgets.QLabel("Ennemy forces multiplier [Disabled for Now]"), 2, 0)
layout.addWidget(multiplier, 2, 1)
self.setLayout(layout)

View File

@@ -9,7 +9,7 @@ from dcs.unittype import UnitType
from game.event import UnitsDeliveryEvent, ControlPointType
from qt_ui.widgets.QBudgetBox import QBudgetBox
from qt_ui.widgets.base.QAirportInformation import QAirportInformation
from qt_ui.widgets.base.QBaseInformation import QBaseInformation
from qt_ui.windows.basemenu.base_defenses.QBaseInformation import QBaseInformation
from qt_ui.windows.mission.QPlannedFlightsView import QPlannedFlightsView
from qt_ui.windows.GameUpdateSignal import GameUpdateSignal
from theater import ControlPoint, CAP, Embarking, CAS, PinpointStrike, db

View File

@@ -18,6 +18,9 @@ class QBaseMenuTabs(QTabWidget):
if not cp.captured:
self.intel = QIntelInfo(cp, game)
self.addTab(self.intel, "Intel")
if not cp.is_carrier:
self.base_defenses_hq = QBaseDefensesHQ(cp, game)
self.addTab(self.base_defenses_hq, "Base Defenses")
else:
if cp.has_runway():
self.airfield_command = QAirfieldCommand(cp, game)
@@ -28,6 +31,9 @@ class QBaseMenuTabs(QTabWidget):
self.addTab(self.ground_forces_hq, "Ground Forces HQ")
self.base_defenses_hq = QBaseDefensesHQ(cp, game)
self.addTab(self.base_defenses_hq, "Base Defenses")
else:
self.base_defenses_hq = QBaseDefensesHQ(cp, game)
self.addTab(self.base_defenses_hq, "Fleet")
else:
tabError = QFrame()

View File

@@ -1,19 +1,8 @@
import traceback
from PySide2.QtWidgets import QVBoxLayout, QGridLayout, QGroupBox
from PySide2.QtCore import Qt
from PySide2.QtGui import QCloseEvent
from PySide2.QtWidgets import QHBoxLayout, QLabel, QWidget, QDialog, QVBoxLayout, QGridLayout, QPushButton, \
QGroupBox, QSizePolicy, QSpacerItem, QFrame
from dcs.unittype import UnitType
from game.event import UnitsDeliveryEvent, ControlPointType
from qt_ui.widgets.QBudgetBox import QBudgetBox
from qt_ui.widgets.base.QAirportInformation import QAirportInformation
from qt_ui.widgets.base.QBaseInformation import QBaseInformation
from game.event import UnitsDeliveryEvent
from qt_ui.windows.basemenu.QRecruitBehaviour import QRecruitBehaviour
from qt_ui.windows.mission.QPlannedFlightsView import QPlannedFlightsView
from qt_ui.windows.GameUpdateSignal import GameUpdateSignal
from theater import ControlPoint, CAP, Embarking, CAS, PinpointStrike, db
from theater import ControlPoint, CAP, CAS, db
from game import Game

View File

@@ -0,0 +1,36 @@
from PySide2.QtWidgets import QGridLayout, QLabel, QGroupBox
from qt_ui.uiconstants import VEHICLES_ICONS
from theater import ControlPoint, TheaterGroundObject
class QBaseDefenseGroupInfo(QGroupBox):
def __init__(self, cp:ControlPoint, ground_object: TheaterGroundObject):
super(QBaseDefenseGroupInfo, self).__init__("Group : " + ground_object.obj_name)
self.ground_object = ground_object
self.init_ui()
def init_ui(self):
unit_dict = {}
layout = QGridLayout()
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[:6] + "</b>")
icon.setProperty("style", "icon-plane")
layout.addWidget(icon, i, 0)
layout.addWidget(QLabel(str(v) + " x " + k), i, 1)
i = i + 1
self.setLayout(layout)

View File

@@ -1,6 +1,6 @@
from PySide2.QtWidgets import QFrame, QGridLayout, QLabel
from PySide2.QtWidgets import QFrame, QGridLayout
from game import Game
from qt_ui.widgets.base.QBaseInformation import QBaseInformation
from qt_ui.windows.basemenu.base_defenses.QBaseInformation import QBaseInformation
from theater import ControlPoint

View File

@@ -0,0 +1,24 @@
from PySide2.QtWidgets import QGridLayout, QLabel, QGroupBox, QVBoxLayout
from game import db
from qt_ui.uiconstants import AIRCRAFT_ICONS, VEHICLES_ICONS
from qt_ui.windows.basemenu.base_defenses.QBaseDefenseGroupInfo import QBaseDefenseGroupInfo
from theater import ControlPoint, Airport
class QBaseInformation(QGroupBox):
def __init__(self, cp:ControlPoint, airport:Airport):
super(QBaseInformation, self).__init__("Base defenses")
self.cp = cp
self.airport = airport
self.setMinimumWidth(500)
self.init_ui()
def init_ui(self):
self.layout = QVBoxLayout()
for g in self.cp.ground_objects:
if g.airbase_group:
group_info = QBaseDefenseGroupInfo(self.cp, g)
self.layout.addWidget(group_info)
self.setLayout(self.layout)

View File

@@ -42,9 +42,9 @@ class QMissionPlanning(QDialog):
self.planned_flight_view.selectionModel().selectionChanged.connect(self.on_flight_selection_change)
if len(self.planned_flight_view.flight_planner.flights) > 0:
self.flight_planner = QFlightPlanner(self.planned_flight_view.flight_planner.flights[0], self.game)
self.flight_planner = QFlightPlanner(self.planned_flight_view.flight_planner.flights[0], self.game, self.planned_flight_view.flight_planner)
else:
self.flight_planner = QFlightPlanner(None, self.game)
self.flight_planner = QFlightPlanner(None, self.game, self.planned_flight_view.flight_planner)
self.add_flight_button = QPushButton("Add Flight")
self.add_flight_button.clicked.connect(self.on_add_flight)
@@ -89,7 +89,7 @@ class QMissionPlanning(QDialog):
index = self.planned_flight_view.selectionModel().currentIndex().row()
flight = self.planner.flights[index]
self.flight_planner = QFlightPlanner(flight, self.game)
self.flight_planner = QFlightPlanner(flight, self.game, self.planner)
self.layout.addWidget(self.flight_planner, 0, 1)
def on_add_flight(self):

View File

@@ -1,7 +1,8 @@
from typing import List
from PySide2.QtCore import Qt
from PySide2.QtWidgets import QDialog, QGridLayout, QLabel, QComboBox, QHBoxLayout, QVBoxLayout, QPushButton, QSpinBox
from PySide2.QtWidgets import QDialog, QGridLayout, QLabel, QComboBox, QHBoxLayout, QVBoxLayout, QPushButton, QSpinBox, \
QMessageBox
from dcs import Point
from dcs.unittype import UnitType
@@ -28,6 +29,7 @@ class QFlightCreator(QDialog):
self.from_cp = from_cp
self.flight_view = flight_view
self.planner = self.game.planners[from_cp.id]
self.available = self.planner.get_available_aircraft()
self.setWindowFlags(Qt.WindowStaysOnTopHint)
self.setModal(True)
@@ -35,7 +37,7 @@ class QFlightCreator(QDialog):
self.setWindowIcon(EVENT_ICONS["strike"])
self.select_type_aircraft = QComboBox()
for aircraft_type in possible_aircraft_type:
for aircraft_type in self.planner.get_available_aircraft().keys():
print(aircraft_type)
print(aircraft_type.name)
self.select_type_aircraft.addItem(aircraft_type.id, userData=aircraft_type)
@@ -47,7 +49,7 @@ class QFlightCreator(QDialog):
self.select_flight_type.addItem("TARCAP [Target Combat Air Patrol]", userData=FlightType.TARCAP)
self.select_flight_type.addItem("INTERCEPT [Interception]", userData=FlightType.INTERCEPTION)
self.select_flight_type.addItem("CAS [Close Air Support]", userData=FlightType.CAS)
self.select_flight_type.addItem("BAI [Battlefield Interdiction]", userData=FlightType.CAS)
self.select_flight_type.addItem("BAI [Battlefield Interdiction]", userData=FlightType.BAI)
self.select_flight_type.addItem("SEAD [Suppression of Enemy Air Defenses]", userData=FlightType.SEAD)
self.select_flight_type.addItem("DEAD [Destruction of Enemy Air Defenses]", userData=FlightType.DEAD)
self.select_flight_type.addItem("STRIKE [Strike]", userData=FlightType.STRIKE)
@@ -60,7 +62,7 @@ class QFlightCreator(QDialog):
self.select_count_of_aircraft.setValue(2)
self.add_button = QPushButton("Add")
self.add_button.clicked.connect(self.create)
self.add_button.clicked.connect(self.create_flight)
self.init_ui()
@@ -91,13 +93,24 @@ class QFlightCreator(QDialog):
self.setLayout(layout)
def create(self):
def create_flight(self):
aircraft_type = self.select_type_aircraft.currentData()
count = self.select_count_of_aircraft.value()
flight = Flight(aircraft_type, count, self.from_cp, self.select_flight_type.currentData())
self.planner.flights.append(flight)
self.planner.custom_flights.append(flight)
if self.flight_view is not None:
self.flight_view.set_flight_planner(self.planner)
self.close()
if self.available[aircraft_type] < count:
msg = QMessageBox()
msg.setIcon(QMessageBox.Information)
msg.setText("Not enough aircraft of this type are available. Only " + str(self.available[aircraft_type]) + " available.")
msg.setWindowTitle("Not enough aircraft")
msg.setStandardButtons(QMessageBox.Ok)
msg.setWindowFlags(Qt.WindowStaysOnTopHint)
msg.exec_()
return
else:
flight = Flight(aircraft_type, count, self.from_cp, self.select_flight_type.currentData())
self.planner.flights.append(flight)
self.planner.custom_flights.append(flight)
if self.flight_view is not None:
self.flight_view.set_flight_planner(self.planner)
self.close()

View File

@@ -9,10 +9,10 @@ from qt_ui.windows.mission.flight.waypoints.QFlightWaypointTab import QFlightWay
class QFlightPlanner(QTabWidget):
def __init__(self, flight: Flight, game: Game):
def __init__(self, flight: Flight, game: Game, planner):
super(QFlightPlanner, self).__init__()
if flight:
self.general_settings_tab = QGeneralFlightSettingsTab(flight, game)
self.general_settings_tab = QGeneralFlightSettingsTab(flight, game, planner)
self.payload_tab = QFlightPayloadTab(flight, game)
self.waypoint_tab = QFlightWaypointTab(game, flight)
self.addTab(self.general_settings_tab, "General Flight settings")

View File

@@ -6,23 +6,32 @@ class QFlightSlotEditor(QGroupBox):
changed = Signal()
def __init__(self, flight, game):
def __init__(self, flight, game, planner):
super(QFlightSlotEditor, self).__init__("Slots")
self.flight = flight
self.game = game
self.planner = planner
self.available = self.planner.get_available_aircraft()
if self.flight.unit_type not in self.available:
max = self.flight.count
else:
max = self.flight.count + self.available[self.flight.unit_type]
if max > 4:
max = 4
layout = QGridLayout()
self.aircraft_count = QLabel("Aircraft count :")
self.aircraft_count_spinner = QSpinBox()
self.aircraft_count_spinner.setMinimum(1)
self.aircraft_count_spinner.setMaximum(4)
self.aircraft_count_spinner.setMaximum(max)
self.aircraft_count_spinner.setValue(flight.count)
self.aircraft_count_spinner.valueChanged.connect(self._changed_aircraft_count)
self.client_count = QLabel("Client slots count :")
self.client_count_spinner = QSpinBox()
self.client_count_spinner.setMinimum(0)
self.client_count_spinner.setMaximum(4)
self.client_count_spinner.setMaximum(max)
self.client_count_spinner.setValue(flight.client_count)
self.client_count_spinner.valueChanged.connect(self._changed_client_count)

View File

@@ -10,17 +10,18 @@ from qt_ui.windows.mission.flight.settings.QFlightTypeTaskInfo import QFlightTyp
class QGeneralFlightSettingsTab(QFrame):
def __init__(self, flight: Flight, game: Game):
def __init__(self, flight: Flight, game: Game, planner):
super(QGeneralFlightSettingsTab, self).__init__()
self.flight = flight
self.game = game
self.planner = planner
self.init_ui()
def init_ui(self):
layout = QGridLayout()
self.flight_info = QFlightTypeTaskInfo(self.flight)
self.flight_departure = QFlightDepartureEditor(self.flight)
self.flight_slots = QFlightSlotEditor(self.flight, self.game)
self.flight_slots = QFlightSlotEditor(self.flight, self.game, self.planner)
self.flight_start_type = QFlightStartType(self.flight)
layout.addWidget(self.flight_info, 0, 0)
layout.addWidget(self.flight_departure, 1, 0)

View File

@@ -5,6 +5,7 @@ from PySide2.QtWidgets import QLabel, QDialog, QGridLayout, QListView, QStackedL
import qt_ui.uiconstants as CONST
from game.game import Game
from game.infos.information import Information
from qt_ui.windows.GameUpdateSignal import GameUpdateSignal
@@ -163,21 +164,28 @@ class QSettingsWindow(QDialog):
self.cheat50M = QPushButton("Cheat +50M")
self.cheat100M = QPushButton("Cheat +100M")
self.cheat200M = QPushButton("Cheat +200M")
self.cheat500M = QPushButton("Cheat +500M")
self.cheat1000M = QPushButton("Cheat +1000M")
self.cheat25M.clicked.connect(lambda: self.cheatMoney(25))
self.cheat50M.clicked.connect(lambda: self.cheatMoney(50))
self.cheat100M.clicked.connect(lambda: self.cheatMoney(100))
self.cheat200M.clicked.connect(lambda: self.cheatMoney(200))
self.cheat500M.clicked.connect(lambda: self.cheatMoney(500))
self.cheat1000M.clicked.connect(lambda: self.cheatMoney(1000))
self.moneyCheatBoxLayout.addWidget(self.cheat25M, 0, 0)
self.moneyCheatBoxLayout.addWidget(self.cheat50M, 0, 1)
self.moneyCheatBoxLayout.addWidget(self.cheat100M, 1, 0)
self.moneyCheatBoxLayout.addWidget(self.cheat200M, 1, 1)
self.moneyCheatBoxLayout.addWidget(self.cheat500M, 2, 0)
self.moneyCheatBoxLayout.addWidget(self.cheat1000M, 2, 1)
self.cheatLayout.addWidget(self.moneyCheatBox, 0, 0)
def cheatMoney(self, amount):
self.game.budget += amount
self.game.informations.append(Information("CHEATER", "You are a cheater and you should feel bad", self.game.turn))
GameUpdateSignal.get_instance().updateGame(self.game)
def applySettings(self):