mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Update armed forces when preset-group is added
This commit is contained in:
parent
807bb16ddf
commit
f112f227cc
@ -18,7 +18,9 @@ from PySide6.QtWidgets import (
|
||||
QPushButton,
|
||||
)
|
||||
|
||||
from game.armedforces.armedforces import ArmedForces
|
||||
from game.ato.flight import Flight
|
||||
from game.factions import Faction
|
||||
from game.server import EventStream
|
||||
from game.sim import GameUpdateEvents
|
||||
from game.squadrons import Squadron
|
||||
@ -270,20 +272,24 @@ class AirWingTabs(QTabWidget):
|
||||
w = QWidget(layout=layout)
|
||||
self.addTab(w, "Cheats")
|
||||
|
||||
qfu_ownfor = QFactionUnits(
|
||||
game_model.game.coalition_for(True).faction,
|
||||
self,
|
||||
show_jtac=True,
|
||||
)
|
||||
qfu_ownfor.preset_groups_changed.connect(self.preset_group_updated_ownfor)
|
||||
self.addTab(
|
||||
QFactionUnits(
|
||||
game_model.game.coalition_for(True).faction,
|
||||
self,
|
||||
show_jtac=True,
|
||||
),
|
||||
qfu_ownfor,
|
||||
"Faction OWNFOR",
|
||||
)
|
||||
qfu_opfor = QFactionUnits(
|
||||
game_model.game.coalition_for(False).faction,
|
||||
self,
|
||||
show_jtac=True,
|
||||
)
|
||||
qfu_opfor.preset_groups_changed.connect(self.preset_group_updated_opfor)
|
||||
self.addTab(
|
||||
QFactionUnits(
|
||||
game_model.game.coalition_for(False).faction,
|
||||
self,
|
||||
show_jtac=False,
|
||||
),
|
||||
qfu_opfor,
|
||||
"Faction OPFOR",
|
||||
)
|
||||
|
||||
@ -293,6 +299,15 @@ class AirWingTabs(QTabWidget):
|
||||
EventStream.put_nowait(events)
|
||||
self.game_model.ato_model.on_sim_update(events)
|
||||
|
||||
def preset_group_updated_ownfor(self, f: Faction) -> None:
|
||||
self.preset_group_updated(f, player=True)
|
||||
|
||||
def preset_group_updated_opfor(self, f: Faction) -> None:
|
||||
self.preset_group_updated(f, player=False)
|
||||
|
||||
def preset_group_updated(self, f: Faction, player: bool) -> None:
|
||||
self.game_model.game.coalition_for(player).armed_forces = ArmedForces(f)
|
||||
|
||||
|
||||
class AirWingDialog(QDialog):
|
||||
"""Dialog window showing the player's air wing."""
|
||||
|
||||
@ -1,12 +1,11 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import json
|
||||
|
||||
from copy import deepcopy
|
||||
from typing import Union, Callable, Set, Optional, List
|
||||
|
||||
from PySide6 import QtWidgets, QtGui
|
||||
from PySide6.QtCore import Qt
|
||||
from PySide6.QtCore import Qt, Signal
|
||||
from PySide6.QtWidgets import (
|
||||
QScrollArea,
|
||||
QWidget,
|
||||
@ -37,6 +36,8 @@ from qt_ui.windows.newgame.jinja_env import jinja_env
|
||||
|
||||
|
||||
class QFactionUnits(QScrollArea):
|
||||
preset_groups_changed = Signal(Faction)
|
||||
|
||||
def __init__(self, faction: Faction, parent=None, show_jtac: bool = False):
|
||||
super().__init__()
|
||||
self.setWidgetResizable(True)
|
||||
@ -302,6 +303,7 @@ class QFactionUnits(QScrollArea):
|
||||
# invalidate the cached property
|
||||
del self.faction.__dict__["accessible_units"]
|
||||
self.updateFaction(self.faction)
|
||||
self.preset_groups_changed.emit(self.faction)
|
||||
|
||||
def updateFaction(self, faction: Faction):
|
||||
self.faction = faction
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user