2022-12-16 13:44:25 +01:00
|
|
|
import { Utils } from "../Utils"
|
2021-10-15 05:20:02 +02:00
|
|
|
import Toggle from "./Input/Toggle"
|
|
|
|
import LeftControls from "./BigComponents/LeftControls"
|
|
|
|
import RightControls from "./BigComponents/RightControls"
|
|
|
|
import CenterMessageBox from "./CenterMessageBox"
|
2021-10-15 14:52:11 +02:00
|
|
|
import ScrollableFullScreen from "./Base/ScrollableFullScreen"
|
|
|
|
import Translations from "./i18n/Translations"
|
2022-12-16 13:44:25 +01:00
|
|
|
import { DefaultGuiState } from "./DefaultGuiState"
|
2022-01-14 01:41:19 +01:00
|
|
|
import Combine from "./Base/Combine"
|
2022-02-14 04:48:33 +01:00
|
|
|
import ExtraLinkButton from "./BigComponents/ExtraLinkButton"
|
2022-12-22 04:13:52 +01:00
|
|
|
import GeoLocationHandler from "../Logic/Actors/GeoLocationHandler"
|
2023-02-06 22:43:34 +01:00
|
|
|
import CopyrightPanel from "./BigComponents/CopyrightPanel"
|
2021-10-15 05:20:02 +02:00
|
|
|
|
|
|
|
/**
|
2022-12-08 02:56:49 +01:00
|
|
|
* The default MapComplete GUI initializer
|
2021-10-15 05:20:02 +02:00
|
|
|
*
|
2022-12-08 02:56:49 +01:00
|
|
|
* Adds a welcome pane, control buttons, ... etc to index.html
|
2021-10-15 05:20:02 +02:00
|
|
|
*/
|
|
|
|
export default class DefaultGUI {
|
2022-04-08 17:59:14 +02:00
|
|
|
private readonly guiState: DefaultGuiState
|
2022-12-22 04:13:52 +01:00
|
|
|
private readonly geolocationHandler: GeoLocationHandler | undefined
|
2021-10-15 05:20:02 +02:00
|
|
|
|
2023-04-07 04:23:45 +02:00
|
|
|
constructor(guiState: DefaultGuiState) {
|
2022-04-08 17:59:14 +02:00
|
|
|
this.guiState = guiState
|
|
|
|
}
|
|
|
|
|
|
|
|
public setup() {
|
2021-10-20 01:13:55 +02:00
|
|
|
this.SetupUIElements()
|
2022-01-14 02:40:55 +01:00
|
|
|
|
2022-04-08 17:59:14 +02:00
|
|
|
if (
|
|
|
|
this.state.layoutToUse.customCss !== undefined &&
|
|
|
|
window.location.pathname.indexOf("index") >= 0
|
|
|
|
) {
|
|
|
|
Utils.LoadCustomCss(this.state.layoutToUse.customCss)
|
2021-11-10 18:42:31 +01:00
|
|
|
}
|
2021-10-20 01:13:55 +02:00
|
|
|
}
|
2021-11-07 16:34:51 +01:00
|
|
|
|
|
|
|
private SetupUIElements() {
|
2023-01-06 03:46:10 +01:00
|
|
|
const extraLink = Toggle.If(
|
|
|
|
state.featureSwitchExtraLinkEnabled,
|
|
|
|
() => new ExtraLinkButton(state, state.layoutToUse.extraLink)
|
|
|
|
)
|
|
|
|
|
2023-04-07 04:23:45 +02:00
|
|
|
new Combine([extraLink]).SetClass("flex flex-col").AttachTo("top-left")
|
2021-10-15 05:20:02 +02:00
|
|
|
|
2022-03-10 23:18:40 +01:00
|
|
|
new Combine([
|
2022-03-10 23:59:18 +01:00
|
|
|
new ExtraLinkButton(state, {
|
|
|
|
...state.layoutToUse.extraLink,
|
|
|
|
newTab: true,
|
|
|
|
requirements: new Set<
|
|
|
|
"iframe" | "no-iframe" | "welcome-message" | "no-welcome-message"
|
|
|
|
>(),
|
|
|
|
}),
|
2022-03-10 23:18:40 +01:00
|
|
|
])
|
|
|
|
.SetClass("flex items-center justify-center normal-background h-full")
|
|
|
|
.AttachTo("on-small-screen")
|
|
|
|
|
2023-04-15 03:15:17 +02:00
|
|
|
const guiState = this.guiState
|
2021-10-15 05:20:02 +02:00
|
|
|
new LeftControls(state, guiState).AttachTo("bottom-left")
|
2022-12-22 04:13:52 +01:00
|
|
|
new RightControls(state, this.geolocationHandler).AttachTo("bottom-right")
|
2021-10-20 01:13:55 +02:00
|
|
|
|
2021-10-15 05:20:02 +02:00
|
|
|
new CenterMessageBox(state).AttachTo("centermessage")
|
2022-12-24 03:44:21 +01:00
|
|
|
document?.getElementById("centermessage")?.classList?.add("pointer-events-none")
|
2021-10-15 05:20:02 +02:00
|
|
|
}
|
|
|
|
}
|