auto update show/hide layer

This commit is contained in:
GRL 2021-05-10 11:20:07 +02:00
parent a6ba8d41b9
commit 841bf29764
2 changed files with 29 additions and 6 deletions

View File

@ -35,6 +35,7 @@ export abstract class DirtyScene extends ResizableScene {
this.events.on(Events.RENDER, () => { this.events.on(Events.RENDER, () => {
this.objectListChanged = false; this.objectListChanged = false;
this.dirty = false;
}); });
} }

View File

@ -91,6 +91,7 @@ import {touchScreenManager} from "../../Touch/TouchScreenManager";
import {PinchManager} from "../UserInput/PinchManager"; import {PinchManager} from "../UserInput/PinchManager";
import {joystickBaseImg, joystickBaseKey, joystickThumbImg, joystickThumbKey} from "../Components/MobileJoystick"; import {joystickBaseImg, joystickBaseKey, joystickThumbImg, joystickThumbKey} from "../Components/MobileJoystick";
import {waScaleManager} from "../Services/WaScaleManager"; import {waScaleManager} from "../Services/WaScaleManager";
import {LayerEvent} from "../../Api/Events/LayerEvent";
export interface GameSceneInitInterface { export interface GameSceneInitInterface {
initPosition: PointInterface|null, initPosition: PointInterface|null,
@ -875,8 +876,30 @@ ${escapedMessage}
scriptedBubbleSprite.destroy(); scriptedBubbleSprite.destroy();
})); }));
this.iframeSubscriptionList.push(iframeListener.showLayerStream.subscribe((layerEvent)=>{
console.log('showLayer 3');
this.setLayerVisibility(layerEvent.name, true);
}));
this.iframeSubscriptionList.push(iframeListener.hideLayerStream.subscribe((layerEvent)=>{
console.log('hideLayer 3');
this.setLayerVisibility(layerEvent.name, false);
}));
} }
private setLayerVisibility(layerName: string, visible: boolean): void {
console.log('visibility');
const layer = this.Layers.find((layer) => layer.layer.name === layerName);
if (layer === undefined) {
console.warn('Could not find layer "' + layerName + '" when calling WA.hideLayer / WA.showLayer');
return;
}
layer.setVisible(visible);
this.dirty = true;
}
private getMapDirUrl(): string { private getMapDirUrl(): string {
return this.MapUrlFile.substr(0, this.MapUrlFile.lastIndexOf('/')); return this.MapUrlFile.substr(0, this.MapUrlFile.lastIndexOf('/'));
} }
@ -1207,7 +1230,6 @@ ${escapedMessage}
* @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate.
*/ */
update(time: number, delta: number) : void { update(time: number, delta: number) : void {
this.dirty = false;
mediaManager.updateScene(); mediaManager.updateScene();
this.currentTick = time; this.currentTick = time;
if (this.CurrentPlayer.isMoving()) { if (this.CurrentPlayer.isMoving()) {