aboutsummaryrefslogtreecommitdiff
path: root/internal/admin/static/map.js
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-07-07 23:28:29 -0400
committerhistoria <[not public]>2026-07-07 23:28:29 -0400
commit59a844137138b328cf415d29b8a1bc40c6469a31 (patch)
tree13eaadd7fac06b3fd516ebba69c7a001630957fa /internal/admin/static/map.js
parent74803657d587b1f93b739c1ee25bb8d62df95413 (diff)
downloadthehouseoficarus-59a844137138b328cf415d29b8a1bc40c6469a31.tar.gz
feat: support up/down for insert/remove in admin gui
Diffstat (limited to 'internal/admin/static/map.js')
-rw-r--r--internal/admin/static/map.js33
1 files changed, 21 insertions, 12 deletions
diff --git a/internal/admin/static/map.js b/internal/admin/static/map.js
index 7cd4430..3507e2d 100644
--- a/internal/admin/static/map.js
+++ b/internal/admin/static/map.js
@@ -20,7 +20,8 @@ var gridDirs = [
var oppositeDir = {
north:'south', south:'north', east:'west', west:'east',
northeast:'southwest', northwest:'southeast',
- southeast:'northwest', southwest:'northeast'
+ southeast:'northwest', southwest:'northeast',
+ up:'down', down:'up'
};
var saveTimer = null;
var upTarget = {}, downTarget = {};
@@ -2215,13 +2216,13 @@ function showRoomContextMenu(x, y, id) {
}
// buildSubmenuItem constructs a parent menu row ("Insert Room"/"Remove Room")
-// that carries a nested submenu of the room's horizontal exits. The submenu is
+// that carries a nested submenu of the room's exits. The submenu is
// revealed by both hover (Windows-style: mouseenter with a small dismiss delay
// on mouseleave) and click (keyboard/mobile accessibility), mirroring how
// Windows cascading menus behave. closeAll closes the whole context menu;
// overlay carries the shared hide-timer slot.
function buildSubmenuItem(label, id, mode, closeAll, overlay, menu) {
- var dirs = roomHorizontalDirs(id);
+ var dirs = roomDirs(id);
var empty = dirs.length === 0;
var item = document.createElement('div');
@@ -2239,8 +2240,8 @@ function buildSubmenuItem(label, id, mode, closeAll, overlay, menu) {
// Still surface the "no exits" reason on click so it's discoverable.
btn.onclick = function() {
notify(mode === 'insert'
- ? 'No horizontal exits to insert into from #' + id
- : 'No horizontal exits to remove from #' + id, 'error');
+ ? 'No exits to insert into from #' + id
+ : 'No exits to remove from #' + id, 'error');
};
return item;
}
@@ -2312,31 +2313,39 @@ function buildSubmenuItem(label, id, mode, closeAll, overlay, menu) {
return item;
}
-// roomHorizontalDirs returns the room's outward horizontal exits on the current
-// z-level, in gridDirs order, derived from mapData.links. Empty when the room
-// has no horizontal exits to insert into / remove from.
-function roomHorizontalDirs(id) {
+// roomDirs returns the room's outward exits (horizontal + up/down) derived from
+// mapData.links and mapData.{upLinks,downLinks}. Horizontal exits are ordered by
+// gridDirs; up/down appear last. Empty when the room has no exits.
+function roomDirs(id) {
if (!mapData || !mapData.links) return [];
var horizontal = {};
gridDirs.forEach(function(d) { horizontal[d.dir] = true; });
var seen = {};
- var dirs = [];
+
mapData.links.forEach(function(l) {
if (l.from === id && horizontal[l.dir] && !seen[l.dir]) {
seen[l.dir] = true;
- dirs.push(l.dir);
} else if (l.to === id && l.bidirectional && horizontal[l.dir]) {
var opp = oppositeDir[l.dir];
if (opp && !seen[opp]) {
seen[opp] = true;
- dirs.push(opp);
}
}
});
+
+ if (mapData.upLinks) mapData.upLinks.forEach(function(l) {
+ if (l.from === id) seen['up'] = true;
+ });
+ if (mapData.downLinks) mapData.downLinks.forEach(function(l) {
+ if (l.from === id) seen['down'] = true;
+ });
+
var ordered = [];
gridDirs.forEach(function(d) {
if (seen[d.dir]) ordered.push(d.dir);
});
+ if (seen['up']) ordered.push('up');
+ if (seen['down']) ordered.push('down');
return ordered;
}