Merge pull request #1813 from thecodingmachine/fix-cowebsite
Fix mozaic layout
This commit is contained in:
commit
c34ee73448
@ -23,8 +23,9 @@
|
|||||||
{#each [...$streamableCollectionStore.values()] as peer (peer.uniqueId)}
|
{#each [...$streamableCollectionStore.values()] as peer (peer.uniqueId)}
|
||||||
<MediaBox
|
<MediaBox
|
||||||
streamable={peer}
|
streamable={peer}
|
||||||
|
mozaicSolo={$streamableCollectionStore.size === 1}
|
||||||
mozaicFullWidth={$streamableCollectionStore.size === 1 || $streamableCollectionStore.size === 2}
|
mozaicFullWidth={$streamableCollectionStore.size === 1 || $streamableCollectionStore.size === 2}
|
||||||
mozaicQuarter={$streamableCollectionStore.size === 3 || $streamableCollectionStore.size === 4}
|
mozaicQuarter={$streamableCollectionStore.size === 3 || $streamableCollectionStore.size >= 4}
|
||||||
/>
|
/>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
export let streamable: Streamable;
|
export let streamable: Streamable;
|
||||||
export let isHightlighted = false;
|
export let isHightlighted = false;
|
||||||
export let isClickable = false;
|
export let isClickable = false;
|
||||||
|
export let mozaicSolo = false;
|
||||||
export let mozaicFullWidth = false;
|
export let mozaicFullWidth = false;
|
||||||
export let mozaicQuarter = false;
|
export let mozaicQuarter = false;
|
||||||
</script>
|
</script>
|
||||||
@ -16,6 +17,7 @@
|
|||||||
<div
|
<div
|
||||||
class="media-container nes-container is-rounded {isHightlighted ? 'hightlighted' : ''}"
|
class="media-container nes-container is-rounded {isHightlighted ? 'hightlighted' : ''}"
|
||||||
class:clickable={isClickable}
|
class:clickable={isClickable}
|
||||||
|
class:mozaic-solo={mozaicSolo}
|
||||||
class:mozaic-full-width={mozaicFullWidth}
|
class:mozaic-full-width={mozaicFullWidth}
|
||||||
class:mozaic-quarter={mozaicQuarter}
|
class:mozaic-quarter={mozaicQuarter}
|
||||||
>
|
>
|
||||||
@ -66,6 +68,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.mozaic-solo {
|
||||||
|
max-height: inherit !important;
|
||||||
|
width: 90% !important;
|
||||||
|
}
|
||||||
|
|
||||||
&.mozaic-full-width {
|
&.mozaic-full-width {
|
||||||
width: 95%;
|
width: 95%;
|
||||||
max-width: 95%;
|
max-width: 95%;
|
||||||
@ -73,6 +80,7 @@
|
|||||||
margin-right: 3%;
|
margin-right: 3%;
|
||||||
margin-top: auto;
|
margin-top: auto;
|
||||||
margin-bottom: auto;
|
margin-bottom: auto;
|
||||||
|
max-height: 95%;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
margin-top: auto;
|
margin-top: auto;
|
||||||
@ -85,6 +93,7 @@
|
|||||||
max-width: 95%;
|
max-width: 95%;
|
||||||
margin-top: auto;
|
margin-top: auto;
|
||||||
margin-bottom: auto;
|
margin-bottom: auto;
|
||||||
|
max-height: 95%;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
margin-top: auto;
|
margin-top: auto;
|
||||||
|
@ -4,6 +4,7 @@ import { PlayerAnimationDirections, PlayerAnimationTypes } from "../Player/Anima
|
|||||||
import { TexturesHelper } from "../Helpers/TexturesHelper";
|
import { TexturesHelper } from "../Helpers/TexturesHelper";
|
||||||
import { Writable, writable } from "svelte/store";
|
import { Writable, writable } from "svelte/store";
|
||||||
import type { PictureStore } from "../../Stores/PictureStore";
|
import type { PictureStore } from "../../Stores/PictureStore";
|
||||||
|
import type CancelablePromise from "cancelable-promise";
|
||||||
|
|
||||||
export interface CompanionStatus {
|
export interface CompanionStatus {
|
||||||
x: number;
|
x: number;
|
||||||
@ -25,8 +26,9 @@ export class Companion extends Container {
|
|||||||
private direction: PlayerAnimationDirections;
|
private direction: PlayerAnimationDirections;
|
||||||
private animationType: PlayerAnimationTypes;
|
private animationType: PlayerAnimationTypes;
|
||||||
private readonly _pictureStore: Writable<string | undefined>;
|
private readonly _pictureStore: Writable<string | undefined>;
|
||||||
|
private texturePromise: CancelablePromise<string | void> | undefined;
|
||||||
|
|
||||||
constructor(scene: Phaser.Scene, x: number, y: number, name: string, texturePromise: Promise<string>) {
|
constructor(scene: Phaser.Scene, x: number, y: number, name: string, texturePromise: CancelablePromise<string>) {
|
||||||
super(scene, x + 14, y + 4);
|
super(scene, x + 14, y + 4);
|
||||||
|
|
||||||
this.sprites = new Map<string, Sprite>();
|
this.sprites = new Map<string, Sprite>();
|
||||||
@ -41,7 +43,7 @@ export class Companion extends Container {
|
|||||||
this.companionName = name;
|
this.companionName = name;
|
||||||
this._pictureStore = writable(undefined);
|
this._pictureStore = writable(undefined);
|
||||||
|
|
||||||
texturePromise
|
this.texturePromise = texturePromise
|
||||||
.then((resource) => {
|
.then((resource) => {
|
||||||
this.addResource(resource);
|
this.addResource(resource);
|
||||||
this.invisible = false;
|
this.invisible = false;
|
||||||
@ -234,6 +236,7 @@ export class Companion extends Container {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public destroy(): void {
|
public destroy(): void {
|
||||||
|
this.texturePromise?.cancel();
|
||||||
for (const sprite of this.sprites.values()) {
|
for (const sprite of this.sprites.values()) {
|
||||||
if (this.scene) {
|
if (this.scene) {
|
||||||
this.scene.sys.updateList.remove(sprite);
|
this.scene.sys.updateList.remove(sprite);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import LoaderPlugin = Phaser.Loader.LoaderPlugin;
|
import LoaderPlugin = Phaser.Loader.LoaderPlugin;
|
||||||
import { COMPANION_RESOURCES, CompanionResourceDescriptionInterface } from "./CompanionTextures";
|
import { COMPANION_RESOURCES, CompanionResourceDescriptionInterface } from "./CompanionTextures";
|
||||||
|
import CancelablePromise from "cancelable-promise";
|
||||||
|
|
||||||
export const getAllCompanionResources = (loader: LoaderPlugin): CompanionResourceDescriptionInterface[] => {
|
export const getAllCompanionResources = (loader: LoaderPlugin): CompanionResourceDescriptionInterface[] => {
|
||||||
COMPANION_RESOURCES.forEach((resource: CompanionResourceDescriptionInterface) => {
|
COMPANION_RESOURCES.forEach((resource: CompanionResourceDescriptionInterface) => {
|
||||||
@ -9,8 +10,12 @@ export const getAllCompanionResources = (loader: LoaderPlugin): CompanionResourc
|
|||||||
return COMPANION_RESOURCES;
|
return COMPANION_RESOURCES;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const lazyLoadCompanionResource = (loader: LoaderPlugin, name: string): Promise<string> => {
|
export const lazyLoadCompanionResource = (loader: LoaderPlugin, name: string): CancelablePromise<string> => {
|
||||||
return new Promise((resolve, reject) => {
|
return new CancelablePromise((resolve, reject, cancel) => {
|
||||||
|
cancel(() => {
|
||||||
|
return;
|
||||||
|
});
|
||||||
|
|
||||||
const resource = COMPANION_RESOURCES.find((item) => item.name === name);
|
const resource = COMPANION_RESOURCES.find((item) => item.name === name);
|
||||||
|
|
||||||
if (typeof resource === "undefined") {
|
if (typeof resource === "undefined") {
|
||||||
|
@ -59,7 +59,7 @@ export abstract class Character extends Container implements OutlineableInterfac
|
|||||||
frame: string | number,
|
frame: string | number,
|
||||||
isClickable: boolean,
|
isClickable: boolean,
|
||||||
companion: string | null,
|
companion: string | null,
|
||||||
companionTexturePromise?: Promise<string>
|
companionTexturePromise?: CancelablePromise<string>
|
||||||
) {
|
) {
|
||||||
super(scene, x, y /*, texture, frame*/);
|
super(scene, x, y /*, texture, frame*/);
|
||||||
this.scene = scene;
|
this.scene = scene;
|
||||||
@ -179,7 +179,7 @@ export abstract class Character extends Container implements OutlineableInterfac
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public addCompanion(name: string, texturePromise?: Promise<string>): void {
|
public addCompanion(name: string, texturePromise?: CancelablePromise<string>): void {
|
||||||
if (typeof texturePromise !== "undefined") {
|
if (typeof texturePromise !== "undefined") {
|
||||||
this.companion = new Companion(this.scene, this.x, this.y, name, texturePromise);
|
this.companion = new Companion(this.scene, this.x, this.y, name, texturePromise);
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ export class RemotePlayer extends Character implements ActivatableInterface {
|
|||||||
moving: boolean,
|
moving: boolean,
|
||||||
visitCardUrl: string | null,
|
visitCardUrl: string | null,
|
||||||
companion: string | null,
|
companion: string | null,
|
||||||
companionTexturePromise?: Promise<string>,
|
companionTexturePromise?: CancelablePromise<string>,
|
||||||
activationRadius?: number
|
activationRadius?: number
|
||||||
) {
|
) {
|
||||||
super(Scene, x, y, texturesPromise, name, direction, moving, 1, true, companion, companionTexturePromise);
|
super(Scene, x, y, texturesPromise, name, direction, moving, 1, true, companion, companionTexturePromise);
|
||||||
|
@ -25,7 +25,7 @@ export class Player extends Character {
|
|||||||
direction: PlayerAnimationDirections,
|
direction: PlayerAnimationDirections,
|
||||||
moving: boolean,
|
moving: boolean,
|
||||||
companion: string | null,
|
companion: string | null,
|
||||||
companionTexturePromise?: Promise<string>
|
companionTexturePromise?: CancelablePromise<string>
|
||||||
) {
|
) {
|
||||||
super(Scene, x, y, texturesPromise, name, direction, moving, 1, true, companion, companionTexturePromise);
|
super(Scene, x, y, texturesPromise, name, direction, moving, 1, true, companion, companionTexturePromise);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user