Skip to content

Commit

Permalink
Toggle area visibility, fix walls not showing
Browse files Browse the repository at this point in the history
  • Loading branch information
cabalex committed Mar 8, 2024
1 parent a890388 commit bd106a0
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 37 deletions.
64 changes: 33 additions & 31 deletions src/Map/Map.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import Panzoom, { type PanzoomObject } from '@panzoom/panzoom';
import { onDestroy, onMount } from 'svelte';
import { questAreaLookup, questLookup } from '../_lib/lookupTable';
import { currentTab, currentEm, session } from '../store';
import { currentTab, currentEm, session, showAreasOnMap } from '../store';
import { Em } from '../_lib/types/EnemySet';
import MapEm from './MapEm.svelte';
import Vector from '../_lib/Vector';
Expand Down Expand Up @@ -91,36 +91,38 @@
<MapEm em={em} set={set} cachedEm={cachedEm} on:click={() => { $currentTab = "enemySets"; $currentEm = em; panToEm(em) }} />
{/each}
{/each}
<svg class="areas" height="4400" width="4400" xmlns="http://www.w3.org/2000/svg">
{#each ($session?.questData.areas || []) as areaGroup}
{#each areaGroup.groups as area}
{#if area.type === 1}
<polygon
points={area.points.map(coord => `${toMap(-coord.z)},${toMap(coord.x)}`).join(" ")}
style={`fill: hsl(${areaGroup.index * 10}, 50%, 50%); opacity: 0.4`}
/>
{:else}
<circle
cx={toMap(-area.center.z)}
cy={toMap(area.center.x)}
r={area.radius * 2}
style="fill: hsl({areaGroup.index * 10}, 50%, 50%); opacity: 0.4"
/>
{/if}
<text
x={toMap(-area.center.z)}
y={toMap(area.center.x)}
fill="hsl({areaGroup.index * 10}, 50%, 10%)"
font-size="10"
width="{area.type === 1 ? (area.points[0].z - area.points[1].z) * 2 : area.radius * 4}px"
text-anchor="middle"
alignment-baseline="middle"
>
{areaGroup.name}
</text>
{/each}
{/each}
</svg>
<svg class="areas" height="4400" width="4400" xmlns="http://www.w3.org/2000/svg">
{#if $showAreasOnMap}
{#each ($session?.questData.areas || []) as areaGroup}
{#each areaGroup.groups as area}
{#if area.type === 1}
<polygon
points={area.points.map(coord => `${toMap(-coord.z)},${toMap(coord.x)}`).join(" ")}
style={`fill: hsl(${areaGroup.index * 10}, 50%, 50%); opacity: 0.4`}
/>
{:else}
<circle
cx={toMap(-area.center.z)}
cy={toMap(area.center.x)}
r={area.radius * 2}
style="fill: hsl({areaGroup.index * 10}, 50%, 50%); opacity: 0.4"
/>
{/if}
<text
x={toMap(-area.center.z)}
y={toMap(area.center.x)}
fill="hsl({areaGroup.index * 10}, 50%, 10%)"
font-size="10"
width="{area.type === 1 ? (area.points[0].z - area.points[1].z) * 2 : area.radius * 4}px"
text-anchor="middle"
alignment-baseline="middle"
>
{areaGroup.name}
</text>
{/each}
{/each}
{/if}
</svg>
</div>
</div>

Expand Down
5 changes: 2 additions & 3 deletions src/Map/MapEm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@
on:click={(e) => {dispatch("click", em); e.stopPropagation()}}
style={`left: ${x}px; top: ${y}px; transform: rotate(${em.Rotation + Math.PI / 2}rad); background-color: hsl(${set.number * 10}, 50%, 60%)`}
>
{#if (questLookup(em.Id.toString(16), true) || "").startsWith("bga00") ||
(questLookup(em.Id.toString(16), true) || "").startsWith("bga03")}
<div class="wall" style={`width: ${em.SetType * 2}px`} />
{#if (questLookup(em.Id.toString(16)) || "").startsWith("No")}
<div class="wall" style={`width: ${(em.SetType || em.ExSetTypeA || em.ExSetTypeB) * 2}px`} />
{/if}
</div>
{#if em.secondaryObjectEnabled}
Expand Down
2 changes: 2 additions & 0 deletions src/SideBar/tabs/Areas/Areas.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import NumberInput from "../../../assets/NumberInput.svelte";
import TextInput from "../../../assets/TextInput.svelte";
import { AreaGroup, Area } from "../../../_lib/types/QuestData";
import { showAreasOnMap } from "../../../store";
export let session: Quest;
Expand All @@ -35,6 +36,7 @@
<span>Regions on the map that can detect players.</span>
</div>
</header>
<BoolInput label="Show areas on the map" bind:value={$showAreasOnMap} />
{#each session.questData.areas as area, i}
<hr />
<h2 class="sectionHeader" translate="yes">{area.name}</h2>
Expand Down
9 changes: 7 additions & 2 deletions src/SideBar/tabs/EnemySets/EmPopup.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@
label="SetNo"
bind:value={em.SetNo}
/>
<NumberInput
label="SetType"
description="Do not touch if this entity has a TalkScript!"
bind:value={em.SetType}
/>
<NumberInput
label="PathNo"
bind:value={em.PathNo}
Expand Down Expand Up @@ -235,12 +240,12 @@
{:else if tab === "extras"}
<NumberInput
label="ExSetTypeA"
description={"0x" + em.ExSetTypeA.toString(16)}
description={"Width on bga050. 0x" + em.ExSetTypeA.toString(16)}
bind:value={em.ExSetTypeA}
/>
<NumberInput
label="ExSetTypeB"
description={"0x" + em.ExSetTypeB.toString(16)}
description={"Height on bga050. 0x" + em.ExSetTypeB.toString(16)}
bind:value={em.ExSetTypeB}
/>
<NumberInput
Expand Down
2 changes: 1 addition & 1 deletion src/_lib/lookupTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ const questTable = {
"q2690": "File 06 Hermit Training",
"q26b0": "File 06 Hermit Aberration",
"q26b5": "File 06 Rooftop Rescue",
"q26c5": "File 06 Dpuglas Chase Sequence",
"q26c5": "File 06 Douglas Chase Sequence",
"q26d5": "File 06 Chimera Takedown",
"q26e5": "File 06 Chimera Takedown",
"q26f0": "File 06 Neuron in Need",
Expand Down
1 change: 1 addition & 0 deletions src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const sessions: Writable<Quest[]> = writable([]);
export const session: Writable<Quest|null> = writable(null);

export const currentTab: Writable<null|string> = writable(null);
export const showAreasOnMap: Writable<boolean> = writable(true);

export const questsCache: Writable<any> = writable(null);
export const textCache: Writable<any> = writable(null);
Expand Down

0 comments on commit bd106a0

Please sign in to comment.