diff --git a/inspector/region.html b/inspector/region.html
index f1ddd391..c85e1148 100644
--- a/inspector/region.html
+++ b/inspector/region.html
@@ -21,7 +21,7 @@
import { signal, effect } from "@preact/signals"
import { html, errors } from "./view.js"
import { useHabitatJson, errorBucket } from "./data.js"
- import { regionView, regionNav, objectDetails, regionSearch } from "./region.js"
+ import { regionView, directionNav, objectNav, objectDetails, regionSearch } from "./region.js"
const q = (k) => (new URLSearchParams(window.location.search)).get(k)
const filename = signal(q("f") ?? "db/new_Downtown/Downtown_4d.json")
@@ -45,11 +45,18 @@
const regionPage = (_) => html`
Region - <${regionName} filename=${filename.value}/>
- <${regionView} filename=${filename.value}/>
-
-
Neighboring regions
- <${regionNav} filename=${filename.value}/>
-
+
+
+ | <${directionNav} filename=${filename.value} position="top"/> | |
+
+ <${directionNav} filename=${filename.value} position="left"/> |
+ <${regionView} filename=${filename.value}/> |
+ <${directionNav} filename=${filename.value} position="right"/> |
+
+ | <${directionNav} filename=${filename.value} position="bottom"/> | |
+ <${objectNav} filename=${filename.value}/> |
+
+
<${regionSearch} label="Region search" onSelected=${(item) => {
errorBucket.value = []
diff --git a/inspector/region.js b/inspector/region.js
index 1e14f1b1..47d814bf 100644
--- a/inspector/region.js
+++ b/inspector/region.js
@@ -357,41 +357,63 @@ export const regionImageView = ({ filename }) => {
}
}
-export const regionNav = ({ filename }) => {
+const positionToCompassOffset = {
+ top: 0,
+ right: 1,
+ bottom: 2,
+ left: 3
+}
+
+export const locationLink = ({ refId, children }) => {
+ if (refId && refId != '') {
+ let name = refId
+ let href = null
+ const ctx = contextMap()[refId]
+ if (ctx) {
+ if (ctx.name && ctx.name.trim() != '') {
+ name = ctx.name
+ }
+ // todo: customizable?
+ href = `region.html?f=${ctx.filename}`
+ }
+ return html`
+ <${Scale.Provider} value="0.5">
+
+ ${children}: ${name}
+ ${ctx ? html`<${regionImageView} filename=${ctx.filename}/>` : null}
+
+ />`
+ } else {
+ return null
+ }
+}
+
+export const directionNav = ({ filename, position }) => {
const objects = useHabitatJson(filename)
const context = objects.find(obj => obj.type == "context")
if (!context || !context.mods[0].neighbors) {
return null
}
const mod = context.mods[0]
+
+ // orientation:
+ // 0 = top is west, 1 = top is north, 2 = top is east, 3 = top is south
+ // neighbour list: North, East, South, West
+ const ineighbor = (mod.orientation + positionToCompassOffset[position] + 3) & 0x03
const compasses = ["North", "East", "South", "West"]
- const directions = compasses.flatMap((compass, ineighbor) => {
- const ref = mod.neighbors[ineighbor]
- if (ref && ref != '') {
- let name = ref
- let href = null
- const ctx = contextMap()[ref]
- if (ctx) {
- if (ctx.name && ctx.name.trim() != '') {
- name = ctx.name
- }
- // todo: customizable?
- href = `region.html?f=${ctx.filename}`
- }
- return [html`
-
-
- <${direction} compass=${compass} orientation=${mod.orientation}/>:
-
${name}
-
- ${ctx ? html`<${Scale.Provider} value="1"><${regionView} filename=${ctx.filename}/>/>` : null}
- `]
- }
- return []
- })
- return html`
`
+ const ref = mod.neighbors[ineighbor]
+ return html`<${locationLink} refId=${ref}>
${compasses[ineighbor]}/>`
}
+export const objectNav = ({ filename }) =>
+ useHabitatJson(filename)
+ .filter(o => o.type == "item" && o.mods[0].connection)
+ .sort((o1, o2) => o1.mods[0].x - o2.mods[0].x)
+ .map(o => html`
+ <${locationLink} refId=${o.mods[0].connection}>
+ <${itemView} viewer=${standaloneItemView} object=${o}/>
+ />`)
+
const propFilter = (key, value) => {
if (key != "bitmap" && key != "data" && key != "canvas" && key != "texture" &&
!(key == "pattern" && typeof(value) === "object")) {