Handle map reset when the game is loaded/unloaded.

https://github.com/dcs-liberation/dcs_liberation/issues/2039

Partial fix for
https://github.com/dcs-liberation/dcs_liberation/issues/2045 (now works
in the new map, old one not fixed yet).
This commit is contained in:
Dan Albert
2022-03-05 18:02:46 -08:00
parent 995e28cb32
commit 73fcfcec7b
37 changed files with 403 additions and 178 deletions

View File

@@ -21,6 +21,7 @@ from game.factions import FACTIONS
from game.profiling import logged_duration
from game.server import EventStream, Server
from game.settings import Settings
from game.sim import GameUpdateEvents
from game.theater.start_generator import GameGenerator, GeneratorSettings, ModSettings
from pydcs_extensions import load_mods
from qt_ui import (
@@ -58,6 +59,11 @@ def inject_custom_payloads(user_path: Path) -> None:
PayloadDirectories.set_preferred(user_path / "MissionEditor" / "UnitPayloads")
def on_game_load(game: Game | None) -> None:
EventStream.drain()
EventStream.put_nowait(GameUpdateEvents().game_loaded(game))
def run_ui(game: Optional[Game], new_map: bool, dev: bool) -> None:
os.environ["QT_AUTO_SCREEN_SCALE_FACTOR"] = "1" # Potential fix for 4K screens
app = QApplication(sys.argv)
@@ -143,7 +149,7 @@ def run_ui(game: Optional[Game], new_map: bool, dev: bool) -> None:
# Apply CSS (need works)
GameUpdateSignal()
GameUpdateSignal.get_instance().game_loaded.connect(EventStream.drain)
GameUpdateSignal.get_instance().game_loaded.connect(on_game_load)
# Start window
window = QLiberationWindow(game, new_map)