Add a basic React implementation of the map.

See client/README.md for instructions.
This commit is contained in:
Dan Albert
2022-02-26 14:15:39 -08:00
parent 4e348dd99a
commit 59e98b31df
32 changed files with 30095 additions and 12 deletions

View File

@@ -57,7 +57,7 @@ def inject_custom_payloads(user_path: Path) -> None:
PayloadDirectories.set_preferred(user_path / "MissionEditor" / "UnitPayloads")
def run_ui(game: Optional[Game]) -> None:
def run_ui(game: Optional[Game], new_map: bool) -> None:
os.environ["QT_AUTO_SCREEN_SCALE_FACTOR"] = "1" # Potential fix for 4K screens
app = QApplication(sys.argv)
@@ -140,7 +140,7 @@ def run_ui(game: Optional[Game]) -> None:
GameUpdateSignal.get_instance().game_loaded.connect(EventStream.drain)
# Start window
window = QLiberationWindow(game)
window = QLiberationWindow(game, new_map)
window.showMaximized()
splash.finish(window)
qt_execution_code = app.exec_()
@@ -168,8 +168,17 @@ def parse_args() -> argparse.Namespace:
help="Emits a warning for weapons without date or fallback information.",
)
parser.add_argument("--new-map", help="Deprecated. Does nothing.")
parser.add_argument("--old-map", help="Deprecated. Does nothing.")
parser.add_argument(
"--new-map",
action="store_true",
help="Use the Vue based map. Not yet fully functional.",
)
parser.add_argument(
"--old-map",
dest="new_map",
action="store_false",
help="Deprecated. Does nothing.",
)
new_game = subparsers.add_parser("new-game")
@@ -339,7 +348,7 @@ def main():
return
with Server().run_in_thread():
run_ui(game)
run_ui(game, args.new_map)
if __name__ == "__main__":

View File

@@ -36,7 +36,7 @@ class LoggingWebPage(QWebEnginePage):
class QLiberationMap(QWebEngineView):
def __init__(self, game_model: GameModel, parent) -> None:
def __init__(self, game_model: GameModel, new_map: bool, parent) -> None:
super().__init__(parent)
self.game_model = game_model
self.setMinimumSize(800, 600)
@@ -52,9 +52,14 @@ class QLiberationMap(QWebEngineView):
QWebEngineSettings.LocalContentCanAccessRemoteUrls, True
)
self.page.setWebChannel(self.channel)
self.page.load(
QUrl.fromLocalFile(str(Path("resources/ui/map/canvas.html").resolve()))
)
if new_map:
url = QUrl("http://localhost:3000")
else:
url = QUrl.fromLocalFile(
str(Path("resources/ui/map/canvas.html").resolve())
)
self.page.load(url)
self.setPage(self.page)
def set_game(self, game: Optional[Game]) -> None:

View File

@@ -20,9 +20,9 @@ from PySide2.QtWidgets import (
import qt_ui.uiconstants as CONST
from game import Game, VERSION, persistency
from game.debriefing import Debriefing
from game.layout import LAYOUTS
from game.server import EventStream, GameContext
from game.server.security import ApiKeyManager
from game.layout import LAYOUTS
from qt_ui import liberation_install
from qt_ui.dialogs import Dialog
from qt_ui.models import GameModel
@@ -46,7 +46,7 @@ from qt_ui.windows.stats.QStatsWindow import QStatsWindow
class QLiberationWindow(QMainWindow):
def __init__(self, game: Optional[Game]) -> None:
def __init__(self, game: Optional[Game], new_map: bool) -> None:
super().__init__()
self._uncaught_exception_handler = UncaughtExceptionHandler(self)
@@ -59,7 +59,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, self)
self.liberation_map = QLiberationMap(self.game_model, new_map, self)
self.setGeometry(300, 100, 270, 100)
self.updateWindowTitle()