mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Implemented stats view.
This commit is contained in:
59
qt_ui/widgets/QStatsWindow.py
Normal file
59
qt_ui/widgets/QStatsWindow.py
Normal file
@@ -0,0 +1,59 @@
|
||||
from PySide2 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
|
||||
|
||||
|
||||
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.initUi()
|
||||
|
||||
def initUi(self):
|
||||
self.layout = QGridLayout()
|
||||
self.generateUnitCharts()
|
||||
self.setLayout(self.layout)
|
||||
|
||||
def generateUnitCharts(self):
|
||||
|
||||
self.alliedAircraft = [d.allied_units.aircraft_count for d in self.game.game_stats.data_per_turn]
|
||||
self.enemyAircraft = [d.enemy_units.aircraft_count for d in self.game.game_stats.data_per_turn]
|
||||
|
||||
self.alliedAircraftSerie = QtCharts.QLineSeries()
|
||||
self.alliedAircraftSerie.setName("Allied aircraft count")
|
||||
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):
|
||||
self.enemyAircraftSerie.append(QPoint(a, i))
|
||||
|
||||
self.chart = QtCharts.QChart()
|
||||
self.chart.addSeries(self.alliedAircraftSerie)
|
||||
self.chart.addSeries(self.enemyAircraftSerie)
|
||||
self.chart.setTitle("Aircraft forces over time")
|
||||
|
||||
self.chart.createDefaultAxes()
|
||||
self.chart.axisX().setRange(0, len(self.alliedAircraft))
|
||||
self.chart.axisY().setRange(0, max(max(self.alliedAircraft), max(self.enemyAircraft)) + 10)
|
||||
|
||||
self.chartView = QtCharts.QChartView(self.chart)
|
||||
self.chartView.setRenderHint(QPainter.Antialiasing)
|
||||
|
||||
self.layout.addWidget(self.chartView, 0, 0)
|
||||
|
||||
@@ -2,6 +2,7 @@ from PySide2.QtWidgets import QFrame, QHBoxLayout, QPushButton, QVBoxLayout, QMe
|
||||
|
||||
from game import Game
|
||||
from qt_ui.widgets.QBudgetBox import QBudgetBox
|
||||
from qt_ui.widgets.QStatsWindow import QStatsWindow
|
||||
from qt_ui.widgets.QTurnCounter import QTurnCounter
|
||||
|
||||
import qt_ui.uiconstants as CONST
|
||||
@@ -60,7 +61,8 @@ class QTopPanel(QFrame):
|
||||
self.subwindow.show()
|
||||
|
||||
def openStatisticsWindow(self):
|
||||
QMessageBox.information(self, "Stats", "Todo open stats window")
|
||||
self.subwindow = QStatsWindow(self.game)
|
||||
self.subwindow.show()
|
||||
|
||||
def passTurn(self):
|
||||
self.game.pass_turn()
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
import os
|
||||
|
||||
from PySide2 import QtCore
|
||||
from PySide2.QtCore import QSize, Qt, QItemSelectionModel, QModelIndex, QPoint
|
||||
from PySide2.QtGui import QMovie, QStandardItemModel, QStandardItem
|
||||
from PySide2.QtWidgets import QLabel, QDialog, QVBoxLayout, QGridLayout, QListView, QStackedLayout, QComboBox, QWidget, \
|
||||
from PySide2.QtCore import QSize, Qt, QItemSelectionModel, QPoint
|
||||
from PySide2.QtGui import QStandardItemModel, QStandardItem
|
||||
from PySide2.QtWidgets import QLabel, QDialog, QGridLayout, QListView, QStackedLayout, QComboBox, QWidget, \
|
||||
QAbstractItemView, QPushButton, QGroupBox, QCheckBox
|
||||
|
||||
from game.game import Event, Game
|
||||
from qt_ui.windows.GameUpdateSignal import GameUpdateSignal
|
||||
import qt_ui.uiconstants as CONST
|
||||
from userdata.debriefing import wait_for_debriefing, Debriefing
|
||||
from userdata.persistency import base_path
|
||||
from game.game import Game
|
||||
from qt_ui.windows.GameUpdateSignal import GameUpdateSignal
|
||||
|
||||
|
||||
class QSettingsWindow(QDialog):
|
||||
|
||||
Reference in New Issue
Block a user