From 19baf7f582ca6f1b36a32fbb71f51a78969dbb31 Mon Sep 17 00:00:00 2001 From: GRL78 <80678534+GRL78@users.noreply.github.com> Date: Wed, 1 Sep 2021 10:11:12 +0200 Subject: [PATCH] fix ReportMenu (#1397) --- .../Components/ReportMenu/ReportMenu.svelte | 2 +- front/src/Phaser/Entity/RemotePlayer.ts | 43 ++++++++++++------- front/src/Stores/UserInputStore.ts | 7 +-- 3 files changed, 33 insertions(+), 19 deletions(-) diff --git a/front/src/Components/ReportMenu/ReportMenu.svelte b/front/src/Components/ReportMenu/ReportMenu.svelte index 9dd0d9f3..7594b1c9 100644 --- a/front/src/Components/ReportMenu/ReportMenu.svelte +++ b/front/src/Components/ReportMenu/ReportMenu.svelte @@ -21,7 +21,7 @@ if (reportScreenStore != null) { userName = reportScreenStore.userName; userUUID = playersStore.getPlayerById(reportScreenStore.userId)?.userUuid; - if (userUUID === undefined) { + if (userUUID === undefined && reportScreenStore !== userReportEmpty) { console.error("Could not find UUID for user with ID " + reportScreenStore.userId); } } diff --git a/front/src/Phaser/Entity/RemotePlayer.ts b/front/src/Phaser/Entity/RemotePlayer.ts index 32881e97..1cd03d12 100644 --- a/front/src/Phaser/Entity/RemotePlayer.ts +++ b/front/src/Phaser/Entity/RemotePlayer.ts @@ -1,16 +1,15 @@ -import type {GameScene} from "../Game/GameScene"; -import type {PointInterface} from "../../Connexion/ConnexionModels"; -import {Character} from "../Entity/Character"; -import type {PlayerAnimationDirections} from "../Player/Animation"; -import {requestVisitCardsStore} from "../../Stores/GameStore"; - +import type { GameScene } from "../Game/GameScene"; +import type { PointInterface } from "../../Connexion/ConnexionModels"; +import { Character } from "../Entity/Character"; +import type { PlayerAnimationDirections } from "../Player/Animation"; +import { requestVisitCardsStore } from "../../Stores/GameStore"; /** * Class representing the sprite of a remote player (a player that plays on another computer) */ export class RemotePlayer extends Character { userId: number; - private visitCardUrl: string|null; + private visitCardUrl: string | null; constructor( userId: number, @@ -21,19 +20,33 @@ export class RemotePlayer extends Character { texturesPromise: Promise, direction: PlayerAnimationDirections, moving: boolean, - visitCardUrl: string|null, - companion: string|null, + visitCardUrl: string | null, + companion: string | null, companionTexturePromise?: Promise ) { - super(Scene, x, y, texturesPromise, name, direction, moving, 1, !!visitCardUrl, companion, companionTexturePromise); - + super( + Scene, + x, + y, + texturesPromise, + name, + direction, + moving, + 1, + !!visitCardUrl, + companion, + companionTexturePromise + ); + //set data this.userId = userId; this.visitCardUrl = visitCardUrl; - - this.on('pointerdown', () => { - requestVisitCardsStore.set(this.visitCardUrl); - }) + + this.on("pointerdown", (event: Phaser.Input.Pointer) => { + if (event.downElement.nodeName === "CANVAS") { + requestVisitCardsStore.set(this.visitCardUrl); + } + }); } updatePosition(position: PointInterface): void { diff --git a/front/src/Stores/UserInputStore.ts b/front/src/Stores/UserInputStore.ts index e24b3afe..6d80d177 100644 --- a/front/src/Stores/UserInputStore.ts +++ b/front/src/Stores/UserInputStore.ts @@ -1,11 +1,12 @@ import { derived } from "svelte/store"; import { menuInputFocusStore } from "./MenuStore"; import { chatInputFocusStore } from "./ChatStore"; +import { showReportScreenStore, userReportEmpty } from "./ShowReportScreenStore"; //derived from the focus on Menu, ConsoleGlobal, Chat and ... export const enableUserInputsStore = derived( - [menuInputFocusStore, chatInputFocusStore], - ([$menuInputFocusStore, $chatInputFocusStore]) => { - return !$menuInputFocusStore && !$chatInputFocusStore; + [menuInputFocusStore, chatInputFocusStore, showReportScreenStore], + ([$menuInputFocusStore, $chatInputFocusStore, $showReportScreenStore]) => { + return !$menuInputFocusStore && !$chatInputFocusStore && !($showReportScreenStore !== userReportEmpty); } );