counters

package module
v0.0.0-...-be111da Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2024 License: GPL-3.0 Imports: 30 Imported by: 0

README

This software is a Cli tools that uses a specific JSON format to read data and produce cards or counters. It can even use counters files to produce cards using the content of the counters.

Settings

Settings are common for card teamplates, counter templates, single counters and single cards:

"width": (px)

When used with a template, it defines the max width for the entire template (regardless of the number of counters or cards). So if defined a 1200 px and a 100px per side counter, you'll get 12 counters per row.

"height": (px)

When used with a template, it defines the max height for the entire template (regardless of the number of counters or cards). So, if you define a 800px height and your cards are 400px height, then you'll get 2 columns per page.

"margins": (px)

"font_height": (px)

"font_path": (string)

If you want to use a custom font, define the path to load it here.

"font_color": (string)

You can use a hexadecimal format or a string format like "red", "blue".

"font_color": "red" "font_color": "#0F0"
{ "texts": [{"string": "font_color", "font_color": "red"}] },
{ "texts": [{"string": "font_color", "font_color": "#0F0"}] },

"background_image": (string)

You can use it in conjunction with the background color.

"background_color": (string)

You can use a hexadecimal format or a string format like "red", "blue".

"background_color": "white" "background_color": "#4682B4"
    {
      "background_color": "white",
      "texts": [
        {"string": "background_color", "font_height": 40, "avoid_clipping": true}
      ]
    },
    {
      "background_color": "#4682B4",
      "texts": [
        {"string": "background_color", "font_height": 40, "avoid_clipping": true}
      ]
    }

"shadow": (px)

If not zero, it will project a shadow to the bottom-right part.

"shadow": 0 "shadow": 5 "shadow": 10
--
{"texts": [{"string": "shadow", "shadow": 0}]},
{"texts": [{"string": "shadow", "shadow": 3}]},
{"texts": [{"string": "shadow", "shadow": 10}]},

"rotation": (degrees)

(numeric, degrees): If you need to rotate the image for whatever reason

{"texts": [{"string": "rotation", "rotation": 45}]},

  • "border_width": (px) (Only cards) Define a border width for the card.

"border_color": (px)

(Only cards) Define the color of the border.

"x_shift": (px)

Displace the image in the x axis (left or right).

"x_shift": 0 "x_shift": 70
    {"texts": [{"string": "x_shift", "x_shift": 0, "font_height": 60}]},
    {"texts": [{"string": "x_shift", "x_shift": 70, "font_height": 60}]},

"y_shift": (px)

Displace the image in the y axis (up or down).

"y_shift": 0 "y_shift": 70
    {"texts": [{"string": "y_shift", "y_shift": 0, "font_height": 60}]},
    {"texts": [{"string": "y_shift", "y_shift": -70, "font_height": 60}]},

multiplier: (numeric)

On cards or counters, define the number of "clones".

stroke_width: (px)

On fonts, it defines the stroke width.

"stroke_width": -1 "stroke_width": 5 "stroke_width": 10
    {"texts": [{"string": "stroke_width", "stroke_width": -1, "font_height": 50}]},
    {"texts": [{"string": "stroke_width", "stroke_width": 5, "font_height": 50}]},
    {"texts": [{"string": "stroke_width", "stroke_width": 15, "font_height": 50}]},

"stroke_color": (string)

On fonts, it defines the stroke color.

"stroke_color": "red" "stroke_color": "#00F"
    {"texts": [{"string": "stroke_color", "stroke_color": "red", "font_height": 50}]},
    {"texts": [{"string": "stroke_color", "stroke_color": "blue", "font_height": 50}]},

"alignment": (string)

Helps in aligning the image: use center, right or left.

"image_scaling": (string)

On images, it defines the way to scale it. fitWidth, wrap or fitHeight

"avoid_clipping": (boolean)

On fonts, it helps with some fonts that have too little space. If you see problems in some font when using long texts, try to set this to true to see if it helps.

    {"texts": [{"string": "avoid _ clipping", "avoid_clipping": true, "font_height": 70}]},
  • position (numeric from 0 to 16): A position in the card/counter. Starting in the top-left corner having "Position" 1 and moving clockwise, each side in a counter or card has 5 positions. For example the top border is: 1 left, 2 left-center, 3 center, 4 right-center and 5 right. The same in top down: 5 top (right), 6 top-middle, 7 middle, 8 bottom-middle, 9 bottom.
"position": 13 The 17 possible positions
    {"texts": [
      {"string": "0", "font_height":30, "stroke_width":3},
      {"position": 1, "string": "1", "font_height":30, "stroke_width":3},
      {"position": 2, "string": "2", "font_height":30, "stroke_width":3},
      {"position": 3, "string": "3", "font_height":30, "stroke_width":3},
      {"position": 4, "string": "4", "font_height":30, "stroke_width":3},
      {"position": 5, "string": "5", "font_height":30, "stroke_width":3},
      {"position": 6, "string": "6", "font_height":30, "stroke_width":3},
      {"position": 7, "string": "7", "font_height":30, "stroke_width":3},
      {"position": 8, "string": "8", "font_height":30, "stroke_width":3},
      {"position": 9, "string": "9", "font_height":30, "stroke_width":3},
      {"position": 10, "string": "10", "font_height":30, "stroke_width":3},
      {"position": 11, "string": "11", "font_height":30, "stroke_width":3},
      {"position": 12, "string": "12", "font_height":30, "stroke_width":3},
      {"position": 13, "string": "13", "font_height":30, "stroke_width":3},
      {"position": 14, "string": "14", "font_height":30, "stroke_width":3},
      {"position": 15, "string": "15", "font_height":30, "stroke_width":3},
      {"position": 16, "string": "16", "font_height":30, "stroke_width":3}
    ]},
    {"texts": [{"position": 13, "string": "position", "font_height": 40, "stroke_width":3}]},
  • skip_borders: Borders can be skipped, it is useful sometimes when wanting to know exactly how an entity will look into the counter or card.

  • scaling: (decimal): A scaling factor for the entire counter. All values in settings, font size, margins, stroke widths, etc. will be scaled appropriately. Use this when you have a working template with some values but you need it 1.5 bigger or smaller. Instead of "redrawing" every value and image one by one, just use scaling and let the magic happens. This is useful for example to create you counters ready for printing, but then you can scale them down and make them smaller for Vassal.

Cards template

A card template is used to generate cards using a JSON file. The possible configuration is the following:

  • settings: All the fields defined above.
  • rows (integer): Number of rows of cards/counters.
  • columns (integer): Number of columns of cards/counters.
  • draw_guides (boolean): Helpful guides while development.
  • mode: 2 possible modes: tiles or template. Template will render a single file for every card. Tiles will use the rows and columns to group cards into a single page.
  • output_path (string): The file destination in case of using tiles mode. At the moment, the filename must contain %d somewhere. This is the placeholder for the page number. For example, if you generate 18 cards on 2 sheets of 9 and 9 cards each, you can use this filename mycards_%d.png and it will generate two files: mycards_1.png and mycards_2.png.
  • extra: See below.
Extra
  • faction_image:
  • faction_image_scale:
  • back_image:
Card
  • settings: See above.
  • areas: A card is composed of 1 or more areas. Each area is effectively a "counter" and contains all the properties and settings of a single counter.
  • texts: A card, by itself, is also a "counter". In this sense you can also use it to establish some things at the card level. For example, a consistent border line around the entire card.
  • images: Images to use at the card level, mostly useful to establish a background image pattern for the entire card.
Areas

Each area behaves like a single counter. For example, a Magic The Gathering card has, essentially, 2 areas: an upper area for the creature / land drawing and a lower area for the text and flavour.

In the following example we can see 3 cards:

  • The first one is a card with a single area, placed at the left of the image with the text "AREA_1" on it.
  • The second is a card with two areas of the same size: This is the card in the middle, with the text "AREA_1" definining the upper area and the text "AREA_2" defining the lower part.
  • A third card is at the right of the image, it has 3 areas: the upper one has a blue background color. Because it is like a counter, it has the text placed in Position 13 of the area (see above for description about the "position" property). A second area named "AREA_2" has been defined with a height of 300 pixels. The third area "AREA_3" takes the remaining space.

The JSON that generated this image is the following:

{
  "rows": 1,
  "columns": 3,
  "width": 300,
  "height": 500,
  "mode": "tiles",
  "output_path": "docs/cards_%02d.png",
  "border_color": "black",
  "border_width": 1,
  "cards": [
    { "areas": [{ "texts": [{ "string": "area_1" }] }] },
    {
      "areas": [
        { "texts": [{ "string": "area_1" }] },
        { "texts": [{ "string": "area_2" }] }
      ]
    },
    {
      "areas": [
        {
          "background_color": "#4682B4",
          "texts": [{ "string": "area_1", "position": 13 }]
        },
        { "height": 300, "texts": [{ "string": "area_2" }] },
        { "texts": [{ "string": "area_3" }] }
      ]
    }
  ]
}

Important: The number of items inside the cards array must match the result of multiplying the numbers in rows and columns. In the example above, the array has 3 items which is the result of multiplying 3 columns by 1 row.

  • settings: See above.
  • single_step (bool): When set to true, the back of a counter won't be printed.
  • frame (bool): TODO, no idea.
  • images (list of images):
  • texts: See above.
  • extra: See above.
Texts
  • string: The text itself.
  • underline:
Image
  • path:
  • scale:
  • avoid_cropping:

Tutorials

Counters

Generate a series of counters using a prototype

In this example we will generate a series of counters using a prototype. The prototype is a JSON file that defines the CounterTemplate. The template must contain a special object: prototypes. Each object in the special object is a prototype. The key is the name of the prototype and the value is a Counter object. The Counter object is the same as the one you can find in counters inside a CounterTemplate. The objects found in the prototype will be generated in the counters array of the CounterTemplate. Use the parameter multiplier on the prototype to generate more than one object in counters. Once executed, it will generate a json file to edit and use more generally.

An example prototype can look like the following:

{
  "rows": 7,
  "columns": 7,
  "width": 82,
  "height": 82,
  "font_height": 35,
  "margins": 2,
  "font_color": "black",
  "background_color": "#62929E",
  "mode": "template",
  "output_folder": "my-output-folder",
  "draw_guides": false,
  "stroke_width": -1,
  "stroke_color": "black",
  "image_scaling": "fitWidth",
  "index_number_for_filename": 3,
  "font_path": "assets/font-bebas.ttf",
  "counters": [],
  "prototypes": {
    "default": {
      "multiplier": 2,
      "texts": [
        {
          "position": 3,
          "string": "Proto",
          "font_color": "white",
          "font_height": 20,
          "avoid_clipping": true
        },
        {
          "position": 10,
          "string": "3-8",
          "avoid_clipping": true
        },
        {
          "string": "HQ",
          "font_color": "white",
          "stroke_width": 3,
          "font_height": 30,
          "y_shift": -5,
          "position": 7,
          "avoid_clipping": true
        }
      ],
      "images": [
        {
          "path": "assets/hd12.png",
          "y_shift": -32,
          "image_scaling": "fitWidth"
        }
      ]
    }
  }
}

An example command to achieve this is the following:

counters json -i my_prototype.json -o my_counters.json --output-type counters

At the output you'll get looks like this:

{
  "rows": 7,
  "columns": 7,
  "width": 82,
  "height": 82,
  "font_height": 35,
  "margins": 2,
  "font_color": "black",
  "background_color": "#62929E",
  "mode": "template",
  "output_folder": "my-output-folder",
  "draw_guides": false,
  "stroke_width": -1,
  "stroke_color": "black",
  "image_scaling": "fitWidth",
  "index_number_for_filename": 3,
  "font_path": "assets/font-bebas.ttf",
  "counters": [
    {
      "multiplier": 2,
      "texts": [
        {
          "position": 3,
          "string": "Proto",
          "font_color": "white",
          "font_height": 20,
          "avoid_clipping": true
        },
        {
          "position": 10,
          "string": "3-8",
          "avoid_clipping": true
        },
        {
          "string": "HQ",
          "font_color": "white",
          "stroke_width": 3,
          "font_height": 30,
          "y_shift": -5,
          "position": 7,
          "avoid_clipping": true
        }
      ],
      "images": [
        {
          "path": "assets/hd12.png",
          "y_shift": -32,
          "image_scaling": "fitWidth"
        }
      ]
    },
    {
      "multiplier": 2,
      "texts": [
        {
          "position": 3,
          "string": "Proto",
          "font_color": "white",
          "font_height": 20,
          "avoid_clipping": true
        },
        {
          "position": 10,
          "string": "3-8",
          "avoid_clipping": true
        },
        {
          "string": "HQ",
          "font_color": "white",
          "stroke_width": 3,
          "font_height": 30,
          "y_shift": -5,
          "position": 7,
          "avoid_clipping": true
        }
      ],
      "images": [
        {
          "path": "assets/hd12.png",
          "y_shift": -32,
          "image_scaling": "fitWidth"
        }
      ]
    }
  ]
}

Documentation

Index

Constants

View Source
const (
	DEFAULT_FONT_HEIGHT = 15.0

	DEFAULT_MARGINS_DISTANCE = 10

	DEFAULT_COUNTER_WIDTH  = 200.0
	DEFAULT_COUNTER_HEIGHT = 200.0

	DEFAULT_MODE = "tiles"

	TEMPLATE_MODE_TILES    = "tiles"
	TEMPLATE_MODE_TEMPLATE = "template"

	DEFAULT_FONT_COLOR       string = "black"
	DEFAULT_BACKGROUND_COLOR string = "white"

	CARD_AREA_FRAME_WIDTH = 4

	DEFAULT_CARD_MARGINS_DISTANCE  = 10
	DEFAULT_IMAGE_MARGINS_DISTANCE = 10
	DEFAULT_TEXT_BOX_MARGINS       = 10

	DEFAULT_IMAGE_WIDTH  = 800.0
	DEFAULT_IMAGE_HEIGHT = 1200.0

	DEFAULT_BORDER_WIDTH = 20
	DEFAULT_BORDER_COLOR = "white"

	IMAGE_SCALING_FIT_NONE   = "none"
	IMAGE_SCALING_FIT_WIDTH  = "fitWidth"
	IMAGE_SCALING_FIT_HEIGHT = "fitHeight"
	IMAGE_SCALING_FIT_WRAP   = "wrap"

	ALIGMENT_LEFT   = "left"
	ALIGMENT_RIGHT  = "right"
	ALIGMENT_CENTER = "center"

	BASE_FOLDER = "TemplateModule"

	STRIPE              = "assets/stripe.png"
	VassalInputXmlFile  = "template.xml"
	VassalOutputXmlFile = BASE_FOLDER + "/buildFile.xml"
)
View Source
const (
	FileContent_CounterTemplate = iota
	FileContent_CardTemplate
	FileContent_Events
	FileContent_Quotes
	FileContent_CSV
	FileContent_JSON
)
View Source
const (
	// Template_VassalPiece           = `+/null/prototype;UnitStep	prototype;RU\	emb2;Activate;128;A;;128;;;128;;;;1;false;0;0;{{ .FrontFilename }},{{ .BackFilename }};,;false;{{ .PieceName }};;;true;StepValue;1;1;true;65,130;;;;1.0;;true\\	piece;;;{{ .FrontFilename }};{{ .Id }}/	\	1\\	null;0;0;398;0`
	Template_NewVassalPiece = `` /* 247-byte string literal not displayed */

)

Variables

This section is empty.

Functions

func ColorFromStringOrDefault

func ColorFromStringOrDefault(s string, d color.Color) color.Color

func CropToContent

func CropToContent(i image.Image) image.Image

func DrawGuides

func DrawGuides(s *Settings) (*image.Image, error)

func Merge

func Merge(d *Settings, s2 Settings, opt ...func(*mergo.Config)) error

func Mergev2

func Mergev2(d *Settings, s *Settings) error

func SetColors

func SetColors(s *Settings)

func TestImageContent

func TestImageContent(t *testing.T, expectedImagePath string, expectedImageLength int, canvas *gg.Context)

func ValidateSchemaAtPath

func ValidateSchemaAtPath[S CounterTemplate | CardsTemplate](inputPath string) error

func ValidateSchemaBytes

func ValidateSchemaBytes[S CounterTemplate | CardsTemplate](docByt []byte) error

func ValidateSchemaReader

func ValidateSchemaReader[S CounterTemplate | CardsTemplate](r io.Reader) error

Types

type Board

type Board struct {
	Text       string  `xml:",chardata"`
	Image      string  `xml:"image,attr"`
	Name       string  `xml:"name,attr"`
	Reversible string  `xml:"reversible,attr"`
	HexGrid    HexGrid `xml:"VASSAL.build.module.map.boardPicker.board.HexGrid"`
}

type BoardPicker

type BoardPicker struct {
	XMLName       xml.Name `xml:"VASSAL.build.module.map.BoardPicker"`
	Text          string   `xml:",chardata"`
	AddColumnText string   `xml:"addColumnText,attr"`
	AddRowText    string   `xml:"addRowText,attr"`
	BoardPrompt   string   `xml:"boardPrompt,attr"`
	SlotHeight    string   `xml:"slotHeight,attr"`
	SlotScale     string   `xml:"slotScale,attr"`
	SlotWidth     string   `xml:"slotWidth,attr"`
	Title         string   `xml:"title,attr"`
	Board         Board    `xml:"VASSAL.build.module.map.boardPicker.Board"`
}

type CSVTemplateData

type CSVTemplateData struct {
	Filename  string
	PieceName string
	Id        string
}

type Card

type Card struct {
	Settings
	Areas  []Counter `json:"areas,omitempty"`
	Texts  Texts     `json:"texts,omitempty"`
	Images Images    `json:"images,omitempty"`
}

func (*Card) EncodeImage

func (c *Card) EncodeImage(w io.Writer, t *CardsTemplate) error

func (*Card) GetAreasHeights

func (c *Card) GetAreasHeights() (hs []float64)

func (*Card) Image

func (c *Card) Image(template *CardsTemplate) (image.Image, error)

func (*Card) ProcessAreav2

func (c *Card) ProcessAreav2(area *Counter, t *CardsTemplate, calculatedAreaHeight int, isLastArea bool) (*gg.Context, error)

func (*Card) ToCanvas

func (c *Card) ToCanvas(template *CardsTemplate) (*gg.Context, error)

type CardTransformer

type CardTransformer interface {
	ToNewCard(c *Card, sourceTemplate *CardsTemplate) (*Card, error)
}

type CardsExtra

type CardsExtra struct {
	FactionImage      string  `json:"faction_image,omitempty"`
	FactionImageScale float64 `json:"faction_image_scale,omitempty"`
	BackImage         string  `json:"back_image,omitempty"`
}

CardsExtra is a container for extra information used in different projects but that they are not common to all of them

type CardsTemplate

type CardsTemplate struct {
	Settings

	Rows    int `json:"rows,omitempty" default:"8"`
	Columns int `json:"columns,omitempty" default:"5"`

	DrawGuides bool `json:"draw_guides,omitempty"`

	// TODO is this field still used? Mode can be 'tiles' or 'template' to generate an A4 sheet
	// like of cards or a single file per card.
	Mode string `json:"mode,omitempty" default:"tiles"`

	// TODO Rename this to OutputFolder or the one in counters to OutputPath and update JSON's
	OutputPath string `json:"output_path,omitempty" default:"output_%02d"`

	Scaling float64 `json:"scaling,omitempty" default:"1.0"`

	Cards           []Card `json:"cards"`
	MaxCardsPerFile int    `json:"max_cards_per_file,omitempty"`

	Extra CardsExtra `json:",omitempty"`
}

CardsTemplate is the template sheet (usually A4) to place cards on top in grid fashion

func ParseCardTemplate

func ParseCardTemplate(byt []byte) (*CardsTemplate, error)

func (*CardsTemplate) ApplyCardWaterfallSettings

func (t *CardsTemplate) ApplyCardWaterfallSettings() error

ApplyCardWaterfallSettings traverses the cards in the template applying the default settings to value that are zero-valued

func (*CardsTemplate) Canvas

func (t *CardsTemplate) Canvas(settings *Settings, width, height int) (*gg.Context, error)

Canvas returns a Canvas with attributes (like background color or size) taken from `settings`

func (*CardsTemplate) SheetCanvas

func (t *CardsTemplate) SheetCanvas() (*gg.Context, error)

type Counter

type Counter struct {
	Settings

	SingleStep bool `json:"single_step,omitempty"`
	Frame      bool `json:"frame,omitempty"`

	Images Images `json:"images,omitempty"`
	Texts  Texts  `json:"texts,omitempty"`
	Extra  *Extra `json:"extra,omitempty"`

	// Generate the following counter with 'back' suffix in its filename
	Back *Counter `json:"back,omitempty"`

	Filename      string     `json:"filename,omitempty"`
	PrototypeName string     `json:"-"`
	VassalPiece   *PieceSlot `json:"vassal,omitempty"`
}

Counter is POGO-like holder for data needed for other parts to fill and draw a counter in a container

func (*Counter) Canvas

func (c *Counter) Canvas(withGuides bool) (*gg.Context, error)

func (*Counter) EncodeCounter

func (c *Counter) EncodeCounter(w io.Writer, drawGuides bool) error

func (*Counter) GenerateCounterFilename

func (c *Counter) GenerateCounterFilename(sideName string, position int, filenamesInUse *sync.Map)

filenumber: CounterTemplate.PositionNumberForFilename. So it will always be fixed number position: The position of the text in the counter (0-16) suffix: A suffix on the file. Constant

func (*Counter) GetTextInPosition

func (c *Counter) GetTextInPosition(i int) string

func (*Counter) ToVassal

func (c *Counter) ToVassal(sideName string) error

type CounterPrototype

type CounterPrototype struct {
	Counter
	ImagePrototypes []ImagePrototype  `json:"image_prototypes,omitempty"`
	TextPrototypes  []TextPrototype   `json:"text_prototypes,omitempty"`
	Back            *CounterPrototype `json:"back,omitempty"`
}

func (*CounterPrototype) ToCounters

func (p *CounterPrototype) ToCounters(filenamesInUse *sync.Map, sideName, prototypeName string, positionNumberForFilename int) ([]Counter, error)

type CounterTemplate

type CounterTemplate struct {
	Settings

	Rows    int `` /* 136-byte string literal not displayed */
	Columns int `` /* 142-byte string literal not displayed */

	DrawGuides       bool                          `json:"draw_guides,omitempty"`
	Mode             string                        `json:"mode"`
	OutputFolder     string                        `json:"output_folder" default:"output"`
	Scaling          *float64                      `json:"scaling,omitempty"`
	Vassal           VassalCounterTemplateSettings `json:"vassal,omitempty"`
	WorkingDirectory string                        `json:"working_directory,omitempty"`

	// 0-16 Specify an position in the counter to use when writing a different file
	PositionNumberForFilename int `json:"position_number_for_filename,omitempty"`

	Counters   []Counter                   `json:"counters,omitempty"`
	Prototypes map[string]CounterPrototype `json:"prototypes,omitempty"`
}

func ParseCounterTemplate

func ParseCounterTemplate(byt []byte, filenamesInUse *sync.Map) (t *CounterTemplate, err error)

ParseCounterTemplate reads a JSON file and parses it into a CounterTemplate after applying it some default settings (if not present in the file)

func (*CounterTemplate) ApplyCounterWaterfallSettings

func (t *CounterTemplate) ApplyCounterWaterfallSettings() error

func (*CounterTemplate) EnrichTemplate

func (t *CounterTemplate) EnrichTemplate() error

func (*CounterTemplate) ExpandPrototypeCounterTemplate

func (t *CounterTemplate) ExpandPrototypeCounterTemplate(filenamesInUse *sync.Map) (*CounterTemplate, error)

func (*CounterTemplate) ParsePrototype

func (t *CounterTemplate) ParsePrototype() (*CounterTemplate, error)

type CounterToCardTransformer

type CounterToCardTransformer interface {
	ToNewCard(c *Counter, sourceTemplate *CardsTemplate) (*Card, error)
}

type CounterTransfomer

type CounterTransfomer interface {
	ToNewCounter(c *Counter) (*Counter, error)
}

type Counters

type Counters []Counter

type DiceButton

type DiceButton struct {
	XMLName xml.Name `xml:"VASSAL.build.module.DiceButton"`

	Raw          string `xml:",innerxml"`
	AddToTotal   int    `xml:"addToTotal,attr"`
	CanDisable   bool   `xml:"canDisable,attr"`
	DisabledIcon string `xml:"disabledIcon,attr"`
	Hotkey       string `xml:"hotkey,attr"`
	Icon         string `xml:"icon,attr"`
	KeepCount    string `xml:"keepCount,attr"`
	KeepDice     string `xml:"keepDice,attr"`
	KeepOption   string `xml:"keepOption,attr"`
	LockAdd      string `xml:"lockAdd,attr"`
	LockDice     string `xml:"lockDice,attr"`
	LockPlus     string `xml:"lockPlus,attr"`
	LockSides    string `xml:"lockSides,attr"`
	NDice        string `xml:"nDice,attr"`
	NSides       string `xml:"nSides,attr"`
	Name         string `xml:"name,attr"`
	Plus         string `xml:"plus,attr"`
	Prompt       string `xml:"prompt,attr"`
	PropertyGate string `xml:"propertyGate,attr"`
	ReportFormat string `xml:"reportFormat,attr"`
	ReportTotal  string `xml:"reportTotal,attr"`
	SortDice     string `xml:"sortDice,attr"`
	Text         string `xml:"text,attr"`
	Tooltip      string `xml:"tooltip,attr"`
}

type Event

type Event struct {
	Desc        string `json:"desc"`
	Title       string `json:"title"`
	InsertQuote bool   `json:"insert_quote"`
	Image       string `json:"image"`
}

type Extra

type Extra struct {
	// PublicIcon in a FOW counter is the visible icon for the enemy. Imagine an icon for the back
	// of a block in a Columbia game
	CardImage          *Image `json:"card_image,omitempty"`
	Cost               int    `json:"cost,omitempty"`
	PublicIcon         *Image `json:"public_icon,omitempty"`
	Side               string `json:"side,omitempty"`
	SkipCardGeneration bool   `json:"skip_card_generation,omitempty"`
	Title              string `json:"title,omitempty"`
	TitlePosition      *int   `json:"title_position,omitempty"`
}

TODO This Extra contains data from all projects

type FileContent

type FileContent int

type HexGrid

type HexGrid struct {
	XMLName xml.Name `xml:"VASSAL.build.module.map.boardPicker.board.HexGrid" json:"-"`

	Text         string `xml:",chardata" json:"text,omitempty"`
	Color        string `xml:"color,attr" json:"color,omitempty"`
	CornersLegal string `xml:"cornersLegal,attr" json:"cornersLegal,omitempty"`
	DotsVisible  string `xml:"dotsVisible,attr" json:"dotsVisible,omitempty"`
	Dx           string `xml:"dx,attr" json:"dx,omitempty"`
	Dy           string `xml:"dy,attr" json:"dy,omitempty"`
	EdgesLegal   string `xml:"edgesLegal,attr" json:"edgesLegal,omitempty"`
	Sideways     string `xml:"sideways,attr" json:"sideways,omitempty"`
	SnapTo       string `xml:"snapTo,attr" json:"snapTo,omitempty"`
	Visible      string `xml:"visible,attr" json:"visible,omitempty"`
	X0           string `xml:"x0,attr" json:"x0,omitempty"`
	Y0           string `xml:"y0,attr" json:"y0,omitempty"`
}

type Image

type Image struct {
	Settings
	Positioner

	Path          string  `json:"path,omitempty"`
	Scale         float64 `json:"scale,omitempty"`
	AvoidCropping bool    `json:"avoid_cropping,omitempty"`
}

func (*Image) Draw

func (i *Image) Draw(dc *gg.Context, pos int) error

func (Image) GetSettings

func (i Image) GetSettings() *Settings

type ImageExtraData

type ImageExtraData struct {
	// the path to find the image file
	Path string `json:"path,omitempty"`

	// a percentage of original image's size
	Scale float64 `json:"scale,omitempty"`

	// none, fitHeight, fitWidth or wrap
	ImageScaling string `json:"image_scaling,omitempty"`
}

type ImagePrototype

type ImagePrototype struct {
	Image
	PathList []string `json:"path_list"`
}

type Images

type Images []Image

func (Images) DrawImagesOnCanvas

func (images Images) DrawImagesOnCanvas(s *Settings, areaCanvas *gg.Context, w, h int) error

DrawImagesOnCanvas using the provided height `h` and width `w`

type ListWidget

type ListWidget struct {
	XMLName xml.Name `xml:"VASSAL.build.widget.ListWidget"`

	Divider   string `xml:"divider,attr"`
	EntryName string `xml:"entryName,attr"`
	Height    string `xml:"height,attr"`
	Scale     string `xml:"scale,attr"`
	Width     string `xml:"width,attr"`
	PieceSlot PieceSlots
}

type Map

type Map struct {
	XMLName xml.Name `xml:"VASSAL.build.module.Map"`

	BoardPicker               BoardPicker `xml:"VASSAL.build.module.map.BoardPicker"`
	Text                      string      `xml:",chardata"`
	AllowMultiple             string      `xml:"allowMultiple,attr"`
	Backgroundcolor           string      `xml:"backgroundcolor,attr"`
	ButtonName                string      `xml:"buttonName,attr"`
	ChangeFormat              string      `xml:"changeFormat,attr"`
	Color                     string      `xml:"color,attr"`
	CreateFormat              string      `xml:"createFormat,attr"`
	EdgeHeight                string      `xml:"edgeHeight,attr"`
	EdgeWidth                 string      `xml:"edgeWidth,attr"`
	HideKey                   string      `xml:"hideKey,attr"`
	Hotkey                    string      `xml:"hotkey,attr"`
	Icon                      string      `xml:"icon,attr"`
	Launch                    string      `xml:"launch,attr"`
	MapName                   string      `xml:"mapName,attr"`
	MarkMoved                 string      `xml:"markMoved,attr"`
	MarkUnmovedHotkey         string      `xml:"markUnmovedHotkey,attr"`
	MarkUnmovedIcon           string      `xml:"markUnmovedIcon,attr"`
	MarkUnmovedReport         string      `xml:"markUnmovedReport,attr"`
	MarkUnmovedText           string      `xml:"markUnmovedText,attr"`
	MarkUnmovedTooltip        string      `xml:"markUnmovedTooltip,attr"`
	MoveKey                   string      `xml:"moveKey,attr"`
	MoveToFormat              string      `xml:"moveToFormat,attr"`
	MoveWithinFormat          string      `xml:"moveWithinFormat,attr"`
	OnlyReportChangedLocation string      `xml:"onlyReportChangedLocation,attr"`
	ShowKey                   string      `xml:"showKey,attr"`
	Thickness                 string      `xml:"thickness,attr"`
	StackMetrics              struct {
		Text     string `xml:",chardata"`
		Bottom   string `xml:"bottom,attr"`
		Disabled string `xml:"disabled,attr"`
		Down     string `xml:"down,attr"`
		ExSepX   string `xml:"exSepX,attr"`
		ExSepY   string `xml:"exSepY,attr"`
		Top      string `xml:"top,attr"`
		UnexSepX string `xml:"unexSepX,attr"`
		UnexSepY string `xml:"unexSepY,attr"`
		Up       string `xml:"up,attr"`
	} `xml:"VASSAL.build.module.map.StackMetrics"`
	ForwardToKeyBuffer string `xml:"VASSAL.build.module.map.ForwardToKeyBuffer"`
	Scroller           string `xml:"VASSAL.build.module.map.Scroller"`
	ForwardToChatter   string `xml:"VASSAL.build.module.map.ForwardToChatter"`
	MenuDisplayer      string `xml:"VASSAL.build.module.map.MenuDisplayer"`
	MapCenterer        string `xml:"VASSAL.build.module.map.MapCenterer"`
	StackExpander      string `xml:"VASSAL.build.module.map.StackExpander"`
	PieceMover         string `xml:"VASSAL.build.module.map.PieceMover"`
	KeyBufferer        string `xml:"VASSAL.build.module.map.KeyBufferer"`
	ImageSaver         struct {
		Text             string `xml:",chardata"`
		ButtonText       string `xml:"buttonText,attr"`
		CanDisable       string `xml:"canDisable,attr"`
		DisabledIcon     string `xml:"disabledIcon,attr"`
		HideWhenDisabled string `xml:"hideWhenDisabled,attr"`
		Hotkey           string `xml:"hotkey,attr"`
		Icon             string `xml:"icon,attr"`
		PropertyGate     string `xml:"propertyGate,attr"`
		Tooltip          string `xml:"tooltip,attr"`
	} `xml:"VASSAL.build.module.map.ImageSaver"`
	CounterDetailViewer struct {
		Text                   string `xml:",chardata"`
		BgColor                string `xml:"bgColor,attr"`
		BorderColor            string `xml:"borderColor,attr"`
		BorderInnerThickness   string `xml:"borderInnerThickness,attr"`
		BorderThickness        string `xml:"borderThickness,attr"`
		BorderWidth            string `xml:"borderWidth,attr"`
		CenterAll              string `xml:"centerAll,attr"`
		CenterPiecesVertically string `xml:"centerPiecesVertically,attr"`
		CenterText             string `xml:"centerText,attr"`
		CombineCounterSummary  string `xml:"combineCounterSummary,attr"`
		CounterReportFormat    string `xml:"counterReportFormat,attr"`
		Delay                  string `xml:"delay,attr"`
		Description            string `xml:"description,attr"`
		Display                string `xml:"display,attr"`
		EmptyHexReportForma    string `xml:"emptyHexReportForma,attr"`
		EnableHTML             string `xml:"enableHTML,attr"`
		ExtraTextPadding       string `xml:"extraTextPadding,attr"`
		FgColor                string `xml:"fgColor,attr"`
		FontSize               string `xml:"fontSize,attr"`
		GraphicsZoom           string `xml:"graphicsZoom,attr"`
		Hotkey                 string `xml:"hotkey,attr"`
		LayerList              string `xml:"layerList,attr"`
		MinDisplayPieces       string `xml:"minDisplayPieces,attr"`
		OnlyShowFirstSummary   string `xml:"onlyShowFirstSummary,attr"`
		PropertyFilter         string `xml:"propertyFilter,attr"`
		ShowDeck               string `xml:"showDeck,attr"`
		ShowDeckDepth          string `xml:"showDeckDepth,attr"`
		ShowDeckMasked         string `xml:"showDeckMasked,attr"`
		ShowMoveSelectde       string `xml:"showMoveSelectde,attr"`
		ShowNoStack            string `xml:"showNoStack,attr"`
		ShowNonMovable         string `xml:"showNonMovable,attr"`
		ShowOnlyTopOfStack     string `xml:"showOnlyTopOfStack,attr"`
		ShowOverlap            string `xml:"showOverlap,attr"`
		ShowTerrainBeneath     string `xml:"showTerrainBeneath,attr"`
		ShowTerrainHeight      string `xml:"showTerrainHeight,attr"`
		ShowTerrainSnappy      string `xml:"showTerrainSnappy,attr"`
		ShowTerrainText        string `xml:"showTerrainText,attr"`
		ShowTerrainWidth       string `xml:"showTerrainWidth,attr"`
		ShowTerrainZoom        string `xml:"showTerrainZoom,attr"`
		Showgraph              string `xml:"showgraph,attr"`
		Showgraphsingle        string `xml:"showgraphsingle,attr"`
		Showtext               string `xml:"showtext,attr"`
		Showtextsingle         string `xml:"showtextsingle,attr"`
		StopAfterShowing       string `xml:"stopAfterShowing,attr"`
		StretchWidthPieces     string `xml:"stretchWidthPieces,attr"`
		StretchWidthSummary    string `xml:"stretchWidthSummary,attr"`
		SummaryReportFormat    string `xml:"summaryReportFormat,attr"`
		UnrotatePieces         string `xml:"unrotatePieces,attr"`
		Version                string `xml:"version,attr"`
		VerticalBottomText     string `xml:"verticalBottomText,attr"`
		VerticalOffset         string `xml:"verticalOffset,attr"`
		VerticalTopText        string `xml:"verticalTopText,attr"`
		Zoomlevel              string `xml:"zoomlevel,attr"`
	} `xml:"VASSAL.build.module.map.CounterDetailViewer"`
	Flare struct {
		Text              string `xml:",chardata"`
		CircleColor       string `xml:"circleColor,attr"`
		CircleScale       string `xml:"circleScale,attr"`
		CircleSize        string `xml:"circleSize,attr"`
		FlareKey          string `xml:"flareKey,attr"`
		FlareName         string `xml:"flareName,attr"`
		FlarePulses       string `xml:"flarePulses,attr"`
		FlarePulsesPerSec string `xml:"flarePulsesPerSec,attr"`
		ReportFormat      string `xml:"reportFormat,attr"`
	} `xml:"VASSAL.build.module.map.Flare"`
	Zoomer struct {
		Text           string `xml:",chardata"`
		InButtonText   string `xml:"inButtonText,attr"`
		InIconName     string `xml:"inIconName,attr"`
		InTooltip      string `xml:"inTooltip,attr"`
		OutButtonText  string `xml:"outButtonText,attr"`
		OutIconName    string `xml:"outIconName,attr"`
		OutTooltip     string `xml:"outTooltip,attr"`
		PickButtonText string `xml:"pickButtonText,attr"`
		PickIconName   string `xml:"pickIconName,attr"`
		PickTooltip    string `xml:"pickTooltip,attr"`
		ZoomInKey      string `xml:"zoomInKey,attr"`
		ZoomLevels     string `xml:"zoomLevels,attr"`
		ZoomOutKey     string `xml:"zoomOutKey,attr"`
		ZoomPickKey    string `xml:"zoomPickKey,attr"`
		ZoomStart      string `xml:"zoomStart,attr"`
	} `xml:"VASSAL.build.module.map.Zoomer"`
	VASSALBuildModulePropertiesGlobalProperties string `xml:"VASSAL.build.module.properties.GlobalProperties"`
	VASSALBuildModuleMapSelectionHighlighters   string `xml:"VASSAL.build.module.map.SelectionHighlighters"`
	HighlightLastMoved                          struct {
		Text      string `xml:",chardata"`
		Color     string `xml:"color,attr"`
		Enabled   string `xml:"enabled,attr"`
		Thickness string `xml:"thickness,attr"`
	} `xml:"VASSAL.build.module.map.HighlightLastMoved"`
	HidePiecesButton struct {
		Text        string `xml:",chardata"`
		ButtonText  string `xml:"buttonText,attr"`
		HiddenIcon  string `xml:"hiddenIcon,attr"`
		Hotkey      string `xml:"hotkey,attr"`
		ShowingIcon string `xml:"showingIcon,attr"`
		Tooltip     string `xml:"tooltip,attr"`
	} `xml:"VASSAL.build.module.map.HidePiecesButton"`
}

type PanelWidget

type PanelWidget struct {
	XMLName xml.Name `xml:"VASSAL.build.widget.PanelWidget"`

	Text       string       `xml:",chardata"`
	EntryName  string       `xml:"entryName,attr"`
	Fixed      string       `xml:"fixed,attr"`
	NColumns   string       `xml:"nColumns,attr"`
	Scale      string       `xml:"scale,attr"`
	Vert       string       `xml:"vert,attr"`
	ListWidget []ListWidget `xml:"VASSAL.build.widget.ListWidget"`
}

type PieceSlot

type PieceSlot struct {
	XMLName xml.Name `xml:"VASSAL.build.widget.PieceSlot"`

	EntryName string `xml:"entryName,attr"`
	Gpid      string `xml:"gpid,attr"`
	Height    int    `xml:"height,attr"`
	Width     int    `xml:"width,attr"`
	Data      string `xml:",chardata"`
}

type PieceSlots

type PieceSlots []PieceSlot

func (PieceSlots) Len

func (p PieceSlots) Len() int

func (PieceSlots) Less

func (p PieceSlots) Less(i, j int) bool

func (PieceSlots) Swap

func (p PieceSlots) Swap(i, j int)

type PieceTemplateData

type PieceTemplateData struct {
	BackFilename  string
	FrontFilename string
	PieceName     string
	Id            string
	FlipName      string
}

type PieceWindow

type PieceWindow struct {
	XMLName xml.Name `xml:"VASSAL.build.module.PieceWindow"`

	DefaultWidth string `xml:"defaultWidth,attr"`
	Hidden       string `xml:"hidden,attr"`
	Hotkey       string `xml:"hotkey,attr"`
	Icon         string `xml:"icon,attr"`
	Scale        string `xml:"scale,attr"`
	Text         string `xml:"text,attr"`
	ToolTip      string `xml:"tooltip,attr"`
	TabWidget    TabWidget
}

type Positioner

type Positioner struct{}

func (*Positioner) GetAnchorPointsAndMaxWidth

func (p *Positioner) GetAnchorPointsAndMaxWidth(pos int, def *Settings) (float64, float64, float64, error)

func (*Positioner) GetXYPosition

func (p *Positioner) GetXYPosition(pos int, def *Settings) (float64, float64, error)

type Quote

type Quote struct {
	Origin string `json:"origin"`
	Quote  string `json:"quote"`
}

type Quotes

type Quotes []Quote

type Settings

type Settings struct {
	Width  int `json:"width,omitempty"`
	Height int `json:"height,omitempty"`

	Margins *float64 `json:"margins,omitempty"`

	FontHeight float64 `json:"font_height,omitempty"`
	FontPath   string  `json:"font_path,omitempty"`

	FontColorS string      `json:"font_color,omitempty"`
	FontColor  color.Color `json:"-"`

	BackgroundImage *string     `json:"background_image,omitempty"`
	BackgroundColor *string     `json:"background_color,omitempty"`
	BgColor         color.Color `json:"-"`

	ShadowDistance *int `json:"shadow,omitempty"`
	ShadowSigma    *int `json:"shadow_sigma,omitempty"`

	Rotation *float64 `json:"rotation,omitempty"`

	//CounterTemplate Card specific
	BorderWidth  *float64    `json:"border_width,omitempty"`
	BorderColorS string      `json:"border_color,omitempty"`
	BorderColor  color.Color `json:"-"`

	XShift *float64 `json:"x_shift,omitempty"`
	YShift *float64 `json:"y_shift,omitempty"`

	//Card specific
	Multiplier *int `json:"multiplier,omitempty" default:"1"`

	//Text options specific
	StrokeWidth  *float64    `json:"stroke_width,omitempty"`
	StrokeColorS string      `json:"stroke_color,omitempty"`
	StrokeColor  color.Color `json:"-"`
	Alignment    string      `json:"alignment,omitempty"`

	//Image options specific
	ImageScaling string `json:"image_scaling,omitempty"`

	AvoidClipping bool `json:"avoid_clipping,omitempty"`

	Position int `json:"position,omitempty"`

	Skip bool `json:"skip,omitempty"`

	BackPersistent bool `json:"back_persistent,omitempty"`

	PrettyName string `json:"pretty_name,omitempty"`
}

Template Settings

Counter / Card Settings
	Image / Text Settings

func (*Settings) ApplySettingsScaling

func (s *Settings) ApplySettingsScaling(scaling float64)

func (*Settings) DrawBackgroundImage

func (s *Settings) DrawBackgroundImage(dc *gg.Context) error

DrawBackgroundImage draws the background image, if any, on the provided context

type SettingsGetter

type SettingsGetter interface {
	GetSettings() *Settings
}

type TabWidget

type TabWidget struct {
	XMLName xml.Name `xml:"VASSAL.build.widget.TabWidget"`

	EntryName string `xml:"entryName,attr"`
	// PanelWidget PanelWidget  `xml:"VASSAL.build.widget.PanelWidget"`
	ListWidget []ListWidget `xml:"VASSAL.build.widget.ListWidget"`
}

type Text

type Text struct {
	Settings
	Positioner

	String string `json:"string,omitempty"`

	Underline bool `json:"underline,omitempty"`

	TextBackgroundColor string      `json:"text_background_color,omitempty"`
	TextBgColor         color.Color `json:"-"`
}

func (*Text) Draw

func (t *Text) Draw(dc *gg.Context, pos int, settings *Settings) error

func (*Text) GetAlignment

func (t *Text) GetAlignment() gg.Align

func (Text) GetSettings

func (t Text) GetSettings() *Settings

type TextPrototype

type TextPrototype struct {
	Text
	StringList []string `json:"string_list"`
}

type Texts

type Texts []Text

func (Texts) DrawTextsOnCanvas

func (texts Texts) DrawTextsOnCanvas(s *Settings, areaCanvas *gg.Context, w, h int) error

DrawTextsOnCanvas draws the texts provided on areaCanvas at positions `w` and `h` using the provided Settings

type VassalCounterTemplateSettings

type VassalCounterTemplateSettings struct {
	SideName   string   `json:"side_name,omitempty"`
	ModuleName string   `json:"module_name,omitempty"`
	MapFile    string   `json:"map_file,omitempty"`
	HexGrid    *HexGrid `json:"hex_grid,omitempty"`
}

type VassalFileModuleData

type VassalFileModuleData struct {
	XMLName xml.Name `xml:"data"`

	Text          string `xml:",chardata"`
	AttrVersion   string `xml:"version,attr"`
	Version       string `xml:"version"`
	Extra1        string `xml:"extra1"`
	Extra2        string `xml:"extra2"`
	VassalVersion string `xml:"VassalVersion"`
	DateSaved     string `xml:"dateSaved"`
	Description   string `xml:"description"`
	Name          string `xml:"name"`
}

type VassalGameModule

type VassalGameModule struct {
	XMLName xml.Name `xml:"VASSAL.build.GameModule"`

	ModuleOther1               string  `xml:"ModuleOther1,attr"`
	ModuleOther2               string  `xml:"ModuleOther2,attr"`
	VassalVersion              string  `xml:"VassalVersion,attr"`
	Description                string  `xml:"description,attr"`
	Name                       string  `xml:"name,attr"`
	NextPieceSlotId            string  `xml:"nextPieceSlotId,attr"`
	Version                    string  `xml:"version,attr"`
	BasicCommandEncoder        capture `xml:"VASSAL.build.module.BasicCommandEncoder"`
	Documentation              capture `xml:"VASSAL.build.module.Documentation"`
	Chatter                    capture `xml:"VASSAL.build.module.Chatter"`
	KeyNamer                   capture `xml:"VASSAL.build.module.KeyNamer"`
	PieceWindow                PieceWindow
	DiceButton                 []DiceButton `xml:"VASSAL.build.module.DiceButton"`
	PlayerRoster               capture      `xml:"VASSAL.build.module.PlayerRoster"`
	GlobalOptions              capture      `xml:"VASSAL.build.module.GlobalOptions"`
	GamePieceDefinitions       capture      `xml:"VASSAL.build.module.gamepieceimage.GamePieceImageDefinitions"`
	GlobalProperties           capture      `xml:"VASSAL.build.module.properties.GlobalProperties"`
	GlobalTranslatableMessages capture      `xml:"VASSAL.build.module.properties.GlobalTranslatableMessages"`
	PrototypesContainer        capture      `xml:"VASSAL.build.module.PrototypesContainer"`
	Language                   capture      `xml:"VASSAL.i18n.Language"`
	Map                        Map          `xml:"VASSAL.build.module.Map"`
}

Directories

Path Synopsis
Description: This file contains the logic to generate images from the JSON files.
Description: This file contains the logic to generate images from the JSON files.
templ: version: v0.2.778
templ: version: v0.2.778

Jump to

Keyboard shortcuts

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