2025-01-23 05:01:55 +01:00
|
|
|
import ThemeConfig from "../ThemeConfig/ThemeConfig"
|
|
|
|
|
import { MenuState } from "../MenuState"
|
|
|
|
|
import Hotkeys from "../../UI/Base/Hotkeys"
|
|
|
|
|
import Translations from "../../UI/i18n/Translations"
|
|
|
|
|
import { WithSpecialLayers } from "./WithSpecialLayers"
|
2025-01-23 12:30:42 +01:00
|
|
|
import { Store } from "../../Logic/UIEventSource"
|
2025-01-23 05:01:55 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Does all things related to:
|
|
|
|
|
* - The UI state
|
|
|
|
|
*/
|
|
|
|
|
export class WithGuiState extends WithSpecialLayers {
|
|
|
|
|
readonly guistate: MenuState
|
|
|
|
|
|
2025-01-23 12:30:42 +01:00
|
|
|
constructor(theme: ThemeConfig, mvtAvailableLayers: Store<Set<string>>) {
|
2025-01-23 05:01:55 +01:00
|
|
|
super(theme, mvtAvailableLayers)
|
2025-01-23 12:30:42 +01:00
|
|
|
this.guistate = new MenuState(this.selectedElement)
|
|
|
|
|
this.guistate.openMenuIfNeeded(
|
2025-01-23 05:01:55 +01:00
|
|
|
this.featureSwitches.featureSwitchWelcomeMessage.data,
|
|
|
|
|
theme.id
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
Object.values(this.guistate.pageStates).forEach((toggle) => {
|
|
|
|
|
toggle.addCallbackD((isOpened) => {
|
|
|
|
|
// When a panel is closed: focus on the map again
|
|
|
|
|
if (!isOpened) {
|
|
|
|
|
if (!this.guistate.isSomethingOpen()) {
|
|
|
|
|
this.focusOnMap()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
this.initHotkeysGui()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private initHotkeysGui() {
|
|
|
|
|
const docs = Translations.t.hotkeyDocumentation
|
|
|
|
|
|
|
|
|
|
Hotkeys.RegisterHotkey({ nomod: "f" }, docs.selectFavourites, () => {
|
|
|
|
|
this.guistate.pageStates.favourites.set(true)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
Hotkeys.RegisterHotkey(
|
|
|
|
|
{
|
2025-01-28 15:42:34 +01:00
|
|
|
nomod: "b",
|
2025-01-23 05:01:55 +01:00
|
|
|
},
|
|
|
|
|
docs.openLayersPanel,
|
|
|
|
|
() => {
|
|
|
|
|
if (this.featureSwitches.featureSwitchBackgroundSelection.data) {
|
|
|
|
|
this.guistate.pageStates.background.setData(true)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
Hotkeys.RegisterHotkey(
|
|
|
|
|
{
|
2025-01-28 15:42:34 +01:00
|
|
|
nomod: "s",
|
2025-01-23 05:01:55 +01:00
|
|
|
},
|
|
|
|
|
Translations.t.hotkeyDocumentation.openFilterPanel,
|
|
|
|
|
() => {
|
|
|
|
|
if (this.featureSwitches.featureSwitchFilter.data) {
|
|
|
|
|
this.guistate.openFilterView()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public selectCurrentView() {
|
|
|
|
|
this.guistate.closeAll()
|
|
|
|
|
this.selectedElement.setData(this.currentView.features?.data?.[0])
|
|
|
|
|
}
|
|
|
|
|
}
|