Merge pull request #686 from thecodingmachine/publicReportedUser
Permit puiblic report
This commit is contained in:
commit
f2b9f6c92a
12 changed files with 282 additions and 101 deletions
|
@ -154,7 +154,7 @@ export class GameScene extends ResizableScene implements CenterListener {
|
|||
private actionableItems: Map<number, ActionableItem> = new Map<number, ActionableItem>();
|
||||
// The item that can be selected by pressing the space key.
|
||||
private outlinedItem: ActionableItem|null = null;
|
||||
private userInputManager!: UserInputManager;
|
||||
public userInputManager!: UserInputManager;
|
||||
private isReconnecting: boolean = false;
|
||||
private startLayerName!: string | null;
|
||||
private openChatIcon!: OpenChatIcon;
|
||||
|
|
|
@ -2,7 +2,7 @@ import {LoginScene, LoginSceneName} from "../Login/LoginScene";
|
|||
import {SelectCharacterScene, SelectCharacterSceneName} from "../Login/SelectCharacterScene";
|
||||
import {gameManager} from "../Game/GameManager";
|
||||
import {localUserStore} from "../../Connexion/LocalUserStore";
|
||||
import {mediaManager} from "../../WebRtc/MediaManager";
|
||||
import {mediaManager, ReportCallback, ShowReportCallBack} from "../../WebRtc/MediaManager";
|
||||
import {coWebsiteManager} from "../../WebRtc/CoWebsiteManager";
|
||||
|
||||
export const MenuSceneName = 'MenuScene';
|
||||
|
@ -10,6 +10,7 @@ const gameMenuKey = 'gameMenu';
|
|||
const gameMenuIconKey = 'gameMenuIcon';
|
||||
const gameSettingsMenuKey = 'gameSettingsMenu';
|
||||
const gameShare = 'gameShare';
|
||||
const gameReport = 'gameReport';
|
||||
|
||||
const closedSideMenuX = -200;
|
||||
const openedSideMenuX = 0;
|
||||
|
@ -21,9 +22,11 @@ export class MenuScene extends Phaser.Scene {
|
|||
private menuElement!: Phaser.GameObjects.DOMElement;
|
||||
private gameQualityMenuElement!: Phaser.GameObjects.DOMElement;
|
||||
private gameShareElement!: Phaser.GameObjects.DOMElement;
|
||||
private gameReportElement!: Phaser.GameObjects.DOMElement;
|
||||
private sideMenuOpened = false;
|
||||
private settingsMenuOpened = false;
|
||||
private gameShareOpened = false;
|
||||
private gameReportOpened = false;
|
||||
private gameQualityValue: number;
|
||||
private videoQualityValue: number;
|
||||
private menuButton!: Phaser.GameObjects.DOMElement;
|
||||
|
@ -40,6 +43,7 @@ export class MenuScene extends Phaser.Scene {
|
|||
this.load.html(gameMenuIconKey, 'resources/html/gameMenuIcon.html');
|
||||
this.load.html(gameSettingsMenuKey, 'resources/html/gameQualityMenu.html');
|
||||
this.load.html(gameShare, 'resources/html/gameShare.html');
|
||||
this.load.html(gameReport, 'resources/html/gameReport.html');
|
||||
}
|
||||
|
||||
create() {
|
||||
|
@ -64,6 +68,19 @@ export class MenuScene extends Phaser.Scene {
|
|||
}
|
||||
});
|
||||
|
||||
this.gameReportElement = this.add.dom(middleX, -400).createFromCache(gameReport);
|
||||
this.revealMenusAfterInit(this.gameReportElement, gameReport);
|
||||
this.gameReportElement.addListener('click');
|
||||
this.gameReportElement.on('click', (event:MouseEvent) => {
|
||||
event.preventDefault();
|
||||
if((event?.target as HTMLInputElement).id === 'gameReportFormSubmit') {
|
||||
this.submitReport();
|
||||
}else if((event?.target as HTMLInputElement).id === 'gameReportFormCancel') {
|
||||
this.closeGameReport();
|
||||
}
|
||||
});
|
||||
mediaManager.setShowReportModalCallBacks(this.openGameReport.bind(this));
|
||||
|
||||
this.input.keyboard.on('keyup-TAB', () => {
|
||||
this.sideMenuOpened ? this.closeSideMenu() : this.openSideMenu();
|
||||
});
|
||||
|
@ -221,6 +238,71 @@ export class MenuScene extends Phaser.Scene {
|
|||
});
|
||||
}
|
||||
|
||||
private openGameReport(userId: string, userName: string|undefined){
|
||||
if (this.gameReportOpened) {
|
||||
this.closeGameReport();
|
||||
return;
|
||||
}
|
||||
|
||||
//close all
|
||||
this.closeAll();
|
||||
|
||||
const gameTitleReport = this.gameReportElement.getChildByID('nameReported') as HTMLElement;
|
||||
gameTitleReport.innerText = userName ? `Report user: ${userName}` : 'Report user';
|
||||
const gameIdUserReported = this.gameReportElement.getChildByID('idUserReported') as HTMLInputElement;
|
||||
gameIdUserReported.value = userId;
|
||||
|
||||
this.gameReportOpened = true;
|
||||
let middleY = (window.innerHeight / 3) - (257);
|
||||
if(middleY < 0){
|
||||
middleY = 0;
|
||||
}
|
||||
let middleX = (window.innerWidth / 3) - 298;
|
||||
if(middleX < 0){
|
||||
middleX = 0;
|
||||
}
|
||||
|
||||
gameManager.getCurrentGameScene(this).userInputManager.clearAllInputKeyboard();
|
||||
|
||||
this.tweens.add({
|
||||
targets: this.gameReportElement,
|
||||
y: middleY,
|
||||
x: middleX,
|
||||
duration: 1000,
|
||||
ease: 'Power3'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
private closeGameReport(): void{
|
||||
this.gameReportOpened = false;
|
||||
gameManager.getCurrentGameScene(this).userInputManager.initKeyBoardEvent();
|
||||
this.tweens.add({
|
||||
targets: this.gameReportElement,
|
||||
y: -400,
|
||||
duration: 1000,
|
||||
ease: 'Power3'
|
||||
});
|
||||
}
|
||||
|
||||
private submitReport(): void{
|
||||
const gamePError = this.gameReportElement.getChildByID('gameReportErr') as HTMLParagraphElement;
|
||||
gamePError.innerText = '';
|
||||
gamePError.style.display = 'none';
|
||||
const gameTextArea = this.gameReportElement.getChildByID('gameReportInput') as HTMLInputElement;
|
||||
const gameIdUserReported = this.gameReportElement.getChildByID('idUserReported') as HTMLInputElement;
|
||||
if(!gameTextArea || !gameTextArea.value || !gameIdUserReported || !gameIdUserReported.value){
|
||||
gamePError.innerText = 'Report message cannot to be empty.';
|
||||
gamePError.style.display = 'block';
|
||||
return;
|
||||
}
|
||||
gameManager.getCurrentGameScene(this).connection.emitReportPlayerMessage(
|
||||
parseInt(gameIdUserReported.value),
|
||||
gameTextArea.value
|
||||
);
|
||||
this.closeGameReport();
|
||||
}
|
||||
|
||||
private onMenuClick(event:MouseEvent) {
|
||||
event.preventDefault();
|
||||
|
||||
|
@ -280,5 +362,6 @@ export class MenuScene extends Phaser.Scene {
|
|||
private closeAll(){
|
||||
this.closeGameQualityMenu();
|
||||
this.closeGameShare();
|
||||
this.closeGameReport();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue