mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Add websocket event stream for sim updates.
As a proof of concept this only covers the flight positions.
This commit is contained in:
@@ -18,7 +18,7 @@ from game.data.weapons import Pylon, Weapon, WeaponGroup
|
||||
from game.db import FACTIONS
|
||||
from game.dcs.aircrafttype import AircraftType
|
||||
from game.profiling import logged_duration
|
||||
from game.server import GameContext, Server
|
||||
from game.server import EventStream, GameContext, Server
|
||||
from game.settings import Settings
|
||||
from game.theater.start_generator import GameGenerator, GeneratorSettings, ModSettings
|
||||
from qt_ui import (
|
||||
@@ -137,6 +137,7 @@ def run_ui(game: Optional[Game]) -> None:
|
||||
# Apply CSS (need works)
|
||||
GameUpdateSignal()
|
||||
GameUpdateSignal.get_instance().game_loaded.connect(GameContext.set)
|
||||
GameUpdateSignal.get_instance().game_loaded.connect(EventStream.drain)
|
||||
|
||||
# Start window
|
||||
window = QLiberationWindow(game)
|
||||
|
||||
@@ -17,6 +17,7 @@ from .waypointjs import WaypointJs
|
||||
|
||||
|
||||
class FlightJs(QObject):
|
||||
idChanged = Signal()
|
||||
positionChanged = Signal()
|
||||
flightPlanChanged = Signal()
|
||||
blueChanged = Signal()
|
||||
@@ -50,6 +51,10 @@ class FlightJs(QObject):
|
||||
self.ato_model = ato_model
|
||||
self._waypoints = self.make_waypoints()
|
||||
|
||||
@Property(str, notify=idChanged)
|
||||
def id(self) -> str:
|
||||
return str(self.flight.id)
|
||||
|
||||
def update_waypoints(self) -> None:
|
||||
for waypoint in self._waypoints:
|
||||
waypoint.timingChanged.emit()
|
||||
|
||||
@@ -125,12 +125,6 @@ class MapModel(QObject):
|
||||
self.cleared.emit()
|
||||
|
||||
def on_sim_update(self, events: GameUpdateEvents) -> None:
|
||||
# TODO: Only update flights with changes.
|
||||
# We have the signal of which flights have updates, but no fast lookup for
|
||||
# Flight -> FlightJs since Flight isn't hashable. Faster to update every flight
|
||||
# than do do the O(n^2) filtered update.
|
||||
for flight in self._flights.values():
|
||||
flight.positionChanged.emit()
|
||||
for combat in events.new_combats:
|
||||
self.on_add_combat(combat)
|
||||
for combat in events.updated_combats:
|
||||
|
||||
@@ -20,6 +20,7 @@ from PySide2.QtWidgets import (
|
||||
import qt_ui.uiconstants as CONST
|
||||
from game import Game, VERSION, persistency
|
||||
from game.debriefing import Debriefing
|
||||
from game.server import EventStream
|
||||
from qt_ui import liberation_install
|
||||
from qt_ui.dialogs import Dialog
|
||||
from qt_ui.models import GameModel
|
||||
@@ -50,6 +51,7 @@ class QLiberationWindow(QMainWindow):
|
||||
|
||||
self.game = game
|
||||
self.sim_controller = SimController(self.game)
|
||||
self.sim_controller.sim_update.connect(EventStream.put_nowait)
|
||||
self.game_model = GameModel(game, self.sim_controller)
|
||||
Dialog.set_game(self.game_model)
|
||||
self.ato_panel = QAirTaskingOrderPanel(self.game_model)
|
||||
|
||||
Reference in New Issue
Block a user