WIP API updates for tutorial and more
This commit is contained in:
parent
353577b1d7
commit
99dfd77600
7 changed files with 115 additions and 15 deletions
|
@ -22,6 +22,8 @@ export const isEmbeddedWebsiteEvent = new tg.IsInterface()
|
|||
y: tg.isNumber,
|
||||
width: tg.isNumber,
|
||||
height: tg.isNumber,
|
||||
origin: tg.isSingletonStringUnion("player", "map"),
|
||||
scale: tg.isNumber,
|
||||
})
|
||||
.get();
|
||||
|
||||
|
@ -35,6 +37,8 @@ export const isCreateEmbeddedWebsiteEvent = new tg.IsInterface()
|
|||
visible: tg.isBoolean,
|
||||
allowApi: tg.isBoolean,
|
||||
allow: tg.isString,
|
||||
origin: tg.isSingletonStringUnion("player", "map"),
|
||||
scale: tg.isNumber,
|
||||
})
|
||||
.get();
|
||||
|
||||
|
|
|
@ -195,6 +195,7 @@ export const isIframeQuery = (event: any): event is IframeQuery<keyof IframeQuer
|
|||
const result = iframeQueryMapTypeGuards[type].query(event.data);
|
||||
if (!result) {
|
||||
console.warn('Received a query with type "' + type + '" but the payload is invalid.');
|
||||
console.log(event);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
|
|
@ -12,6 +12,8 @@ export class EmbeddedWebsite {
|
|||
private _allow: string;
|
||||
private _allowApi: boolean;
|
||||
private _position: Rectangle;
|
||||
private readonly origin: "map" | "player" | undefined;
|
||||
private _scale: number | undefined;
|
||||
|
||||
constructor(private config: CreateEmbeddedWebsiteEvent) {
|
||||
this.name = config.name;
|
||||
|
@ -20,6 +22,12 @@ export class EmbeddedWebsite {
|
|||
this._allow = config.allow ?? "";
|
||||
this._allowApi = config.allowApi ?? false;
|
||||
this._position = config.position;
|
||||
this.origin = config.origin;
|
||||
this._scale = config.scale;
|
||||
}
|
||||
|
||||
public get url() {
|
||||
return this._url;
|
||||
}
|
||||
|
||||
public set url(url: string) {
|
||||
|
@ -33,6 +41,10 @@ export class EmbeddedWebsite {
|
|||
});
|
||||
}
|
||||
|
||||
public get visible() {
|
||||
return this._visible;
|
||||
}
|
||||
|
||||
public set visible(visible: boolean) {
|
||||
this._visible = visible;
|
||||
sendToWorkadventure({
|
||||
|
@ -44,6 +56,10 @@ export class EmbeddedWebsite {
|
|||
});
|
||||
}
|
||||
|
||||
public get x() {
|
||||
return this._position.x;
|
||||
}
|
||||
|
||||
public set x(x: number) {
|
||||
this._position.x = x;
|
||||
sendToWorkadventure({
|
||||
|
@ -55,6 +71,10 @@ export class EmbeddedWebsite {
|
|||
});
|
||||
}
|
||||
|
||||
public get y() {
|
||||
return this._position.y;
|
||||
}
|
||||
|
||||
public set y(y: number) {
|
||||
this._position.y = y;
|
||||
sendToWorkadventure({
|
||||
|
@ -66,6 +86,10 @@ export class EmbeddedWebsite {
|
|||
});
|
||||
}
|
||||
|
||||
public get width() {
|
||||
return this._position.width;
|
||||
}
|
||||
|
||||
public set width(width: number) {
|
||||
this._position.width = width;
|
||||
sendToWorkadventure({
|
||||
|
@ -77,6 +101,10 @@ export class EmbeddedWebsite {
|
|||
});
|
||||
}
|
||||
|
||||
public get height() {
|
||||
return this._position.height;
|
||||
}
|
||||
|
||||
public set height(height: number) {
|
||||
this._position.height = height;
|
||||
sendToWorkadventure({
|
||||
|
@ -87,4 +115,19 @@ export class EmbeddedWebsite {
|
|||
},
|
||||
});
|
||||
}
|
||||
|
||||
public get scale() {
|
||||
return this._scale;
|
||||
}
|
||||
|
||||
public set scale(scale: number) {
|
||||
this._scale = scale;
|
||||
sendToWorkadventure({
|
||||
type: "modifyEmbeddedWebsite",
|
||||
data: {
|
||||
name: this.name,
|
||||
scale: this._scale,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
import type { LoadSoundEvent } from "../Events/LoadSoundEvent";
|
||||
import type { PlaySoundEvent } from "../Events/PlaySoundEvent";
|
||||
import type { StopSoundEvent } from "../Events/StopSoundEvent";
|
||||
import { IframeApiContribution, queryWorkadventure, sendToWorkadventure } from "./IframeApiContribution";
|
||||
import { Sound } from "./Sound/Sound";
|
||||
import { EmbeddedWebsite } from "./Room/EmbeddedWebsite";
|
||||
import type { CreateEmbeddedWebsiteEvent } from "../Events/EmbeddedWebsiteEvent";
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue