fix cowebsite

This commit is contained in:
_Bastler 2021-11-01 19:14:53 +01:00
parent 00d9df1f4e
commit a044afd34c
2 changed files with 13 additions and 29 deletions

View File

@ -16,6 +16,7 @@ enum OpenCoWebsiteState {
LOADING, LOADING,
OPENED, OPENED,
MUST_BE_CLOSE, MUST_BE_CLOSE,
TRIGGER,
} }
interface OpenCoWebsite { interface OpenCoWebsite {
@ -106,11 +107,6 @@ export class GameMapPropertiesListener {
return; return;
} }
this.coWebsitesOpenByLayer.set(layer, {
coWebsite: undefined,
state: OpenCoWebsiteState.LOADING,
});
const openWebsiteFunction = () => { const openWebsiteFunction = () => {
coWebsiteManager.loadCoWebsite( coWebsiteManager.loadCoWebsite(
openWebsiteProperty as string, openWebsiteProperty as string,
@ -137,6 +133,11 @@ export class GameMapPropertiesListener {
}; };
if (websiteTriggerProperty && websiteTriggerProperty === ON_ACTION_TRIGGER_BUTTON) { if (websiteTriggerProperty && websiteTriggerProperty === ON_ACTION_TRIGGER_BUTTON) {
this.coWebsitesOpenByLayer.set(layer, {
coWebsite: undefined,
state: OpenCoWebsiteState.TRIGGER,
});
if (!websiteTriggerMessageProperty) { if (!websiteTriggerMessageProperty) {
websiteTriggerMessageProperty = "Press SPACE or touch here to open web site"; websiteTriggerMessageProperty = "Press SPACE or touch here to open web site";
} }
@ -151,6 +152,11 @@ export class GameMapPropertiesListener {
userInputManager: this.scene.userInputManager, userInputManager: this.scene.userInputManager,
}); });
} else { } else {
this.coWebsitesOpenByLayer.set(layer, {
coWebsite: undefined,
state: OpenCoWebsiteState.LOADING,
});
openWebsiteFunction(); openWebsiteFunction();
} }
}); });
@ -196,7 +202,7 @@ export class GameMapPropertiesListener {
return; return;
} }
if (coWebsiteOpen.state !== OpenCoWebsiteState.OPENED) { if (coWebsiteOpen.state !== OpenCoWebsiteState.OPENED && coWebsiteOpen.state !== OpenCoWebsiteState.TRIGGER) {
return; return;
} }

View File

@ -1183,29 +1183,7 @@ export class GameScene extends DirtyScene {
); );
this.iframeSubscriptionList.push(iframeListener.unregisterIFrameStream.subscribe(() => { this.iframeSubscriptionList.push(iframeListener.unregisterIFrameStream.subscribe(() => {
const allProps = this.gameMap.getCurrentProperties(); // TODO: open trigger
if (allProps.get("openWebsite") == null) {
layoutManagerActionStore.removeAction("openWebsite");
} else {
const openWebsiteFunction = () => {
coWebsiteManager.loadCoWebsite(allProps.get("openWebsite") as string, this.MapUrlFile, allProps.get('openWebsiteAllowApi') as boolean | undefined, allProps.get('openWebsitePolicy') as string | undefined);
layoutManagerActionStore.removeAction("openWebsite");
};
let message = allProps.get(WEBSITE_MESSAGE_PROPERTIES);
if (message === undefined) {
message = 'Press SPACE or touch here to open web site';
}
layoutManagerActionStore.addAction({
uuid: "openWebsite",
type: "message",
message: message,
callback: () => openWebsiteFunction(),
userInputManager: this.userInputManager,
});
}
})); }));
this.iframeSubscriptionList.push(iframeListener.setTilesStream.subscribe((eventTiles) => { this.iframeSubscriptionList.push(iframeListener.setTilesStream.subscribe((eventTiles) => {