Merge branch 'develop' into codeAPI

This commit is contained in:
César Cardinale
2022-04-13 17:00:55 +02:00
committed by GitHub
183 changed files with 1645 additions and 1330 deletions
-4
View File
@@ -1,9 +1,7 @@
import ImageFrameConfig = Phaser.Types.Loader.FileTypes.ImageFrameConfig;
import { DirtyScene } from "../Game/DirtyScene";
import { gameManager } from "../Game/GameManager";
import { SuperLoaderPlugin } from "../Services/SuperLoaderPlugin";
import CancelablePromise from "cancelable-promise";
import Image = Phaser.GameObjects.Image;
import Texture = Phaser.Textures.Texture;
const TextName: string = "Loading...";
@@ -35,8 +33,6 @@ export class Loader {
const logoResource = gameManager.currentStartedRoom.loadingLogo ?? "static/images/logo.png";
this.logoNameIndex = "logoLoading" + logoResource;
const loadingBarWidth: number = Math.floor(this.scene.game.renderer.width / 3);
//add loading if logo image until logo image is ready
this.loadingText = this.scene.add.text(
this.scene.game.renderer.width / 2,
-1
View File
@@ -1,6 +1,5 @@
import type { ITiledMapObject } from "../Map/ITiledMap";
import type { GameScene } from "../Game/GameScene";
import { type } from "os";
import { GameMapProperties } from "../Game/GameMapProperties";
export class TextUtils {
+1 -6
View File
@@ -1,9 +1,4 @@
import {
AnimationData,
getPlayerAnimations,
PlayerAnimationDirections,
PlayerAnimationTypes,
} from "../Player/Animation";
import { getPlayerAnimations, PlayerAnimationDirections, PlayerAnimationTypes } from "../Player/Animation";
import { SpeechBubble } from "./SpeechBubble";
import Text = Phaser.GameObjects.Text;
import Container = Phaser.GameObjects.Container;
@@ -1,6 +1,5 @@
import LoaderPlugin = Phaser.Loader.LoaderPlugin;
import type { CharacterTexture } from "../../Connexion/LocalUser";
import { BodyResourceDescriptionInterface, mapLayerToLevel, PlayerTextures, PlayerTexturesKey } from "./PlayerTextures";
import { BodyResourceDescriptionInterface, PlayerTextures, PlayerTexturesKey } from "./PlayerTextures";
import CancelablePromise from "cancelable-promise";
import { SuperLoaderPlugin } from "../Services/SuperLoaderPlugin";
import Texture = Phaser.Textures.Texture;
+2
View File
@@ -97,6 +97,7 @@ export class CameraManager extends Phaser.Events.EventEmitter {
});
return;
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
this.camera.pan(setTo.x, setTo.y, duration, Easing.SineEaseOut, true, (camera, progress, x, y) => {
if (this.cameraMode === CameraMode.Positioned) {
this.waScaleManager.zoomModifier = currentZoomModifier + progress * zoomModifierChange;
@@ -138,6 +139,7 @@ export class CameraManager extends Phaser.Events.EventEmitter {
this.emit(CameraManagerEvent.CameraUpdate, this.getCameraUpdateEventData());
return;
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
this.camera.pan(focusOn.x, focusOn.y, duration, Easing.SineEaseOut, true, (camera, progress, x, y) => {
this.waScaleManager.zoomModifier = currentZoomModifier + progress * zoomModifierChange;
if (progress === 1) {
@@ -223,7 +223,7 @@ height,*/
}
close(): void {
for (const [key, website] of this.embeddedWebsites) {
for (const website of this.embeddedWebsites.values()) {
if (website.allowApi) {
iframeListener.unregisterIframe(website.iframe);
}
-2
View File
@@ -1,6 +1,4 @@
import { SKIP_RENDER_OPTIMIZATIONS } from "../../Enum/EnvironmentVariable";
import { coWebsiteManager } from "../../WebRtc/CoWebsiteManager";
import { waScaleManager } from "../Services/WaScaleManager";
import { ResizableScene } from "../Login/ResizableScene";
const Events = Phaser.Core.Events;
@@ -112,7 +112,7 @@ export class GameMapPropertiesListener {
}
});
this.gameMap.onPropertyChange(GameMapProperties.EXIT_SCENE_URL, (newValue, oldValue) => {
this.gameMap.onPropertyChange(GameMapProperties.EXIT_SCENE_URL, (newValue) => {
if (newValue) {
this.scene
.onMapExit(
@@ -130,7 +130,7 @@ export class GameMapPropertiesListener {
}
});
this.gameMap.onPropertyChange(GameMapProperties.EXIT_URL, (newValue, oldValue) => {
this.gameMap.onPropertyChange(GameMapProperties.EXIT_URL, (newValue) => {
if (newValue) {
this.scene
.onMapExit(Room.getRoomPathFromExitUrl(newValue as string, window.location.toString()))
@@ -142,7 +142,7 @@ export class GameMapPropertiesListener {
}
});
this.gameMap.onPropertyChange(GameMapProperties.SILENT, (newValue, oldValue) => {
this.gameMap.onPropertyChange(GameMapProperties.SILENT, (newValue) => {
if (newValue === undefined || newValue === false || newValue === "") {
this.scene.connection?.setSilent(false);
this.scene.CurrentPlayer.noSilent();
@@ -162,7 +162,7 @@ export class GameMapPropertiesListener {
});
// TODO: This legacy property should be removed at some point
this.gameMap.onPropertyChange(GameMapProperties.PLAY_AUDIO_LOOP, (newValue, oldValue) => {
this.gameMap.onPropertyChange(GameMapProperties.PLAY_AUDIO_LOOP, (newValue) => {
newValue === undefined
? audioManagerFileStore.unloadAudio()
: audioManagerFileStore.playAudio(newValue, this.scene.getMapDirUrl(), undefined, true);
+15 -7
View File
@@ -97,7 +97,6 @@ import { startLayerNamesStore } from "../../Stores/StartLayerNamesStore";
import { JitsiCoWebsite } from "../../WebRtc/CoWebsite/JitsiCoWebsite";
import { SimpleCoWebsite } from "../../WebRtc/CoWebsite/SimpleCoWebsite";
import type { CoWebsite } from "../../WebRtc/CoWebsite/CoWesbite";
import type { VideoPeer } from "../../WebRtc/VideoPeer";
import CancelablePromise from "cancelable-promise";
import { Deferred } from "ts-deferred";
import { SuperLoaderPlugin } from "../Services/SuperLoaderPlugin";
@@ -178,6 +177,7 @@ export class GameScene extends DirtyScene {
private localVolumeStoreUnsubscriber: Unsubscriber | undefined;
private followUsersColorStoreUnsubscribe!: Unsubscriber;
private currentPlayerGroupIdStoreUnsubscribe!: Unsubscriber;
private privacyShutdownStoreUnsubscribe!: Unsubscriber;
private userIsJitsiDominantSpeakerStoreUnsubscriber!: Unsubscriber;
private jitsiParticipantsCountStoreUnsubscriber!: Unsubscriber;
@@ -190,7 +190,7 @@ export class GameScene extends DirtyScene {
currentTick!: number;
lastSentTick!: number; // The last tick at which a position was sent.
lastMoveEventSent: HasPlayerMovedEvent = {
direction: "",
direction: "down",
moving: false,
x: -1000,
y: -1000,
@@ -222,8 +222,8 @@ export class GameScene extends DirtyScene {
private loader: Loader;
private lastCameraEvent: WasCameraUpdatedEvent | undefined;
private firstCameraUpdateSent: boolean = false;
private showVoiceIndicatorChangeMessageSent: boolean = false;
private currentPlayerGroupId?: number;
private showVoiceIndicatorChangeMessageSent: boolean = false;
private jitsiDominantSpeaker: boolean = false;
private jitsiParticipantsCount: number = 0;
public readonly superLoad: SuperLoaderPlugin;
@@ -843,6 +843,10 @@ export class GameScene extends DirtyScene {
this.currentPlayerGroupId = message.groupId;
});
this.connection.groupUsersUpdateMessageStream.subscribe((message) => {
this.currentPlayerGroupId = message.groupId;
});
/**
* Triggered when we receive the JWT token to connect to Jitsi
*/
@@ -1046,6 +1050,7 @@ ${escapedMessage}
}, 100);
id = 0;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
for (const button of openPopupEvent.buttons) {
const button = HtmlUtils.getElementByIdOrFail<HTMLButtonElement>(
`popup-${openPopupEvent.popupId}-${id}`
@@ -1304,7 +1309,7 @@ ${escapedMessage}
await this.connectionAnswerPromiseDeferred.promise;
return {
mapUrl: this.MapUrlFile,
startLayerName: this.startPositionCalculator.startLayerName,
startLayerName: this.startPositionCalculator.startLayerName ?? undefined,
uuid: localUserStore.getLocalUser()?.uuid,
nickname: this.playerName,
language: get(locale),
@@ -1413,6 +1418,7 @@ ${escapedMessage}
break;
}
default: {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const _exhaustiveCheck: never = event.target;
}
}
@@ -1432,7 +1438,7 @@ ${escapedMessage}
this.connection?.emitPlayerOutlineColor(color);
});
iframeListener.registerAnswerer("removePlayerOutline", (message) => {
iframeListener.registerAnswerer("removePlayerOutline", () => {
this.CurrentPlayer.removeApiOutlineColor();
this.connection?.emitPlayerOutlineColor(null);
});
@@ -1715,6 +1721,7 @@ ${escapedMessage}
private createCollisionWithPlayer() {
//add collision layer
for (const phaserLayer of this.gameMap.phaserLayers) {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
this.physics.add.collider(this.CurrentPlayer, phaserLayer, (object1: GameObject, object2: GameObject) => {
//this.CurrentPlayer.say("Collision with layer : "+ (object2 as Tile).layer.name)
});
@@ -1765,9 +1772,11 @@ ${escapedMessage}
emoteMenuStore.openEmoteMenu();
}
});
// eslint-disable-next-line @typescript-eslint/no-unused-vars
this.CurrentPlayer.on(Phaser.Input.Events.POINTER_OVER, (pointer: Phaser.Input.Pointer) => {
this.CurrentPlayer.pointerOverOutline(0x365dff);
});
// eslint-disable-next-line @typescript-eslint/no-unused-vars
this.CurrentPlayer.on(Phaser.Input.Events.POINTER_OUT, (pointer: Phaser.Input.Pointer) => {
this.CurrentPlayer.pointerOutOutline();
});
@@ -1869,6 +1878,7 @@ ${escapedMessage}
break;
}
default: {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const tmp: never = event;
}
}
@@ -2030,8 +2040,6 @@ ${escapedMessage}
this.currentTick,
{
...message.position,
oldX: undefined,
oldY: undefined,
},
this.currentTick + POSITION_DELAY
);
+13 -10
View File
@@ -4,14 +4,13 @@ import type { ITiledMapObject } from "../../Map/ITiledMap";
import type { ItemFactoryInterface } from "../ItemFactoryInterface";
import type { GameScene } from "../../Game/GameScene";
import { ActionableItem } from "../ActionableItem";
import * as tg from "generic-type-guard";
import { z } from "zod";
const isComputerState = new tg.IsInterface()
.withProperties({
status: tg.isString,
})
.get();
type ComputerState = tg.GuardedType<typeof isComputerState>;
export const isComputerState = z.object({
status: z.string(),
});
export type ComputerState = z.infer<typeof isComputerState>;
let state: ComputerState = {
status: "off",
@@ -55,10 +54,14 @@ export default {
},
factory: (scene: GameScene, object: ITiledMapObject, initState: unknown): ActionableItem => {
if (initState !== undefined) {
if (!isComputerState(initState)) {
throw new Error("Invalid state received for computer object");
try {
state = isComputerState.parse(initState);
} catch (err) {
if (err instanceof z.ZodError) {
console.error(err.issues);
}
throw new Error(`Invalid state received for computer object`);
}
state = initState;
}
const computer = new Sprite(scene, object.x, object.y, "computer");
+1
View File
@@ -112,6 +112,7 @@ export class CustomizeScene extends AbstractCharacterScene {
this.onResize();
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
public update(time: number, dt: number): void {
this.customWokaPreviewer.update();
}
+1
View File
@@ -13,5 +13,6 @@ export class EmptyScene extends Scene {
create() {}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
update(time: number, delta: number): void {}
}
+1 -1
View File
@@ -1,7 +1,6 @@
import { gameManager } from "../Game/GameManager";
import { ResizableScene } from "./ResizableScene";
import { enableCameraSceneVisibilityStore } from "../../Stores/MediaStore";
import { localUserStore } from "../../Connexion/LocalUserStore";
import { analyticsClient } from "../../Administration/AnalyticsClient";
export const EnableCameraSceneName = "EnableCameraScene";
@@ -25,6 +24,7 @@ export class EnableCameraScene extends ResizableScene {
public onResize(): void {}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
update(time: number, delta: number): void {}
public login(): void {
+1
View File
@@ -49,6 +49,7 @@ export class LoginScene extends ResizableScene {
loginSceneVisibleStore.set(false);
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
update(time: number, delta: number): void {}
public onResize(): void {}
@@ -1,6 +1,5 @@
import { TextField } from "../Components/TextField";
import Image = Phaser.GameObjects.Image;
import Sprite = Phaser.GameObjects.Sprite;
import LL from "../../i18n/i18n-svelte";
import { get } from "svelte/store";
+1 -1
View File
@@ -86,7 +86,7 @@ export class WaScaleManager {
const { width: gameWidth, height: gameHeight } = coWebsiteManager.getGameSize();
const devicePixelRatio = window.devicePixelRatio ?? 1;
const { game: gameSize, real: realSize } = this.hdpiManager.getOptimalGameSize({
const { real: realSize } = this.hdpiManager.getOptimalGameSize({
width: gameWidth * devicePixelRatio,
height: gameHeight * devicePixelRatio,
});
@@ -16,6 +16,7 @@ export class GameSceneUserInputHandler implements UserInputHandlerInterface {
gameObjects: Phaser.GameObjects.GameObject[],
deltaX: number,
deltaY: number,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
deltaZ: number
): void {
this.gameScene.zoomByFactor(1 - (deltaY / 53) * 0.1);
@@ -43,13 +44,14 @@ export class GameSceneUserInputHandler implements UserInputHandlerInterface {
.then((path) => {
// Remove first step as it is for the tile we are currently standing on
path.shift();
this.gameScene.CurrentPlayer.setPathToFollow(path).catch((reason) => {});
this.gameScene.CurrentPlayer.setPathToFollow(path).catch(() => {});
})
.catch((reason) => {
console.warn(reason);
});
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
public handlePointerDownEvent(pointer: Phaser.Input.Pointer, gameObjects: Phaser.GameObjects.GameObject[]): void {}
public handleSpaceKeyUpEvent(event: Event): Event {