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

View File

@ -1183,29 +1183,7 @@ export class GameScene extends DirtyScene {
);
this.iframeSubscriptionList.push(iframeListener.unregisterIFrameStream.subscribe(() => {
const allProps = this.gameMap.getCurrentProperties();
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,
});
}
// TODO: open trigger
}));
this.iframeSubscriptionList.push(iframeListener.setTilesStream.subscribe((eventTiles) => {