mirror of
https://codeberg.org/demostf/frontend.git
synced 2026-06-03 18:24:12 +02:00
viewer fixes
This commit is contained in:
parent
5910b2f35a
commit
e94f0474ef
9 changed files with 125 additions and 100 deletions
|
|
@ -2,7 +2,7 @@ import {Player as PlayerDot} from './Render/Player';
|
|||
import {Building as BuildingDot} from './Render/Building';
|
||||
import {findMapAlias} from './MapBoundries';
|
||||
import {PlayerState, Header, WorldBoundaries, BuildingState} from "./Data/Parser";
|
||||
import {splitProps} from "solid-js";
|
||||
import {createEffect, Show} from "solid-js";
|
||||
|
||||
export interface MapRenderProps {
|
||||
header: Header;
|
||||
|
|
@ -18,29 +18,22 @@ export interface MapRenderProps {
|
|||
|
||||
export function MapRender(props: MapRenderProps) {
|
||||
const mapAlias = findMapAlias(props.header.map);
|
||||
const image = `images/leveloverview/dist/${mapAlias}.webp`;
|
||||
const image = `/images/leveloverview/dist/${mapAlias}.webp`;
|
||||
const background = `url(${image})`;
|
||||
|
||||
const playerDots = () => props.players
|
||||
.filter((player: PlayerState) => player.health)
|
||||
.map((player: PlayerState) => {
|
||||
return <PlayerDot player={player} mapBoundary={props.world}
|
||||
targetSize={props.size} scale={props.scale} />
|
||||
});
|
||||
|
||||
const buildingDots = () => props.buildings
|
||||
.filter((building: PlayerState) => building.position.x)
|
||||
.map((building: PlayerState) => {
|
||||
return <BuildingDot building={building}
|
||||
mapBoundary={props.world}
|
||||
targetSize={props.size} scale={props.scale}/>
|
||||
});
|
||||
|
||||
return (
|
||||
<svg class="map-background" width={props.size.width} height={props.size.height}
|
||||
style={{"background-image": background}}>
|
||||
{playerDots()}
|
||||
{buildingDots()}
|
||||
<For each={props.players}>{(player) =>
|
||||
<Show when={player.health}>
|
||||
<PlayerDot player={player} mapBoundary={props.world} targetSize={props.size} scale={props.scale} />
|
||||
</Show>
|
||||
}</For>
|
||||
<For each={props.buildings}>{(building) =>
|
||||
<Show when={building.position.x}>
|
||||
<BuildingDot building={building} mapBoundary={props.world} targetSize={props.size} scale={props.scale}/>
|
||||
</Show>
|
||||
}</For>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue