wxx

package module
v0.48.0-beta Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2026 License: Apache-2.0 Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

wxx

wxx is a Go package and command-line toolkit for reading, writing, inspecting, and modifying Worldographer files.

The name comes from .wxx, Worldographer’s default file extension.

This README marks planned work as planned. Anything under a (planned) heading or in a Planned list does not exist yet. Everything else describes the tree you are looking at.

What exists today:

  • A Go API for working with Worldographer data
  • Reading and writing .wxx files
  • Inspecting maps, and modifying them (resize or crop, copy)
  • A wxx export subcommand, plus a set of separate single-purpose binaries

Planned — not built yet:

  • Folding the separate binaries into wxx and retiring them
  • Turning wxx into a Lua script host using GopherLua
  • Interactive scripting against a loaded map
  • Validating maps (#20)

Worldographer versions

Worldographer has two file-format families. wxx reads and writes only the newer one:

  • 2025 — the Worldographer 2025 format (XML 1.1, with a schema version in the map element).
  • Classic — the original Worldographer / Hexographer 2 format (XML 1.0, no schema version in the file). No longer read or written.

Classic support was removed by #103 (see ADR 0005). Worldographer 2025 converts a classic map itself; convert it there, then use wxx on the result. wxx refuses a classic file before decoding any of it:

$ dist/local/info testdata/2017-1.77-1.0-columns-blank.wxx
info:	testdata/2017-1.77-1.0-columns-blank.wxx
	classic (Worldographer 1.x) map: convert it in Worldographer 2025 first
map: version "1.77": no release
Version identity

Every decoded map carries MetaData.Version, the two independent version axes a file states — and nothing else (ADR 0004). The verbatim on-disk strings are also kept in MetaData.Worldographer.*.

type Version_t struct {
	App    Dotted  // map/@version -- the build that wrote the file
	Schema *Dotted // map/@schema  -- nil when the file states none
}
release map/@release map/@version (App) map/@schema (Schema) wxx
Worldographer 2025 2025 2.06, 2.07, 2.08 1.06 reads and writes
classic (Hexographer 2) absent 1.73, 1.74, 1.77 absent refused on read (wxx.ErrClassicMap): "convert it in Worldographer 2025 first"

The application version selects the codec. Two application versions sharing a schema use one codec and differ only in the identity it writes. Each codec declares the application versions it accepts in its own apps.go, and the registry in xmlio/codecs.go is built from those declarations. Today they are 2.06, 2.07 and 2.08, all on the v1_06 codec.

Callers name an application version, never a schema and never a codec: xmlio.MarshalXML(m, "2.06"). The codecs themselves live under xmlio/internal/, where an external caller cannot reach them, and xmlio/internal/README.md explains why the package is named v1_06. Adding support for a further application version on schema 1.06 means an entry in xmlio/internal/v1_06/apps.go.

These on-disk values are not semantic versions: "2.06" through a semver round-trip comes back as "2.6", a different string and therefore a different file. They are modeled as Dotted, whose Raw is authoritative for output and whose components exist only to compare. wxx re-emits verbatim whatever it read; nothing is ever re-rendered from components. That — not any defect in the numbers — is why they are treated as opaque identifiers.

A version that does not fit the dotted grammar still decodes, and Raw still carries its bytes — but it has no components at all, reports Parsed() == false, and Compare/Less return an error rather than ordering it. ParseDotted and NewDotted are the two constructors that produce a comparable value. NewDotted takes components, so it renders "2.6" and cannot express the padded "2.06": use it to order versions, not to name one. See ADR 0004 Decision 1, as amended by #38.

An earlier claim that the 2025 numbers are buggy (1.x written where 2.x was intended) is retired: it does not survive the two-axis model, and #13 was closed as not planned for that reason. The claim read schema="1.06" as a mis-numbered version, which is the single-slot conflation ADR 0002 was built on and ADR 0004 superseded. Separate the axes and both numbers are correct: @version="2.06" is the application version and is 2.x; @schema="1.06" is the schema version, a different axis whose numbering starts at 1 by design.

See docs/adr/0003-version-axes.md for the two-axis model and docs/adr/0004-version-struct-and-release-registry.md for the identity and registry design. ADR 0002, which modeled identity as a single semver keyed by a family year, is superseded.

Go package

The wxx package can be imported into other Go applications that need to work with Worldographer files.

The root wxx package holds the data types (wxx.Map_t and friends); the file-level read/write helpers live in the xmlio package (xmlio imports wxx, so the helpers cannot live in wxx without an import cycle).

package main

import (
	"fmt"
	"log"

	"github.com/maloquacious/wxx/xmlio"
)

func main() {
	world, err := xmlio.ReadFile("world.wxx")
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(world)

	// Write it back out, naming the application version to write:
	if err := xmlio.WriteFile("world.wxx", world, "2.06"); err != nil {
		log.Fatal(err)
	}
}

The public API supports parsing, inspecting, modifying and writing Worldographer data without the command-line tool. Map_t.Validate() reports a map that cannot be written, and every encode runs it first, so a refused map writes nothing (#20).

Creating a map

xmlio.NewMap returns a new map of the size you ask for, with every hex Blank (#136):

m, err := xmlio.NewMap(115, 230) // 115 columns x 230 rows, COLUMNS, current version
m, err := xmlio.NewMap(13, 11,
	xmlio.WithHexOrientation("ROWS"), // "COLUMNS" (the default) or "ROWS"
	xmlio.WithApp("2.07"),            // the defaults 2.07 writes
)

The map carries what Worldographer writes for File > New World/Kingdom map with the suggested pixel sizes: flat projection, WORLD view level, the grid and numbering, the map key, the label and shape styles, and the eight map layers. Tiles[col][row] is filled, each tile's Coords, Column and Row set as the decoder sets them, and the terrain table holds Blank alone, at index 0. The result passes Validate(). Each dimension must be at least 2.

The defaults belong to an application version, so NewMap takes one. WithApp names it verbatim, as MarshalXML does, and an unregistered version is the same error (wxx.ErrUnsupportedMapVersion). Without WithApp, NewMap uses xmlio.CurrentApp(): the newest version the registry accepts (2.08 today). Registering a newer version moves it, so a tool can offer -app current and print CurrentApp() to say which version that means.

A 13 x 11 map from NewMap, written as a version, is that version's testdata/2025-<version>-13x11-941577-blank.wxx written the same way, with two differences. Worldographer fills <informations> with lore generated from its random seed, and NewMap leaves it empty. The show* flags are UI settings, saved as they stood at the time (the 2.06 fixture was saved with the grid hidden), and NewMap always shows the grid and its numbers.

Values wxx changes when it reads a file

There is one place where wxx deliberately changes a value as it reads a file, and the change is lossy:

  • A resource on an <extraTerrain> layer outside 0..100 is clamped: 0 below, 100 above (#124). Worldographer will not open a file holding 128 or more there, and it saves a tile's 101..127 as 100, so wxx reads the value the way the app is assumed to rather than refusing the map. The map then holds the clamped value, and writing it back writes the clamped value: the original is lost.

Every clamp is reported. Pass xmlio.WithDecoderDiagnostics and read DecoderDiagnostics.Clamped; each entry names the place in the file, the Map_t field, the old and new values, and why. A caller that never asks for diagnostics is not told, so a program that writes a decoded map back out should ask, and tell its user. The command-line tools that read a map (copy, info, import, merge, resize) print each one to stderr as a warning: ... changed on read: ... line.

wxx never writes an out-of-range resource. Validate() refuses any tile or <extraTerrain> resource outside 0..100 (#122, #124), and a tile resource outside 0..100 is refused on read rather than clamped.

The exact package path and API are still evolving, and the API has already made breaking changes at 0.x.

Command-line tool

Today, the wxx command has exactly one subcommand:

wxx export world.wxx

Everything else is a separate binary, built individually:

go build -o dist/local/info ./cmd/info
dist/local/info world.wxx

The full set is bounds, copy, import, info, merge, resize, schema and version. To crop a map, use resize with negative -top, -bottom, -left or -right. import and merge are works in progress.

Where this is going (planned)

Those separate binaries fold into wxx and are retired, and wxx becomes a Lua script host rather than a subcommand tree. That also drops the ff/v4 dependency, which exists only to parse subcommands.

So the current subcommand surface is transitional and not worth learning.

Lua scripting (planned)

Not implemented. GopherLua is not a dependency, and there is no script, run or shell subcommand.

The intent is for wxx to embed Lua using GopherLua so that scripts can inspect and modify Worldographer data, with wxx acting as the script host. An interactive shell against a loaded map is part of the same idea. This keeps wxx as the name of the overall project while treating scripting and the shell as parts of a broader toolkit.

The API a script would use to discover which application versions it may write is being designed in #46.

Why wxx?

The name directly reflects the file format the project works with. It is short, distinctive, and suitable for both a Go package and a command-line executable.

Other names considered included wsh, short for “Worldographer shell.” However, wsh is already strongly associated with Microsoft Windows Script Host, and it describes only the scripting portion of the project.

Using wxx leaves room for the project to cover the full Worldographer workflow:

  • Use the Go package in other applications
  • Inspect or convert files from the command line
  • Automate changes with Lua scripts
  • Explore map data through an interactive shell

Documentation

Overview

Package wxx defines the major data types for decoding, manipulating, and encoding Worldographer data files. We support Worldographer 2025. Files from the original Worldographer, sometimes called "Worldographer classic," are refused (ErrClassicMap); Worldographer 2025 converts them.

Index

Constants

View Source
const (
	ErrAmbiguousAppCodec           = Error("ambiguous application version codec")
	ErrAttributeSpelledTwice       = Error("attribute stated in two spellings")
	ErrCDATATerminator             = Error("text contains the CDATA terminator \"]]>\"")
	ErrClassicMap                  = Error("classic (Worldographer 1.x) map: convert it in Worldographer 2025 first")
	ErrFSError                     = Error("file-system")
	ErrGUnZipFailed                = Error("gunzip failed")
	ErrGZipFailed                  = Error("gzip failed")
	ErrGZipNewReaderFailed         = Error("gzip new reader failed")
	ErrIncompleteMap               = Error("incomplete map")
	ErrInvalidCodecDeclaration     = Error("invalid codec declaration")
	ErrInvalidDottedComponent      = Error("invalid dotted version component")
	ErrInvalidDottedComponentCount = Error("invalid dotted version component count")
	ErrInvalidDottedVersion        = Error("invalid dotted version")
	ErrInvalidEncodingHeader       = Error("invalid encoding header")
	ErrInvalidExtraTerrainResource = Error("invalid extra terrain resource")
	ErrInvalidGZip                 = Error("invalid gzip")
	ErrInvalidHexOrientation       = Error("invalid hex orientation")
	ErrInvalidColorAttribute       = Error("invalid color attribute")
	ErrInvalidIntegerAttribute     = Error("invalid integer attribute")
	ErrInvalidMapMetadata          = Error("invalid <map> metadata")
	ErrInvalidTerrainMapFieldCount = Error("invalid terrain map field count")
	ErrInvalidTerrainMap           = Error("invalid terrain map")
	ErrInvalidTileGrid             = Error("invalid tile grid")
	ErrInvalidTileResource         = Error("invalid tile resource")
	ErrInvalidUTF16                = Error("invalid utf-16")
	ErrInvalidUTF8                 = Error("invalid utf-8")
	ErrInvalidVersion              = Error("invalid version")
	ErrInvalidXML                  = Error("invalid xml")
	ErrInvalidXMLHeader            = Error("invalid xml header")
	ErrMapNotClosed                = Error("<map> not closed")
	ErrMissingBOM                  = Error("missing bom")
	ErrMissingFinalByte            = Error("missing final byte")
	ErrMissingMapElement           = Error("missing map element")
	ErrMissingVersion              = Error("missing version")
	ErrMissingWxxExtension         = Error("missing .wxx extension")
	ErrMissingXMLHeader            = Error("missing xml header")
	ErrNilMap                      = Error("nil map")
	ErrNoteKeyMismatch             = Error("note key disagrees with its location")
	ErrNoteWithoutLocation         = Error("note without location")
	ErrNotBigEndianUTF16Encoded    = Error("not big-endian utf-16 encoded")
	ErrNotCompressed               = Error("not compressed")
	ErrNotExists                   = Error("not exists")
	ErrNotFile                     = Error("not a file")
	ErrNotImplemented              = Error("not implemented")
	ErrPipelineHalted              = Error("pipeline halted")
	ErrRawReadFailed               = Error("raw read failed")
	ErrUnacceptedAppVersion        = Error("unaccepted application version")
	ErrUnknownVersion              = Error("unknown version")
	ErrUnknownXMLHeader            = Error("unknown xml header")
	ErrUnmodeledStubLoss           = Error("target cannot express an unmodeled stub")
	ErrUnparsedDottedVersion       = Error("unparsed dotted version")
	ErrUnsupportedHexOrientation   = Error("unsupported hex orientation")
	ErrUnsupportedMapMetadata      = Error("unsupported map metadata")
	ErrUnsupportedMapVersion       = Error("unsupported map version")
	ErrUnsupportedSchemaVersion    = Error("unsupported schema version")
	ErrUnsupportedVersion          = Error("unsupported version")
	ErrUnsupportedWXMLVersion      = Error("unsupported wxml version")
)
View Source
const BlankTerrain = "Blank"

BlankTerrain is the terrain Worldographer treats as always available.

Variables

This section is empty.

Functions

func Version

func Version() semver.Version

Types

type BlurTerrainBG_t

type BlurTerrainBG_t struct {
	Blur        bool    `json:"blur,omitempty"`
	TopBleed    float64 `json:"topBleed,omitempty"`
	BottomBleed float64 `json:"bottomBleed,omitempty"`
	Randomness  float64 `json:"randomness,omitempty"`
	BlurStart   float64 `json:"blurStart,omitempty"`
	BlurEnd     float64 `json:"blurEnd,omitempty"`
}

BlurTerrainBG models the W2025 top-level <blurTerrainBG> element. It is referenced as a pointer on Map_t so that nil distinguishes "absent from the file" from "present with zero-valued attributes".

type Configuration_t

type Configuration_t struct {
	TerrainConfig []*TerrainConfig_t `json:"terrain-config,omitempty"`
	FeatureConfig []*FeatureConfig_t `json:"feature-config,omitempty"`
	TextureConfig []*TextureConfig_t `json:"texture-config,omitempty"`
	TextConfig    *TextConfig_t      `json:"text-config,omitempty"`
	ShapeConfig   *ShapeConfig_t     `json:"shape-config"`
	InnerText     string             `json:"InnerText,omitempty"`
}

type CurveControl_t

type CurveControl_t struct {
	CX1 float64 `json:"cx1"`
	CY1 float64 `json:"cy1"`
	CX2 float64 `json:"cx2"`
	CY2 float64 `json:"cy2"`
}

CurveControl_t is the pair of control points on a <p type="c">. The values are written with a decimal point, as every sample spells them.

type Decoder

type Decoder interface {
	Decode(io.Reader) (*Map_t, error)
}

type Dotted

type Dotted struct {
	Raw   string // verbatim, exactly as read or to be written
	Major int
	Minor int
	// contains filtered or unexported fields
}

Dotted is an on-disk dotted version. It is NOT semver: "2.06" != "2.6". Raw is authoritative for output; the components exist to compare.

Worldographer writes these values as zero-padded ordinals (map/@version "2.06", map/@schema "1.06"). A semver round-trip drops the padding and returns "2.6", which is a different string and therefore a different file. Dotted keeps the bytes it was given and parses the components only so that two versions can be ordered.

A Dotted carries its bytes whether or not they were parseable, because a decoder must be able to keep a malformed on-disk version verbatim without failing (see the fallbacks in the codec packages). Such a value has NO components — not zero components, none — and the unexported parsed flag is what makes that distinction real rather than documented. Only the two constructors, ParseDotted and NewDotted, set it, so a composite literal from any other package (wxx.Dotted{Raw: s}, and the zero Dotted with it) is unparsed by construction and cannot claim an ordering it has no data for. Compare and Less report an error rather than answer from components that are absent; see Parsed.

This is issue #38. Before it, a malformed version decoded to {Raw: "garbage", Major: 0, Minor: 0}, which compared EQUAL to "0.0" and LESS than every real version — a silent wrong answer waiting for the first caller to order two versions.

func NewDotted

func NewDotted(major, minor int) (Dotted, error)

NewDotted builds a comparable Dotted from components, for a caller that has no string to parse -- a threshold to compare against, a version computed rather than read.

Raw is rendered as "<major>.<minor>", and that rendering is the whole of what this constructor can know: components carry no padding, so NewDotted(2, 6) gives Raw "2.6" and there is NO WAY to reach "2.06" through it. That is not an omission to be fixed with a padding argument. "2.06" and "2.6" are different files (ADR 0004 Decision 1), and a caller who wants the padded one HAS the string it wants -- ParseDotted("2.06") is the constructor for that, and it is the only one, because a Raw supplied alongside components is a second source for the same fact and the two can disagree. That disagreement is the class of bug issue #38 closed; this constructor does not reopen it from the other side.

So: use this to ORDER versions, not to name one. A Dotted from here is a legitimate operand of Compare and Less, and its Raw is a legitimate string to display -- but passing that Raw as an encode target names the unpadded string literally, which for the supported releases is no application version at all and misses the registry cleanly.

It rejects a negative component, wrapping the same sentinels ParseDotted uses for the same fact, so a caller can test one thing whichever constructor it used. There is no upper bound: no dotted component has a meaningful ceiling.

NewDotted(major, minor) and ParseDotted(fmt.Sprintf("%d.%d", major, minor)) produce identical values, flag included. This is the constructor the #38 amendment to ADR 0004 left open, added in the same change on the maintainer's call.

func ParseDotted

func ParseDotted(s string) (Dotted, error)

ParseDotted parses an on-disk dotted version such as "2.06" or "1.73".

Raw is set to s verbatim, including any zero padding; Major and Minor are parsed only to support comparison. The grammar is deliberately strict: exactly two components separated by a single ".", each one or more ASCII digits. No sign, no whitespace, no third component.

On success the result reports Parsed; on failure it is the zero Dotted, which does not. Parsing a string is the usual way to obtain a comparable Dotted -- the values come off disk -- but see NewDotted for a caller that holds components rather than bytes.

func (Dotted) Compare

func (d Dotted) Compare(other Dotted) (int, error)

Compare orders d against other by Major, then Minor, returning -1, 0, or +1.

Raw is never consulted. "2.06" and "2.6" are different strings but the same ordinal, so they compare equal. That is the point of the type: the components answer "which is newer" and Raw answers "what do we write", and the two must not be confused.

It returns an error, wrapping ErrUnparsedDottedVersion, when either side is not Parsed. There is no ordering to report in that case and the returned int is not one: an unparsed Dotted has no components, so answering from them would be inventing a fact about a file (issue #38). Callers that hold a version straight from a decoder must handle this; callers holding one from ParseDotted or NewDotted cannot reach it.

func (Dotted) Less

func (d Dotted) Less(other Dotted) (bool, error)

Less reports whether d orders before other. See Compare, including the error.

func (Dotted) Parsed

func (d Dotted) Parsed() bool

Parsed reports whether Major and Minor mean anything.

It is false for the zero Dotted and for one a decoder built from a version string that does not fit the dotted grammar. Raw is trustworthy in every case — it is what goes back to disk — but only a Parsed Dotted can be ordered, and only ParseDotted and NewDotted produce one.

func (Dotted) String

func (d Dotted) String() string

String returns the verbatim string this Dotted was parsed from.

It never re-renders from Major and Minor: that would turn "2.06" into "2.6" and corrupt any file written from it. Anything written to disk comes from Raw. It is defined for an unparsed Dotted too — Raw is exactly what such a value exists to carry.

type Encoder

type Encoder interface {
	Encode(io.Writer, *Map_t) error
}

type Error

type Error string

Error implements constant errors

func (Error) Error

func (e Error) Error() string

Error implements the Errors interface

type ExtraTerrainLayer_t

type ExtraTerrainLayer_t struct {
	Name    string                  `json:"name"`
	Terrain []*TerrainAndLocation_t `json:"terrain,omitempty"`
}

ExtraTerrainLayer_t is one <mapLayer> inside <extraTerrain>. Name refers to one of Map_t.MapLayers by name; nothing checks that it does.

type ExtraTerrain_t

type ExtraTerrain_t struct {
	MapLayers []*ExtraTerrainLayer_t `json:"mapLayers,omitempty"`
}

ExtraTerrain_t models the W2025 top-level <extraTerrain> element: terrain placed on a map layer other than a hex's base tile (issue #34). It is a pointer on Map_t so nil distinguishes absent from present-but-empty.

Each hex's base terrain lives in Tiles, one per hex, and carries no layer. Samples suggest that is the terrain's default layer -- "Terrain Land" for land, "Terrain Water" for water -- and that only terrain the user places on another layer is written here. That is inferred from two 2.08 samples, not confirmed. One hex may appear in several layers, and more than once in one layer, so this is a list per layer, not a map keyed by hex.

type FeatureConfig_t

type FeatureConfig_t struct {
	InnerText string `json:"innerText,omitempty"`
}

type FeatureLocation_t

type FeatureLocation_t struct {
	ViewLevel string  `json:"viewLevel,omitempty"`
	X         float64 `json:"x,omitempty"`
	Y         float64 `json:"y,omitempty"`
}

type Feature_t

type Feature_t struct {
	Type              string  `json:"type,omitempty"`
	Rotate            float64 `json:"rotate,omitempty"`
	Uuid              string  `json:"uuid,omitempty"`
	MapLayer          string  `json:"mapLayer,omitempty"`
	IsFlipHorizontal  bool    `json:"isFlipHorizontal,omitempty"`
	IsFlipVertical    bool    `json:"isFlipVertical,omitempty"`
	Scale             float64 `json:"scale,omitempty"`
	ScaleHt           float64 `json:"scaleHt,omitempty"`
	Tags              string  `json:"tags,omitempty"`
	Color             *RGBA_t `json:"color,omitempty"`
	RingColor         *RGBA_t `json:"ringcolor,omitempty"`
	IsGMOnly          bool    `json:"isGMOnly,omitempty"`
	IsPlaceFreely     bool    `json:"isPlaceFreely,omitempty"`
	LabelPosition     string  `json:"labelPosition,omitempty"`
	LabelDistance     int     `json:"labelDistance,omitempty"`
	IsWorld           bool    `json:"isWorld,omitempty"`
	IsContinent       bool    `json:"isContinent,omitempty"`
	IsKingdom         bool    `json:"isKingdom,omitempty"`
	IsProvince        bool    `json:"isProvince,omitempty"`
	IsFillHexBottom   bool    `json:"isFillHexBottom,omitempty"`
	IsHideTerrainIcon bool    `json:"isHideTerrainIcon,omitempty"`

	Location *FeatureLocation_t `json:"location,omitempty"`
	Label    *Label_t           `json:"label,omitempty"`
}

type GridAndNumbering_t

type GridAndNumbering_t struct {
	Color0                      string  `json:"color0,omitempty"` // hex - "0x00000040"
	Color1                      string  `json:"color1,omitempty"` // hex - "0x00000040"
	Color2                      string  `json:"color2,omitempty"` // hex - "0x00000040"
	Color3                      string  `json:"color3,omitempty"` // hex - "0x00000040"
	Color4                      string  `json:"color4,omitempty"` // hex - "0x00000040"
	Width0                      float64 `json:"width0,omitempty"`
	Width1                      float64 `json:"width1,omitempty"`
	Width2                      float64 `json:"width2,omitempty"`
	Width3                      float64 `json:"width3,omitempty"`
	Width4                      float64 `json:"width4,omitempty"`
	GridOffsetContinentKingdomX float64 `json:"gridOffsetContinentKingdomX,omitempty"`
	GridOffsetContinentKingdomY float64 `json:"gridOffsetContinentKingdomY,omitempty"`
	GridOffsetWorldContinentX   float64 `json:"gridOffsetWorldContinentX,omitempty"`
	GridOffsetWorldContinentY   float64 `json:"gridOffsetWorldContinentY,omitempty"`
	GridOffsetWorldKingdomX     float64 `json:"gridOffsetWorldKingdomX,omitempty"`
	GridOffsetWorldKingdomY     float64 `json:"gridOffsetWorldKingdomY,omitempty"`
	GridSquare                  int     `json:"gridSquare,omitempty"`
	GridSquareHeight            float64 `json:"gridSquareHeight,omitempty"` // "-1.0" is special?
	GridSquareWidth             float64 `json:"gridSquareWidth,omitempty"`  // "-1.0" is special?
	GridOffsetX                 float64 `json:"gridOffsetX,omitempty"`
	GridOffsetY                 float64 `json:"gridOffsetY,omitempty"`
	NumberFont                  string  `json:"numberFont,omitempty"`
	NumberColor                 string  `json:"numberColor,omitempty"` // hex - "0x000000ff"
	NumberSize                  int     `json:"numberSize,omitempty"`
	NumberStyle                 string  `json:"numberStyle,omitempty"`     // "PLAIN" or ??
	NumberFirstCol              int     `json:"numberFirstCol,omitempty"`  // "0"
	NumberFirstRow              int     `json:"numberFirstRow,omitempty"`  // "0"
	NumberOrder                 string  `json:"numberOrder,omitempty"`     // "COL_ROW" or ??
	NumberPosition              string  `json:"numberPosition,omitempty"`  // "BOTTOM" or ??
	NumberPrePad                string  `json:"numberPrePad,omitempty"`    // "DOUBLE_ZERO" or ??
	NumberSeparator             string  `json:"numberSeparator,omitempty"` // "." or free text?
}

type Information_t

type Information_t struct {
	Uuid         string  `json:"uuid,omitempty"`
	Type         string  `json:"type,omitempty"`
	Title        string  `json:"title,omitempty"`
	Rulers       *string `json:"rulers,omitempty"`
	Government   *string `json:"government,omitempty"`
	Cultures     *string `json:"cultures,omitempty"`
	Language     *string `json:"language,omitempty"`
	ReligionType *string `json:"religionType,omitempty"`
	Culture      *string `json:"culture,omitempty"`
	HolySymbol   *string `json:"holySymbol,omitempty"`
	Domains      *string `json:"domains,omitempty"`

	Details   []*Information_t `json:"details,omitempty"`
	InnerText string           `json:"innerText,omitempty"`
}

Information_t is one lore entry. The eight lore attributes (Rulers through Domains) are pointers because a file may omit any of them and may also state one as "": nil means the file states no such attribute, and a pointer to "" means it states the attribute empty. Worldographer writes both -- an "Information" entry carries none, a "Religion" entry carries domains="" -- and an encoder must reproduce whichever it was given (issue #66).

Details holds the entries nested inside this one, each itself an Information_t, to any depth. Real files nest three deep -- Information > Religion (a pantheon) > Religion (each god) -- and nothing in the format suggests a limit, so the model imposes none (issue #69).

type Informations_t

type Informations_t struct {
	Informations []*Information_t `json:"informations,omitempty"`
	InnerText    string           `json:"innerText,omitempty"`
}

type LabelLocation_t

type LabelLocation_t struct {
	ViewLevel string  `json:"viewLevel,omitempty"`
	X         float64 `json:"x,omitempty"`
	Y         float64 `json:"y,omitempty"`
	Scale     float64 `json:"scale,omitempty"`
}

type LabelStyle_t

type LabelStyle_t struct {
	Name            string  `json:"name,omitempty"`
	FontFace        string  `json:"fontFace,omitempty"`
	Scale           float64 `json:"scale,omitempty"`
	IsBold          bool    `json:"isBold,omitempty"`
	IsItalic        bool    `json:"isItalic,omitempty"`
	Color           *RGBA_t `json:"color,omitempty"`
	BackgroundColor *RGBA_t `json:"backgroundColor,omitempty"`
	OutlineSize     float64 `json:"outlineSize,omitempty"`
	OutlineColor    *RGBA_t `json:"outlineColor,omitempty"`

	// W2025 drop-shadow attributes. DropShadowColor is a nullable string that
	// preserves the literal "null" spelling (mirrors Shape_t.DsColor).
	DropShadowColor  string  `json:"dropShadowColor,omitempty"`
	DropShadowRadius float64 `json:"dropShadowRadius,omitempty"`
	DropShadowSpread float64 `json:"dropShadowSpread,omitempty"`
}

type Label_t

type Label_t struct {
	MapLayer        string  `json:"mapLayer,omitempty"`
	Style           string  `json:"style,omitempty"`
	FontFace        string  `json:"fontFace,omitempty"`
	Color           *RGBA_t `json:"color,omitempty"`
	OutlineColor    *RGBA_t `json:"outlineColor,omitempty"`
	OutlineSize     float64 `json:"outlineSize,omitempty"`
	Rotate          float64 `json:"rotate,omitempty"`
	IsBold          bool    `json:"isBold,omitempty"`
	IsItalic        bool    `json:"isItalic,omitempty"`
	IsWorld         bool    `json:"isWorld,omitempty"`
	IsContinent     bool    `json:"isContinent,omitempty"`
	IsKingdom       bool    `json:"isKingdom,omitempty"`
	IsProvince      bool    `json:"isProvince,omitempty"`
	IsGMOnly        bool    `json:"isGMOnly,omitempty"`
	Tags            string  `json:"tags,omitempty"`
	BackgroundColor *RGBA_t `json:"backgroundColor,omitempty"`

	// W2025 drop-shadow attributes. DropShadowColor is a nullable string that
	// preserves the literal "null" spelling (mirrors Shape_t.DsColor).
	DropShadowColor  string  `json:"dropShadowColor,omitempty"`
	DropShadowRadius float64 `json:"dropShadowRadius,omitempty"`
	DropShadowSpread float64 `json:"dropShadowSpread,omitempty"`

	Location  *LabelLocation_t `json:"location,omitempty"`
	InnerText string           `json:"innerText,omitempty"`
}

type MapKey_t

type MapKey_t struct {
	// attributes
	PositionX         float64 `json:"positionx,omitempty"`
	PositionY         float64 `json:"positiony,omitempty"`
	Viewlevel         string  `json:"viewlevel,omitempty"` // "null", "WORLD"
	Height            float64 `json:"height,omitempty"`
	BackgroundColor   *RGBA_t `json:"backgroundcolor,omitempty"`
	BackgroundOpacity float64 `json:"backgroundopacity,omitempty"`
	TitleText         string  `json:"titleText,omitempty"`
	TitleFontFace     string  `json:"titleFontFace,omitempty"`
	TitleFontColor    *RGBA_t `json:"titleFontColor,omitempty"`
	TitleFontBold     bool    `json:"titleFontBold,omitempty"`
	TitleFontItalic   bool    `json:"titleFontItalic,omitempty"`
	TitleScale        float64 `json:"titleScale,omitempty"`
	ScaleText         string  `json:"scaleText,omitempty"`
	ScaleFontFace     string  `json:"scaleFontFace,omitempty"`
	ScaleFontColor    *RGBA_t `json:"scaleFontColor,omitempty"`
	ScaleFontBold     bool    `json:"scaleFontBold,omitempty"`
	ScaleFontItalic   bool    `json:"scaleFontItalic,omitempty"`
	ScaleScale        float64 `json:"scaleScale,omitempty"`
	EntryFontFace     string  `json:"entryFontFace,omitempty"`
	EntryFontColor    *RGBA_t `json:"entryFontColor,omitempty"`
	EntryFontBold     bool    `json:"entryFontBold,omitempty"`
	EntryFontItalic   bool    `json:"entryFontItalic,omitempty"`
	EntryScale        float64 `json:"entryScale,omitempty"`
}

type MapLayer_t

type MapLayer_t struct {
	Name      string  `json:"name"`
	IsVisible bool    `json:"isVisible"`
	Opacity   float64 `json:"opacity,omitempty"`
}

type Map_t

type Map_t struct {
	MetaData struct {
		// AppVersion is this tool's own version -- a genuine semver, and the only
		// semver in this struct. The versions the file states are not semver and
		// live in Version.
		AppVersion semver.Version `json:"appVersion"`
		// Version is the file's on-disk version identity: map/@version and
		// map/@schema as the two independent axes they are (ADR 0004). It is
		// populated by every decoder, and its Schema selects the codec an encode
		// dispatches to.
		//
		// It replaces DataVersion, which held one semver whose Major was a family
		// year and whose Minor.Patch meant the application version for classic and
		// the schema version for W2025 -- a different axis per family, in one slot,
		// keyed by a label no file states (ADR 0004 Decisions 2 and 4).
		Version Version_t `json:"version"`
		// Worldographer defines the metadata for the WXX file
		Worldographer struct {
			Name    string    `json:"name"`    // name of input
			Created time.Time `json:"created"` // timestamp of input
			Release string    `json:"release"` // Worldographer release (e.g., 2025)
			Version string    `json:"version"` // Worldographer/Hexographer version (e.g. 2.06)
			Schema  string    `json:"schema"`  // Worldographer XML Schema version (e.g. 1.06)
		} `json:"worldographer"`
		Created string `json:"created"` // timestamp of this file
	} `json:"meta-data"`

	// attributes
	//
	// There is no Release, Version or Schema here, and their absence is load-bearing.
	// They held map/@release, map/@version and map/@schema as the SOURCE file stated
	// them, which is provenance, and provenance has one home: MetaData.Worldographer
	// (issue #45 Decision 9). Carried here as well, they were a second copy of the
	// same facts sitting among the fields an encoder reads -- which is how issue #45
	// happened, the encoder writing the input file's identity into the output. The
	// encoder now derives every identity byte it writes from the application version
	// the caller requires and never reads the map for one, so the copy had no reader
	// and is gone. A future reader wanting to know what wrote a file asks
	// MetaData.Worldographer; a future writer wanting to know what to emit is told,
	// and asks nothing.
	Type                      string       `json:"type,omitempty"`
	LastViewLevel             string       `json:"lastViewLevel,omitempty"`
	ContinentFactor           int          `json:"continentFactor,omitempty"`
	KingdomFactor             int          `json:"kingdomFactor,omitempty"`
	ProvinceFactor            int          `json:"provinceFactor,omitempty"`
	WorldToContinentHOffset   float64      `json:"worldToContinentHOffset,omitempty"`
	ContinentToKingdomHOffset float64      `json:"continentToKingdomHOffset,omitempty"`
	KingdomToProvinceHOffset  float64      `json:"kingdomToProvinceHOffset,omitempty"`
	WorldToContinentVOffset   float64      `json:"worldToContinentVOffset,omitempty"`
	ContinentToKingdomVOffset float64      `json:"continentToKingdomVOffset,omitempty"`
	KingdomToProvinceVOffset  float64      `json:"kingdomToProvinceVOffset,omitempty"`
	HexWidth                  float64      `json:"hexWidth,omitempty"`
	HexHeight                 float64      `json:"hexHeight,omitempty"`
	HexOrientation            string       `json:"hexOrientation,omitempty"` // "COLUMNS" or "ROWS"; Validate rejects anything else; GridOrientation derives the hexg layout from it
	RowsHigh                  int          `json:"rowsHigh,omitempty"`       // number of rows (derived from TilesHigh based on orientation)
	ColumnsWide               int          `json:"columnsWide,omitempty"`    // number of columns (derived from TilesWide based on orientation)
	MapProjection             Projection_e `json:"mapProjection,omitempty"`
	ShowNotes                 bool         `json:"showNotes,omitempty"`
	ShowGMOnly                bool         `json:"showGMOnly,omitempty"`
	ShowGMOnlyGlow            bool         `json:"showGMOnlyGlow,omitempty"`
	ShowFeatureLabels         bool         `json:"showFeatureLabels,omitempty"`
	ShowGrid                  bool         `json:"showGrid,omitempty"`
	ShowGridNumbers           bool         `json:"showGridNumbers,omitempty"`
	ShowShadows               bool         `json:"showShadows,omitempty"`
	TriangleSize              int          `json:"triangleSize,omitempty"`
	HScrollbarPos             float64      `json:"hScrollbarPos,omitempty"` // W2025 UI scroll position
	VScrollbarPos             float64      `json:"vScrollbarPos,omitempty"` // W2025 UI scroll position

	// elements
	GridAndNumbering *GridAndNumbering_t `json:"gridAndNumbering,omitempty"`

	// BlurTerrainBG is a W2025 top-level element; nil means absent from the file.
	BlurTerrainBG *BlurTerrainBG_t `json:"blurTerrainBG,omitempty"`

	// ExtraTerrain is a W2025 top-level element; nil means absent from the file.
	// It holds terrain placed on layers other than the base tile -- see
	// ExtraTerrain_t.
	ExtraTerrain *ExtraTerrain_t `json:"extraTerrain,omitempty"`

	// TerrainMap assigns numbers to each terrain type.
	// The terrain type is used in the TileRow struct.
	TerrainMap *TerrainMap_t `json:"terrainMap,omitempty"`

	// MapLayers assigns a boolean "isVisible" to each layer.
	MapLayers []*MapLayer_t `json:"mapLayers,omitempty"`

	Tiles *Tiles_t `json:"tiles,omitempty"`

	MapKey *MapKey_t `json:"mapKey,omitempty"`

	Features []*Feature_t `json:"features,omitempty"`

	Labels []*Label_t `json:"labels,omitempty"`

	Shapes []*Shape_t `json:"shapes,omitempty"`

	Notes []*Note_t `json:"notes,omitempty"`

	Informations *Informations_t `json:"informations"`

	Configuration *Configuration_t `json:"configuration"`
}

Map_t is the in-memory representation of the map data. We have created this to work with the known versions of Worldographer XML data. We are assuming that this will continue to work with future versions of the application.

func (*Map_t) GridOrientation

func (m *Map_t) GridOrientation() (hexg.LayoutOffset, bool)

GridOrientation returns the hexg offset layout of m's grid. It is derived from HexOrientation, the only field that holds the orientation, and is never stored: "COLUMNS" is hexg.OddQ and "ROWS" is hexg.OddR. For any other HexOrientation, including the unset "", ok is false and the layout is meaningless; hexg.LayoutOffset has no unset value (its zero is OddR), so a caller must check ok rather than the layout.

Tile_t.Coords follow the same layout: odd-q for COLUMNS and odd-r for ROWS, because Worldographer staggers odd columns down and odd rows right (#80, #130).

func (*Map_t) Validate

func (m *Map_t) Validate() error

Validate reports every way m is internally inconsistent (issue #20).

Map_t is a fully-exported struct with no constructor: a caller assembles one field by field, and nothing until now told them when they had assembled something a Worldographer file cannot be. No decoder produces the states checked here -- a decoder that cannot make sense of a file errors instead -- so every one of them is a map a CALLER built, and the write path met them by panicking. All eight nil substructures below were verified to crash at least one codec, and a grid one column shorter than its own @tilesWide header crashed both -- "index out of range [5] with length 5" through classic, "[13] with length 13" through W2025. A panic is not a diagnosis: it names the encoder's line, not the caller's mistake, and it is not recoverable by a caller who is encoding a map they were handed.

It returns ALL of the problems, joined, rather than the first: a half-assembled map usually has several, and a caller fixing them one error at a time is being made to do the work this method exists to do. Each is wrapped in a constant from errors.go, so errors.Is answers "which KIND of malformed" while the message says which field.

WHAT IT DOES NOT CHECK, deliberately:

  • MetaData.Version. It can still hold a pair no release ever stated -- the classic application version "1.77" alongside the W2025 schema "1.06" -- and that is issue #20's other half, left open on purpose. Checking it means asking what is registered, the registry is xmlio's, and xmlio cannot be imported here (import cycle). Discovery is #46's to design; a hard-coded list of releases here would be a second registry to drift. Nothing reads MetaData.Version on the encode path today (issue #45 deleted the reader), so the pair is unread rather than obeyed.

  • RowsHigh and ColumnsWide. They are decode-side labels derived from the orientation and the grid dimensions, and no encoder writes them -- neither schema has an attribute for them. Requiring a caller to set a field nothing emits would reject maps that encode perfectly.

  • Whether a target can express what m carries. That is a question about the target, not about m, and it is answered by the encoder (see xmlio's downgradeLoss).

A nil receiver is a problem in itself and is reported as one rather than panicking, because "the map I was given is nil" is exactly the sort of caller mistake this method exists to name.

type NoteLocation_t

type NoteLocation_t struct {
	ViewLevel string  `json:"viewLevel,omitempty"`
	X         float64 `json:"x,omitempty"`
	Y         float64 `json:"y,omitempty"`
}

NoteLocation_t is a note's <location>.

type Note_t

type Note_t struct {
	// attributes
	OriginalViewLevel string  `json:"originalViewLevel,omitempty"`
	Filename          string  `json:"filename,omitempty"`
	Parent            string  `json:"parent,omitempty"`
	Color             *RGBA_t `json:"color,omitempty"`
	IsWorld           bool    `json:"isWorld,omitempty"`
	IsContinent       bool    `json:"isContinent,omitempty"`
	IsKingdom         bool    `json:"isKingdom,omitempty"`
	IsProvince        bool    `json:"isProvince,omitempty"`
	Title             string  `json:"title,omitempty"`

	// notetext CDATA body
	NoteText string `json:"notetext,omitempty"`

	// Location is the note's position. The W2025 encoder refuses a note
	// without one rather than writing it at 0,0.
	Location *NoteLocation_t `json:"location,omitempty"`
}

Note_t is a note pinned to a point on the map, in the W2025 spelling that 2.06, 2.07 and 2.08 write (issue #94).

There is no Key field. On disk, @key is "<viewLevel>,<x>,<y>" of the note's <location>: the same position stated twice. The encoder derives @key from Location, so the two cannot disagree in a file this package writes, and a caller who moves a note moves only Location.

type Point_t

type Point_t struct {
	Type string  `json:"type,omitempty"`
	X    float64 `json:"x,omitempty"`
	Y    float64 `json:"y,omitempty"`

	// IntegerXY records that the file spelled both coordinates as integers,
	// with no decimal point and no exponent: x="2700" y="150" rather than
	// x="2700.0" y="150.0" (issue #94). Worldographer 2.06, 2.07 and 2.08
	// spell a tile-border polygon's points this way and a path's with a
	// decimal point; the W2025 decoder records which spelling it read, and the
	// W2025 encoder writes it back, so a same-version round trip keeps it.
	//
	// It is a fact about spelling, not about value: the two spellings of 2700
	// are the same number. A point whose coordinates are spelled one each way
	// decodes with IntegerXY false, and is written back with both decimal.
	//
	// A caller who sets IntegerXY, or moves such a point, must keep both
	// coordinates whole numbers: the W2025 encoder refuses to write a point
	// with IntegerXY set and a fractional coordinate rather than round it.
	IntegerXY bool `json:"integerXY,omitempty"`

	// Control holds a curve point's two Bezier control points, the W2025
	// @cx1 @cy1 @cx2 @cy2, and is nil when the point states none (issue #94).
	// Worldographer 2.08 writes them on a curved path's type="c" points; the
	// W2025 encoder writes all four when Control is set and none when it is
	// nil, so a control point at 0,0 is kept.
	Control *CurveControl_t `json:"control,omitempty"`
}

Point_t is one <p> vertex of a shape.

Type is the point's @type ("m" on the first point of a path in the samples), and "" when the file states none. The W2025 encoder writes @type only when it is not empty, so a point that stated none is written without one.

type Projection_e

type Projection_e int
const (
	FLAT Projection_e
	ICOSAHEDRAL
)

type RGBA_t

type RGBA_t struct {
	R float64
	G float64
	B float64
	A float64
}

type Resources_t

type Resources_t struct {
	Animal int
	Brick  int
	Crops  int
	Gems   int
	Lumber int
	Metals int
	Rock   int
}

type ShapeConfig_t

type ShapeConfig_t struct {
	ShapeStyles []*ShapeStyle_t `json:"shapeStyles,omitempty"`
	InnerText   string          `json:"innerText,omitempty"`
}

type ShapeStyle_t

type ShapeStyle_t struct {
	Name          string  `json:"name,omitempty"`
	StrokeType    string  `json:"strokeType,omitempty"`
	IsFractal     bool    `json:"isFractal,omitempty"`
	StrokeWidth   float64 `json:"strokeWidth,omitempty"`
	Opacity       float64 `json:"opacity,omitempty"`
	SnapVertices  bool    `json:"snapVertices,omitempty"`
	Tags          string  `json:"tags,omitempty"`
	DropShadow    bool    `json:"dropShadow,omitempty"`
	InnerShadow   bool    `json:"innerShadow,omitempty"`
	BoxBlur       bool    `json:"boxBlur,omitempty"`
	DsSpread      float64 `json:"dsSpread,omitempty"`
	DsRadius      float64 `json:"dsRadius,omitempty"`
	DsOffsetX     float64 `json:"dsOffsetX,omitempty"`
	DsOffsetY     float64 `json:"dsOffsetY,omitempty"`
	InsChoke      float64 `json:"insChoke,omitempty"`
	InsRadius     float64 `json:"insRadius,omitempty"`
	InsOffsetX    float64 `json:"insOffsetX,omitempty"`
	InsOffsetY    float64 `json:"insOffsetY,omitempty"`
	BbWidth       float64 `json:"bbWidth,omitempty"`
	BbHeight      float64 `json:"bbHeight,omitempty"`
	BbIterations  int     `json:"bbIterations,omitempty"`
	FillTexture   string  `json:"fillTexture,omitempty"`
	StrokeTexture string  `json:"strokeTexture,omitempty"`
	StrokePaint   *RGBA_t `json:"strokePaint,omitempty"`
	FillPaint     *RGBA_t `json:"fillPaint,omitempty"`
	DsColor       *RGBA_t `json:"dscolor,omitempty"`
	InsColor      *RGBA_t `json:"insColor,omitempty"`

	// W2025 line rendering attributes (mirrors Shape_t.LineCap/LineJoin).
	LineCap  string `json:"lineCap,omitempty"`
	LineJoin string `json:"lineJoin,omitempty"`
}

type Shape_t

type Shape_t struct {
	// attributes0
	BbHeight              float64 `json:"bbHeight,omitempty"`
	BbIterations          int     `json:"bbIterations,omitempty"`
	BbWidth               float64 `json:"bbWidth,omitempty"`
	CreationType          string  `json:"creationType,omitempty"`
	CurrentShapeViewLevel string  `json:"currentShapeViewLevel,omitempty"`
	DsColor               string  `json:"dsColor,omitempty"`
	DsOffsetX             float64 `json:"dsOffsetX,omitempty"`
	DsOffsetY             float64 `json:"dsOffsetY,omitempty"`
	DsRadius              float64 `json:"dsRadius,omitempty"`
	DsSpread              float64 `json:"dsSpread,omitempty"`
	// ExtraLineDistance, ExtraLineLength, ExtraLineWidth and
	// ExtraLineSeparation are the W2025 @extraLine* attributes, which 2.06,
	// 2.07 and 2.08 write on every shape (issue #94). The W2025 encoder writes
	// none of them when all four are zero.
	ExtraLineDistance   float64 `json:"extraLineDistance,omitempty"`
	ExtraLineLength     float64 `json:"extraLineLength,omitempty"`
	ExtraLineWidth      float64 `json:"extraLineWidth,omitempty"`
	ExtraLineSeparation float64 `json:"extraLineSeparation,omitempty"`
	// FillRule is "" when the file states no @fillRule, and the W2025 encoder
	// then writes none.
	FillRule           string  `json:"fillRule,omitempty"`
	FillTexture        string  `json:"fillTexture,omitempty"`
	HighestViewLevel   string  `json:"highestViewLevel,omitempty"`
	InsChoke           float64 `json:"insChoke,omitempty"`
	InsColor           string  `json:"insColor,omitempty"`
	InsOffsetX         float64 `json:"insOffsetX,omitempty"`
	InsOffsetY         float64 `json:"insOffsetY,omitempty"`
	InsRadius          float64 `json:"insRadius,omitempty"`
	IsBoxBlur          bool    `json:"isBoxBlur,omitempty"`
	IsContinent        bool    `json:"isContinent,omitempty"`
	IsCurve            bool    `json:"isCurve,omitempty"`
	IsDropShadow       bool    `json:"isDropShadow,omitempty"`
	IsGMOnly           bool    `json:"isGMOnly,omitempty"`
	IsInnerShadow      bool    `json:"isInnerShadow,omitempty"`
	IsKingdom          bool    `json:"isKingdom,omitempty"`
	IsMatchTileBorders bool    `json:"isMatchTileBorders,omitempty"`
	IsProvince         bool    `json:"isProvince,omitempty"`
	IsSnapVertices     bool    `json:"isSnapVertices,omitempty"`
	IsWorld            bool    `json:"isWorld,omitempty"`
	LineCap            string  `json:"lineCap,omitempty"`
	LineJoin           string  `json:"lineJoin,omitempty"`
	MapLayer           string  `json:"mapLayer,omitempty"`
	Opacity            float64 `json:"opacity,omitempty"`
	StrokeColor        string  `json:"strokeColor,omitempty"`
	StrokeTexture      string  `json:"strokeTexture,omitempty"`
	StrokeType         string  `json:"strokeType,omitempty"`
	StrokeWidth        float64 `json:"strokeWidth,omitempty"`
	Tags               string  `json:"tags,omitempty"`
	Type               string  `json:"type,omitempty"`

	Points []*Point_t `json:"points,omitempty"`
}

type TerrainAndLocation_t

type TerrainAndLocation_t struct {
	Terrain               string      `json:"terrain"`
	Elevation             float64     `json:"elevation"`
	IsIcy                 bool        `json:"isIcy,omitempty"`
	IsGMOnly              bool        `json:"isGMOnly,omitempty"`
	Resources             Resources_t `json:"resources"`
	CustomBackgroundColor *RGBA_t     `json:"customBackgroundColor,omitempty"`
	X                     float64     `json:"x"`
	Y                     float64     `json:"y"`
}

TerrainAndLocation_t is one terrain placed on a layer (<terrainAndLocation>).

Terrain is the terrain's NAME (on disk, @name), e.g. "Classic/Flat Beach" -- not the Tiles_t index into TerrainMap that a base tile uses.

X and Y are the on-disk @location: a point in the map's drawing coordinates, not a hex. They are kept as written, because the mapping to a hex is inferred (on the COLUMNS samples, x = 225*col and y = 300*row + 150 for odd columns) and unconfirmed for ROWS maps or other hex sizes; see #34.

CustomBackgroundColor is the on-disk @bgColor, written by the app when the placement has Override BG set and omitted otherwise (issue #126). nil means the attribute is absent; opaque black is a colour, not nil (#99).

type TerrainConfig_t

type TerrainConfig_t struct {
	InnerText string `json:"innerText,omitempty"`
}

type TerrainMap_t

type TerrainMap_t struct {
	Data map[string]int `json:"data,omitempty"`
	List []*Terrain_t   `json:"list,omitempty"`
}

func (*TerrainMap_t) EnsureTerrain

func (tm *TerrainMap_t) EnsureTerrain(name string) int

EnsureTerrain returns the index of the named terrain, adding it at the next free index if the table does not list it (issue #81).

Worldographer lists only the terrains a map uses, so a fully painted map has no "Blank" entry, yet Blank is always available to it. The maintainer's rule is that no wxx operation may lose Blank. An operation that writes a tile with a terrain the table might not list -- resize filling the hexes it adds with Blank -- takes its index from here instead of refusing the map. Worldographer 2.08 opens a map whose table gained an entry this way.

The next free index is one past the highest, so a table numbered 0..n-1 stays contiguous (see #87 for why that matters to the encoders).

type Terrain_t

type Terrain_t struct {
	Index int    `json:"index"`
	Label string `json:"label"`
}

type TextConfig_t

type TextConfig_t struct {
	LabelStyles []*LabelStyle_t `json:"labelStyles,omitempty"`
	InnerText   string          `json:"innerText,omitempty"`
}

type TextureConfig_t

type TextureConfig_t struct {
	InnerText string `json:"innerText,omitempty"`
}

type Tile_t

type Tile_t struct {
	Coords                hexg.Hex
	Row                   int
	Column                int
	Terrain               int // lookup into TerrainMap
	Elevation             float64
	IsIcy                 bool
	IsGMOnly              bool
	Resources             Resources_t
	CustomBackgroundColor *RGBA_t
}

type Tiles_t

type Tiles_t struct {
	ViewLevel string `json:"viewLevel,omitempty"`
	TilesWide int    `json:"tilesWide,omitempty"` // number of columns of tiles (x)
	TilesHigh int    `json:"tilesHigh,omitempty"` // number of rows of tiles    (y)

	// Tiles is a two-dimensional array that is indexed by [col][row]
	Tiles [][]*Tile_t `json:"tiles,omitempty"`
}

type Version_t

type Version_t struct {
	// App is map/@version, the application build that wrote the file: "2.06"
	// for the W2025 baseline. Every supported file states it, so it is a value
	// rather than a pointer.
	App Dotted

	// Schema is map/@schema, the on-disk data format the file conforms to
	// ("1.06" for the W2025 baseline).
	//
	// nil means the map states no schema. Every supported file states one, so
	// a decoded map never holds nil; only a map a caller built can. It was the
	// classic (Worldographer 1.x) format's identity, which states no @schema
	// attribute at all, until issue #103 removed classic support.
	Schema *Dotted
}

Version_t is a file's on-disk version identity: the two independent axes a Worldographer file states (ADR 0003) and nothing else.

There is deliberately no family year. "2017" is a project coinage that appears in no classic file, and "2025" is a marketing label that may change while the data format does not; neither is a fact about the format, so neither belongs in a version identity (ADR 0004). The marketing label survives verbatim in MetaData.Worldographer.Release, where it is provenance rather than identity -- a fact about the file that came in. On the way out it is neither: the encoder derives map/@release from the application version it was required to write (issue #45 Decision 5).

Both members are Dotted, never semver: the components exist to compare and Raw is what goes back to disk.

func (Version_t) String

func (v Version_t) String() string

String renders both axes for display: `app 2.06, schema 1.06` for a W2025 file, and `schema none` when Schema is nil.

This is for humans -- a report line, an error message, a template. Nothing written to a file ever comes from here: an encoder emits App.Raw and Schema.Raw individually, into the attributes they came from.

Directories

Path Synopsis
cmd
bounds command
Package main implements a tool to read a Worldographer file and print the orientation, height, and width.
Package main implements a tool to read a Worldographer file and print the orientation, height, and width.
copy command
Package copy implements a command to copy a Worldographer file by reading the XML from the input and writing it out the new file.
Package copy implements a command to copy a Worldographer file by reading the XML from the input and writing it out the new file.
import command
Package main implements a command to import worldographer terrain layers.
Package main implements a command to import worldographer terrain layers.
info command
Package main implements a command line tool that shows information on WXX data files.
Package main implements a command line tool that shows information on WXX data files.
merge command
Package main implements a simple merge command.
Package main implements a simple merge command.
resize command
Package resize implements a command to resize a Worldographer map
Package resize implements a command to resize a Worldographer map
schema command
Package main implements a command line tool for dumping an XML schema.
Package main implements a command line tool for dumping an XML schema.
version command
Package main implements a command to display the WXX package version.
Package main implements a command to display the WXX package version.
wxx command
Package main implements the `wxx` command line tool.
Package main implements the `wxx` command line tool.
Package xmlio implements the XML decoding and encoding pipeline for Worldographer .wxx files and hosts the registry that maps an application version to the encoder that writes it.
Package xmlio implements the XML decoding and encoding pipeline for Worldographer .wxx files and hosts the registry that maps an application version to the encoder that writes it.
internal/appver
Package appver models a codec's declaration of the application versions it accepts, verifies that a declaration is valid on its own terms, and verifies that no two codecs claim the same application version.
Package appver models a codec's declaration of the application versions it accepts, verifies that a declaration is valid on its own terms, and verifies that no two codecs claim the same application version.
internal/codec
Package codec defines the codec as the DISPATCHER sees one: the emit half of the parse/emit pair for one schema (ADR 0004 Decision 4), plus the declaration it states about itself.
Package codec defines the codec as the DISPATCHER sees one: the emit half of the parse/emit pair for one schema (ADR 0004 Decision 4), plus the declaration it states about itself.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL