From 8165d3bd8c5fc451cb04aa06d20ba413397de13d Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Sun, 6 Mar 2022 00:47:40 -0800 Subject: [PATCH] Add support for running the build react map. https://github.com/dcs-liberation/dcs_liberation/issues/2039 --- .github/workflows/build.yml | 5 +++++ client/package.json | 1 + pyinstaller.spec | 1 + qt_ui/main.py | 2 +- qt_ui/widgets/map/QLiberationMap.py | 6 ++++-- qt_ui/windows/QLiberationWindow.py | 4 ++-- 6 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 829c5d0f..cbb6f1cd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,6 +50,11 @@ jobs: cd client npm ci + - name: Build client + run: | + cd client + npm run build + - name: Build binaries run: | ./venv/scripts/activate diff --git a/client/package.json b/client/package.json index aee7d946..0c4c08d0 100644 --- a/client/package.json +++ b/client/package.json @@ -4,6 +4,7 @@ "private": true, "main": "main.js", "license": "LGPL-3.0-or-later", + "homepage": ".", "dependencies": { "@reduxjs/toolkit": "^1.7.2", "@testing-library/jest-dom": "^5.16.2", diff --git a/pyinstaller.spec b/pyinstaller.spec index 88436110..93e94fed 100644 --- a/pyinstaller.spec +++ b/pyinstaller.spec @@ -11,6 +11,7 @@ analysis = Analysis( ('resources', 'resources'), ('resources/caucasus.p', 'dcs/terrain/'), ('resources/nevada.p', 'dcs/terrain/'), + ('client/build', 'client/build'), ], hookspath=[], runtime_hooks=[], diff --git a/qt_ui/main.py b/qt_ui/main.py index 712b6a9e..3d78bea3 100644 --- a/qt_ui/main.py +++ b/qt_ui/main.py @@ -152,7 +152,7 @@ def run_ui(game: Optional[Game], new_map: bool, dev: bool) -> None: GameUpdateSignal.get_instance().game_loaded.connect(on_game_load) # Start window - window = QLiberationWindow(game, new_map) + window = QLiberationWindow(game, new_map, dev) window.showMaximized() splash.finish(window) qt_execution_code = app.exec_() diff --git a/qt_ui/widgets/map/QLiberationMap.py b/qt_ui/widgets/map/QLiberationMap.py index 4697d563..a6afe3a3 100644 --- a/qt_ui/widgets/map/QLiberationMap.py +++ b/qt_ui/widgets/map/QLiberationMap.py @@ -36,7 +36,7 @@ class LoggingWebPage(QWebEnginePage): class QLiberationMap(QWebEngineView): - def __init__(self, game_model: GameModel, new_map: bool, parent) -> None: + def __init__(self, game_model: GameModel, new_map: bool, dev: bool, parent) -> None: super().__init__(parent) self.game_model = game_model self.setMinimumSize(800, 600) @@ -53,8 +53,10 @@ class QLiberationMap(QWebEngineView): ) self.page.setWebChannel(self.channel) - if new_map: + if new_map and dev: url = QUrl("http://localhost:3000") + elif new_map: + url = QUrl.fromLocalFile(str(Path("client/build/index.html").resolve())) else: url = QUrl.fromLocalFile( str(Path("resources/ui/map/canvas.html").resolve()) diff --git a/qt_ui/windows/QLiberationWindow.py b/qt_ui/windows/QLiberationWindow.py index acea9df7..b32817ac 100644 --- a/qt_ui/windows/QLiberationWindow.py +++ b/qt_ui/windows/QLiberationWindow.py @@ -54,7 +54,7 @@ class QLiberationWindow(QMainWindow): tgo_info_signal = Signal(TheaterGroundObject) control_point_info_signal = Signal(ControlPoint) - def __init__(self, game: Optional[Game], new_map: bool) -> None: + def __init__(self, game: Optional[Game], new_map: bool, dev: bool) -> None: super().__init__() self._uncaught_exception_handler = UncaughtExceptionHandler(self) @@ -79,7 +79,7 @@ class QLiberationWindow(QMainWindow): Dialog.set_game(self.game_model) self.ato_panel = QAirTaskingOrderPanel(self.game_model) self.info_panel = QInfoPanel(self.game) - self.liberation_map = QLiberationMap(self.game_model, new_map, self) + self.liberation_map = QLiberationMap(self.game_model, new_map, dev, self) self.setGeometry(300, 100, 270, 100) self.updateWindowTitle()