mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Merge forcegroups with the same task
This commit is contained in:
parent
9a2fa50b0f
commit
f0a3fd1e3a
@ -22,14 +22,12 @@ class ArmedForces:
|
|||||||
self._load_forces(faction)
|
self._load_forces(faction)
|
||||||
|
|
||||||
def add_or_update_force_group(self, new_group: ForceGroup) -> None:
|
def add_or_update_force_group(self, new_group: ForceGroup) -> None:
|
||||||
"""TODO Description"""
|
"""Adds or update a forcegroup depending if a forcegroup with the exact same
|
||||||
# Check if a force group with the same units exists
|
tasking already exists"""
|
||||||
|
# Check if a force group with the same tasking already exists
|
||||||
for force_group in self.forces:
|
for force_group in self.forces:
|
||||||
if (
|
if force_group.tasks == new_group.tasks:
|
||||||
force_group.units == new_group.units
|
# Update existing group if tasks are equal
|
||||||
and force_group.tasks == new_group.tasks
|
|
||||||
):
|
|
||||||
# Update existing group if units and tasks are equal
|
|
||||||
force_group.update_group(new_group)
|
force_group.update_group(new_group)
|
||||||
return
|
return
|
||||||
# Add a new force group
|
# Add a new force group
|
||||||
|
|||||||
@ -160,8 +160,9 @@ class ForceGroup:
|
|||||||
return random.choice(self.dcs_unit_types_for_group(group))
|
return random.choice(self.dcs_unit_types_for_group(group))
|
||||||
|
|
||||||
def update_group(self, new_group: ForceGroup) -> None:
|
def update_group(self, new_group: ForceGroup) -> None:
|
||||||
"""Update the group from another group. This will merge statics and layouts."""
|
"""Update the group from another group.
|
||||||
# Merge layouts and statics
|
This will merge units, statics and layouts."""
|
||||||
|
self.units = list(set(self.units + new_group.units))
|
||||||
self.statics = list(set(self.statics + new_group.statics))
|
self.statics = list(set(self.statics + new_group.statics))
|
||||||
self.layouts = list(set(self.layouts + new_group.layouts))
|
self.layouts = list(set(self.layouts + new_group.layouts))
|
||||||
|
|
||||||
|
|||||||
@ -248,7 +248,6 @@ class QGroundObjectBuyMenu(QDialog):
|
|||||||
self.force_group_selector.setMinimumWidth(250)
|
self.force_group_selector.setMinimumWidth(250)
|
||||||
self.layout_selector = QComboBox()
|
self.layout_selector = QComboBox()
|
||||||
self.layout_selector.setMinimumWidth(250)
|
self.layout_selector.setMinimumWidth(250)
|
||||||
self.layout_selector.setEnabled(False)
|
|
||||||
|
|
||||||
# Get the layouts and fill the combobox
|
# Get the layouts and fill the combobox
|
||||||
tasks = []
|
tasks = []
|
||||||
@ -276,6 +275,7 @@ class QGroundObjectBuyMenu(QDialog):
|
|||||||
for layout in force_group.layouts:
|
for layout in force_group.layouts:
|
||||||
self.layout_selector.addItem(layout.name, userData=layout)
|
self.layout_selector.addItem(layout.name, userData=layout)
|
||||||
self.layout_selector.adjustSize()
|
self.layout_selector.adjustSize()
|
||||||
|
self.layout_selector.setEnabled(len(force_group.layouts) > 1)
|
||||||
selected_template = self.layout_selector.itemData(
|
selected_template = self.layout_selector.itemData(
|
||||||
self.layout_selector.currentIndex()
|
self.layout_selector.currentIndex()
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user