Fix panning to players across worlds
This commit is contained in:
parent
774d83e896
commit
38476266b0
@ -112,6 +112,11 @@ export default defineComponent({
|
||||
},
|
||||
panTarget(newValue) {
|
||||
if(newValue) {
|
||||
//Immediately clear if on the correct world, to allow repeated panning
|
||||
if(this.currentWorld && newValue.location.world === this.currentWorld.name) {
|
||||
useStore().commit(MutationTypes.CLEAR_PAN_TARGET, undefined);
|
||||
}
|
||||
|
||||
this.updateFollow(newValue, false);
|
||||
}
|
||||
},
|
||||
@ -124,10 +129,20 @@ export default defineComponent({
|
||||
|
||||
store.dispatch(ActionTypes.GET_MARKER_SETS, undefined);
|
||||
|
||||
if(oldValue || !store.state.parsedUrl.location) {
|
||||
location = newValue.center;
|
||||
} else {
|
||||
//Abort if follow target is present, to avoid panning twice
|
||||
if(store.state.followTarget && store.state.followTarget.location.world === newValue.name) {
|
||||
return;
|
||||
//Abort if pan target is present, to avoid panning to the wrong place.
|
||||
// Also clear it to allow repeated panning.
|
||||
} else if(store.state.panTarget && store.state.panTarget.location.world === newValue.name) {
|
||||
store.commit(MutationTypes.CLEAR_PAN_TARGET, undefined);
|
||||
return;
|
||||
//Otherwise pan to url location, if present and if we have just loaded
|
||||
} else if(!oldValue && store.state.parsedUrl.location) {
|
||||
location = store.state.parsedUrl.location;
|
||||
//Otherwise pan to world center
|
||||
} else {
|
||||
location = newValue.center;
|
||||
}
|
||||
|
||||
if(!oldValue) {
|
||||
|
@ -68,6 +68,7 @@ export type Mutations<S = State> = {
|
||||
[MutationTypes.SET_FOLLOW_TARGET](state: S, payload: DynmapPlayer): void
|
||||
[MutationTypes.SET_PAN_TARGET](state: S, payload: DynmapPlayer): void
|
||||
[MutationTypes.CLEAR_FOLLOW_TARGET](state: S, a?: void): void
|
||||
[MutationTypes.CLEAR_PAN_TARGET](state: S, a?: void): void
|
||||
}
|
||||
|
||||
export const mutations: MutationTree<State> & Mutations = {
|
||||
@ -347,5 +348,10 @@ export const mutations: MutationTree<State> & Mutations = {
|
||||
//Clear the follow target
|
||||
[MutationTypes.CLEAR_FOLLOW_TARGET](state: State) {
|
||||
state.followTarget = undefined;
|
||||
},
|
||||
|
||||
//Clear the pan target
|
||||
[MutationTypes.CLEAR_PAN_TARGET](state: State) {
|
||||
state.panTarget = undefined;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user