add/edit/delet objectives and participants in war

This commit is contained in:
Maxime Réaux 2026-01-28 16:25:40 +01:00
parent e33dec40be
commit 495a5adb98
14 changed files with 1088 additions and 322 deletions

View file

@ -81,44 +81,50 @@ class Ui_MainWindow(object):
font.setPointSize(12)
self.warYear.setFont(font)
self.warYear.setObjectName("warYear")
self.labelEntrants = QtWidgets.QLabel(parent=self.pageWar)
self.labelEntrants.setGeometry(QtCore.QRect(10, 150, 111, 16))
self.labelEntrants.setObjectName("labelEntrants")
self.addEntrantBtn = QtWidgets.QPushButton(parent=self.pageWar)
self.addEntrantBtn.setGeometry(QtCore.QRect(420, 270, 81, 23))
self.addEntrantBtn.setObjectName("addEntrantBtn")
self.playersTable_2 = QtWidgets.QTableWidget(parent=self.pageWar)
self.playersTable_2.setGeometry(QtCore.QRect(10, 170, 401, 211))
self.playersTable_2.setObjectName("playersTable_2")
self.playersTable_2.setColumnCount(5)
self.playersTable_2.setRowCount(0)
self.labelParticipants = QtWidgets.QLabel(parent=self.pageWar)
self.labelParticipants.setGeometry(QtCore.QRect(10, 150, 111, 16))
self.labelParticipants.setObjectName("labelParticipants")
self.addWarParticipantBtn = QtWidgets.QPushButton(parent=self.pageWar)
self.addWarParticipantBtn.setGeometry(QtCore.QRect(420, 270, 81, 23))
self.addWarParticipantBtn.setObjectName("addWarParticipantBtn")
self.warParticipantsTable = QtWidgets.QTableWidget(parent=self.pageWar)
self.warParticipantsTable.setGeometry(QtCore.QRect(10, 170, 401, 211))
self.warParticipantsTable.setObjectName("warParticipantsTable")
self.warParticipantsTable.setColumnCount(5)
self.warParticipantsTable.setRowCount(0)
item = QtWidgets.QTableWidgetItem()
self.playersTable_2.setHorizontalHeaderItem(0, item)
self.warParticipantsTable.setHorizontalHeaderItem(0, item)
item = QtWidgets.QTableWidgetItem()
self.playersTable_2.setHorizontalHeaderItem(1, item)
self.warParticipantsTable.setHorizontalHeaderItem(1, item)
item = QtWidgets.QTableWidgetItem()
self.playersTable_2.setHorizontalHeaderItem(2, item)
self.warParticipantsTable.setHorizontalHeaderItem(2, item)
item = QtWidgets.QTableWidgetItem()
self.playersTable_2.setHorizontalHeaderItem(3, item)
self.warParticipantsTable.setHorizontalHeaderItem(3, item)
item = QtWidgets.QTableWidgetItem()
self.playersTable_2.setHorizontalHeaderItem(4, item)
self.addRoundBtn_8 = QtWidgets.QPushButton(parent=self.pageWar)
self.addRoundBtn_8.setEnabled(True)
self.addRoundBtn_8.setGeometry(QtCore.QRect(230, 400, 61, 23))
self.addRoundBtn_8.setObjectName("addRoundBtn_8")
self.listObjectives = QtWidgets.QListWidget(parent=self.pageWar)
self.listObjectives.setGeometry(QtCore.QRect(10, 60, 161, 71))
self.listObjectives.setObjectName("listObjectives")
self.warParticipantsTable.setHorizontalHeaderItem(4, item)
self.endWarBtn = QtWidgets.QPushButton(parent=self.pageWar)
self.endWarBtn.setEnabled(True)
self.endWarBtn.setGeometry(QtCore.QRect(230, 400, 61, 23))
self.endWarBtn.setObjectName("endWarBtn")
self.objectivesTable = QtWidgets.QTableWidget(parent=self.pageWar)
self.objectivesTable.setGeometry(QtCore.QRect(10, 60, 401, 71))
self.objectivesTable.setObjectName("objectivesTable")
self.objectivesTable.setColumnCount(2)
self.objectivesTable.setRowCount(0)
item = QtWidgets.QTableWidgetItem()
self.objectivesTable.setHorizontalHeaderItem(0, item)
item = QtWidgets.QTableWidgetItem()
self.objectivesTable.setHorizontalHeaderItem(1, item)
self.labelObjectives = QtWidgets.QLabel(parent=self.pageWar)
self.labelObjectives.setGeometry(QtCore.QRect(10, 40, 111, 20))
self.labelObjectives.setObjectName("labelObjectives")
self.addCampaignBtn_3 = QtWidgets.QPushButton(parent=self.pageWar)
self.addCampaignBtn_3.setEnabled(True)
self.addCampaignBtn_3.setGeometry(QtCore.QRect(180, 80, 91, 23))
self.addObjectiveBtn = QtWidgets.QPushButton(parent=self.pageWar)
self.addObjectiveBtn.setEnabled(True)
self.addObjectiveBtn.setGeometry(QtCore.QRect(420, 80, 91, 23))
font = QtGui.QFont()
font.setPointSize(10)
self.addCampaignBtn_3.setFont(font)
self.addCampaignBtn_3.setObjectName("addCampaignBtn_3")
self.addObjectiveBtn.setFont(font)
self.addObjectiveBtn.setObjectName("addObjectiveBtn")
self.selectedDetailsStack.addWidget(self.pageWar)
self.pageCampaign = QtWidgets.QWidget()
self.pageCampaign.setObjectName("pageCampaign")
@ -128,49 +134,49 @@ class Ui_MainWindow(object):
font.setPointSize(12)
self.campaignName.setFont(font)
self.campaignName.setObjectName("campaignName")
self.labelRound = QtWidgets.QLabel(parent=self.pageCampaign)
self.labelRound.setGeometry(QtCore.QRect(10, 40, 91, 16))
self.labelRound.setObjectName("labelRound")
self.addEntrantBtn_2 = QtWidgets.QPushButton(parent=self.pageCampaign)
self.addEntrantBtn_2.setGeometry(QtCore.QRect(420, 270, 75, 23))
self.addEntrantBtn_2.setObjectName("addEntrantBtn_2")
self.labelSectors = QtWidgets.QLabel(parent=self.pageCampaign)
self.labelSectors.setGeometry(QtCore.QRect(10, 40, 91, 16))
self.labelSectors.setObjectName("labelSectors")
self.addCampaignParticipantBtn = QtWidgets.QPushButton(parent=self.pageCampaign)
self.addCampaignParticipantBtn.setGeometry(QtCore.QRect(420, 270, 75, 23))
self.addCampaignParticipantBtn.setObjectName("addCampaignParticipantBtn")
self.campaignMonth = QtWidgets.QLabel(parent=self.pageCampaign)
self.campaignMonth.setGeometry(QtCore.QRect(280, 10, 121, 16))
font = QtGui.QFont()
font.setPointSize(12)
self.campaignMonth.setFont(font)
self.campaignMonth.setObjectName("campaignMonth")
self.labelEntrants_2 = QtWidgets.QLabel(parent=self.pageCampaign)
self.labelEntrants_2.setGeometry(QtCore.QRect(10, 180, 47, 13))
self.labelEntrants_2.setObjectName("labelEntrants_2")
self.playersTable_3 = QtWidgets.QTableWidget(parent=self.pageCampaign)
self.playersTable_3.setGeometry(QtCore.QRect(10, 200, 401, 181))
self.playersTable_3.setObjectName("playersTable_3")
self.playersTable_3.setColumnCount(4)
self.playersTable_3.setRowCount(0)
self.labelParticipants_2 = QtWidgets.QLabel(parent=self.pageCampaign)
self.labelParticipants_2.setGeometry(QtCore.QRect(10, 180, 47, 13))
self.labelParticipants_2.setObjectName("labelParticipants_2")
self.campaignParticipantsTable = QtWidgets.QTableWidget(parent=self.pageCampaign)
self.campaignParticipantsTable.setGeometry(QtCore.QRect(10, 200, 401, 181))
self.campaignParticipantsTable.setObjectName("campaignParticipantsTable")
self.campaignParticipantsTable.setColumnCount(4)
self.campaignParticipantsTable.setRowCount(0)
item = QtWidgets.QTableWidgetItem()
self.playersTable_3.setHorizontalHeaderItem(0, item)
self.campaignParticipantsTable.setHorizontalHeaderItem(0, item)
item = QtWidgets.QTableWidgetItem()
self.playersTable_3.setHorizontalHeaderItem(1, item)
self.campaignParticipantsTable.setHorizontalHeaderItem(1, item)
item = QtWidgets.QTableWidgetItem()
self.playersTable_3.setHorizontalHeaderItem(2, item)
self.campaignParticipantsTable.setHorizontalHeaderItem(2, item)
item = QtWidgets.QTableWidgetItem()
self.playersTable_3.setHorizontalHeaderItem(3, item)
self.playersTable_4 = QtWidgets.QTableWidget(parent=self.pageCampaign)
self.playersTable_4.setGeometry(QtCore.QRect(10, 60, 401, 101))
self.playersTable_4.setObjectName("playersTable_4")
self.playersTable_4.setColumnCount(5)
self.playersTable_4.setRowCount(0)
self.campaignParticipantsTable.setHorizontalHeaderItem(3, item)
self.sectorsTable = QtWidgets.QTableWidget(parent=self.pageCampaign)
self.sectorsTable.setGeometry(QtCore.QRect(10, 60, 401, 101))
self.sectorsTable.setObjectName("sectorsTable")
self.sectorsTable.setColumnCount(5)
self.sectorsTable.setRowCount(0)
item = QtWidgets.QTableWidgetItem()
self.playersTable_4.setHorizontalHeaderItem(0, item)
self.sectorsTable.setHorizontalHeaderItem(0, item)
item = QtWidgets.QTableWidgetItem()
self.playersTable_4.setHorizontalHeaderItem(1, item)
self.sectorsTable.setHorizontalHeaderItem(1, item)
item = QtWidgets.QTableWidgetItem()
self.playersTable_4.setHorizontalHeaderItem(2, item)
self.sectorsTable.setHorizontalHeaderItem(2, item)
item = QtWidgets.QTableWidgetItem()
self.playersTable_4.setHorizontalHeaderItem(3, item)
self.sectorsTable.setHorizontalHeaderItem(3, item)
item = QtWidgets.QTableWidgetItem()
self.playersTable_4.setHorizontalHeaderItem(4, item)
self.sectorsTable.setHorizontalHeaderItem(4, item)
self.addSectorBtn = QtWidgets.QPushButton(parent=self.pageCampaign)
self.addSectorBtn.setEnabled(True)
self.addSectorBtn.setGeometry(QtCore.QRect(420, 110, 71, 23))
@ -202,32 +208,32 @@ class Ui_MainWindow(object):
font.setPointSize(12)
self.roundNb.setFont(font)
self.roundNb.setObjectName("roundNb")
self.resolveBtn = QtWidgets.QPushButton(parent=self.pageRound)
self.resolveBtn.setEnabled(True)
self.resolveBtn.setGeometry(QtCore.QRect(320, 110, 91, 23))
self.resolveBtn.setObjectName("resolveBtn")
self.playersTable_6 = QtWidgets.QTableWidget(parent=self.pageRound)
self.playersTable_6.setGeometry(QtCore.QRect(10, 240, 301, 111))
self.playersTable_6.setObjectName("playersTable_6")
self.playersTable_6.setColumnCount(3)
self.playersTable_6.setRowCount(0)
self.resolvePairingBtn = QtWidgets.QPushButton(parent=self.pageRound)
self.resolvePairingBtn.setEnabled(True)
self.resolvePairingBtn.setGeometry(QtCore.QRect(320, 110, 91, 23))
self.resolvePairingBtn.setObjectName("resolvePairingBtn")
self.battlesTable = QtWidgets.QTableWidget(parent=self.pageRound)
self.battlesTable.setGeometry(QtCore.QRect(10, 240, 301, 111))
self.battlesTable.setObjectName("battlesTable")
self.battlesTable.setColumnCount(3)
self.battlesTable.setRowCount(0)
item = QtWidgets.QTableWidgetItem()
self.playersTable_6.setHorizontalHeaderItem(0, item)
self.battlesTable.setHorizontalHeaderItem(0, item)
item = QtWidgets.QTableWidgetItem()
self.playersTable_6.setHorizontalHeaderItem(1, item)
self.battlesTable.setHorizontalHeaderItem(1, item)
item = QtWidgets.QTableWidgetItem()
self.playersTable_6.setHorizontalHeaderItem(2, item)
self.resultBtn = QtWidgets.QPushButton(parent=self.pageRound)
self.resultBtn.setEnabled(True)
self.resultBtn.setGeometry(QtCore.QRect(320, 290, 91, 23))
self.resultBtn.setObjectName("resultBtn")
self.battlesTable.setHorizontalHeaderItem(2, item)
self.enterResultBtn = QtWidgets.QPushButton(parent=self.pageRound)
self.enterResultBtn.setEnabled(True)
self.enterResultBtn.setGeometry(QtCore.QRect(320, 290, 91, 23))
self.enterResultBtn.setObjectName("enterResultBtn")
self.endRoundBtn = QtWidgets.QPushButton(parent=self.pageRound)
self.endRoundBtn.setEnabled(True)
self.endRoundBtn.setGeometry(QtCore.QRect(220, 400, 71, 23))
self.endRoundBtn.setObjectName("endRoundBtn")
self.labelChoices_2 = QtWidgets.QLabel(parent=self.pageRound)
self.labelChoices_2.setGeometry(QtCore.QRect(10, 220, 91, 16))
self.labelChoices_2.setObjectName("labelChoices_2")
self.labelBattles = QtWidgets.QLabel(parent=self.pageRound)
self.labelBattles.setGeometry(QtCore.QRect(10, 220, 91, 16))
self.labelBattles.setObjectName("labelBattles")
self.selectedDetailsStack.addWidget(self.pageRound)
icon2 = QtGui.QIcon()
icon2.addPixmap(QtGui.QPixmap(".\\src\\warchron\\view\\ui\\../resources/swords-small.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
@ -331,43 +337,47 @@ class Ui_MainWindow(object):
self.labelSelect.setText(_translate("MainWindow", "Select an element within the tree to show/edit details."))
self.warName.setText(_translate("MainWindow", "warName"))
self.warYear.setText(_translate("MainWindow", "warYear"))
self.labelEntrants.setText(_translate("MainWindow", "Entrants"))
self.addEntrantBtn.setText(_translate("MainWindow", "Add entrant"))
item = self.playersTable_2.horizontalHeaderItem(0)
self.labelParticipants.setText(_translate("MainWindow", "Participants"))
self.addWarParticipantBtn.setText(_translate("MainWindow", "Add participant"))
item = self.warParticipantsTable.horizontalHeaderItem(0)
item.setText(_translate("MainWindow", "Name"))
item = self.playersTable_2.horizontalHeaderItem(1)
item = self.warParticipantsTable.horizontalHeaderItem(1)
item.setText(_translate("MainWindow", "Faction"))
item = self.playersTable_2.horizontalHeaderItem(2)
item = self.warParticipantsTable.horizontalHeaderItem(2)
item.setText(_translate("MainWindow", "Campaigns"))
item = self.playersTable_2.horizontalHeaderItem(3)
item = self.warParticipantsTable.horizontalHeaderItem(3)
item.setText(_translate("MainWindow", "Victory pts."))
item = self.playersTable_2.horizontalHeaderItem(4)
item = self.warParticipantsTable.horizontalHeaderItem(4)
item.setText(_translate("MainWindow", "Theme pts"))
self.addRoundBtn_8.setText(_translate("MainWindow", "End war"))
self.endWarBtn.setText(_translate("MainWindow", "End war"))
item = self.objectivesTable.horizontalHeaderItem(0)
item.setText(_translate("MainWindow", "Name"))
item = self.objectivesTable.horizontalHeaderItem(1)
item.setText(_translate("MainWindow", "Description"))
self.labelObjectives.setText(_translate("MainWindow", "Objectives"))
self.addCampaignBtn_3.setText(_translate("MainWindow", "Add objective"))
self.addObjectiveBtn.setText(_translate("MainWindow", "Add objective"))
self.campaignName.setText(_translate("MainWindow", "campaignName"))
self.labelRound.setText(_translate("MainWindow", "Sectors"))
self.addEntrantBtn_2.setText(_translate("MainWindow", "Add entrant"))
self.labelSectors.setText(_translate("MainWindow", "Sectors"))
self.addCampaignParticipantBtn.setText(_translate("MainWindow", "Add participant"))
self.campaignMonth.setText(_translate("MainWindow", "campaignMonth"))
self.labelEntrants_2.setText(_translate("MainWindow", "Entrants"))
item = self.playersTable_3.horizontalHeaderItem(0)
self.labelParticipants_2.setText(_translate("MainWindow", "Participants"))
item = self.campaignParticipantsTable.horizontalHeaderItem(0)
item.setText(_translate("MainWindow", "Name"))
item = self.playersTable_3.horizontalHeaderItem(1)
item = self.campaignParticipantsTable.horizontalHeaderItem(1)
item.setText(_translate("MainWindow", "Leader"))
item = self.playersTable_3.horizontalHeaderItem(2)
item = self.campaignParticipantsTable.horizontalHeaderItem(2)
item.setText(_translate("MainWindow", "Victory pts."))
item = self.playersTable_3.horizontalHeaderItem(3)
item = self.campaignParticipantsTable.horizontalHeaderItem(3)
item.setText(_translate("MainWindow", "Theme pts."))
item = self.playersTable_4.horizontalHeaderItem(0)
item = self.sectorsTable.horizontalHeaderItem(0)
item.setText(_translate("MainWindow", "Name"))
item = self.playersTable_4.horizontalHeaderItem(1)
item = self.sectorsTable.horizontalHeaderItem(1)
item.setText(_translate("MainWindow", "Round"))
item = self.playersTable_4.horizontalHeaderItem(2)
item = self.sectorsTable.horizontalHeaderItem(2)
item.setText(_translate("MainWindow", "Major obj."))
item = self.playersTable_4.horizontalHeaderItem(3)
item = self.sectorsTable.horizontalHeaderItem(3)
item.setText(_translate("MainWindow", "Minor opp."))
item = self.playersTable_4.horizontalHeaderItem(4)
item = self.sectorsTable.horizontalHeaderItem(4)
item.setText(_translate("MainWindow", "Influence imp."))
self.addSectorBtn.setText(_translate("MainWindow", "Add Sector"))
self.endCampaignBtn.setText(_translate("MainWindow", "End campaign"))
@ -379,16 +389,16 @@ class Ui_MainWindow(object):
item = self.choicesTable.horizontalHeaderItem(2)
item.setText(_translate("MainWindow", "Secondary"))
self.roundNb.setText(_translate("MainWindow", "Round Nb"))
self.resolveBtn.setText(_translate("MainWindow", "Resolve pairing"))
item = self.playersTable_6.horizontalHeaderItem(0)
self.resolvePairingBtn.setText(_translate("MainWindow", "Resolve pairing"))
item = self.battlesTable.horizontalHeaderItem(0)
item.setText(_translate("MainWindow", "Sector"))
item = self.playersTable_6.horizontalHeaderItem(1)
item = self.battlesTable.horizontalHeaderItem(1)
item.setText(_translate("MainWindow", "Player 1"))
item = self.playersTable_6.horizontalHeaderItem(2)
item = self.battlesTable.horizontalHeaderItem(2)
item.setText(_translate("MainWindow", "Player 2"))
self.resultBtn.setText(_translate("MainWindow", "Enter results"))
self.enterResultBtn.setText(_translate("MainWindow", "Enter results"))
self.endRoundBtn.setText(_translate("MainWindow", "End round"))
self.labelChoices_2.setText(_translate("MainWindow", "Battles"))
self.labelBattles.setText(_translate("MainWindow", "Battles"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.warsTab), _translate("MainWindow", "Wars"))
self.menuFile.setTitle(_translate("MainWindow", "File"))
self.menuEdit.setTitle(_translate("MainWindow", "Edit"))

View file

@ -214,7 +214,7 @@
<string>warYear</string>
</property>
</widget>
<widget class="QLabel" name="labelEntrants">
<widget class="QLabel" name="labelParticipants">
<property name="geometry">
<rect>
<x>10</x>
@ -224,10 +224,10 @@
</rect>
</property>
<property name="text">
<string>Entrants</string>
<string>Participants</string>
</property>
</widget>
<widget class="QPushButton" name="addEntrantBtn">
<widget class="QPushButton" name="addWarParticipantBtn">
<property name="geometry">
<rect>
<x>420</x>
@ -237,10 +237,10 @@
</rect>
</property>
<property name="text">
<string>Add entrant</string>
<string>Add participant</string>
</property>
</widget>
<widget class="QTableWidget" name="playersTable_2">
<widget class="QTableWidget" name="warParticipantsTable">
<property name="geometry">
<rect>
<x>10</x>
@ -275,7 +275,7 @@
</property>
</column>
</widget>
<widget class="QPushButton" name="addRoundBtn_8">
<widget class="QPushButton" name="endWarBtn">
<property name="enabled">
<bool>true</bool>
</property>
@ -291,15 +291,25 @@
<string>End war</string>
</property>
</widget>
<widget class="QListWidget" name="listObjectives">
<widget class="QTableWidget" name="objectivesTable">
<property name="geometry">
<rect>
<x>10</x>
<y>60</y>
<width>161</width>
<width>401</width>
<height>71</height>
</rect>
</property>
<column>
<property name="text">
<string>Name</string>
</property>
</column>
<column>
<property name="text">
<string>Description</string>
</property>
</column>
</widget>
<widget class="QLabel" name="labelObjectives">
<property name="geometry">
@ -314,13 +324,13 @@
<string>Objectives</string>
</property>
</widget>
<widget class="QPushButton" name="addCampaignBtn_3">
<widget class="QPushButton" name="addObjectiveBtn">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>180</x>
<x>420</x>
<y>80</y>
<width>91</width>
<height>23</height>
@ -355,7 +365,7 @@
<string>campaignName</string>
</property>
</widget>
<widget class="QLabel" name="labelRound">
<widget class="QLabel" name="labelSectors">
<property name="geometry">
<rect>
<x>10</x>
@ -368,7 +378,7 @@
<string>Sectors</string>
</property>
</widget>
<widget class="QPushButton" name="addEntrantBtn_2">
<widget class="QPushButton" name="addCampaignParticipantBtn">
<property name="geometry">
<rect>
<x>420</x>
@ -378,7 +388,7 @@
</rect>
</property>
<property name="text">
<string>Add entrant</string>
<string>Add participant</string>
</property>
</widget>
<widget class="QLabel" name="campaignMonth">
@ -399,7 +409,7 @@
<string>campaignMonth</string>
</property>
</widget>
<widget class="QLabel" name="labelEntrants_2">
<widget class="QLabel" name="labelParticipants_2">
<property name="geometry">
<rect>
<x>10</x>
@ -409,10 +419,10 @@
</rect>
</property>
<property name="text">
<string>Entrants</string>
<string>Participants</string>
</property>
</widget>
<widget class="QTableWidget" name="playersTable_3">
<widget class="QTableWidget" name="campaignParticipantsTable">
<property name="geometry">
<rect>
<x>10</x>
@ -442,7 +452,7 @@
</property>
</column>
</widget>
<widget class="QTableWidget" name="playersTable_4">
<widget class="QTableWidget" name="sectorsTable">
<property name="geometry">
<rect>
<x>10</x>
@ -567,7 +577,7 @@
<string>Round Nb</string>
</property>
</widget>
<widget class="QPushButton" name="resolveBtn">
<widget class="QPushButton" name="resolvePairingBtn">
<property name="enabled">
<bool>true</bool>
</property>
@ -583,7 +593,7 @@
<string>Resolve pairing</string>
</property>
</widget>
<widget class="QTableWidget" name="playersTable_6">
<widget class="QTableWidget" name="battlesTable">
<property name="geometry">
<rect>
<x>10</x>
@ -608,7 +618,7 @@
</property>
</column>
</widget>
<widget class="QPushButton" name="resultBtn">
<widget class="QPushButton" name="enterResultBtn">
<property name="enabled">
<bool>true</bool>
</property>
@ -640,7 +650,7 @@
<string>End round</string>
</property>
</widget>
<widget class="QLabel" name="labelChoices_2">
<widget class="QLabel" name="labelBattles">
<property name="geometry">
<rect>
<x>10</x>

View file

@ -0,0 +1,59 @@
# Form implementation generated from reading ui file '.\src\warchron\view\ui\ui_objective_dialog.ui'
#
# Created by: PyQt6 UI code generator 6.7.1
#
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt6 import QtCore, QtGui, QtWidgets
class Ui_objectiveDialog(object):
def setupUi(self, objectiveDialog):
objectiveDialog.setObjectName("objectiveDialog")
objectiveDialog.setWindowModality(QtCore.Qt.WindowModality.ApplicationModal)
objectiveDialog.resize(394, 148)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(".\\src\\warchron\\view\\ui\\../resources/warchron_logo.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
objectiveDialog.setWindowIcon(icon)
self.gridLayout = QtWidgets.QGridLayout(objectiveDialog)
self.gridLayout.setObjectName("gridLayout")
self.label = QtWidgets.QLabel(parent=objectiveDialog)
self.label.setObjectName("label")
self.gridLayout.addWidget(self.label, 0, 0, 1, 1)
self.objectiveName = QtWidgets.QLineEdit(parent=objectiveDialog)
self.objectiveName.setObjectName("objectiveName")
self.gridLayout.addWidget(self.objectiveName, 0, 1, 1, 1)
self.label_2 = QtWidgets.QLabel(parent=objectiveDialog)
self.label_2.setObjectName("label_2")
self.gridLayout.addWidget(self.label_2, 1, 0, 1, 1)
self.objectiveDescription = QtWidgets.QTextEdit(parent=objectiveDialog)
self.objectiveDescription.setObjectName("objectiveDescription")
self.gridLayout.addWidget(self.objectiveDescription, 1, 1, 1, 1)
self.buttonBox = QtWidgets.QDialogButtonBox(parent=objectiveDialog)
self.buttonBox.setOrientation(QtCore.Qt.Orientation.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.StandardButton.Cancel|QtWidgets.QDialogButtonBox.StandardButton.Ok)
self.buttonBox.setObjectName("buttonBox")
self.gridLayout.addWidget(self.buttonBox, 2, 0, 1, 2)
self.retranslateUi(objectiveDialog)
self.buttonBox.accepted.connect(objectiveDialog.accept) # type: ignore
self.buttonBox.rejected.connect(objectiveDialog.reject) # type: ignore
QtCore.QMetaObject.connectSlotsByName(objectiveDialog)
def retranslateUi(self, objectiveDialog):
_translate = QtCore.QCoreApplication.translate
objectiveDialog.setWindowTitle(_translate("objectiveDialog", "Objective"))
self.label.setText(_translate("objectiveDialog", "Name"))
self.label_2.setText(_translate("objectiveDialog", "Description"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
objectiveDialog = QtWidgets.QDialog()
ui = Ui_objectiveDialog()
ui.setupUi(objectiveDialog)
objectiveDialog.show()
sys.exit(app.exec())

View file

@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>objectiveDialog</class>
<widget class="QDialog" name="objectiveDialog">
<property name="windowModality">
<enum>Qt::ApplicationModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>394</width>
<height>148</height>
</rect>
</property>
<property name="windowTitle">
<string>Objective</string>
</property>
<property name="windowIcon">
<iconset>
<normaloff>../resources/warchron_logo.png</normaloff>../resources/warchron_logo.png</iconset>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="objectiveName"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Description</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QTextEdit" name="objectiveDescription"/>
</item>
<item row="2" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>objectiveDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>objectiveDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View file

@ -0,0 +1,64 @@
# Form implementation generated from reading ui file '.\src\warchron\view\ui\ui_participant_dialog.ui'
#
# Created by: PyQt6 UI code generator 6.7.1
#
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt6 import QtCore, QtGui, QtWidgets
class Ui_participantDialog(object):
def setupUi(self, participantDialog):
participantDialog.setObjectName("participantDialog")
participantDialog.setWindowModality(QtCore.Qt.WindowModality.ApplicationModal)
participantDialog.resize(394, 148)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(".\\src\\warchron\\view\\ui\\../resources/warchron_logo.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
participantDialog.setWindowIcon(icon)
self.gridLayout = QtWidgets.QGridLayout(participantDialog)
self.gridLayout.setObjectName("gridLayout")
self.label = QtWidgets.QLabel(parent=participantDialog)
self.label.setObjectName("label")
self.gridLayout.addWidget(self.label, 0, 0, 1, 1)
self.playerComboBox = QtWidgets.QComboBox(parent=participantDialog)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.playerComboBox.sizePolicy().hasHeightForWidth())
self.playerComboBox.setSizePolicy(sizePolicy)
self.playerComboBox.setObjectName("playerComboBox")
self.gridLayout.addWidget(self.playerComboBox, 0, 1, 1, 1)
self.label_2 = QtWidgets.QLabel(parent=participantDialog)
self.label_2.setObjectName("label_2")
self.gridLayout.addWidget(self.label_2, 1, 0, 1, 1)
self.faction = QtWidgets.QLineEdit(parent=participantDialog)
self.faction.setObjectName("faction")
self.gridLayout.addWidget(self.faction, 1, 1, 1, 1)
self.buttonBox = QtWidgets.QDialogButtonBox(parent=participantDialog)
self.buttonBox.setOrientation(QtCore.Qt.Orientation.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.StandardButton.Cancel|QtWidgets.QDialogButtonBox.StandardButton.Ok)
self.buttonBox.setObjectName("buttonBox")
self.gridLayout.addWidget(self.buttonBox, 2, 0, 1, 2)
self.retranslateUi(participantDialog)
self.buttonBox.accepted.connect(participantDialog.accept) # type: ignore
self.buttonBox.rejected.connect(participantDialog.reject) # type: ignore
QtCore.QMetaObject.connectSlotsByName(participantDialog)
def retranslateUi(self, participantDialog):
_translate = QtCore.QCoreApplication.translate
participantDialog.setWindowTitle(_translate("participantDialog", "Participant"))
self.label.setText(_translate("participantDialog", "Player"))
self.label_2.setText(_translate("participantDialog", "Faction"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
participantDialog = QtWidgets.QDialog()
ui = Ui_participantDialog()
ui.setupUi(participantDialog)
participantDialog.show()
sys.exit(app.exec())

View file

@ -0,0 +1,98 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>participantDialog</class>
<widget class="QDialog" name="participantDialog">
<property name="windowModality">
<enum>Qt::ApplicationModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>394</width>
<height>148</height>
</rect>
</property>
<property name="windowTitle">
<string>Participant</string>
</property>
<property name="windowIcon">
<iconset>
<normaloff>../resources/warchron_logo.png</normaloff>../resources/warchron_logo.png</iconset>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Player</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="playerComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Faction</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="faction"/>
</item>
<item row="2" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>participantDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>participantDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View file

@ -11,6 +11,8 @@ from warchron.view.ui.ui_main_window import Ui_MainWindow
from warchron.view.ui.ui_player_dialog import Ui_playerDialog
from warchron.view.ui.ui_war_dialog import Ui_warDialog
from warchron.view.ui.ui_campaign_dialog import Ui_campaignDialog
from warchron.view.ui.ui_objective_dialog import Ui_objectiveDialog
from warchron.view.ui.ui_participant_dialog import Ui_participantDialog
class View(QtWidgets.QMainWindow, Ui_MainWindow):
def __init__(self, parent=None):
@ -25,6 +27,10 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
self.show_details(None)
self.playersTable.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
self.playersTable.customContextMenuRequested.connect(self._on_players_table_context_menu)
self.warParticipantsTable.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
self.warParticipantsTable.customContextMenuRequested.connect(self._on_war_participants_table_context_menu)
self.objectivesTable.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
self.objectivesTable.customContextMenuRequested.connect(self._on_objectives_table_context_menu)
self.warsTree.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
self.warsTree.customContextMenuRequested.connect(self._on_wars_tree_context_menu)
self.addCampaignBtn.clicked.connect(self._on_add_campaign_clicked)
@ -41,46 +47,15 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
"id": current.data(0, ROLE_ID),
})
def _on_players_table_context_menu(self, pos):
item = self.playersTable.itemAt(pos)
if not item:
return
player_id = item.data(Qt.ItemDataRole.UserRole)
menu = QMenu(self)
edit_action = menu.addAction("Edit")
delete_action = menu.addAction("Delete")
action = menu.exec(self.playersTable.viewport().mapToGlobal(pos))
if action == edit_action and self.on_edit_item:
self.on_edit_item(ItemType.PLAYER, player_id)
elif action == delete_action and self.on_delete_item:
self.on_delete_item(ItemType.PLAYER, player_id)
def get_current_tab(self) -> str:
index = self.tabWidget.currentIndex()
if index == 0:
return "players"
elif index == 1:
return "wars"
return ""
def _on_wars_tree_context_menu(self, pos):
item = self.warsTree.itemAt(pos)
if not item:
return
item_type = item.data(0, ROLE_TYPE)
item_id = item.data(0, ROLE_ID)
menu = QMenu(self)
edit_action = None
if item_type != ItemType.ROUND:
edit_action = menu.addAction("Edit")
delete_action = menu.addAction("Delete")
action = menu.exec(self.warsTree.viewport().mapToGlobal(pos))
if action == edit_action:
if self.on_edit_item:
self.on_edit_item(item_type, item_id)
elif action == delete_action:
if self.on_delete_item:
self.on_delete_item(item_type, item_id)
def _on_add_campaign_clicked(self):
if self.on_add_campaign:
self.on_add_campaign()
def _on_add_round_clicked(self):
if self.on_add_round:
self.on_add_round()
# General popups
def closeEvent(self, event: QCloseEvent):
if self.on_close_callback:
@ -108,6 +83,26 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
)
return Path(filename) if filename else None
# Players view
def _on_players_table_context_menu(self, pos):
item = self.playersTable.itemAt(pos)
if not item:
return
row = item.row()
name_item = self.playersTable.item(row, 0)
if not name_item:
return
player_id = name_item.data(Qt.ItemDataRole.UserRole)
menu = QMenu(self)
edit_action = menu.addAction("Edit")
delete_action = menu.addAction("Delete")
action = menu.exec(self.playersTable.viewport().mapToGlobal(pos))
if action == edit_action and self.on_edit_item:
self.on_edit_item(ItemType.PLAYER, player_id)
elif action == delete_action and self.on_delete_item:
self.on_delete_item(ItemType.PLAYER, player_id)
def display_players(self, players: list):
table = self.playersTable
table.setRowCount(len(players))
@ -117,8 +112,43 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
table.setItem(row, 0, play_item)
table.resizeColumnsToContents()
# Wars view
def _on_add_campaign_clicked(self):
if self.on_add_campaign:
self.on_add_campaign()
def _on_add_round_clicked(self):
if self.on_add_round:
self.on_add_round()
def set_add_campaign_enabled(self, enabled: bool):
self.addCampaignBtn.setEnabled(enabled)
def set_add_round_enabled(self, enabled: bool):
self.addRoundBtn.setEnabled(enabled)
def _on_wars_tree_context_menu(self, pos):
item = self.warsTree.itemAt(pos)
if not item:
return
item_type = item.data(0, ROLE_TYPE)
item_id = item.data(0, ROLE_ID)
menu = QMenu(self)
edit_action = None
if item_type != ItemType.ROUND:
edit_action = menu.addAction("Edit")
delete_action = menu.addAction("Delete")
action = menu.exec(self.warsTree.viewport().mapToGlobal(pos))
if action == edit_action:
if self.on_edit_item:
self.on_edit_item(item_type, item_id)
elif action == delete_action:
if self.on_delete_item:
self.on_delete_item(item_type, item_id)
def _format_war_label(self, war) -> str:
return f"{war.name} ({war.name} ({war.year}))"
return f"{war.name} ({war.year})"
def _format_campaign_label(self, camp) -> str:
return f"{camp.name} ({calendar.month_name[camp.month]})"
@ -149,26 +179,21 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
tree.currentItemChanged.connect(self._emit_selection_changed)
tree.expandAll()
def show_details(self, item_type: str | None):
if item_type == ItemType.WAR:
self.selectedDetailsStack.setCurrentWidget(self.pageWar)
elif item_type == ItemType.CAMPAIGN:
self.selectedDetailsStack.setCurrentWidget(self.pageCampaign)
elif item_type == ItemType.ROUND:
self.selectedDetailsStack.setCurrentWidget(self.pageRound)
else:
self.selectedDetailsStack.setCurrentWidget(self.pageEmpty)
def show_war_details(self, *, name: str, year: int):
self.warName.setText(name)
self.warYear.setText(year)
def show_campaign_details(self, *, name: str, month: int):
self.campaignName.setText(name)
self.campaignMonth.setText(calendar.month_name[month])
def show_round_details(self, *, index: int):
self.roundNb.setText(f"Round {index}")
def select_tree_item(self, *, item_type: ItemType, item_id: str):
def walk(item: QTreeWidgetItem):
if (
item.data(0, ROLE_TYPE) == item_type
and item.data(0, ROLE_ID) == item_id
):
self.warsTree.setCurrentItem(item)
return True
for i in range(item.childCount()):
if walk(item.child(i)):
return True
return False
for i in range(self.warsTree.topLevelItemCount()):
if walk(self.warsTree.topLevelItem(i)):
return
def get_selected_tree_item(self):
item = self.warsTree.currentItem()
@ -179,20 +204,94 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
"id": item.data(0, ROLE_ID)
}
def set_add_campaign_enabled(self, enabled: bool):
self.addCampaignBtn.setEnabled(enabled)
def show_details(self, item_type: str | None):
if item_type == ItemType.WAR:
self.selectedDetailsStack.setCurrentWidget(self.pageWar)
elif item_type == ItemType.CAMPAIGN:
self.selectedDetailsStack.setCurrentWidget(self.pageCampaign)
elif item_type == ItemType.ROUND:
self.selectedDetailsStack.setCurrentWidget(self.pageRound)
else:
self.selectedDetailsStack.setCurrentWidget(self.pageEmpty)
def set_add_round_enabled(self, enabled: bool):
self.addRoundBtn.setEnabled(enabled)
# War page
def get_current_tab(self) -> str:
index = self.tabWidget.currentIndex()
if index == 0:
return "players"
elif index == 1:
return "wars"
return ""
def _on_objectives_table_context_menu(self, pos):
item = self.objectivesTable.itemAt(pos)
if not item:
return
row = item.row()
name_item = self.objectivesTable.item(row, 0)
if not name_item:
return
objective_id = name_item.data(Qt.ItemDataRole.UserRole)
menu = QMenu(self)
edit_action = menu.addAction("Edit")
delete_action = menu.addAction("Delete")
action = menu.exec(self.objectivesTable.viewport().mapToGlobal(pos))
if action == edit_action and self.on_edit_item:
self.on_edit_item(ItemType.OBJECTIVE, objective_id)
elif action == delete_action and self.on_delete_item:
self.on_delete_item(ItemType.OBJECTIVE, objective_id)
def _on_war_participants_table_context_menu(self, pos):
item = self.warParticipantsTable.itemAt(pos)
if not item:
return
row = item.row()
name_item = self.warParticipantsTable.item(row, 0)
if not name_item:
return
participant_id = name_item.data(Qt.ItemDataRole.UserRole)
menu = QMenu(self)
edit_action = menu.addAction("Edit")
delete_action = menu.addAction("Delete")
action = menu.exec(self.warParticipantsTable.viewport().mapToGlobal(pos))
if action == edit_action and self.on_edit_item:
self.on_edit_item(ItemType.WAR_PARTICIPANT, participant_id)
elif action == delete_action and self.on_delete_item:
self.on_delete_item(ItemType.WAR_PARTICIPANT, participant_id)
def show_war_details(self, *, name: str, year: int):
self.warName.setText(name)
self.warYear.setText(str(year))
def display_war_objectives(self, objectives: list):
table = self.objectivesTable
table.clearContents()
table.setRowCount(len(objectives))
for row, obj in enumerate(objectives):
name_item = QtWidgets.QTableWidgetItem(obj.name)
desc_item = QtWidgets.QTableWidgetItem(obj.description)
name_item.setData(Qt.ItemDataRole.UserRole, obj.id)
table.setItem(row, 0, name_item)
table.setItem(row, 1, desc_item)
table.resizeColumnsToContents()
def display_war_participants(self, participants: list[tuple[str, str, str]]):
table = self.warParticipantsTable
table.clearContents()
table.setRowCount(len(participants))
for row, (name, faction, pid) in enumerate(participants):
name_item = QtWidgets.QTableWidgetItem(name)
fact_item = QtWidgets.QTableWidgetItem(faction)
name_item.setData(Qt.ItemDataRole.UserRole, pid)
table.setItem(row, 0, name_item)
table.setItem(row, 1, fact_item)
table.resizeColumnsToContents()
# Campaign page
def show_campaign_details(self, *, name: str, month: int):
self.campaignName.setText(name)
self.campaignMonth.setText(calendar.month_name[month])
# Round page
def show_round_details(self, *, index: int):
self.roundNb.setText(f"Round {index}")
class PlayerDialog(QDialog):
def __init__(self, parent=None, *, default_name: str = ""):
super().__init__(parent)
@ -231,4 +330,38 @@ class CampaignDialog(QDialog):
return self.ui.campaignName.text().strip()
def get_campaign_month(self) -> int:
return int(self.ui.campaignMonth.value())
return int(self.ui.campaignMonth.value())
class ObjectiveDialog(QDialog):
def __init__(self, parent=None, *, default_name="", default_description=""):
super().__init__(parent)
self.ui = Ui_objectiveDialog()
self.ui.setupUi(self)
self.ui.objectiveName.setText(default_name)
self.ui.objectiveDescription.setPlainText(default_description)
def get_objective_name(self) -> str:
return self.ui.objectiveName.text().strip()
def get_objective_description(self) -> str:
return self.ui.objectiveDescription.toPlainText().strip()
class ParticipantDialog(QDialog):
def __init__(self, parent=None, *, players: list, default_player_id=None, default_faction="", editable_player=True):
super().__init__(parent)
self.ui = Ui_participantDialog()
self.ui.setupUi(self)
for player in players:
self.ui.playerComboBox.addItem(player.name, player.id)
if default_player_id:
index = self.ui.playerComboBox.findData(default_player_id)
if index != -1:
self.ui.playerComboBox.setCurrentIndex(index)
self.ui.playerComboBox.setEnabled(editable_player)
self.ui.faction.setText(default_faction)
def get_player_id(self) -> str:
return self.ui.playerComboBox.currentData()
def get_participant_faction(self) -> str:
return self.ui.faction.text().strip()