Compare commits

...

2 commits

Author SHA1 Message Date
Maxime Réaux
9f676f6b9d auto create & edit choice 2026-01-30 15:32:44 +01:00
Maxime Réaux
723723dea1 list round choices ; fix UI 2026-01-30 10:52:19 +01:00
15 changed files with 813 additions and 122 deletions

View file

@ -15,6 +15,8 @@ class ItemType(StrEnum):
WAR_PARTICIPANT = "war_participant" WAR_PARTICIPANT = "war_participant"
SECTOR = "sector" SECTOR = "sector"
CAMPAIGN_PARTICIPANT = "campaign_participant" CAMPAIGN_PARTICIPANT = "campaign_participant"
CHOICE = "choice"
BATTLE = "battle"
class RefreshScope(Enum): class RefreshScope(Enum):
NONE = auto() NONE = auto()

View file

@ -5,19 +5,19 @@ from warchron.model.model import Model
from warchron.view.view import View from warchron.view.view import View
from warchron.constants import ItemType, RefreshScope from warchron.constants import ItemType, RefreshScope
from warchron.view.view import PlayerDialog, WarDialog, CampaignDialog, ObjectiveDialog, WarParticipantDialog, CampaignParticipantDialog, SectorDialog
from warchron.controller.dtos import ParticipantOption from warchron.controller.dtos import ParticipantOption
from warchron.view.view import PlayerDialog, WarDialog, CampaignDialog, ObjectiveDialog, WarParticipantDialog, CampaignParticipantDialog, SectorDialog, ChoicesDialog
class Controller: class Controller:
def __init__(self, model: Model, view: View): def __init__(self, model: Model, view: View):
self.model = model self.model: Model = model
self.view = view self.view: View = view
self.current_file: Path | None = None self.current_file: Path | None = None
self.selected_war_id = None self.selected_war_id: str = None
self.selected_campaign_id = None self.selected_campaign_id: str = None
self.selected_round_id = None self.selected_round_id: str = None
self.view.on_close_callback = self.on_app_close self.view.on_close_callback = self.on_app_close
self.is_dirty = False self.is_dirty: bool = False
self.__connect() self.__connect()
self.refresh_players_view() self.refresh_players_view()
self.refresh_wars_view() self.refresh_wars_view()
@ -165,8 +165,24 @@ class Controller:
self.view.display_campaign_participants(participants_for_display) self.view.display_campaign_participants(participants_for_display)
def _fill_round_details(self, round_id: str): def _fill_round_details(self, round_id: str):
index = self.model.get_round_index(round_id) rnd = self.model.get_round(round_id)
self.view.show_round_details(index=index) camp = self.model.get_campaign_by_round(round_id)
self.view.show_round_details(index=camp.get_round_index(round_id))
participants = self.model.get_round_participants(round_id)
choices_for_display = []
for part in participants:
choice = rnd.get_choice(part.id)
if not choice:
choice=self.model.create_choice(round_id=rnd.id, participant_id=part.id)
priority_name = camp.get_sector_name(choice.priority_sector_id) if choice else ""
secondary_name = camp.get_sector_name(choice.secondary_sector_id) if choice else ""
choices_for_display.append((
self.model.get_player_name(part.id),
priority_name,
secondary_name,
choice.participant_id
))
self.view.display_round_choices(choices_for_display)
def on_tree_selection_changed(self, selection): def on_tree_selection_changed(self, selection):
self.selected_war_id = None self.selected_war_id = None
@ -325,7 +341,9 @@ class Controller:
theme = dialog.get_participant_theme() theme = dialog.get_participant_theme()
self.model.update_campaign_participant(item_id, leader=leader, theme=theme) self.model.update_campaign_participant(item_id, leader=leader, theme=theme)
self.refresh(RefreshScope.CAMPAIGN_DETAILS) self.refresh(RefreshScope.CAMPAIGN_DETAILS)
self.is_dirty = True elif item_type == ItemType.CHOICE:
self.edit_round_choice(item_id)
self.refresh(RefreshScope.ROUND_DETAILS)
def delete_item(self, item_type: str, item_id: str): def delete_item(self, item_type: str, item_id: str):
reply = QMessageBox.question( reply = QMessageBox.question(
@ -556,4 +574,34 @@ class Controller:
return return
rnd = self.model.add_round(self.selected_campaign_id) rnd = self.model.add_round(self.selected_campaign_id)
self.is_dirty = True self.is_dirty = True
self.refresh_and_select(RefreshScope.WARS_TREE, item_type=ItemType.ROUND, item_id=rnd.id) self.refresh_and_select(RefreshScope.WARS_TREE, item_type=ItemType.ROUND, item_id=rnd.id)
# Choices methods
def edit_round_choice(self, choice_id: str):
round_id = self.selected_round_id
if not round_id:
return
camp, rnd, participants, sectors = self.model.get_round_choices_data(round_id)
choice = rnd.get_choice(choice_id)
if not choice:
return
part = camp.participants[choice.participant_id]
player = self.model.get_player(part.id)
part_opt = ParticipantOption(id=player.id, name=player.name)
dialog = ChoicesDialog(
self.view,
participants=[part_opt],
default_participant_id=part.id,
sectors=sectors,
default_priority_id=choice.priority_sector_id,
default_secondary_id=choice.secondary_sector_id,
)
if dialog.exec() != QDialog.DialogCode.Accepted:
return
rnd.set_choice(
participant_id=part.id,
priority_sector_id=dialog.get_priority_id(),
secondary_sector_id=dialog.get_secondary_id(),
)

View file

@ -1,7 +1,7 @@
from __future__ import annotations from __future__ import annotations
from uuid import uuid4 from uuid import uuid4
from warchron.model.round import Round from warchron.model.round import Round, Choice, Battle
class Campaign: class Campaign:
def __init__(self, name: str, month: int): def __init__(self, name: str, month: int):
@ -10,7 +10,7 @@ class Campaign:
self.month: int = month self.month: int = month
self.participants: dict[str, CampaignParticipant] = {} self.participants: dict[str, CampaignParticipant] = {}
self.sectors: dict[str, Sector] = {} self.sectors: dict[str, Sector] = {}
self.rounds = [] self.rounds: list[Round] = []
self.is_over = False self.is_over = False
def set_id(self, new_id: str): def set_id(self, new_id: str):
@ -72,6 +72,8 @@ class Campaign:
part.set_theme(theme) part.set_theme(theme)
def remove_campaign_participant(self, player_id: str): def remove_campaign_participant(self, player_id: str):
# TODO manage choices referring to it
# TODO manage battles referring to it
del self.participants[player_id] del self.participants[player_id]
# Sector methods # Sector methods
@ -81,12 +83,18 @@ class Campaign:
self.sectors[sect.id] = sect self.sectors[sect.id] = sect
return sect return sect
def get_sector(self, id: str) -> Sector: def get_sector(self, sector_id: str) -> Sector:
return self.sectors[id] return self.sectors[sector_id]
def get_sector_name(self, sector_id: str) -> str:
if sector_id is None:
return ""
return self.sectors[sector_id].name
def get_all_sectors(self) -> list[Sector]: def get_all_sectors(self) -> list[Sector]:
return list(self.sectors.values()) return list(self.sectors.values())
# TODO manage choices referring to it (round order!)
def update_sector(self, sector_id: str, *, name: str, round_id: str, major_id: str, minor_id: str, influence_id: str): def update_sector(self, sector_id: str, *, name: str, round_id: str, major_id: str, minor_id: str, influence_id: str):
sect = self.get_sector(sector_id) sect = self.get_sector(sector_id)
sect.set_name(name) sect.set_name(name)
@ -96,6 +104,8 @@ class Campaign:
sect.set_influence(influence_id) sect.set_influence(influence_id)
def remove_sector(self, sector_id: str): def remove_sector(self, sector_id: str):
# TODO manage choices referring to it
# TODO manage battles referring to it
del self.sectors[sector_id] del self.sectors[sector_id]
# Round methods # Round methods
@ -104,7 +114,10 @@ class Campaign:
return any(r.id == round_id for r in self.rounds) return any(r.id == round_id for r in self.rounds)
def get_round(self, round_id: str) -> Round: def get_round(self, round_id: str) -> Round:
return self.rounds[round_id] for rnd in self.rounds:
if rnd.id == round_id:
return rnd
raise KeyError(f"Round {round_id} not found")
def get_all_rounds(self) -> list[Round]: def get_all_rounds(self) -> list[Round]:
return list(self.rounds) return list(self.rounds)
@ -135,6 +148,16 @@ class Campaign:
return rnd.name return rnd.name
return "" return ""
# Choice methods
def create_choice(self, round_id: str, participant_id: str) -> Choice:
rnd = self.get_round(round_id)
return rnd.create_choice(participant_id)
def remove_choice(self, round_id: str, participant_id: str) -> Choice:
rnd = self.get_round(round_id)
rnd.remove_choice(participant_id)
class CampaignParticipant: class CampaignParticipant:
def __init__(self,player_id: str, leader: str, theme: str): def __init__(self,player_id: str, leader: str, theme: str):
self.id: str = player_id # ref to War.participants self.id: str = player_id # ref to War.participants
@ -155,9 +178,9 @@ class Sector:
self.id: str = str(uuid4()) self.id: str = str(uuid4())
self.name: str = name self.name: str = name
self.round_id: str = round_id self.round_id: str = round_id
self.major_objective_id: str = major_id self.major_objective_id: str | None = major_id # ref to War.objectives
self.minor_objective_id: str = minor_id self.minor_objective_id: str | None = minor_id # ref to War.objectives
self.influence_objective_id: str = influence_id self.influence_objective_id: str | None = influence_id # ref to War.objectives
def set_id(self, new_id: str): def set_id(self, new_id: str):
self.id = new_id self.id = new_id

View file

@ -6,7 +6,7 @@ from datetime import datetime
from warchron.model.player import Player from warchron.model.player import Player
from warchron.model.war import War, Objective, WarParticipant from warchron.model.war import War, Objective, WarParticipant
from warchron.model.campaign import Campaign, Sector, CampaignParticipant from warchron.model.campaign import Campaign, Sector, CampaignParticipant
from warchron.model.round import Round from warchron.model.round import Round, Choice, Battle
class Model: class Model:
def __init__(self): def __init__(self):
@ -76,6 +76,7 @@ class Model:
return list(self.players.values()) return list(self.players.values())
def remove_player(self, player_id: str): def remove_player(self, player_id: str):
# TODO manage war_participants referring to it
del self.players[player_id] del self.players[player_id]
# War methods # War methods
@ -100,6 +101,22 @@ class Model:
return war return war
raise KeyError(f"Campaign {campaign_id} not found in any War") raise KeyError(f"Campaign {campaign_id} not found in any War")
def get_war_by_sector(self, sector_id: str) -> Campaign:
for war in self.wars.values():
for camp in war.campaigns:
for sect in camp.sectors.values():
if sect.id == sector_id:
return camp
raise KeyError(f"Sector {sector_id} not found in any War")
def get_war_by_round(self, round_id: str) -> Campaign:
for war in self.wars.values():
for camp in war.campaigns:
for rnd in camp.rounds:
if rnd.id == round_id:
return camp
raise KeyError(f"Round {round_id} not found in any War")
def get_war_by_objective(self, objective_id: str) -> War: def get_war_by_objective(self, objective_id: str) -> War:
for war in self.wars.values(): for war in self.wars.values():
for obj in war.objectives.values(): for obj in war.objectives.values():
@ -107,6 +124,7 @@ class Model:
return war return war
raise KeyError(f"Objective {objective_id} not found in any War") raise KeyError(f"Objective {objective_id} not found in any War")
# TODO don't use this method as participant with same ID (player) can be in several wars!
def get_war_by_war_participant(self, participant_id: str) -> War: def get_war_by_war_participant(self, participant_id: str) -> War:
for war in self.wars.values(): for war in self.wars.values():
for part in war.participants.values(): for part in war.participants.values():
@ -199,6 +217,7 @@ class Model:
return camp return camp
raise KeyError(f"Round {round_id} not found") raise KeyError(f"Round {round_id} not found")
# TODO don't use this method as participant with same ID (player) can be in several campaigns!
def get_campaign_by_campaign_participant(self, participant_id: str) -> Campaign: def get_campaign_by_campaign_participant(self, participant_id: str) -> Campaign:
for war in self.wars.values(): for war in self.wars.values():
camp = war.get_campaign_by_campaign_participant(participant_id) camp = war.get_campaign_by_campaign_participant(participant_id)
@ -236,8 +255,8 @@ class Model:
raise KeyError("Sector not found") raise KeyError("Sector not found")
def update_sector(self, sector_id: str, *, name: str, round_id: str, major_id: str, minor_id: str, influence_id: str): def update_sector(self, sector_id: str, *, name: str, round_id: str, major_id: str, minor_id: str, influence_id: str):
camp = self.get_campaign_by_sector(sector_id) war = self.get_war_by_sector(sector_id)
camp.update_sector(sector_id, name=name, round_id=round_id, major_id=major_id, minor_id=minor_id, influence_id=influence_id) war.update_sector(sector_id, name=name, round_id=round_id, major_id=major_id, minor_id=minor_id, influence_id=influence_id)
def remove_sector(self, sector_id: str): def remove_sector(self, sector_id: str):
camp = self.get_campaign_by_sector(sector_id) camp = self.get_campaign_by_sector(sector_id)
@ -286,7 +305,35 @@ class Model:
def get_round_index(self, round_id: str) -> int: def get_round_index(self, round_id: str) -> int:
camp = self.get_campaign_by_round(round_id) camp = self.get_campaign_by_round(round_id)
return camp.get_round_index(round_id) return camp.get_round_index(round_id)
def get_round_sectors(self, round_id: str) -> list[Sector]:
camp = self.get_campaign_by_round(round_id)
return [s for s in camp.sectors.values() if s.round_id == round_id]
def get_round_participants(self, round_id: str) -> list[CampaignParticipant]:
camp = self.get_campaign_by_round(round_id)
return list(camp.participants.values())
def remove_round(self, round_id: str): def remove_round(self, round_id: str):
war = self.get_war_by_round(round_id)
war.remove_round(round_id)
# Choices methods
def create_choice(self, round_id: str, participant_id: str) -> Choice:
war = self.get_war_by_round(round_id)
return war.create_choice(round_id, participant_id)
def remove_choice(self, round_id: str, participant_id: str):
war = self.get_war_by_round(round_id)
war.remove_choice(round_id, participant_id)
def get_round_choices_data(self, round_id: str):
camp = self.get_campaign_by_round(round_id) camp = self.get_campaign_by_round(round_id)
camp.remove_round(round_id) rnd = self.get_round(round_id)
participants = camp.participants.values()
sectors = [
s for s in camp.sectors.values()
if s.round_id == round_id
]
return camp, rnd, participants, sectors

View file

@ -1,11 +1,11 @@
from __future__ import annotations
from uuid import uuid4 from uuid import uuid4
class Round: class Round:
def __init__(self): def __init__(self):
self.id: str = str(uuid4()) self.id: str = str(uuid4())
self.sectors = {} self.choices: dict[str, Choice] = {}
self.choices = {} self.battles: dict[str, Battle] = {}
self.battles = {}
self.is_over: bool = False self.is_over: bool = False
def set_id(self, new_id: str): def set_id(self, new_id: str):
@ -14,6 +14,9 @@ class Round:
def set_state(self, new_state: bool): def set_state(self, new_state: bool):
self.is_over = new_state self.is_over = new_state
def set_choice(self, participant_id: str, priority_sector_id: str | None, secondary_sector_id: str | None):
self.choices[participant_id] = Choice(participant_id, priority_sector_id, secondary_sector_id)
def toDict(self): def toDict(self):
return { return {
"id": self.id, "id": self.id,
@ -31,4 +34,34 @@ class Round:
# rnd.choices = data.get("choices", {}) # rnd.choices = data.get("choices", {})
# rnd.battles = data.get("battles", {}) # rnd.battles = data.get("battles", {})
rnd.set_state(data.get("is_over", False)) rnd.set_state(data.get("is_over", False))
return rnd return rnd
# Choices methods
def get_choice(self, participant_id: str) -> Choice | None:
return self.choices.get(participant_id)
def create_choice(self, participant_id: str) -> Choice:
if participant_id not in self.choices:
choice = Choice(
participant_id=participant_id,
priority_sector_id=None,
secondary_sector_id=None
)
self.choices[participant_id] = choice
return self.choices[participant_id]
def remove_choice(self,participant_id: str):
del self.choices[participant_id]
class Choice:
def __init__(self, participant_id: str, priority_sector_id: str | None = None, secondary_sector_id: str | None = None):
self.participant_id: str = participant_id # ref to Campaign.participants
self.priority_sector_id: str | None = priority_sector_id # ref to Campaign.sectors
self.secondary_sector_id: str | None = secondary_sector_id # ref to Campaign.sectors
class Battle:
def __init__(self, sector_id: str, player_1_id: str | None = None, player_2_id: str | None = None):
self.sector_id: str = sector_id # ref to Campaign.sector
self.player_1_id: str | None = player_1_id # ref to Campaign.participants
self.player_2_id: str | None = player_2_id # ref to Campaign.participants

View file

@ -3,6 +3,7 @@ from uuid import uuid4
from datetime import datetime from datetime import datetime
from warchron.model.campaign import Campaign, Sector, CampaignParticipant from warchron.model.campaign import Campaign, Sector, CampaignParticipant
from warchron.model.round import Round, Choice, Battle
class War: class War:
@ -12,7 +13,7 @@ class War:
self.year: int = year self.year: int = year
self.participants: dict[str, WarParticipant] = {} self.participants: dict[str, WarParticipant] = {}
self.objectives: dict[str, Objective] = {} self.objectives: dict[str, Objective] = {}
self.campaigns = [] self.campaigns: list[Campaign] = []
self.is_over: bool = False self.is_over: bool = False
def set_id(self, new_id: str): def set_id(self, new_id: str):
@ -72,6 +73,7 @@ class War:
obj.set_description(description) obj.set_description(description)
def remove_objective(self, objective_id: str): def remove_objective(self, objective_id: str):
# TODO manage sectors referring to it
del self.objectives[objective_id] del self.objectives[objective_id]
# War participant methods # War participant methods
@ -100,6 +102,7 @@ class War:
part.set_faction(faction) part.set_faction(faction)
def remove_war_participant(self, player_id: str): def remove_war_participant(self, player_id: str):
# TODO manage campaign_participants referring to it
del self.participants[player_id] del self.participants[player_id]
# Campaign methods # Campaign methods
@ -167,10 +170,10 @@ class War:
def get_sector(self, id: str) -> Sector: def get_sector(self, id: str) -> Sector:
return self.sectors[id] return self.sectors[id]
def update_sector(self, objective_id: str, *, name: str, round_id: str, major_id: str, minor_id: str, influence_id: str): def update_sector(self, sector_id: str, *, name: str, round_id: str, major_id: str, minor_id: str, influence_id: str):
obj = self.get_objective(objective_id) camp = self.get_campaign_by_sector(sector_id)
obj.set_name(name) camp.update_sector(sector_id, name=name, round_id=round_id, major_id=major_id, minor_id=minor_id, influence_id=influence_id)
def remove_sector(self, sector_id: str): def remove_sector(self, sector_id: str):
camp = self.get_campaign_by_sector(sector_id) camp = self.get_campaign_by_sector(sector_id)
camp.remove_sector(sector_id) camp.remove_sector(sector_id)
@ -204,6 +207,26 @@ class War:
camp = self.get_campaign_by_campaign_participant(participant_id) camp = self.get_campaign_by_campaign_participant(participant_id)
camp.remove_campaign_participant(participant_id) camp.remove_campaign_participant(participant_id)
# Round methods
def add_round(self, campaign_id: str) -> Round:
camp = self.get_campaign(campaign_id)
return camp.add_round()
def remove_round(self, round_id: str):
camp = self.get_campaign_by_round(round_id)
camp.remove_round(round_id)
# Choice methods
def create_choice(self, round_id: str, participant_id: str) -> Choice:
camp = self.get_campaign_by_round(round_id)
return camp.create_choice(round_id, participant_id)
def remove_choice(self, round_id: str, participant_id: str):
camp = self.get_campaign_by_round(round_id)
camp.remove_choice(round_id, participant_id)
class Objective: class Objective:
def __init__(self, name: str, description: str): def __init__(self, name: str, description: str):
self.id: str = str(uuid4()) self.id: str = str(uuid4())

View file

@ -0,0 +1,78 @@
# Form implementation generated from reading ui file '.\src\warchron\view\ui\ui_battle_result_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_battleResultDialog(object):
def setupUi(self, battleResultDialog):
battleResultDialog.setObjectName("battleResultDialog")
battleResultDialog.setWindowModality(QtCore.Qt.WindowModality.ApplicationModal)
battleResultDialog.resize(561, 246)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(".\\src\\warchron\\view\\ui\\../resources/warchron_logo.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
battleResultDialog.setWindowIcon(icon)
self.formLayout = QtWidgets.QFormLayout(battleResultDialog)
self.formLayout.setObjectName("formLayout")
self.label = QtWidgets.QLabel(parent=battleResultDialog)
self.label.setObjectName("label")
self.formLayout.setWidget(0, QtWidgets.QFormLayout.ItemRole.LabelRole, self.label)
self.winnerComboBox = QtWidgets.QComboBox(parent=battleResultDialog)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.winnerComboBox.sizePolicy().hasHeightForWidth())
self.winnerComboBox.setSizePolicy(sizePolicy)
self.winnerComboBox.setObjectName("winnerComboBox")
self.formLayout.setWidget(0, QtWidgets.QFormLayout.ItemRole.FieldRole, self.winnerComboBox)
self.label_2 = QtWidgets.QLabel(parent=battleResultDialog)
self.label_2.setObjectName("label_2")
self.formLayout.setWidget(1, QtWidgets.QFormLayout.ItemRole.LabelRole, self.label_2)
self.score = QtWidgets.QLineEdit(parent=battleResultDialog)
self.score.setObjectName("score")
self.formLayout.setWidget(1, QtWidgets.QFormLayout.ItemRole.FieldRole, self.score)
self.label_3 = QtWidgets.QLabel(parent=battleResultDialog)
self.label_3.setObjectName("label_3")
self.formLayout.setWidget(2, QtWidgets.QFormLayout.ItemRole.LabelRole, self.label_3)
self.victoryCondition = QtWidgets.QLineEdit(parent=battleResultDialog)
self.victoryCondition.setObjectName("victoryCondition")
self.formLayout.setWidget(2, QtWidgets.QFormLayout.ItemRole.FieldRole, self.victoryCondition)
self.label_4 = QtWidgets.QLabel(parent=battleResultDialog)
self.label_4.setObjectName("label_4")
self.formLayout.setWidget(3, QtWidgets.QFormLayout.ItemRole.LabelRole, self.label_4)
self.battleComment = QtWidgets.QPlainTextEdit(parent=battleResultDialog)
self.battleComment.setObjectName("battleComment")
self.formLayout.setWidget(3, QtWidgets.QFormLayout.ItemRole.FieldRole, self.battleComment)
self.buttonBox = QtWidgets.QDialogButtonBox(parent=battleResultDialog)
self.buttonBox.setOrientation(QtCore.Qt.Orientation.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.StandardButton.Cancel|QtWidgets.QDialogButtonBox.StandardButton.Ok)
self.buttonBox.setObjectName("buttonBox")
self.formLayout.setWidget(4, QtWidgets.QFormLayout.ItemRole.SpanningRole, self.buttonBox)
self.retranslateUi(battleResultDialog)
self.buttonBox.accepted.connect(battleResultDialog.accept) # type: ignore
self.buttonBox.rejected.connect(battleResultDialog.reject) # type: ignore
QtCore.QMetaObject.connectSlotsByName(battleResultDialog)
def retranslateUi(self, battleResultDialog):
_translate = QtCore.QCoreApplication.translate
battleResultDialog.setWindowTitle(_translate("battleResultDialog", "Battle result"))
self.label.setText(_translate("battleResultDialog", "Winner"))
self.label_2.setText(_translate("battleResultDialog", "Score"))
self.label_3.setText(_translate("battleResultDialog", "Victory condition"))
self.label_4.setText(_translate("battleResultDialog", "Comment"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
battleResultDialog = QtWidgets.QDialog()
ui = Ui_battleResultDialog()
ui.setupUi(battleResultDialog)
battleResultDialog.show()
sys.exit(app.exec())

View file

@ -0,0 +1,118 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>battleResultDialog</class>
<widget class="QDialog" name="battleResultDialog">
<property name="windowModality">
<enum>Qt::ApplicationModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>561</width>
<height>246</height>
</rect>
</property>
<property name="windowTitle">
<string>Battle result</string>
</property>
<property name="windowIcon">
<iconset>
<normaloff>../resources/warchron_logo.png</normaloff>../resources/warchron_logo.png</iconset>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Winner</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="winnerComboBox">
<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>Score</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="score"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Victory condition</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="victoryCondition"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Comment</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QPlainTextEdit" name="battleComment"/>
</item>
<item row="4" 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>battleResultDialog</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>battleResultDialog</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,88 @@
# Form implementation generated from reading ui file '.\src\warchron\view\ui\ui_choices_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_choicesDialog(object):
def setupUi(self, choicesDialog):
choicesDialog.setObjectName("choicesDialog")
choicesDialog.setWindowModality(QtCore.Qt.WindowModality.ApplicationModal)
choicesDialog.resize(561, 246)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(".\\src\\warchron\\view\\ui\\../resources/warchron_logo.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
choicesDialog.setWindowIcon(icon)
self.gridLayout = QtWidgets.QGridLayout(choicesDialog)
self.gridLayout.setObjectName("gridLayout")
self.label = QtWidgets.QLabel(parent=choicesDialog)
self.label.setObjectName("label")
self.gridLayout.addWidget(self.label, 0, 0, 1, 1)
self.playerComboBox = QtWidgets.QComboBox(parent=choicesDialog)
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=choicesDialog)
self.label_2.setObjectName("label_2")
self.gridLayout.addWidget(self.label_2, 1, 0, 1, 1)
self.priorityComboBox = QtWidgets.QComboBox(parent=choicesDialog)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.priorityComboBox.sizePolicy().hasHeightForWidth())
self.priorityComboBox.setSizePolicy(sizePolicy)
self.priorityComboBox.setObjectName("priorityComboBox")
self.gridLayout.addWidget(self.priorityComboBox, 1, 1, 1, 1)
self.label_3 = QtWidgets.QLabel(parent=choicesDialog)
self.label_3.setObjectName("label_3")
self.gridLayout.addWidget(self.label_3, 2, 0, 1, 1)
self.secondaryComboBox = QtWidgets.QComboBox(parent=choicesDialog)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.secondaryComboBox.sizePolicy().hasHeightForWidth())
self.secondaryComboBox.setSizePolicy(sizePolicy)
self.secondaryComboBox.setObjectName("secondaryComboBox")
self.gridLayout.addWidget(self.secondaryComboBox, 2, 1, 1, 1)
self.label_4 = QtWidgets.QLabel(parent=choicesDialog)
self.label_4.setObjectName("label_4")
self.gridLayout.addWidget(self.label_4, 3, 0, 1, 1)
self.choiceComment = QtWidgets.QPlainTextEdit(parent=choicesDialog)
self.choiceComment.setObjectName("choiceComment")
self.gridLayout.addWidget(self.choiceComment, 3, 1, 1, 1)
self.buttonBox = QtWidgets.QDialogButtonBox(parent=choicesDialog)
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, 4, 0, 1, 2)
self.retranslateUi(choicesDialog)
self.buttonBox.accepted.connect(choicesDialog.accept) # type: ignore
self.buttonBox.rejected.connect(choicesDialog.reject) # type: ignore
QtCore.QMetaObject.connectSlotsByName(choicesDialog)
def retranslateUi(self, choicesDialog):
_translate = QtCore.QCoreApplication.translate
choicesDialog.setWindowTitle(_translate("choicesDialog", "Choices"))
self.label.setText(_translate("choicesDialog", "Player"))
self.label_2.setText(_translate("choicesDialog", "Priority"))
self.label_3.setText(_translate("choicesDialog", "Secondary"))
self.label_4.setText(_translate("choicesDialog", "Comment"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
choicesDialog = QtWidgets.QDialog()
ui = Ui_choicesDialog()
ui.setupUi(choicesDialog)
choicesDialog.show()
sys.exit(app.exec())

View file

@ -0,0 +1,132 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>choicesDialog</class>
<widget class="QDialog" name="choicesDialog">
<property name="windowModality">
<enum>Qt::ApplicationModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>561</width>
<height>246</height>
</rect>
</property>
<property name="windowTitle">
<string>Choices</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>Priority</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="priorityComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Secondary</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="secondaryComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Comment</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QPlainTextEdit" name="choiceComment"/>
</item>
<item row="4" 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>choicesDialog</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>choicesDialog</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

@ -183,28 +183,6 @@ class Ui_MainWindow(object):
self.gridLayout_4.addItem(spacerItem5, 5, 2, 1, 1) self.gridLayout_4.addItem(spacerItem5, 5, 2, 1, 1)
self.horizontalLayout_12 = QtWidgets.QHBoxLayout() self.horizontalLayout_12 = QtWidgets.QHBoxLayout()
self.horizontalLayout_12.setObjectName("horizontalLayout_12") self.horizontalLayout_12.setObjectName("horizontalLayout_12")
self.sectorsTable = QtWidgets.QTableWidget(parent=self.pageCampaign)
self.sectorsTable.setObjectName("sectorsTable")
self.sectorsTable.setColumnCount(5)
self.sectorsTable.setRowCount(0)
item = QtWidgets.QTableWidgetItem()
self.sectorsTable.setHorizontalHeaderItem(0, item)
item = QtWidgets.QTableWidgetItem()
self.sectorsTable.setHorizontalHeaderItem(1, item)
item = QtWidgets.QTableWidgetItem()
self.sectorsTable.setHorizontalHeaderItem(2, item)
item = QtWidgets.QTableWidgetItem()
self.sectorsTable.setHorizontalHeaderItem(3, item)
item = QtWidgets.QTableWidgetItem()
self.sectorsTable.setHorizontalHeaderItem(4, item)
self.horizontalLayout_12.addWidget(self.sectorsTable)
self.addSectorBtn = QtWidgets.QPushButton(parent=self.pageCampaign)
self.addSectorBtn.setEnabled(True)
self.addSectorBtn.setObjectName("addSectorBtn")
self.horizontalLayout_12.addWidget(self.addSectorBtn)
self.gridLayout_4.addLayout(self.horizontalLayout_12, 4, 0, 1, 3)
self.horizontalLayout_13 = QtWidgets.QHBoxLayout()
self.horizontalLayout_13.setObjectName("horizontalLayout_13")
self.campaignParticipantsTable = QtWidgets.QTableWidget(parent=self.pageCampaign) self.campaignParticipantsTable = QtWidgets.QTableWidget(parent=self.pageCampaign)
self.campaignParticipantsTable.setObjectName("campaignParticipantsTable") self.campaignParticipantsTable.setObjectName("campaignParticipantsTable")
self.campaignParticipantsTable.setColumnCount(5) self.campaignParticipantsTable.setColumnCount(5)
@ -219,10 +197,32 @@ class Ui_MainWindow(object):
self.campaignParticipantsTable.setHorizontalHeaderItem(3, item) self.campaignParticipantsTable.setHorizontalHeaderItem(3, item)
item = QtWidgets.QTableWidgetItem() item = QtWidgets.QTableWidgetItem()
self.campaignParticipantsTable.setHorizontalHeaderItem(4, item) self.campaignParticipantsTable.setHorizontalHeaderItem(4, item)
self.horizontalLayout_13.addWidget(self.campaignParticipantsTable) self.horizontalLayout_12.addWidget(self.campaignParticipantsTable)
self.addCampaignParticipantBtn = QtWidgets.QPushButton(parent=self.pageCampaign) self.addCampaignParticipantBtn = QtWidgets.QPushButton(parent=self.pageCampaign)
self.addCampaignParticipantBtn.setObjectName("addCampaignParticipantBtn") self.addCampaignParticipantBtn.setObjectName("addCampaignParticipantBtn")
self.horizontalLayout_13.addWidget(self.addCampaignParticipantBtn) self.horizontalLayout_12.addWidget(self.addCampaignParticipantBtn)
self.gridLayout_4.addLayout(self.horizontalLayout_12, 4, 0, 1, 3)
self.horizontalLayout_13 = QtWidgets.QHBoxLayout()
self.horizontalLayout_13.setObjectName("horizontalLayout_13")
self.sectorsTable = QtWidgets.QTableWidget(parent=self.pageCampaign)
self.sectorsTable.setObjectName("sectorsTable")
self.sectorsTable.setColumnCount(5)
self.sectorsTable.setRowCount(0)
item = QtWidgets.QTableWidgetItem()
self.sectorsTable.setHorizontalHeaderItem(0, item)
item = QtWidgets.QTableWidgetItem()
self.sectorsTable.setHorizontalHeaderItem(1, item)
item = QtWidgets.QTableWidgetItem()
self.sectorsTable.setHorizontalHeaderItem(2, item)
item = QtWidgets.QTableWidgetItem()
self.sectorsTable.setHorizontalHeaderItem(3, item)
item = QtWidgets.QTableWidgetItem()
self.sectorsTable.setHorizontalHeaderItem(4, item)
self.horizontalLayout_13.addWidget(self.sectorsTable)
self.addSectorBtn = QtWidgets.QPushButton(parent=self.pageCampaign)
self.addSectorBtn.setEnabled(True)
self.addSectorBtn.setObjectName("addSectorBtn")
self.horizontalLayout_13.addWidget(self.addSectorBtn)
self.gridLayout_4.addLayout(self.horizontalLayout_13, 2, 0, 1, 3) self.gridLayout_4.addLayout(self.horizontalLayout_13, 2, 0, 1, 3)
self.horizontalLayout_11 = QtWidgets.QHBoxLayout() self.horizontalLayout_11 = QtWidgets.QHBoxLayout()
self.horizontalLayout_11.setObjectName("horizontalLayout_11") self.horizontalLayout_11.setObjectName("horizontalLayout_11")
@ -385,7 +385,7 @@ class Ui_MainWindow(object):
self.retranslateUi(MainWindow) self.retranslateUi(MainWindow)
self.tabWidget.setCurrentIndex(1) self.tabWidget.setCurrentIndex(1)
self.selectedDetailsStack.setCurrentIndex(3) self.selectedDetailsStack.setCurrentIndex(2)
QtCore.QMetaObject.connectSlotsByName(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow): def retranslateUi(self, MainWindow):
@ -429,17 +429,6 @@ class Ui_MainWindow(object):
self.labelSectors.setText(_translate("MainWindow", "Sectors")) self.labelSectors.setText(_translate("MainWindow", "Sectors"))
self.labelParticipants_2.setText(_translate("MainWindow", "Participants")) self.labelParticipants_2.setText(_translate("MainWindow", "Participants"))
self.endCampaignBtn.setText(_translate("MainWindow", "End campaign")) self.endCampaignBtn.setText(_translate("MainWindow", "End campaign"))
item = self.sectorsTable.horizontalHeaderItem(0)
item.setText(_translate("MainWindow", "Name"))
item = self.sectorsTable.horizontalHeaderItem(1)
item.setText(_translate("MainWindow", "Round"))
item = self.sectorsTable.horizontalHeaderItem(2)
item.setText(_translate("MainWindow", "Major obj."))
item = self.sectorsTable.horizontalHeaderItem(3)
item.setText(_translate("MainWindow", "Minor opp."))
item = self.sectorsTable.horizontalHeaderItem(4)
item.setText(_translate("MainWindow", "Influence imp."))
self.addSectorBtn.setText(_translate("MainWindow", "Add Sector"))
item = self.campaignParticipantsTable.horizontalHeaderItem(0) item = self.campaignParticipantsTable.horizontalHeaderItem(0)
item.setText(_translate("MainWindow", "Name")) item.setText(_translate("MainWindow", "Name"))
item = self.campaignParticipantsTable.horizontalHeaderItem(1) item = self.campaignParticipantsTable.horizontalHeaderItem(1)
@ -451,6 +440,17 @@ class Ui_MainWindow(object):
item = self.campaignParticipantsTable.horizontalHeaderItem(4) item = self.campaignParticipantsTable.horizontalHeaderItem(4)
item.setText(_translate("MainWindow", "Theme pts.")) item.setText(_translate("MainWindow", "Theme pts."))
self.addCampaignParticipantBtn.setText(_translate("MainWindow", "Add participant")) self.addCampaignParticipantBtn.setText(_translate("MainWindow", "Add participant"))
item = self.sectorsTable.horizontalHeaderItem(0)
item.setText(_translate("MainWindow", "Name"))
item = self.sectorsTable.horizontalHeaderItem(1)
item.setText(_translate("MainWindow", "Round"))
item = self.sectorsTable.horizontalHeaderItem(2)
item.setText(_translate("MainWindow", "Major obj."))
item = self.sectorsTable.horizontalHeaderItem(3)
item.setText(_translate("MainWindow", "Minor opp."))
item = self.sectorsTable.horizontalHeaderItem(4)
item.setText(_translate("MainWindow", "Influence imp."))
self.addSectorBtn.setText(_translate("MainWindow", "Add Sector"))
self.campaignName.setText(_translate("MainWindow", "campaignName")) self.campaignName.setText(_translate("MainWindow", "campaignName"))
self.campaignMonth.setText(_translate("MainWindow", "campaignMonth")) self.campaignMonth.setText(_translate("MainWindow", "campaignMonth"))
self.labelChoices.setText(_translate("MainWindow", "Choices")) self.labelChoices.setText(_translate("MainWindow", "Choices"))
@ -466,7 +466,7 @@ class Ui_MainWindow(object):
item = self.choicesTable.horizontalHeaderItem(0) item = self.choicesTable.horizontalHeaderItem(0)
item.setText(_translate("MainWindow", "Player")) item.setText(_translate("MainWindow", "Player"))
item = self.choicesTable.horizontalHeaderItem(1) item = self.choicesTable.horizontalHeaderItem(1)
item.setText(_translate("MainWindow", "Prioritary")) item.setText(_translate("MainWindow", "Priority"))
item = self.choicesTable.horizontalHeaderItem(2) item = self.choicesTable.horizontalHeaderItem(2)
item.setText(_translate("MainWindow", "Secondary")) item.setText(_translate("MainWindow", "Secondary"))
self.resolvePairingBtn.setText(_translate("MainWindow", "Resolve pairing")) self.resolvePairingBtn.setText(_translate("MainWindow", "Resolve pairing"))

View file

@ -150,7 +150,7 @@
<item> <item>
<widget class="QStackedWidget" name="selectedDetailsStack"> <widget class="QStackedWidget" name="selectedDetailsStack">
<property name="currentIndex"> <property name="currentIndex">
<number>3</number> <number>2</number>
</property> </property>
<widget class="QWidget" name="pageEmpty"> <widget class="QWidget" name="pageEmpty">
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_4">
@ -379,6 +379,46 @@
</item> </item>
<item row="4" column="0" colspan="3"> <item row="4" column="0" colspan="3">
<layout class="QHBoxLayout" name="horizontalLayout_12"> <layout class="QHBoxLayout" name="horizontalLayout_12">
<item>
<widget class="QTableWidget" name="campaignParticipantsTable">
<column>
<property name="text">
<string>Name</string>
</property>
</column>
<column>
<property name="text">
<string>Leader</string>
</property>
</column>
<column>
<property name="text">
<string>Theme</string>
</property>
</column>
<column>
<property name="text">
<string>Victory pts.</string>
</property>
</column>
<column>
<property name="text">
<string>Theme pts.</string>
</property>
</column>
</widget>
</item>
<item>
<widget class="QPushButton" name="addCampaignParticipantBtn">
<property name="text">
<string>Add participant</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0" colspan="3">
<layout class="QHBoxLayout" name="horizontalLayout_13">
<item> <item>
<widget class="QTableWidget" name="sectorsTable"> <widget class="QTableWidget" name="sectorsTable">
<column> <column>
@ -420,46 +460,6 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="2" column="0" colspan="3">
<layout class="QHBoxLayout" name="horizontalLayout_13">
<item>
<widget class="QTableWidget" name="campaignParticipantsTable">
<column>
<property name="text">
<string>Name</string>
</property>
</column>
<column>
<property name="text">
<string>Leader</string>
</property>
</column>
<column>
<property name="text">
<string>Theme</string>
</property>
</column>
<column>
<property name="text">
<string>Victory pts.</string>
</property>
</column>
<column>
<property name="text">
<string>Theme pts.</string>
</property>
</column>
</widget>
</item>
<item>
<widget class="QPushButton" name="addCampaignParticipantBtn">
<property name="text">
<string>Add participant</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0" colspan="3"> <item row="0" column="0" colspan="3">
<layout class="QHBoxLayout" name="horizontalLayout_11"> <layout class="QHBoxLayout" name="horizontalLayout_11">
<item> <item>
@ -573,7 +573,7 @@
</column> </column>
<column> <column>
<property name="text"> <property name="text">
<string>Prioritary</string> <string>Priority</string>
</property> </property>
</column> </column>
<column> <column>

View file

@ -13,7 +13,7 @@ class Ui_sectorDialog(object):
def setupUi(self, sectorDialog): def setupUi(self, sectorDialog):
sectorDialog.setObjectName("sectorDialog") sectorDialog.setObjectName("sectorDialog")
sectorDialog.setWindowModality(QtCore.Qt.WindowModality.ApplicationModal) sectorDialog.setWindowModality(QtCore.Qt.WindowModality.ApplicationModal)
sectorDialog.resize(514, 129) sectorDialog.resize(602, 338)
icon = QtGui.QIcon() icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(".\\src\\warchron\\view\\ui\\../resources/warchron_logo.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off) icon.addPixmap(QtGui.QPixmap(".\\src\\warchron\\view\\ui\\../resources/warchron_logo.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
sectorDialog.setWindowIcon(icon) sectorDialog.setWindowIcon(icon)
@ -59,6 +59,13 @@ class Ui_sectorDialog(object):
self.minorComboBox.setSizePolicy(sizePolicy) self.minorComboBox.setSizePolicy(sizePolicy)
self.minorComboBox.setObjectName("minorComboBox") self.minorComboBox.setObjectName("minorComboBox")
self.gridLayout.addWidget(self.minorComboBox, 1, 3, 1, 1) self.gridLayout.addWidget(self.minorComboBox, 1, 3, 1, 1)
self.label_7 = QtWidgets.QLabel(parent=sectorDialog)
self.label_7.setObjectName("label_7")
self.gridLayout.addWidget(self.label_7, 2, 0, 1, 1)
self.sectorMission = QtWidgets.QLineEdit(parent=sectorDialog)
self.sectorMission.setText("")
self.sectorMission.setObjectName("sectorMission")
self.gridLayout.addWidget(self.sectorMission, 2, 1, 1, 1)
self.label_5 = QtWidgets.QLabel(parent=sectorDialog) self.label_5 = QtWidgets.QLabel(parent=sectorDialog)
self.label_5.setObjectName("label_5") self.label_5.setObjectName("label_5")
self.gridLayout.addWidget(self.label_5, 2, 2, 1, 1) self.gridLayout.addWidget(self.label_5, 2, 2, 1, 1)
@ -70,11 +77,17 @@ class Ui_sectorDialog(object):
self.influenceComboBox.setSizePolicy(sizePolicy) self.influenceComboBox.setSizePolicy(sizePolicy)
self.influenceComboBox.setObjectName("influenceComboBox") self.influenceComboBox.setObjectName("influenceComboBox")
self.gridLayout.addWidget(self.influenceComboBox, 2, 3, 1, 1) self.gridLayout.addWidget(self.influenceComboBox, 2, 3, 1, 1)
self.label_6 = QtWidgets.QLabel(parent=sectorDialog)
self.label_6.setObjectName("label_6")
self.gridLayout.addWidget(self.label_6, 3, 0, 1, 1)
self.sectorDescription = QtWidgets.QPlainTextEdit(parent=sectorDialog)
self.sectorDescription.setObjectName("sectorDescription")
self.gridLayout.addWidget(self.sectorDescription, 3, 1, 1, 3)
self.buttonBox = QtWidgets.QDialogButtonBox(parent=sectorDialog) self.buttonBox = QtWidgets.QDialogButtonBox(parent=sectorDialog)
self.buttonBox.setOrientation(QtCore.Qt.Orientation.Horizontal) self.buttonBox.setOrientation(QtCore.Qt.Orientation.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.StandardButton.Cancel|QtWidgets.QDialogButtonBox.StandardButton.Ok) self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.StandardButton.Cancel|QtWidgets.QDialogButtonBox.StandardButton.Ok)
self.buttonBox.setObjectName("buttonBox") self.buttonBox.setObjectName("buttonBox")
self.gridLayout.addWidget(self.buttonBox, 3, 2, 1, 2) self.gridLayout.addWidget(self.buttonBox, 4, 2, 1, 2)
self.retranslateUi(sectorDialog) self.retranslateUi(sectorDialog)
self.buttonBox.accepted.connect(sectorDialog.accept) # type: ignore self.buttonBox.accepted.connect(sectorDialog.accept) # type: ignore
@ -88,7 +101,9 @@ class Ui_sectorDialog(object):
self.label_3.setText(_translate("sectorDialog", "Major objective")) self.label_3.setText(_translate("sectorDialog", "Major objective"))
self.label.setText(_translate("sectorDialog", "Round")) self.label.setText(_translate("sectorDialog", "Round"))
self.label_4.setText(_translate("sectorDialog", "Minor opportunity")) self.label_4.setText(_translate("sectorDialog", "Minor opportunity"))
self.label_7.setText(_translate("sectorDialog", "Mission"))
self.label_5.setText(_translate("sectorDialog", "Influence")) self.label_5.setText(_translate("sectorDialog", "Influence"))
self.label_6.setText(_translate("sectorDialog", "Description"))
if __name__ == "__main__": if __name__ == "__main__":

View file

@ -9,8 +9,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>514</width> <width>602</width>
<height>129</height> <height>338</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -86,6 +86,20 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Mission</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="sectorMission">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="2"> <item row="2" column="2">
<widget class="QLabel" name="label_5"> <widget class="QLabel" name="label_5">
<property name="text"> <property name="text">
@ -103,7 +117,17 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="2" colspan="2"> <item row="3" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Description</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="3">
<widget class="QPlainTextEdit" name="sectorDescription"/>
</item>
<item row="4" column="2" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox"> <widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>

View file

@ -7,6 +7,7 @@ from PyQt6.QtWidgets import QDialog, QFileDialog, QTreeWidgetItem, QMenu
from PyQt6.QtGui import QCloseEvent from PyQt6.QtGui import QCloseEvent
from warchron.constants import ROLE_TYPE, ROLE_ID, ItemType from warchron.constants import ROLE_TYPE, ROLE_ID, ItemType
from warchron.controller.dtos import ParticipantOption
from warchron.view.ui.ui_main_window import Ui_MainWindow 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_player_dialog import Ui_playerDialog
from warchron.view.ui.ui_war_dialog import Ui_warDialog from warchron.view.ui.ui_war_dialog import Ui_warDialog
@ -15,7 +16,7 @@ from warchron.view.ui.ui_objective_dialog import Ui_objectiveDialog
from warchron.view.ui.ui_war_participant_dialog import Ui_warParticipantDialog from warchron.view.ui.ui_war_participant_dialog import Ui_warParticipantDialog
from warchron.view.ui.ui_campaign_participant_dialog import Ui_campaignParticipantDialog from warchron.view.ui.ui_campaign_participant_dialog import Ui_campaignParticipantDialog
from warchron.view.ui.ui_sector_dialog import Ui_sectorDialog from warchron.view.ui.ui_sector_dialog import Ui_sectorDialog
from warchron.controller.dtos import ParticipantOption from warchron.view.ui.ui_choices_dialog import Ui_choicesDialog
# utils... # utils...
@ -50,6 +51,11 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
self.show_details(None) self.show_details(None)
self.playersTable.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.playersTable.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
self.playersTable.customContextMenuRequested.connect(self._on_players_table_context_menu) self.playersTable.customContextMenuRequested.connect(self._on_players_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)
self.addRoundBtn.clicked.connect(self._on_add_round_clicked)
# Pages
self.warParticipantsTable.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.warParticipantsTable.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
self.warParticipantsTable.customContextMenuRequested.connect(self._on_war_participants_table_context_menu) self.warParticipantsTable.customContextMenuRequested.connect(self._on_war_participants_table_context_menu)
self.objectivesTable.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.objectivesTable.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
@ -58,10 +64,8 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
self.campaignParticipantsTable.customContextMenuRequested.connect(self._on_campaign_participants_table_context_menu) self.campaignParticipantsTable.customContextMenuRequested.connect(self._on_campaign_participants_table_context_menu)
self.sectorsTable.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.sectorsTable.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
self.sectorsTable.customContextMenuRequested.connect(self._on_sectors_table_context_menu) self.sectorsTable.customContextMenuRequested.connect(self._on_sectors_table_context_menu)
self.warsTree.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.choicesTable.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
self.warsTree.customContextMenuRequested.connect(self._on_wars_tree_context_menu) self.choicesTable.customContextMenuRequested.connect(self._on_choices_table_context_menu)
self.addCampaignBtn.clicked.connect(self._on_add_campaign_clicked)
self.addRoundBtn.clicked.connect(self._on_add_round_clicked)
def _emit_selection_changed(self, current, previous): def _emit_selection_changed(self, current, previous):
if not self.on_tree_selection_changed: if not self.on_tree_selection_changed:
@ -374,10 +378,40 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
# Round page # Round page
def _on_choices_table_context_menu(self, pos):
item = self.choicesTable.itemAt(pos)
if not item:
return
row = item.row()
name_item = self.choicesTable.item(row, 0)
if not name_item:
return
choice_id = name_item.data(Qt.ItemDataRole.UserRole)
if choice_id is None:
return
menu = QMenu(self)
edit_action = menu.addAction("Edit")
action = menu.exec(self.choicesTable.viewport().mapToGlobal(pos))
if action == edit_action and self.on_edit_item:
self.on_edit_item(ItemType.CHOICE, choice_id)
def show_round_details(self, *, index: int): def show_round_details(self, *, index: int):
self.roundNb.setText(f"Round {index}") self.roundNb.setText(f"Round {index}")
def display_round_choices(self, participants: list[tuple[str, str, str, str]]):
table = self.choicesTable
table.clearContents()
table.setRowCount(len(participants))
for row, (participant, priority, secondary, choice_id) in enumerate(participants):
participant_item = QtWidgets.QTableWidgetItem(participant)
priority_item = QtWidgets.QTableWidgetItem(priority)
secondary_item = QtWidgets.QTableWidgetItem(secondary)
participant_item.setData(Qt.ItemDataRole.UserRole, choice_id)
table.setItem(row, 0, participant_item)
table.setItem(row, 1, priority_item)
table.setItem(row, 2, secondary_item)
table.resizeColumnsToContents()
class PlayerDialog(QDialog): class PlayerDialog(QDialog):
def __init__(self, parent=None, *, default_name: str = ""): def __init__(self, parent=None, *, default_name: str = ""):
super().__init__(parent) super().__init__(parent)
@ -504,3 +538,29 @@ class SectorDialog(QDialog):
def get_influence_id(self) -> str: def get_influence_id(self) -> str:
return self.ui.influenceComboBox.currentData() return self.ui.influenceComboBox.currentData()
class ChoicesDialog(QDialog):
def __init__(self, parent=None, *, participants: list, default_participant_id=None, sectors: list, default_priority_id=None, default_secondary_id=None):
super().__init__(parent)
self.ui = Ui_choicesDialog()
self.ui.setupUi(self)
for part in participants:
self.ui.playerComboBox.addItem(part.name, part.id)
select_if_exists(self.ui.playerComboBox, default_participant_id)
self.ui.playerComboBox.setEnabled(False)
self.ui.priorityComboBox.addItem("(none)", None)
self.ui.secondaryComboBox.addItem("(none)", None)
for sect in sectors:
self.ui.priorityComboBox.addItem(sect.name, sect.id)
self.ui.secondaryComboBox.addItem(sect.name, sect.id)
select_if_exists(self.ui.priorityComboBox, default_priority_id)
select_if_exists(self.ui.secondaryComboBox, default_secondary_id)
def get_participant_id(self) -> str:
return self.ui.playerComboBox.currentData()
def get_priority_id(self) -> str:
return self.ui.priorityComboBox.currentData()
def get_secondary_id(self) -> str:
return self.ui.secondaryComboBox.currentData()