Skip to content

Commit

Permalink
Add option to disable map context menu
Browse files Browse the repository at this point in the history
  • Loading branch information
JLyne committed Feb 20, 2022
1 parent 431f34e commit eba601e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@

// Use more compact pre-2.0 player marker style
compactPlayerMarkers: false,

// Disable the map right click menu
disableContextMenu: false,
},

// Config version. Do not modify.
Expand Down
4 changes: 3 additions & 1 deletion src/components/Map.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</template>
</div>

<MapContextMenu :leaflet="leaflet" v-if="leaflet"></MapContextMenu>
<MapContextMenu v-if="contextMenuEnabled && leaflet" :leaflet="leaflet"></MapContextMenu>
</template>

<script lang="ts">
Expand Down Expand Up @@ -81,6 +81,7 @@ export default defineComponent({
linkControlEnabled = computed(() => store.state.components.linkControl),
chatBoxEnabled = computed(() => store.state.components.chatBox),
loginEnabled = computed(() => store.state.components.login),
contextMenuEnabled = computed(() => !store.state.ui.disableContextMenu),
logoControls = computed(() => store.state.components.logoControls),
currentWorld = computed(() => store.state.currentWorld),
Expand Down Expand Up @@ -108,6 +109,7 @@ export default defineComponent({
linkControlEnabled,
chatBoxEnabled,
loginEnabled,
contextMenuEnabled,
logoControls,
followTarget,
Expand Down
1 change: 1 addition & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ interface LiveAtlasUIConfig {
playersAboveMarkers: boolean;
playersSearch: boolean;
compactPlayerMarkers: boolean;
disableContextMenu: boolean;
}

export type LiveAtlasUIElement = 'layers' | 'chat' | LiveAtlasSidebarSection;
Expand Down
4 changes: 4 additions & 0 deletions src/store/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ export const mutations: MutationTree<State> & Mutations = {
state.ui.compactPlayerMarkers = uiConfig.compactPlayerMarkers;
}

if(typeof uiConfig.disableContextMenu === 'boolean') {
state.ui.disableContextMenu = uiConfig.disableContextMenu;
}

if(typeof uiConfig.playersSearch === 'boolean') {
state.ui.playersSearch = uiConfig.playersSearch;
}
Expand Down
2 changes: 2 additions & 0 deletions src/store/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export type State = {
playersAboveMarkers: boolean;
playersSearch: boolean;
compactPlayerMarkers: boolean;
disableContextMenu: boolean;

screenWidth: number;
screenHeight: number;
Expand Down Expand Up @@ -222,6 +223,7 @@ export const state: State = {
playersAboveMarkers: true,
playersSearch: true,
compactPlayerMarkers: false,
disableContextMenu: false,

screenWidth: window.innerWidth,
screenHeight: window.innerHeight,
Expand Down

0 comments on commit eba601e

Please sign in to comment.