From 59a844137138b328cf415d29b8a1bc40c6469a31 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Tue, 7 Jul 2026 23:28:29 -0400 Subject: feat: support up/down for insert/remove in admin gui --- internal/admin/static/map.js | 33 +++++++++++++++++++++------------ internal/admin/static/objecteditor.js | 4 ++-- 2 files changed, 23 insertions(+), 14 deletions(-) (limited to 'internal') 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; } diff --git a/internal/admin/static/objecteditor.js b/internal/admin/static/objecteditor.js index d4cca21..2046f2e 100644 --- a/internal/admin/static/objecteditor.js +++ b/internal/admin/static/objecteditor.js @@ -73,8 +73,8 @@ var SECTIONS = [ ['respawn_ticks', 'Respawn Ticks', 'number', '50', 'narrow'], ], subtables: [ - {label:'Levels', key:'levels', fields:[ - ['message', 'Message', 'text'], ['degrade_message', 'Degrade Message', 'text'] + {label:'Levels of Decay', key:'levels', fields:[ + ['message', 'Look Message', 'text'], ['degrade_message', 'Degrade Message', 'text'] ]} ] }, -- cgit v1.2.3