Add map support #10
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Can you make on dragonroll, on the sidebar, add a button that also lists maps? For creating a map, you should be able to upload a photo, set its grid size, offset and scale. When a map is selected from the sidebar, you should be able to view it, pan by dragging the mouse and zoom in and out with the mouse wheel.
Now let me write the backend pieces.
Now the sidebar:
Implementation complete. Here's what I did for Syndria98/dragonroll#10 — Add map support.
Backend
backend/src/models/Map.js(new) —name*,image(filename insrc/uploads, served at/api/public/<file>),gridSize(cell size in image px, default 50),offsetX/offsetY(grid origin in image px, default 0),scale(distance one cell stands for, default 5),campaign*,date.backend/src/routes/map.js(new) — same envelope + duplicateduserOwnsCampaignstyle asactor.js/item.js:GET /api/map/list?campaign=→{status:'ok',maps}POST /api/map/create— multipart (imagefield) or JSON, grid values parsed with atoNumber(value, fallback)helper (multipart fields arrive as strings)POST /api/map/update— partial, ownership checked; animagefile replaces the photo, JSON-only bodies keep itPOST /api/map/delete— ownership checkedbackend/src/index.js— mounted/api/mapafter the JWT guard (and dropped the now-real// app.use('/maps', …)line from the commented block).Frontend
ContentSidebar.vue— new map button (/icons/iconoir/regular/map.svg) +mapssection that lists maps (name, grid summary, hint when no image). Click / Enter opens the viewer; right-click gives Edit / Delete. The existing actor/item entry plumbing was generalised intoentryEntityType()+ anentryListslookup instead ofentityType === 'actor' ? actors : itemsternaries, so all three entity types share one code path.CreateMapWindow.vue(new, windowcreate_map) — name, photo picker with preview, grid size, offset X/Y and scale. Creates and edits (passentry); postsFormData, then emitscampaign-entry-created/campaign-entry-updatedwithentityType: 'map'so the sidebar and any open viewer update.MapViewerWindow.vue(new, windowmap_viewer) — image at natural size in a transformed layer: drag to pan (pointer events + capture), mouse wheel to zoom towards the cursor, plus zoom in/out buttons, zoom %, fit-to-window, grid toggle and an edit shortcut. The grid overlay is drawn in screen space fromgridSize/offsetX/offsetY(lines stay 1px at any zoom, themed withvar(--color-link)), and it re-fits when a new photo lands.WindowDefinitions.js— registeredcreate_mapandmap_viewer.campaigns.json(sections.maps,states.empty-maps, amapblock) andwindows.json(create-map,map-viewer) for en / es / ca; verified everycampaigns.*/windows.*key used by the new and touched components resolves in all three locales.AGENTS.md— documented theMapmodel, the map routes and the data-model entry.Verification
npm --prefix frontend run build→ succeeds (both new windows emitted as chunks; only the repo's pre-existing warnings)./tmp/drtest/verify-maps.js, since the repo has no test harness and adding one would mean new dev dependencies). All 14 checks passed: create with photo + grid values, defaults when grid fields are omitted,errors.missing-datawithout a campaign, list ordering, JSON update keeping the image, multipart update replacing the photo and keeping the grid,/api/public/<file>serving the upload, delete, plus cross-user list/edit/delete rejected asunauthorizedand anonymous requests getting 401.screen = pan + zoom × imagePoint, with wheel zoom keeping the point under the cursor fixed.Nothing committed or pushed, as requested.
Implementation is ready for review: #11