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

23
.github/workflows/lint.yml vendored Normal file
View File

@ -0,0 +1,23 @@
name: Build
on: [push, pull_request]
jobs:
lint:
runs-on: windows-latest
steps:
- name: Check out Git repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v1
with:
node-version: 12
- name: Install Node.js dependencies
run: npm ci
- name: Lint
run: |
cd client
npm run lint

23
client/.gitignore vendored Normal file
View File

@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*

66
client/README.md Normal file
View File

@ -0,0 +1,66 @@
# DCS Liberation Client
This is a React app for the front-end of DCS Liberation. It is a work in
progress that just barely implements the map. This is not useful for players
yet.
For development, set the following environment variables when launching DCS
Liberation (the Qt UI):
- `REQUIRE_API_KEY=false`
This will disable API key authentication. The API key is randomly generated at
server startup and we don't currently have a mechanism for communicating that
key to the front-end.
- `CORS_ALLOW_DEBUG_SERVER=true`
This will allow the front-end to make requests to the server, as long as the
front-end is running on http://localhost:3000.
Then, run `npm start` to start the development server. Launch the Qt UI with
`--new-map` to connect the webview to the development server, or navigate to
http://localhost:3000 in your browser.
## Available Scripts
In the project directory, you can run:
### `npm start`
Runs the app in the development mode.<br />
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
The page will reload if you make edits.<br />
You will also see any lint errors in the console.
### `npm test`
Launches the test runner in the interactive watch mode.<br />
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
### `npm run build`
Builds the app for production to the `build` folder.<br />
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.<br />
Your app is ready to be deployed!
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
### `npm run eject`
**Note: this is a one-way operation. Once you `eject`, you cant go back!**
If you arent satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point youre on your own.
You dont have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldnt feel obligated to use this feature. However we understand that this tool wouldnt be useful if you couldnt customize it when you are ready for it.
## Learn More
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
To learn React, check out the [React documentation](https://reactjs.org/).

29403
client/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

52
client/package.json Normal file
View File

@ -0,0 +1,52 @@
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"@reduxjs/toolkit": "^1.7.2",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"@types/jest": "^24.9.1",
"@types/node": "^12.20.46",
"@types/react": "^16.14.23",
"@types/react-dom": "^16.9.14",
"@types/react-redux": "^7.1.22",
"axios": "^0.26.0",
"esri-leaflet": "^3.0.7",
"leaflet": "^1.7.1",
"milsymbol": "^2.0.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-esri-leaflet": "^1.3.1",
"react-leaflet": "^3.2.5",
"react-redux": "^7.2.6",
"react-scripts": "5.0.0",
"typescript": "~4.1.5"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@types/axios": "^0.14.0",
"@types/leaflet": "^1.7.9"
}
}

BIN
client/public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

43
client/public/index.html Normal file
View File

@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React Redux App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>

BIN
client/public/logo192.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

BIN
client/public/logo512.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -0,0 +1,25 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}

3
client/public/robots.txt Normal file
View File

@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:

38
client/src/App.css Normal file
View File

@ -0,0 +1,38 @@
.App {
text-align: center;
}
.App-logo {
height: 40vmin;
pointer-events: none;
}
@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}
.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}
.App-link {
color: #61dafb;
}
@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}

9
client/src/App.test.tsx Normal file
View File

@ -0,0 +1,9 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import App from './App';
test('renders learn react link', () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});

35
client/src/App.tsx Normal file
View File

@ -0,0 +1,35 @@
import { LatLng } from "leaflet";
import "./App.css";
import { LiberationMap } from "./map/liberationmap/LiberationMap";
import { ControlPoint } from "./game/controlpoint";
import { useEffect } from "react";
import { useAppDispatch } from "./app/hooks";
import { setControlPoints } from "./game/theater/theaterSlice";
import axios from "axios";
function App() {
const mapCenter: LatLng = new LatLng(25.58, 54.9);
const dispatch = useAppDispatch();
useEffect(() => {
axios
.get("http://[::1]:5000/control-points")
.catch((error) => console.log(`Error fetching control points: ${error}`))
.then((response) => {
if (response != null) {
dispatch(setControlPoints(response.data as ControlPoint[]));
}
});
});
console.log(`mapCenter=${mapCenter}`);
return (
<div className="App">
<LiberationMap mapCenter={mapCenter} />
</div>
);
}
export default App;

