mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Stats view now has a tab for vehicles forces. Display waypoint coordinates in waypoint tab.
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
from PySide2.QtWidgets import QFrame, QHBoxLayout, QPushButton, QVBoxLayout, QMessageBox, QGridLayout
|
||||
from PySide2.QtWidgets import QFrame, QHBoxLayout, QPushButton, QVBoxLayout
|
||||
|
||||
from game import Game
|
||||
from qt_ui.widgets.QBudgetBox import QBudgetBox
|
||||
from qt_ui.widgets.QStatsWindow import QStatsWindow
|
||||
from qt_ui.windows.stats.QStatsWindow import QStatsWindow
|
||||
from qt_ui.widgets.QTurnCounter import QTurnCounter
|
||||
|
||||
import qt_ui.uiconstants as CONST
|
||||
|
||||
@@ -66,7 +66,7 @@ class QLiberationMap(QGraphicsView):
|
||||
scene.clear()
|
||||
|
||||
self.addBackground()
|
||||
self.add_game_events()
|
||||
#self.add_game_events()
|
||||
|
||||
for cp in self.game.theater.controlpoints:
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
from PySide2.QtCore import Qt, Slot, QItemSelectionModel, QPoint
|
||||
from PySide2.QtWidgets import QDialog, QGridLayout, QScrollArea, QVBoxLayout
|
||||
from PySide2.QtWidgets import QDialog, QGridLayout, QScrollArea, QVBoxLayout, QPushButton
|
||||
from game import Game
|
||||
from game.event import StrikeEvent, InsurgentAttackEvent, FrontlineAttackEvent, CAP, CAS
|
||||
from qt_ui.uiconstants import EVENT_ICONS
|
||||
from qt_ui.windows.QWaitingForMissionResultWindow import QWaitingForMissionResultWindow
|
||||
from qt_ui.windows.mission.QPlannedFlightsView import QPlannedFlightsView
|
||||
from qt_ui.windows.mission.QChooseAirbase import QChooseAirbase
|
||||
from qt_ui.windows.mission.flight.QFlightPlanner import QFlightPlanner
|
||||
@@ -15,6 +18,7 @@ class QMissionPlanning(QDialog):
|
||||
self.setMinimumSize(750, 350)
|
||||
self.setModal(True)
|
||||
self.setWindowTitle("Mission Preparation")
|
||||
self.setWindowIcon(EVENT_ICONS[StrikeEvent])
|
||||
self.init_ui()
|
||||
print("DONE")
|
||||
|
||||
@@ -37,12 +41,16 @@ class QMissionPlanning(QDialog):
|
||||
|
||||
self.flight_planner = QFlightPlanner(self.planned_flight_view.flight_planner.flights[0], self.game)
|
||||
|
||||
self.mission_start_button = QPushButton("Take Off")
|
||||
self.mission_start_button.setProperty("style", "start-button")
|
||||
self.mission_start_button.clicked.connect(self.on_start)
|
||||
|
||||
self.left_bar_layout.addWidget(self.select_airbase)
|
||||
self.left_bar_layout.addWidget(self.planned_flight_view)
|
||||
|
||||
self.layout.addLayout(self.left_bar_layout, 0, 0)
|
||||
self.layout.addWidget(self.flight_planner, 0, 1)
|
||||
self.layout.addWidget(self.mission_start_button, 1, 1, alignment=Qt.AlignRight)
|
||||
|
||||
self.setLayout(self.layout)
|
||||
|
||||
@@ -61,3 +69,31 @@ class QMissionPlanning(QDialog):
|
||||
|
||||
self.flight_planner = QFlightPlanner(flight, self.game)
|
||||
self.layout.addWidget(self.flight_planner,0 ,1)
|
||||
|
||||
def on_start(self):
|
||||
|
||||
for event in self.game.events:
|
||||
if isinstance(event, FrontlineAttackEvent) and event.is_player_attacking:
|
||||
self.gameEvent = event
|
||||
|
||||
#if self.awacs_checkbox.isChecked() == 1:
|
||||
# self.gameEvent.is_awacs_enabled = True
|
||||
# self.game.awacs_expense_commit()
|
||||
#else:
|
||||
# self.gameEvent.is_awacs_enabled = False
|
||||
self.gameEvent.is_awacs_enabled = False
|
||||
self.gameEvent.ca_slots = 1
|
||||
self.gameEvent.departure_cp = self.game.theater.controlpoints[0]
|
||||
|
||||
if self.game.is_player_attack(self.gameEvent):
|
||||
self.gameEvent.player_attacking({CAS:{}, CAP:{}})
|
||||
else:
|
||||
self.gameEvent.player_defending({CAS: {}, CAP: {}})
|
||||
self.gameEvent.depart_from = self.game.theater.controlpoints[0]
|
||||
|
||||
self.game.initiate_event(self.gameEvent)
|
||||
waiting = QWaitingForMissionResultWindow(self.gameEvent, self.game)
|
||||
waiting.show()
|
||||
self.close()
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
from typing import List
|
||||
|
||||
from PySide2.QtGui import QStandardItem
|
||||
|
||||
|
||||
class QWaypointItem(QStandardItem):
|
||||
|
||||
def __init__(self, point: List[int]):
|
||||
super(QWaypointItem, self).__init__()
|
||||
|
||||
self.setText("X: " + str(int(point[0])) + "; Y: " + str(int(point[1])) + "; Alt: " + str(int(point[2])) + "m")
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
from PySide2.QtGui import QStandardItemModel
|
||||
from PySide2.QtWidgets import QListView
|
||||
|
||||
from gen.flights.flight import Flight
|
||||
from qt_ui.windows.mission.flight.waypoints.QFlightWaypointItem import QWaypointItem
|
||||
|
||||
|
||||
class QFlightWaypointList(QListView):
|
||||
|
||||
def __init__(self, flight: Flight):
|
||||
super(QFlightWaypointList, self).__init__()
|
||||
self.model = QStandardItemModel(self)
|
||||
self.setModel(self.model)
|
||||
self.flight = flight
|
||||
|
||||
self.model.appendRow(QWaypointItem([flight.from_cp.position.x, flight.from_cp.position.y, 0]))
|
||||
for i, point in enumerate(self.flight.points):
|
||||
self.model.appendRow(QWaypointItem(point))
|
||||
@@ -1,6 +1,7 @@
|
||||
from PySide2.QtWidgets import QFrame, QGridLayout, QLabel
|
||||
|
||||
from gen.flights.flight import Flight
|
||||
from qt_ui.windows.mission.flight.waypoints.QFlightWaypointList import QFlightWaypointList
|
||||
|
||||
|
||||
class QFlightWaypointTab(QFrame):
|
||||
@@ -12,5 +13,6 @@ class QFlightWaypointTab(QFrame):
|
||||
|
||||
def init_ui(self):
|
||||
layout = QGridLayout()
|
||||
layout.addWidget(QLabel("Coming in two weeks"))
|
||||
self.flight_waypoint_list = QFlightWaypointList(self.flight)
|
||||
layout.addWidget(self.flight_waypoint_list)
|
||||
self.setLayout(layout)
|
||||
|
||||
@@ -1,25 +1,15 @@
|
||||
from PySide2 import QtCharts
|
||||
from PySide2.QtCharts import QtCharts
|
||||
from PySide2.QtCore import QPoint, Qt
|
||||
from PySide2.QtGui import QPainter
|
||||
from PySide2.QtWidgets import QDialog, QGridLayout
|
||||
from PySide2.QtCharts import QtCharts
|
||||
|
||||
import qt_ui.uiconstants as CONST
|
||||
from game.game import Game
|
||||
from PySide2.QtWidgets import QFrame, QGridLayout
|
||||
from game import Game
|
||||
|
||||
|
||||
class QStatsWindow(QDialog):
|
||||
class QAircraftChart(QFrame):
|
||||
|
||||
def __init__(self, game: Game):
|
||||
super(QStatsWindow, self).__init__()
|
||||
|
||||
super(QAircraftChart, self).__init__()
|
||||
self.game = game
|
||||
|
||||
self.setModal(True)
|
||||
self.setWindowTitle("Stats")
|
||||
self.setWindowIcon(CONST.ICONS["Statistics"])
|
||||
self.setMinimumSize(600, 250)
|
||||
|
||||
self.initUi()
|
||||
|
||||
def initUi(self):
|
||||
@@ -34,13 +24,13 @@ class QStatsWindow(QDialog):
|
||||
|
||||
self.alliedAircraftSerie = QtCharts.QLineSeries()
|
||||
self.alliedAircraftSerie.setName("Allied aircraft count")
|
||||
for a,i in enumerate(self.alliedAircraft):
|
||||
for a, i in enumerate(self.alliedAircraft):
|
||||
self.alliedAircraftSerie.append(QPoint(a, i))
|
||||
|
||||
self.enemyAircraftSerie = QtCharts.QLineSeries()
|
||||
self.enemyAircraftSerie.setColor(Qt.red)
|
||||
self.enemyAircraftSerie.setName("Enemy aircraft count")
|
||||
for a,i in enumerate(self.enemyAircraft):
|
||||
for a, i in enumerate(self.enemyAircraft):
|
||||
self.enemyAircraftSerie.append(QPoint(a, i))
|
||||
|
||||
self.chart = QtCharts.QChart()
|
||||
@@ -56,4 +46,3 @@ class QStatsWindow(QDialog):
|
||||
self.chartView.setRenderHint(QPainter.Antialiasing)
|
||||
|
||||
self.layout.addWidget(self.chartView, 0, 0)
|
||||
|
||||
48
qt_ui/windows/stats/QArmorChart.py
Normal file
48
qt_ui/windows/stats/QArmorChart.py
Normal file
@@ -0,0 +1,48 @@
|
||||
from PySide2.QtCharts import QtCharts
|
||||
from PySide2.QtCore import QPoint, Qt
|
||||
from PySide2.QtGui import QPainter
|
||||
from PySide2.QtWidgets import QFrame, QGridLayout
|
||||
from game import Game
|
||||
|
||||
|
||||
class QArmorChart(QFrame):
|
||||
|
||||
def __init__(self, game: Game):
|
||||
super(QArmorChart, self).__init__()
|
||||
self.game = game
|
||||
self.initUi()
|
||||
|
||||
def initUi(self):
|
||||
self.layout = QGridLayout()
|
||||
self.generateUnitCharts()
|
||||
self.setLayout(self.layout)
|
||||
|
||||
def generateUnitCharts(self):
|
||||
|
||||
self.alliedArmor = [d.allied_units.vehicles_count for d in self.game.game_stats.data_per_turn]
|
||||
self.enemyArmor = [d.enemy_units.vehicles_count for d in self.game.game_stats.data_per_turn]
|
||||
|
||||
self.alliedArmorSerie = QtCharts.QLineSeries()
|
||||
self.alliedArmorSerie.setName("Allied vehicle count")
|
||||
for a, i in enumerate(self.alliedArmor):
|
||||
self.alliedArmorSerie.append(QPoint(a, i))
|
||||
|
||||
self.enemyArmorSerie = QtCharts.QLineSeries()
|
||||
self.enemyArmorSerie.setColor(Qt.red)
|
||||
self.enemyArmorSerie.setName("Enemy vehicle count")
|
||||
for a, i in enumerate(self.enemyArmor):
|
||||
self.enemyArmorSerie.append(QPoint(a, i))
|
||||
|
||||
self.chart = QtCharts.QChart()
|
||||
self.chart.addSeries(self.alliedArmorSerie)
|
||||
self.chart.addSeries(self.enemyArmorSerie)
|
||||
self.chart.setTitle("Combat vehicles over time")
|
||||
|
||||
self.chart.createDefaultAxes()
|
||||
self.chart.axisX().setRange(0, len(self.alliedArmor))
|
||||
self.chart.axisY().setRange(0, max(max(self.alliedArmor), max(self.enemyArmor)) + 10)
|
||||
|
||||
self.chartView = QtCharts.QChartView(self.chart)
|
||||
self.chartView.setRenderHint(QPainter.Antialiasing)
|
||||
|
||||
self.layout.addWidget(self.chartView, 0, 0)
|
||||
27
qt_ui/windows/stats/QStatsWindow.py
Normal file
27
qt_ui/windows/stats/QStatsWindow.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from PySide2.QtWidgets import QDialog, QGridLayout, QTabWidget
|
||||
|
||||
import qt_ui.uiconstants as CONST
|
||||
from game.game import Game
|
||||
from qt_ui.windows.stats.QAircraftChart import QAircraftChart
|
||||
from qt_ui.windows.stats.QArmorChart import QArmorChart
|
||||
|
||||
|
||||
class QStatsWindow(QDialog):
|
||||
|
||||
def __init__(self, game: Game):
|
||||
super(QStatsWindow, self).__init__()
|
||||
|
||||
self.game = game
|
||||
self.setModal(True)
|
||||
self.setWindowTitle("Stats")
|
||||
self.setWindowIcon(CONST.ICONS["Statistics"])
|
||||
self.setMinimumSize(600, 250)
|
||||
|
||||
self.layout = QGridLayout()
|
||||
self.aircraft_charts = QAircraftChart(self.game)
|
||||
self.armor_charts = QArmorChart(self.game)
|
||||
self.tabview = QTabWidget()
|
||||
self.tabview.addTab(self.aircraft_charts, "Aircraft")
|
||||
self.tabview.addTab(self.armor_charts, "Armor")
|
||||
self.layout.addWidget(self.tabview, 0, 0)
|
||||
self.setLayout(self.layout)
|
||||
Reference in New Issue
Block a user