remove customize button if no body parts are available

This commit is contained in:
Hanusiak Piotr
2022-03-09 12:45:04 +01:00
parent 674c5bdeb8
commit e5095db048
4 changed files with 25 additions and 5 deletions
@@ -2,6 +2,7 @@
import type { Game } from "../../Phaser/Game/Game"; import type { Game } from "../../Phaser/Game/Game";
import { SelectCharacterScene, SelectCharacterSceneName } from "../../Phaser/Login/SelectCharacterScene"; import { SelectCharacterScene, SelectCharacterSceneName } from "../../Phaser/Login/SelectCharacterScene";
import LL from "../../i18n/i18n-svelte"; import LL from "../../i18n/i18n-svelte";
import { customizeAvailableStore } from "../../Stores/SelectCharacterSceneStore";
export let game: Game; export let game: Game;
@@ -40,11 +41,13 @@
class="selectCharacterSceneFormSubmit nes-btn is-primary" class="selectCharacterSceneFormSubmit nes-btn is-primary"
on:click|preventDefault={cameraScene}>{$LL.woka.selectWoka.continue()}</button on:click|preventDefault={cameraScene}>{$LL.woka.selectWoka.continue()}</button
> >
<button {#if $customizeAvailableStore}
type="submit" <button
class="selectCharacterSceneFormCustomYourOwnSubmit nes-btn" type="submit"
on:click|preventDefault={customizeScene}>{$LL.woka.selectWoka.customize()}</button class="selectCharacterSceneFormCustomYourOwnSubmit nes-btn"
> on:click|preventDefault={customizeScene}>{$LL.woka.selectWoka.customize()}</button
>
{/if}
</section> </section>
</form> </form>
@@ -88,6 +88,9 @@ export class PlayerTextures {
private getMappedResources(category: PlayerTexturesCategory): BodyResourceDescriptionListInterface { private getMappedResources(category: PlayerTexturesCategory): BodyResourceDescriptionListInterface {
const resources: BodyResourceDescriptionListInterface = {}; const resources: BodyResourceDescriptionListInterface = {};
if (!category) {
return {};
}
for (const collection of category.collections) { for (const collection of category.collections) {
for (const texture of collection.textures) { for (const texture of collection.textures) {
resources[texture.id] = { id: texture.id, label: texture.name, img: texture.url }; resources[texture.id] = { id: texture.id, label: texture.name, img: texture.url };
@@ -15,6 +15,7 @@ import { waScaleManager } from "../Services/WaScaleManager";
import { analyticsClient } from "../../Administration/AnalyticsClient"; import { analyticsClient } from "../../Administration/AnalyticsClient";
import { isMediaBreakpointUp } from "../../Utils/BreakpointsUtils"; import { isMediaBreakpointUp } from "../../Utils/BreakpointsUtils";
import { PUSHER_URL } from "../../Enum/EnvironmentVariable"; import { PUSHER_URL } from "../../Enum/EnvironmentVariable";
import { customizeAvailableStore } from "../../Stores/SelectCharacterSceneStore";
//todo: put this constants in a dedicated file //todo: put this constants in a dedicated file
export const SelectCharacterSceneName = "SelectCharacterScene"; export const SelectCharacterSceneName = "SelectCharacterScene";
@@ -78,6 +79,7 @@ export class SelectCharacterScene extends AbstractCharacterScene {
} }
create() { create() {
customizeAvailableStore.set(this.isCustomizationAvailable());
selectCharacterSceneVisibleStore.set(true); selectCharacterSceneVisibleStore.set(true);
this.events.addListener("wake", () => { this.events.addListener("wake", () => {
waScaleManager.saveZoom(); waScaleManager.saveZoom();
@@ -295,4 +297,13 @@ export class SelectCharacterScene extends AbstractCharacterScene {
//move position of user //move position of user
this.moveUser(); this.moveUser();
} }
private isCustomizationAvailable(): boolean {
for (const layer of PlayerTextures.LAYERS) {
if (Object.keys(layer).length > 0) {
return true;
}
}
return false;
}
} }
@@ -0,0 +1,3 @@
import { writable } from "svelte/store";
export const customizeAvailableStore = writable(false);