6
client/src/app/hooks.ts Normal file
View File

@ -0,0 +1,6 @@
import { TypedUseSelectorHook, useDispatch, useSelector } from "react-redux";
import type { RootState, AppDispatch } from "./store";
// Use throughout your app instead of plain `useDispatch` and `useSelector`
export const useAppDispatch = () => useDispatch<AppDispatch>();
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;

17
client/src/app/store.ts Normal file
View File

@ -0,0 +1,17 @@
import { configureStore, ThunkAction, Action } from "@reduxjs/toolkit";
import theaterReducer from "../game/theater/theaterSlice";
export const store = configureStore({
reducer: {
theater: theaterReducer,
},
});
export type AppDispatch = typeof store.dispatch;
export type RootState = ReturnType<typeof store.getState>;
export type AppThunk<ReturnType = void> = ThunkAction<
ReturnType,
RootState,
unknown,
Action<string>
>;

View File

@ -0,0 +1,11 @@
import { LatLng } from "leaflet";
export interface ControlPoint {
id: number;
name: string;
blue: boolean;
position: LatLng;
mobile: boolean;
destination: LatLng | null;
sidc: string;
}

View File

@ -0,0 +1,28 @@
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
import { RootState } from "../../app/store";
import { ControlPoint } from "../controlpoint";
interface TheaterState {
controlPoints: ControlPoint[];
}
const initialState: TheaterState = {
controlPoints: [],
};
export const theaterSlice = createSlice({
name: "theater",
initialState,
reducers: {
setControlPoints: (state, action: PayloadAction<ControlPoint[]>) => {
state.controlPoints = action.payload;
},
},
});
export const { setControlPoints } = theaterSlice.actions;
export const selectControlPoints = (state: RootState) =>
state.theater.controlPoints;
export default theaterSlice.reducer;

13
client/src/index.css Normal file
View File

@ -0,0 +1,13 @@
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}

21
client/src/index.tsx Normal file
View File

@ -0,0 +1,21 @@
import React from "react";
import ReactDOM from "react-dom";
import "./index.css";
import App from "./App";
import { store } from "./app/store";
import * as serviceWorker from "./serviceWorker";
import { Provider } from "react-redux";
ReactDOM.render(
<React.StrictMode>
<Provider store={store}>
<App />
</Provider>
</React.StrictMode>,
document.getElementById("root")
);
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();

1
client/src/logo.svg Normal file
View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><g fill="#764ABC"><path d="M65.6 65.4c2.9-.3 5.1-2.8 5-5.8-.1-3-2.6-5.4-5.6-5.4h-.2c-3.1.1-5.5 2.7-5.4 5.8.1 1.5.7 2.8 1.6 3.7-3.4 6.7-8.6 11.6-16.4 15.7-5.3 2.8-10.8 3.8-16.3 3.1-4.5-.6-8-2.6-10.2-5.9-3.2-4.9-3.5-10.2-.8-15.5 1.9-3.8 4.9-6.6 6.8-8-.4-1.3-1-3.5-1.3-5.1-14.5 10.5-13 24.7-8.6 31.4 3.3 5 10 8.1 17.4 8.1 2 0 4-.2 6-.7 12.8-2.5 22.5-10.1 28-21.4z"/><path d="M83.2 53c-7.6-8.9-18.8-13.8-31.6-13.8H50c-.9-1.8-2.8-3-4.9-3h-.2c-3.1.1-5.5 2.7-5.4 5.8.1 3 2.6 5.4 5.6 5.4h.2c2.2-.1 4.1-1.5 4.9-3.4H52c7.6 0 14.8 2.2 21.3 6.5 5 3.3 8.6 7.6 10.6 12.8 1.7 4.2 1.6 8.3-.2 11.8-2.8 5.3-7.5 8.2-13.7 8.2-4 0-7.8-1.2-9.8-2.1-1.1 1-3.1 2.6-4.5 3.6 4.3 2 8.7 3.1 12.9 3.1 9.6 0 16.7-5.3 19.4-10.6 2.9-5.8 2.7-15.8-4.8-24.3z"/><path d="M32.4 67.1c.1 3 2.6 5.4 5.6 5.4h.2c3.1-.1 5.5-2.7 5.4-5.8-.1-3-2.6-5.4-5.6-5.4h-.2c-.2 0-.5 0-.7.1-4.1-6.8-5.8-14.2-5.2-22.2.4-6 2.4-11.2 5.9-15.5 2.9-3.7 8.5-5.5 12.3-5.6 10.6-.2 15.1 13 15.4 18.3 1.3.3 3.5 1 5 1.5-1.2-16.2-11.2-24.6-20.8-24.6-9 0-17.3 6.5-20.6 16.1-4.6 12.8-1.6 25.1 4 34.8-.5.7-.8 1.8-.7 2.9z"/></g></svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -0,0 +1,31 @@
import { Icon, Point } from "leaflet";
import { Marker, Popup } from "react-leaflet";
import { ControlPoint as ControlPointModel } from "../../game/controlpoint";
import { Symbol as MilSymbol } from "milsymbol";
function iconForControlPoint(cp: ControlPointModel) {
const symbol = new MilSymbol(cp.sidc, {
size: 24,
colorMode: "Dark",
});
return new Icon({
iconUrl: symbol.toDataURL(),
iconAnchor: new Point(symbol.getAnchor().x, symbol.getAnchor().y),
});
}
interface ControlPointProps {
controlPoint: ControlPointModel;
}
export function ControlPoint(props: ControlPointProps) {
return (
<Marker
position={props.controlPoint.position}
icon={iconForControlPoint(props.controlPoint)}
>
<Popup>{props.controlPoint.name}</Popup>
</Marker>
);
}

View File

@ -0,0 +1,18 @@
import { LayerGroup } from "react-leaflet";
import { useAppSelector } from "../../app/hooks";
import { selectControlPoints } from "../../game/theater/theaterSlice";
import { ControlPoint } from "../controlpoint/ControlPoint";
export function ControlPointsLayer() {
const controlPoints = useAppSelector(selectControlPoints);
console.log(`controlPoints is ${controlPoints}`);
return (
<LayerGroup>
{controlPoints.map((controlPoint) => {
return (
<ControlPoint key={controlPoint.name} controlPoint={controlPoint} />
);
})}
</LayerGroup>
);
}

View File

@ -0,0 +1,7 @@
@import "~leaflet/dist/leaflet.css";
.leaflet-container {
width: 100%;
height: 100%;
min-height: 100vh;
}

View File

@ -0,0 +1,18 @@
import { MapContainer } from "react-leaflet";
import { BasemapLayer } from "react-esri-leaflet";
import { ControlPointsLayer } from "../controlpointslayer/ControlPointsLayer";
import "./LiberationMap.css";
import { LatLng } from "leaflet";
interface GameProps {
mapCenter: LatLng;
}
export function LiberationMap(props: GameProps) {
return (
<MapContainer zoom={8} center={props.mapCenter}>
<BasemapLayer name="ImageryClarity" />
<ControlPointsLayer />
</MapContainer>
);
}

1
client/src/react-app-env.d.ts vendored Normal file
View File

@ -0,0 +1 @@
/// <reference types="react-scripts" />

146
client/src/serviceWorker.ts Normal file
View File

@ -0,0 +1,146 @@
// This optional code is used to register a service worker.
// register() is not called by default.
// This lets the app load faster on subsequent visits in production, and gives
// it offline capabilities. However, it also means that developers (and users)
// will only see deployed updates on subsequent visits to a page, after all the
// existing tabs open on the page have been closed, since previously cached
// resources are updated in the background.
// To learn more about the benefits of this model and instructions on how to
// opt-in, read https://bit.ly/CRA-PWA
const isLocalhost = Boolean(
window.location.hostname === 'localhost' ||
// [::1] is the IPv6 localhost address.
window.location.hostname === '[::1]' ||
// 127.0.0.0/8 are considered localhost for IPv4.
window.location.hostname.match(
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
)
);
type Config = {
onSuccess?: (registration: ServiceWorkerRegistration) => void;
onUpdate?: (registration: ServiceWorkerRegistration) => void;
};
export function register(config?: Config) {
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
// The URL constructor is available in all browsers that support SW.
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
if (publicUrl.origin !== window.location.origin) {
// Our service worker won't work if PUBLIC_URL is on a different origin
// from what our page is served on. This might happen if a CDN is used to
// serve assets; see https://github.com/facebook/create-react-app/issues/2374
return;
}
window.addEventListener('load', () => {
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
if (isLocalhost) {
// This is running on localhost. Let's check if a service worker still exists or not.
checkValidServiceWorker(swUrl, config);
// Add some additional logging to localhost, pointing developers to the
// service worker/PWA documentation.
navigator.serviceWorker.ready.then(() => {
console.log(
'This web app is being served cache-first by a service ' +
'worker. To learn more, visit https://bit.ly/CRA-PWA'
);
});
} else {
// Is not localhost. Just register service worker
registerValidSW(swUrl, config);
}
});
}
}
function registerValidSW(swUrl: string, config?: Config) {
navigator.serviceWorker
.register(swUrl)
.then((registration) => {
registration.onupdatefound = () => {
const installingWorker = registration.installing;
if (installingWorker == null) {
return;
}
installingWorker.onstatechange = () => {
if (installingWorker.state === 'installed') {
if (navigator.serviceWorker.controller) {
// At this point, the updated precached content has been fetched,
// but the previous service worker will still serve the older
// content until all client tabs are closed.
console.log(
'New content is available and will be used when all ' +
'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
);
// Execute callback
if (config && config.onUpdate) {
config.onUpdate(registration);
}
} else {
// At this point, everything has been precached.
// It's the perfect time to display a
// "Content is cached for offline use." message.
console.log('Content is cached for offline use.');
// Execute callback
if (config && config.onSuccess) {
config.onSuccess(registration);
}
}
}
};
};
})
.catch((error) => {
console.error('Error during service worker registration:', error);
});
}
function checkValidServiceWorker(swUrl: string, config?: Config) {
// Check if the service worker can be found. If it can't reload the page.
fetch(swUrl, {
headers: { 'Service-Worker': 'script' },
})
.then((response) => {
// Ensure service worker exists, and that we really are getting a JS file.
const contentType = response.headers.get('content-type');
if (
response.status === 404 ||
(contentType != null && contentType.indexOf('javascript') === -1)
) {
// No service worker found. Probably a different app. Reload the page.
navigator.serviceWorker.ready.then((registration) => {
registration.unregister().then(() => {
window.location.reload();
});
});
} else {
// Service worker found. Proceed as normal.
registerValidSW(swUrl, config);
}
})
.catch(() => {
console.log(
'No internet connection found. App is running in offline mode.'
);
});
}
export function unregister() {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready
.then((registration) => {
registration.unregister();
})
.catch((error) => {
console.error(error.message);
});
}
}

5
client/src/setupTests.ts Normal file
View File

@ -0,0 +1,5 @@
// jest-dom adds custom jest matchers for asserting on DOM nodes.
// allows you to do things like:
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom/extend-expect';

26
client/tsconfig.json Normal file
View File

@ -0,0 +1,26 @@
{
"compilerOptions": {
"target": "es6",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": [
"src"
]
}

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()