added loadPage Api call
This commit is contained in:
parent
5dc2f0ac47
commit
6c6789411a
4 changed files with 37 additions and 0 deletions
13
front/src/Api/Events/LoadPageEvent.ts
Normal file
13
front/src/Api/Events/LoadPageEvent.ts
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
import * as tg from "generic-type-guard";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export const isLoadPageEvent =
|
||||||
|
new tg.IsInterface().withProperties({
|
||||||
|
url: tg.isString,
|
||||||
|
}).get();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A message sent from the iFrame to the game to add a message in the chat.
|
||||||
|
*/
|
||||||
|
export type LoadPageEvent = tg.GuardedType<typeof isLoadPageEvent>;
|
|
@ -12,6 +12,7 @@ import {ClosePopupEvent, isClosePopupEvent} from "./Events/ClosePopupEvent";
|
||||||
import {scriptUtils} from "./ScriptUtils";
|
import {scriptUtils} from "./ScriptUtils";
|
||||||
import {GoToPageEvent, isGoToPageEvent} from "./Events/GoToPageEvent";
|
import {GoToPageEvent, isGoToPageEvent} from "./Events/GoToPageEvent";
|
||||||
import {isOpenCoWebsite, OpenCoWebSiteEvent} from "./Events/OpenCoWebSiteEvent";
|
import {isOpenCoWebsite, OpenCoWebSiteEvent} from "./Events/OpenCoWebSiteEvent";
|
||||||
|
import { isLoadPageEvent } from './Events/LoadPageEvent';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,6 +32,10 @@ class IframeListener {
|
||||||
private readonly _goToPageStream: Subject<GoToPageEvent> = new Subject();
|
private readonly _goToPageStream: Subject<GoToPageEvent> = new Subject();
|
||||||
public readonly goToPageStream = this._goToPageStream.asObservable();
|
public readonly goToPageStream = this._goToPageStream.asObservable();
|
||||||
|
|
||||||
|
|
||||||
|
private readonly _loadPageStream: Subject<string> = new Subject();
|
||||||
|
public readonly loadPageStream = this._loadPageStream.asObservable();
|
||||||
|
|
||||||
private readonly _openCoWebSiteStream: Subject<OpenCoWebSiteEvent> = new Subject();
|
private readonly _openCoWebSiteStream: Subject<OpenCoWebSiteEvent> = new Subject();
|
||||||
public readonly openCoWebSiteStream = this._openCoWebSiteStream.asObservable();
|
public readonly openCoWebSiteStream = this._openCoWebSiteStream.asObservable();
|
||||||
|
|
||||||
|
@ -103,6 +108,8 @@ class IframeListener {
|
||||||
}
|
}
|
||||||
else if (payload.type === 'removeBubble'){
|
else if (payload.type === 'removeBubble'){
|
||||||
this._removeBubbleStream.next();
|
this._removeBubbleStream.next();
|
||||||
|
}else if (payload.type === 'loadPage' && isLoadPageEvent(payload.data)){
|
||||||
|
this._loadPageStream.next(payload.data.url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -841,6 +841,12 @@ ${escapedMessage}
|
||||||
this.iframeSubscriptionList.push(iframeListener.enablePlayerControlStream.subscribe(()=>{
|
this.iframeSubscriptionList.push(iframeListener.enablePlayerControlStream.subscribe(()=>{
|
||||||
this.userInputManager.restoreControls();
|
this.userInputManager.restoreControls();
|
||||||
}));
|
}));
|
||||||
|
this.iframeSubscriptionList.push(iframeListener.loadPageStream.subscribe((url:string)=>{
|
||||||
|
this.loadNextGame(url).then(()=>{
|
||||||
|
this.scene.systems.settings.isTransition=true
|
||||||
|
this.onMapExit(url)
|
||||||
|
})
|
||||||
|
}));
|
||||||
let scriptedBubbleSprite : Sprite;
|
let scriptedBubbleSprite : Sprite;
|
||||||
this.iframeSubscriptionList.push(iframeListener.displayBubbleStream.subscribe(()=>{
|
this.iframeSubscriptionList.push(iframeListener.displayBubbleStream.subscribe(()=>{
|
||||||
scriptedBubbleSprite = new Sprite(this,this.CurrentPlayer.x + 25,this.CurrentPlayer.y,'circleSprite-white');
|
scriptedBubbleSprite = new Sprite(this,this.CurrentPlayer.x + 25,this.CurrentPlayer.y,'circleSprite-white');
|
||||||
|
|
|
@ -9,6 +9,7 @@ import {ClosePopupEvent} from "./Api/Events/ClosePopupEvent";
|
||||||
import {OpenTabEvent} from "./Api/Events/OpenTabEvent";
|
import {OpenTabEvent} from "./Api/Events/OpenTabEvent";
|
||||||
import {GoToPageEvent} from "./Api/Events/GoToPageEvent";
|
import {GoToPageEvent} from "./Api/Events/GoToPageEvent";
|
||||||
import {OpenCoWebSiteEvent} from "./Api/Events/OpenCoWebSiteEvent";
|
import {OpenCoWebSiteEvent} from "./Api/Events/OpenCoWebSiteEvent";
|
||||||
|
import { LoadPageEvent } from './Api/Events/LoadPageEvent';
|
||||||
|
|
||||||
interface WorkAdventureApi {
|
interface WorkAdventureApi {
|
||||||
sendChatMessage(message: string, author: string): void;
|
sendChatMessage(message: string, author: string): void;
|
||||||
|
@ -18,6 +19,7 @@ interface WorkAdventureApi {
|
||||||
openPopup(targetObject: string, message: string, buttons: ButtonDescriptor[]): Popup;
|
openPopup(targetObject: string, message: string, buttons: ButtonDescriptor[]): Popup;
|
||||||
openTab(url : string): void;
|
openTab(url : string): void;
|
||||||
goToPage(url : string): void;
|
goToPage(url : string): void;
|
||||||
|
loadPage(url : string): void;
|
||||||
openCoWebSite(url : string): void;
|
openCoWebSite(url : string): void;
|
||||||
closeCoWebSite(): void;
|
closeCoWebSite(): void;
|
||||||
disablePlayerControl() : void;
|
disablePlayerControl() : void;
|
||||||
|
@ -122,6 +124,15 @@ window.WA = {
|
||||||
},'*');
|
},'*');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
loadPage(url : string) : void{
|
||||||
|
window.parent.postMessage({
|
||||||
|
"type" : 'loadPage',
|
||||||
|
"data" : {
|
||||||
|
url
|
||||||
|
} as LoadPageEvent
|
||||||
|
},'*');
|
||||||
|
},
|
||||||
|
|
||||||
openCoWebSite(url : string) : void{
|
openCoWebSite(url : string) : void{
|
||||||
window.parent.postMessage({
|
window.parent.postMessage({
|
||||||
"type" : 'openCoWebSite',
|
"type" : 'openCoWebSite',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue