Stats view now has a tab for vehicles forces. Display waypoint coordinates in waypoint tab.

This commit is contained in:
Khopa
2019-10-19 13:12:21 +02:00
parent 7fbc75b375
commit 48a40f2511
16 changed files with 187 additions and 41 deletions

View 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 QAircraftChart(QFrame):
def __init__(self, game: Game):
super(QAircraftChart, self).__init__()
self.game = game
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)

View 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)

View 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)