Add custom image from errors thrown by the API
This commit is contained in:
parent
ec2b23f32f
commit
5d360c8770
@ -2,6 +2,8 @@
|
|||||||
import { fly } from "svelte/transition";
|
import { fly } from "svelte/transition";
|
||||||
import { errorScreenStore } from "../../Stores/ErrorScreenStore";
|
import { errorScreenStore } from "../../Stores/ErrorScreenStore";
|
||||||
import { gameManager } from "../../Phaser/Game/GameManager";
|
import { gameManager } from "../../Phaser/Game/GameManager";
|
||||||
|
import { get } from "svelte/store";
|
||||||
|
import {onDestroy} from "svelte";
|
||||||
|
|
||||||
import logoImg from "../images/logo-min-white.png";
|
import logoImg from "../images/logo-min-white.png";
|
||||||
let logo = gameManager?.currentStartedRoom?.loginSceneLogo ?? logoImg;
|
let logo = gameManager?.currentStartedRoom?.loginSceneLogo ?? logoImg;
|
||||||
@ -9,10 +11,11 @@
|
|||||||
import cup from "../images/cup.png";
|
import cup from "../images/cup.png";
|
||||||
import reload from "../images/reload.png";
|
import reload from "../images/reload.png";
|
||||||
import external from "../images/external-link.png";
|
import external from "../images/external-link.png";
|
||||||
import { get } from "svelte/store";
|
|
||||||
|
|
||||||
let errorScreen = get(errorScreenStore);
|
let errorScreen = get(errorScreenStore);
|
||||||
|
|
||||||
|
const image = errorScreen.image ?? (errorScreen.type === "retry" ? cup : error);
|
||||||
|
|
||||||
function click() {
|
function click() {
|
||||||
if (errorScreen.urlToRedirect) window.location.replace(errorScreen.urlToRedirect);
|
if (errorScreen.urlToRedirect) window.location.replace(errorScreen.urlToRedirect);
|
||||||
else if (errorScreen.type === "redirect" && window.history.length > 2) history.back();
|
else if (errorScreen.type === "redirect" && window.history.length > 2) history.back();
|
||||||
@ -20,11 +23,13 @@
|
|||||||
}
|
}
|
||||||
let details = errorScreen.details;
|
let details = errorScreen.details;
|
||||||
let timeVar = errorScreen.timeToRetry ?? 0;
|
let timeVar = errorScreen.timeToRetry ?? 0;
|
||||||
|
|
||||||
if (errorScreen.type === "retry") {
|
if (errorScreen.type === "retry") {
|
||||||
setInterval(() => {
|
let interval = setInterval(() => {
|
||||||
if (timeVar <= 1000) click();
|
if (timeVar <= 1000) click();
|
||||||
timeVar -= 1000;
|
timeVar -= 1000;
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
onDestroy(() => clearInterval(interval));
|
||||||
}
|
}
|
||||||
|
|
||||||
$: detailsStylized = details.replace("{time}", `${timeVar / 1000}`);
|
$: detailsStylized = details.replace("{time}", `${timeVar / 1000}`);
|
||||||
@ -33,7 +38,7 @@
|
|||||||
<main class="errorScreen" transition:fly={{ y: -200, duration: 500 }}>
|
<main class="errorScreen" transition:fly={{ y: -200, duration: 500 }}>
|
||||||
<div style="width: 90%;">
|
<div style="width: 90%;">
|
||||||
<img src={logo} alt="WorkAdventure" class="logo" />
|
<img src={logo} alt="WorkAdventure" class="logo" />
|
||||||
<div><img src={$errorScreenStore.type === "retry" ? cup : error} alt="" class="icon" /></div>
|
<div><img src={image} alt="" class="icon" /></div>
|
||||||
{#if $errorScreenStore.type !== "retry"}<h2>{$errorScreenStore.title}</h2>{/if}
|
{#if $errorScreenStore.type !== "retry"}<h2>{$errorScreenStore.title}</h2>{/if}
|
||||||
<p>{$errorScreenStore.subtitle}</p>
|
<p>{$errorScreenStore.subtitle}</p>
|
||||||
{#if $errorScreenStore.type !== "retry"}<p class="code">Code : {$errorScreenStore.code}</p>{/if}
|
{#if $errorScreenStore.type !== "retry"}<p class="code">Code : {$errorScreenStore.code}</p>{/if}
|
||||||
@ -74,10 +79,14 @@
|
|||||||
.logo {
|
.logo {
|
||||||
width: 50%;
|
width: 50%;
|
||||||
margin-bottom: 50px;
|
margin-bottom: 50px;
|
||||||
|
max-height: 10vh;
|
||||||
|
max-width: 50vw;
|
||||||
}
|
}
|
||||||
.icon {
|
.icon {
|
||||||
height: 125px;
|
height: 125px;
|
||||||
margin-bottom: 25px;
|
margin-bottom: 25px;
|
||||||
|
max-height: 10vh;
|
||||||
|
max-width: 50vw;
|
||||||
}
|
}
|
||||||
h2 {
|
h2 {
|
||||||
font-family: "Press Start 2P";
|
font-family: "Press Start 2P";
|
||||||
|
@ -234,6 +234,7 @@ message ErrorScreenMessage {
|
|||||||
bool canRetryManual = 7;
|
bool canRetryManual = 7;
|
||||||
string urlToRedirect = 8;
|
string urlToRedirect = 8;
|
||||||
string buttonTitle = 9;
|
string buttonTitle = 9;
|
||||||
|
string image = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ItemStateMessage {
|
message ItemStateMessage {
|
||||||
|
@ -22,6 +22,7 @@ import {
|
|||||||
FollowAbortMessage,
|
FollowAbortMessage,
|
||||||
VariableMessage,
|
VariableMessage,
|
||||||
LockGroupPromptMessage,
|
LockGroupPromptMessage,
|
||||||
|
ErrorScreenMessage
|
||||||
} from "../Messages/generated/messages_pb";
|
} from "../Messages/generated/messages_pb";
|
||||||
import { UserMovesMessage } from "../Messages/generated/messages_pb";
|
import { UserMovesMessage } from "../Messages/generated/messages_pb";
|
||||||
import { parse } from "query-string";
|
import { parse } from "query-string";
|
||||||
@ -486,18 +487,7 @@ export class IoSocketController {
|
|||||||
} else if (ws.reason === "textureInvalid") {
|
} else if (ws.reason === "textureInvalid") {
|
||||||
socketManager.emitInvalidTextureMessage(ws);
|
socketManager.emitInvalidTextureMessage(ws);
|
||||||
} else if (ws.reason === "error") {
|
} else if (ws.reason === "error") {
|
||||||
socketManager.emitErrorScreenMessage(
|
socketManager.emitErrorScreenMessage(ws, ws.error as ErrorScreenMessage);
|
||||||
ws,
|
|
||||||
ws.error.type,
|
|
||||||
ws.error.code,
|
|
||||||
ws.error.title,
|
|
||||||
ws.error.subtitle,
|
|
||||||
ws.error.details,
|
|
||||||
ws.error.timeToRetry,
|
|
||||||
ws.error.canRetryManual,
|
|
||||||
ws.error.urlToRedirect,
|
|
||||||
ws.error.buttonTitle
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
socketManager.emitConnexionErrorMessage(ws, ws.message);
|
socketManager.emitConnexionErrorMessage(ws, ws.message);
|
||||||
}
|
}
|
||||||
|
@ -646,29 +646,10 @@ export class SocketManager implements ZoneEventListener {
|
|||||||
|
|
||||||
public emitErrorScreenMessage(
|
public emitErrorScreenMessage(
|
||||||
client: compressors.WebSocket,
|
client: compressors.WebSocket,
|
||||||
type: string,
|
error: ErrorScreenMessage
|
||||||
code: string,
|
|
||||||
title: string,
|
|
||||||
subtitle: string,
|
|
||||||
details: string,
|
|
||||||
timeToRetry: number,
|
|
||||||
canRetryManual: boolean,
|
|
||||||
urlToRedirect: string,
|
|
||||||
buttonTitle: string
|
|
||||||
) {
|
) {
|
||||||
const errorMessage = new ErrorScreenMessage();
|
|
||||||
errorMessage.setType(type);
|
|
||||||
errorMessage.setCode(code);
|
|
||||||
errorMessage.setTitle(title);
|
|
||||||
errorMessage.setSubtitle(subtitle);
|
|
||||||
errorMessage.setDetails(details);
|
|
||||||
errorMessage.setTimetoretry(timeToRetry);
|
|
||||||
errorMessage.setCanretrymanual(canRetryManual);
|
|
||||||
errorMessage.setUrltoredirect(urlToRedirect);
|
|
||||||
errorMessage.setButtontitle(buttonTitle);
|
|
||||||
|
|
||||||
const serverToClientMessage = new ServerToClientMessage();
|
const serverToClientMessage = new ServerToClientMessage();
|
||||||
serverToClientMessage.setErrorscreenmessage(errorMessage);
|
serverToClientMessage.setErrorscreenmessage(error);
|
||||||
|
|
||||||
//if (!client.disconnecting) {
|
//if (!client.disconnecting) {
|
||||||
client.send(serverToClientMessage.serializeBinary().buffer, true);
|
client.send(serverToClientMessage.serializeBinary().buffer, true);
|
||||||
|
Loading…
Reference in New Issue
Block a user