Data type: field

--Overview--

A field is a description of a kind of 'container' to hold a value.

For example the [[type:value]] of a 'text field' is a piece of text, that of a 'color field' a [[type:color]], etc.

Things that are fields are, "card color" and "card name".
Not a particular color or name, but a description of what a card color and a card name are for a particular [[type:game]].

Fields are part of the [[file:style triangle]]:
| Description		Looks			Data
| [[type:Game]]		[[type:Stylesheet]]	[[type:Set]]
| '''Field'''		[[type:Style]]		[[type:Value]]

--Properties--
! Property		Type			Default		Description
| @type@		One of:			''required''	Type of field.
			* @text@
			* @choice@
			* @multiple choice@
			* @package choice@
			* @boolean@
			* @slider@
			* @image@
			* @symbol@
			* @color@
			* @info@
| @name@		[[type:string]]		''required''	Name of the field.
| @alt names@		[[type:list]] of [[type:string]]		 	Possible alternate names for this field, mainly to look for it when importing CSV files. They are trimmed, made case insensitive, and don't distinguish between spaces and underscores.
| @description@		[[type:localized string]]		@""@		Description of the field, shown in the status bar when the mouse is over the field.
| @icon@		[[type:filename]]	 		Filename of an icon for this field, used for automatically generated [[type:statistics category]]s.
| @editable@		[[type:boolean]]	@true@		Can values of this field be edited?
| @save value@		[[type:boolean]]	@true@		Should values of this field be saved to files? Should be disabled for values that are generated by scripts.
| @show statistics@	[[type:boolean]]	@true@		Should a [[type:statistics dimension]] and [[type:statistics category|category]] be made for this field,
			 			 		causing it to be listed on the statistics panel?
| @identifying@		[[type:boolean]]	@false@		Does this field give the name of the [[type:card]] or [[type:set]]?
| @card list column@	[[type:int]]		@0@		On what position in the card list should this field be put?
| @card list width@	[[type:int]]		@100@		Width of the card list column in pixels.
| @card list visible@	[[type:boolean]]	@false@		Should this field be shown in the card list by default?
| @card list allow@	[[type:boolean]]	@true@		Should this field be allowed in the card list at all?
| @card list name@	[[type:localized string]]		field name	Alternate name to use for the card list, for example an abbreviation.
| @card list alignment@	[[type:alignment]]	@left@		Alignment of the card list column.
| @sort script@		[[type:script]]		 		Alternate way to sort the card list when using this column to sort the list.
| @import script@		[[type:script]]		 		Script applied to the value given when creating a card with the new_card function. The script may return a map from field names to values.
			 			 		For example, the pt field should not be initialized directly, since it is a combination of the power field and toughness field.
			 			 		So if a value is given for pt, it must be redirected to power and toughness like so: {split := split_text(value, match:"/"); [power:split[0], toughness:split[1]]}.
			 			 		Use the make_map function to dynamically create maps.

The @type@ determines what values of this field contain:
! Type			Values contain								Displayed as
| @text@		Text with markup (a [[type:tagged string]])				Text
| @choice@		A choice from a list							Text or an image
| @multiple choice@	Zero or more choices from a list					A single image or multiple images
| @package choice@	A choice from a list of installed [[type:package]]s			Text and/or an image
| @boolean@		@yes@ or @no@								Text or an image or both
| @slider@		A choice from a list of numbers							Text or an image
| @color@		Any color or a restricted selection from a list				A box filled with the color
| @image@		Any image								The image
| @symbol@		A [[type:symbol]] edited with the symbol editor				The image
| @info@		An informational message, for example to group fields together.		A box containing the label

Additional properties are available, depending on the type of field:

! Type		Property	Type		Default		Description
| @"text"@	@script@	[[type:script]]		 	Script to apply to values of this field after each change.<br/>
		 		 		 		If the script evaluates to a constant (i.e. doesn't use @value@) then values in this field can effectively not be edited.
| ^^^		@default@	[[type:script]]		 	Script to determine the value when it is in the default state (not edited).
| ^^^		@default name@	[[type:string]]	@"Default"@	Name of the default state, currently not used.
| ^^^		@multi line@	[[type:boolean]]	@false@	Can values of this field contain line breaks?
	
| @"choice"@	@script@	[[type:script]]		 	Script to apply to values of this field after each change.<br/>
		 		 		 		If the script evaluates to a constant (i.e. doesn't use @value@) then values in this field can effectively not be edited.
| ^^^		@default@	[[type:script]]		 	Script to determine the value when it is in the default state (not edited).
| ^^^		@initial@	[[type:string]]		 	Initial value for new values for this field.
| ^^^		@default name@	[[type:string]]	@"Default"@	Name of the default state.
| ^^^		@choices@	[[type:list]] of [[type:choice]]s	 	Possible values for this field.
| ^^^		@choice colors@	[[type:map]] of opaque [[type:color]]s	 	Colors of the choices for statistics graphs.
| ^^^		@choice colors cardlist@	[[type:map]] of opaque [[type:color]]s	 	Colors of the choices for lines in the card list,<br/> see also the @card list color script@ property of [[type:game]]s.
	
| @"multiple choice"@	 	<<<	<<<	<<<
		'' Multiple choice fields have the same attributes as normal choice fields.''<br/>
		To refer to a combination of values in the initial attribute use @choice1, choice2, choice3@.<br/>
		These choices must appear in the same order as they do in the @choices@ property.
	
| @"boolean"@	''A boolean field is a choice field with the choices @"yes"@ and @"no"@.''	<<<	<<<	<<<
	
| @"slider"@	''A slider field is a choice field where the choices are all numbers.''	<<<	<<<	<<<
| ^^^		@script@	[[type:script]]		 	Script to apply to values of this field after each change.<br/>
		 		 		 		If the script evaluates to a constant (i.e. doesn't use @value@) then values in this field can effectively not be edited.
| ^^^		@default@	[[type:script]]		 	Script to determine the value when it is in the default state (not edited).
| ^^^		@initial@	[[type:string]]		 	Initial value for new values for this field. Must be a number, otherwise it will be replaced with minimum.
| ^^^		@default name@	[[type:string]]	@"Default"@	Name of the default state.
| ^^^		@minimum@	[[type:integer]]	 	Minimum possible value for this field.
| ^^^		@maximum@	[[type:integer]]	 	Maximum possible value for this field.
| ^^^		@increment@	[[type:integer]]	 	Gap between possible values for this field.
| ^^^		@choice colors@	[[type:map]] of opaque [[type:color]]s	 	Colors of the choices for statistics graphs.
| ^^^		@choice colors cardlist@	[[type:map]] of opaque [[type:color]]s	 	Colors of the choices for lines in the card list,<br/> see also the @card list color script@ property of [[type:game]]s.
	
| @"package choice"@
		@script@	[[type:script]]		 	Script to apply to values of this field after each change.<br/>
		 		 		 		If the script evaluates to a constant (i.e. doesn't use @value@) then values in this field can effectively not be edited.
| ^^^		@match@		[[type:string]]	''required'' 	Filenames of the packages to match, can include wildcards @"*"@. For example @"magic-mana-*.mse-symbol-font"@.
| ^^^		@initial@	[[type:string]]	''required'' 	Initial package for new values for this field.
| ^^^		@reqired@	[[type:boolean]]	@true@ 	Must a package always be selected? Or is it allowed to select nothing?
| ^^^		@empty name@	[[type:string]]	@"None"@	Name of the empty state. Applies only if @required: false@.
	
| @"color"@	@script@	[[type:script]]		 	Script to apply to values of this field after each change.<br/>
		 		 		 		If the script evaluates to a constant (i.e. doesn't use @value@) then values in this field can effectively not be edited.
| ^^^		@default@	[[type:script]]		 	Script to determine the value when it is in the default state (not edited).
| ^^^		@initial@	[[type:string]]		 	Initial color for new values for this field.
| ^^^		@default name@	[[type:string]]	@"Default"@	Name of the default state.
| ^^^		@allow custom@	[[type:boolean]]	@true@	Are colors other then those from the choices allowed?
| ^^^		@choices@	[[type:list]] of [[type:color choice]]s	 	Possible values for this field.
	
| @"image"@	''no extra properties''	<<<	<<<	<<<
	
| @"symbol"@	''no extra properties''	<<<	<<<	<<<
	
| @"info"@	@script@	[[type:script]]		 	Script to determine the value to show.

--Example--
The @title@ field gives the title of a set:
>set field:
>	type: text
>	name: title
>	identifying: true

The border color of cards can be selected from a list of choices, but other values are also possible.
The default is based on a set field. Statistics don't make much sense for the border color.
>card field:
>	type: color
>	name: border color
>	default: set.border_color
>	choice:
>		name: black
>		color: rgb(0,0,0)
>	choice:
>		name: white
>		color: rgb(255,255,255)
>	choice:
>		name: silver
>		color: rgb(128,128,128)
>	choice:
>		name: gold
>		color: rgb(200,180,0)
>	show statistics: false
