exceptions adding in closed elements
This commit is contained in:
parent
88bd28e949
commit
a2b6c7c684
10 changed files with 179 additions and 82 deletions
|
|
@ -3,6 +3,7 @@ from typing import TYPE_CHECKING
|
|||
from PyQt6.QtWidgets import QMessageBox, QDialog
|
||||
|
||||
from warchron.constants import RefreshScope
|
||||
from warchron.model.player import Player
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from warchron.controller.app_controller import AppController
|
||||
|
|
@ -21,16 +22,15 @@ class PlayerController:
|
|||
return False
|
||||
return True
|
||||
|
||||
def add_player(self) -> None:
|
||||
def create_player(self) -> Player | None:
|
||||
dialog = PlayerDialog(self.app.view)
|
||||
result = dialog.exec() # modal blocking dialog
|
||||
if result == QDialog.DialogCode.Accepted:
|
||||
name = dialog.get_player_name()
|
||||
if not self._validate_player_inputs(name):
|
||||
return
|
||||
self.app.model.add_player(name)
|
||||
self.app.is_dirty = True
|
||||
self.app.navigation.refresh(RefreshScope.PLAYERS_LIST)
|
||||
result = dialog.exec()
|
||||
if result != QDialog.DialogCode.Accepted:
|
||||
return None
|
||||
name = dialog.get_player_name()
|
||||
if not self._validate_player_inputs(name):
|
||||
return None
|
||||
return self.app.model.add_player(name)
|
||||
|
||||
def edit_player(self, player_id: str) -> None:
|
||||
play = self.app.model.get_player(player_id)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue