Per-map grid config (gridEnabled, easting/northing origin, spacing, label digits, over-lines) rides on the Maps collection and surfaces via /api/map-features. Pure math in src/lib/map/grid.ts mirrors CfgWorlds Grid (floor truncation, mod-10^digits wrapping, nested levels). GridLayer renders hairlines + edge labels on the world map and mission planning maps, and armaGridRef now delegates to gridRef. Migration 20261005_001212_add_map_grid_config.
312 lines
8.9 KiB
TypeScript
312 lines
8.9 KiB
TypeScript
import { CollectionConfig } from "payload";
|
|
import { requirePermission } from "@/utils/access-control/hasPermission";
|
|
|
|
export const Maps: CollectionConfig = {
|
|
slug: "maps",
|
|
admin: {
|
|
group: "World",
|
|
useAsTitle: "name",
|
|
},
|
|
access: {
|
|
create: requirePermission("maps:create"),
|
|
update: requirePermission("maps:update"),
|
|
delete: requirePermission("maps:delete"),
|
|
read: requirePermission("maps:read"),
|
|
},
|
|
fields: [
|
|
{
|
|
name: "name",
|
|
type: "text",
|
|
required: true,
|
|
unique: true,
|
|
},
|
|
{
|
|
name: "isActive",
|
|
type: "checkbox",
|
|
label: "Active",
|
|
defaultValue: true,
|
|
admin: {
|
|
description: "Inactive maps are hidden from the map page and cannot receive placements.",
|
|
},
|
|
},
|
|
{
|
|
name: "worldMap",
|
|
type: "checkbox",
|
|
label: "World Map Entry",
|
|
defaultValue: false,
|
|
admin: {
|
|
description:
|
|
"Show on the World Map screen. Leave off for mission-only maps (e.g. side op maps without imagery).",
|
|
},
|
|
},
|
|
{
|
|
name: "campaign",
|
|
type: "relationship",
|
|
relationTo: "campaigns",
|
|
label: "Campaign",
|
|
admin: {
|
|
description:
|
|
"Campaign this map belongs to. Maps tied to custom (side) campaigns are excluded from the World Map screen even when flagged as world map entries.",
|
|
},
|
|
},
|
|
{
|
|
name: "description",
|
|
type: "textarea",
|
|
label: "Description",
|
|
admin: {
|
|
description: "Optional map blurb shown on the World Map picker cards.",
|
|
},
|
|
},
|
|
{
|
|
name: "weather",
|
|
type: "text",
|
|
label: "General Weather",
|
|
admin: {
|
|
description:
|
|
"Optional freeform weather condition for intel display (e.g. Clear, Monsoon, Ashfall).",
|
|
},
|
|
},
|
|
{
|
|
name: "latitude",
|
|
type: "number",
|
|
label: "Real-World Latitude",
|
|
admin: {
|
|
description: "Optional real-world reference coordinate (degrees).",
|
|
},
|
|
},
|
|
{
|
|
name: "longitude",
|
|
type: "number",
|
|
label: "Real-World Longitude",
|
|
admin: {
|
|
description: "Optional real-world reference coordinate (degrees).",
|
|
},
|
|
},
|
|
{
|
|
name: "easeOfAccess",
|
|
type: "select",
|
|
label: "Ease of Access",
|
|
options: [
|
|
{ label: "Easy", value: "easy" },
|
|
{ label: "Moderate", value: "moderate" },
|
|
{ label: "Difficult", value: "difficult" },
|
|
],
|
|
admin: {
|
|
description: "Optional: how hard the area is to reach for intel display.",
|
|
},
|
|
},
|
|
{
|
|
name: "factionControl",
|
|
type: "relationship",
|
|
relationTo: "factions",
|
|
label: "Faction Control",
|
|
admin: {
|
|
description: "Optional faction associated with or controlling this map.",
|
|
},
|
|
},
|
|
{
|
|
label: "World Size (meters)",
|
|
type: "group",
|
|
fields: [
|
|
{
|
|
name: "worldSizeWidth",
|
|
type: "number",
|
|
label: "Width (m)",
|
|
required: true,
|
|
min: 1,
|
|
defaultValue: 8192,
|
|
admin: {
|
|
description: "Map width in real meters (e.g. Altis is 8192).",
|
|
},
|
|
},
|
|
{
|
|
name: "worldSizeHeight",
|
|
type: "number",
|
|
label: "Height (m)",
|
|
required: true,
|
|
min: 1,
|
|
defaultValue: 8192,
|
|
admin: {
|
|
description: "Map height in real meters (e.g. Altis is 8192).",
|
|
},
|
|
},
|
|
],
|
|
},
|
|
{
|
|
label: "Basemap",
|
|
type: "group",
|
|
fields: [
|
|
{
|
|
name: "basemapMode",
|
|
type: "select",
|
|
required: true,
|
|
defaultValue: "image",
|
|
options: [
|
|
{ label: "Image Upload", value: "image" },
|
|
{ label: "XYZ Tile Layer", value: "tiles" },
|
|
],
|
|
admin: {
|
|
description:
|
|
"Image: a single uploaded map image stretched over the world bounds. Tiles: an external XYZ tile server.",
|
|
},
|
|
},
|
|
{
|
|
name: "basemapImage",
|
|
type: "upload",
|
|
relationTo: "media",
|
|
label: "Basemap Image",
|
|
admin: {
|
|
condition: (_data, siblingData) => siblingData?.basemapMode !== "tiles",
|
|
description: "Top-down map image. Rendered stretched across the full world size.",
|
|
},
|
|
},
|
|
{
|
|
name: "tileUrlTemplate",
|
|
type: "text",
|
|
label: "Tile URL Template",
|
|
admin: {
|
|
condition: (_data, siblingData) => siblingData?.basemapMode === "tiles",
|
|
description: "XYZ template, e.g. https://tiles.example.com/{z}/{x}/{y}.png",
|
|
},
|
|
},
|
|
{
|
|
name: "minZoom",
|
|
type: "number",
|
|
defaultValue: 0,
|
|
},
|
|
{
|
|
name: "maxZoom",
|
|
type: "number",
|
|
defaultValue: 12,
|
|
},
|
|
],
|
|
},
|
|
{
|
|
label: "Default View",
|
|
type: "group",
|
|
fields: [
|
|
{
|
|
name: "defaultCenterX",
|
|
type: "number",
|
|
label: "Center X (m)",
|
|
admin: {
|
|
description: "Defaults to half the world width when empty.",
|
|
},
|
|
},
|
|
{
|
|
name: "defaultCenterY",
|
|
type: "number",
|
|
label: "Center Y (m)",
|
|
admin: {
|
|
description: "Defaults to half the world height when empty.",
|
|
},
|
|
},
|
|
{
|
|
name: "defaultZoom",
|
|
type: "number",
|
|
defaultValue: 2,
|
|
},
|
|
],
|
|
},
|
|
{
|
|
label: "Coordinate Grid",
|
|
type: "group",
|
|
admin: {
|
|
description:
|
|
"Arma-style coordinate grid overlay + grid references. Set up to match the terrain's in-game grid (CfgWorlds Grid class).",
|
|
},
|
|
fields: [
|
|
{
|
|
name: "gridEnabled",
|
|
type: "checkbox",
|
|
label: "Enable Grid",
|
|
defaultValue: false,
|
|
admin: {
|
|
description:
|
|
"Show a coordinate grid on the world map and mission planning maps, and use it for grid reference readouts.",
|
|
},
|
|
},
|
|
{
|
|
name: "gridOriginEasting",
|
|
type: "number",
|
|
label: "Origin Easting (m)",
|
|
defaultValue: 0,
|
|
admin: {
|
|
condition: (_data, siblingData) => siblingData?.gridEnabled === true,
|
|
description:
|
|
"Meters from the west edge (in-game X) to the grid's zero line. Vanilla terrains use 0 (zero line on the west edge).",
|
|
},
|
|
},
|
|
{
|
|
name: "gridOriginNorthing",
|
|
type: "number",
|
|
label: "Origin Northing (m)",
|
|
defaultValue: 0,
|
|
admin: {
|
|
condition: (_data, siblingData) => siblingData?.gridEnabled === true,
|
|
description:
|
|
"Meters from the south edge (in-game Y) to the grid's zero line. Vanilla terrains use 0 (zero line on the south edge).",
|
|
},
|
|
},
|
|
{
|
|
name: "gridStartEasting",
|
|
type: "number",
|
|
label: "Starting Easting Number",
|
|
defaultValue: 0,
|
|
admin: {
|
|
condition: (_data, siblingData) => siblingData?.gridEnabled === true,
|
|
description:
|
|
"Number shown on the first easting line (at the origin). Applies at the base spacing and finer subdivisions.",
|
|
},
|
|
},
|
|
{
|
|
name: "gridStartNorthing",
|
|
type: "number",
|
|
label: "Starting Northing Number",
|
|
defaultValue: 0,
|
|
admin: {
|
|
condition: (_data, siblingData) => siblingData?.gridEnabled === true,
|
|
description:
|
|
"Number shown on the first northing line (at the origin). Applies at the base spacing and finer subdivisions.",
|
|
},
|
|
},
|
|
{
|
|
name: "gridSpacingMeters",
|
|
type: "number",
|
|
label: "Cell Spacing (m)",
|
|
defaultValue: 1000,
|
|
min: 1,
|
|
admin: {
|
|
condition: (_data, siblingData) => siblingData?.gridEnabled === true,
|
|
description:
|
|
"Base grid cell size in meters. The map subdivides 10x automatically as you zoom in, like the in-game map.",
|
|
},
|
|
},
|
|
{
|
|
name: "gridLabelDigits",
|
|
type: "number",
|
|
label: "Label Digits",
|
|
defaultValue: 2,
|
|
min: 1,
|
|
max: 6,
|
|
admin: {
|
|
condition: (_data, siblingData) => siblingData?.gridEnabled === true,
|
|
description:
|
|
"Digits shown per axis at the base spacing (Arma shows 2 at 1 km, 3 at 100 m). Numbers wrap at the digit width.",
|
|
},
|
|
},
|
|
{
|
|
name: "gridNumbersOverLines",
|
|
type: "checkbox",
|
|
label: "Numbers Over Lines",
|
|
defaultValue: false,
|
|
admin: {
|
|
condition: (_data, siblingData) => siblingData?.gridEnabled === true,
|
|
description:
|
|
"Draw labels on the grid lines instead of centered in the cells (Tanoa style).",
|
|
},
|
|
},
|
|
],
|
|
},
|
|
],
|
|
};
|