split dialogs and war/campaign/round classes to files
This commit is contained in:
parent
55abdccc64
commit
019e62565f
22 changed files with 562 additions and 502 deletions
33
src/warchron/view/war_participant_dialog.py
Normal file
33
src/warchron/view/war_participant_dialog.py
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
from typing import cast, List
|
||||
|
||||
from PyQt6.QtWidgets import QWidget, QDialog
|
||||
|
||||
from warchron.controller.dtos import ParticipantOption
|
||||
from warchron.view.helpers import select_if_exists
|
||||
from warchron.view.ui.ui_war_participant_dialog import Ui_warParticipantDialog
|
||||
|
||||
|
||||
class WarParticipantDialog(QDialog):
|
||||
def __init__(
|
||||
self,
|
||||
parent: QWidget | None = None,
|
||||
*,
|
||||
players: List[ParticipantOption],
|
||||
default_player_id: str | None = None,
|
||||
default_faction: str | None = "",
|
||||
editable_player: bool = True,
|
||||
):
|
||||
super().__init__(parent)
|
||||
self.ui: Ui_warParticipantDialog = Ui_warParticipantDialog()
|
||||
self.ui.setupUi(self) # type: ignore
|
||||
for player in players:
|
||||
self.ui.playerComboBox.addItem(player.name, player.id)
|
||||
select_if_exists(self.ui.playerComboBox, default_player_id)
|
||||
self.ui.playerComboBox.setEnabled(editable_player)
|
||||
self.ui.faction.setText(default_faction)
|
||||
|
||||
def get_player_id(self) -> str:
|
||||
return cast(str, self.ui.playerComboBox.currentData())
|
||||
|
||||
def get_participant_faction(self) -> str:
|
||||
return self.ui.faction.text().strip()
|
||||
Loading…
Add table
Add a link
Reference in a new issue