diff --git a/front/src/Components/selectCharacter/SelectCharacterScene.svelte b/front/src/Components/selectCharacter/SelectCharacterScene.svelte index 9f6e5f9c..807cf88f 100644 --- a/front/src/Components/selectCharacter/SelectCharacterScene.svelte +++ b/front/src/Components/selectCharacter/SelectCharacterScene.svelte @@ -2,6 +2,7 @@ import type { Game } from "../../Phaser/Game/Game"; import { SelectCharacterScene, SelectCharacterSceneName } from "../../Phaser/Login/SelectCharacterScene"; import LL from "../../i18n/i18n-svelte"; + import { customizeAvailableStore } from "../../Stores/SelectCharacterSceneStore"; export let game: Game; @@ -40,11 +41,13 @@ class="selectCharacterSceneFormSubmit nes-btn is-primary" on:click|preventDefault={cameraScene}>{$LL.woka.selectWoka.continue()} - + {#if $customizeAvailableStore} + + {/if} diff --git a/front/src/Phaser/Entity/PlayerTextures.ts b/front/src/Phaser/Entity/PlayerTextures.ts index 84157a92..d41fc9f6 100644 --- a/front/src/Phaser/Entity/PlayerTextures.ts +++ b/front/src/Phaser/Entity/PlayerTextures.ts @@ -88,6 +88,9 @@ export class PlayerTextures { private getMappedResources(category: PlayerTexturesCategory): BodyResourceDescriptionListInterface { const resources: BodyResourceDescriptionListInterface = {}; + if (!category) { + return {}; + } for (const collection of category.collections) { for (const texture of collection.textures) { resources[texture.id] = { id: texture.id, label: texture.name, img: texture.url }; diff --git a/front/src/Phaser/Login/SelectCharacterScene.ts b/front/src/Phaser/Login/SelectCharacterScene.ts index f2af9cb9..5fe0ecc9 100644 --- a/front/src/Phaser/Login/SelectCharacterScene.ts +++ b/front/src/Phaser/Login/SelectCharacterScene.ts @@ -15,6 +15,7 @@ import { waScaleManager } from "../Services/WaScaleManager"; import { analyticsClient } from "../../Administration/AnalyticsClient"; import { isMediaBreakpointUp } from "../../Utils/BreakpointsUtils"; import { PUSHER_URL } from "../../Enum/EnvironmentVariable"; +import { customizeAvailableStore } from "../../Stores/SelectCharacterSceneStore"; //todo: put this constants in a dedicated file export const SelectCharacterSceneName = "SelectCharacterScene"; @@ -78,6 +79,7 @@ export class SelectCharacterScene extends AbstractCharacterScene { } create() { + customizeAvailableStore.set(this.isCustomizationAvailable()); selectCharacterSceneVisibleStore.set(true); this.events.addListener("wake", () => { waScaleManager.saveZoom(); @@ -295,4 +297,13 @@ export class SelectCharacterScene extends AbstractCharacterScene { //move position of user this.moveUser(); } + + private isCustomizationAvailable(): boolean { + for (const layer of PlayerTextures.LAYERS) { + if (Object.keys(layer).length > 0) { + return true; + } + } + return false; + } } diff --git a/front/src/Stores/SelectCharacterSceneStore.ts b/front/src/Stores/SelectCharacterSceneStore.ts new file mode 100644 index 00000000..654da03c --- /dev/null +++ b/front/src/Stores/SelectCharacterSceneStore.ts @@ -0,0 +1,3 @@ +import { writable } from "svelte/store"; + +export const customizeAvailableStore = writable(false);