list round choices ; fix UI
This commit is contained in:
parent
032ab2d2c4
commit
723723dea1
14 changed files with 683 additions and 99 deletions
|
|
@ -5,8 +5,8 @@ from warchron.model.model import Model
|
|||
from warchron.view.view import View
|
||||
|
||||
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.view.view import PlayerDialog, WarDialog, CampaignDialog, ObjectiveDialog, WarParticipantDialog, CampaignParticipantDialog, SectorDialog, ChoicesDialog
|
||||
|
||||
class Controller:
|
||||
def __init__(self, model: Model, view: View):
|
||||
|
|
@ -167,6 +167,24 @@ class Controller:
|
|||
def _fill_round_details(self, round_id: str):
|
||||
index = self.model.get_round_index(round_id)
|
||||
self.view.show_round_details(index=index)
|
||||
camp, rnd, participants, sectors = self.model.get_round_choices_data(round_id)
|
||||
rows = []
|
||||
for part in participants:
|
||||
player = self.model.get_player(part.id)
|
||||
choice = rnd.get_choice(part.id)
|
||||
priority_name = ""
|
||||
secondary_name = ""
|
||||
if choice and choice.priority_sector_id:
|
||||
priority_name = self.model.get_sector(choice.priority_sector_id).name
|
||||
if choice and choice.secondary_sector_id:
|
||||
secondary_name = self.model.get_sector(choice.secondary_sector_id).name
|
||||
rows.append({
|
||||
"participant_id": part.id,
|
||||
"participant_name": player.name,
|
||||
"priority": priority_name,
|
||||
"secondary": secondary_name,
|
||||
})
|
||||
self.view.display_round_choices(rows)
|
||||
|
||||
def on_tree_selection_changed(self, selection):
|
||||
self.selected_war_id = None
|
||||
|
|
@ -325,7 +343,9 @@ class Controller:
|
|||
theme = dialog.get_participant_theme()
|
||||
self.model.update_campaign_participant(item_id, leader=leader, theme=theme)
|
||||
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):
|
||||
reply = QMessageBox.question(
|
||||
|
|
@ -556,4 +576,29 @@ class Controller:
|
|||
return
|
||||
rnd = self.model.add_round(self.selected_campaign_id)
|
||||
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)
|
||||
|
||||
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
|
||||
participant = camp.participants[choice.participant_id]
|
||||
dialog = ChoicesDialog(
|
||||
self.view,
|
||||
participants=[participant],
|
||||
default_participant_id=participant.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=participant.id,
|
||||
priority_sector_id=dialog.get_priority_id(),
|
||||
secondary_sector_id=dialog.get_secondary_id(),
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue