workadventure/front/src/Components/Woka/Woka.svelte

46 lines
1.2 KiB
Svelte
Raw Normal View History

2021-11-30 19:10:35 +01:00
<script lang="typescript">
2021-12-07 14:01:30 +01:00
import { onDestroy } from "svelte";
2021-11-30 19:10:35 +01:00
2021-12-07 14:01:30 +01:00
import { gameManager } from "../../Phaser/Game/GameManager";
2021-11-30 19:10:35 +01:00
export let userId: number;
2021-12-01 11:14:54 +01:00
export let placeholderSrc: string;
2021-12-07 14:56:42 +01:00
export let width: string = "62px";
export let height: string = "62px";
2021-11-30 19:10:35 +01:00
const gameScene = gameManager.getCurrentGameScene();
let playerWokaPictureStore;
if (userId === -1) {
playerWokaPictureStore = gameScene.CurrentPlayer.pictureStore;
} else {
playerWokaPictureStore = gameScene.MapPlayersByKey.getNestedStore(userId, (item) => item.pictureStore);
}
2021-11-30 19:10:35 +01:00
2021-12-01 11:14:54 +01:00
let src = placeholderSrc;
const unsubscribe = playerWokaPictureStore.subscribe((source) => {
2021-12-04 16:29:28 +01:00
src = source ?? placeholderSrc;
2021-11-30 19:10:35 +01:00
});
onDestroy(unsubscribe);
</script>
2021-12-07 14:56:42 +01:00
<img {src} alt="" class="nes-pointer" style="--theme-width: {width}; --theme-height: {height}" />
2021-11-30 19:10:35 +01:00
<style>
img {
2021-12-07 14:56:42 +01:00
display: inline-block;
2021-11-30 19:10:35 +01:00
pointer-events: auto;
2021-12-07 14:56:42 +01:00
width: var(--theme-width);
height: var(--theme-height);
2021-12-01 10:26:09 +01:00
margin: 0;
padding: 0;
2021-12-07 15:21:54 +01:00
position: static;
left: 0;
bottom: 0;
right: 0;
top: 0;
2021-11-30 19:10:35 +01:00
image-rendering: pixelated;
}
2021-12-07 14:01:30 +01:00
</style>