UFO-Scripts/icons.ufo/2.4

From UFO:AI
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Version 2.4 provide a more generic wait to describe icons (called sprite). It allow to define icons from pack, single and blended icons, or auto generated icon description according to file name.

Autogenerated sprite description

For developement, the more easy way to define a sprite is to move an image with the right size into pics/icons. It can be used without .ufo description as an icon. For example we can use File:Bordered_cross.png with the sprite name Bordered_cross; If we add the file File:Bordered_cross_disabled.png, the sprite will change when it is need to display it disabled.

_disabled
Image used when the widget/srite is disabled
_hovered
Image used when the widget/sprite is hovered by the mouse
_clicked
Not used anyway

For the release, we can merge all this sprites into a big image bank, and generate .ufo script expected to decode it. The result can looks like File:Generated pack 0.png. The generate .ufo file use default sprite script syntax (see bellow).

Script syntax

The language is a really common .ufo script way. It is a mapping from a sprite name to a set of properties. This example define a one-state-sprite named skull_1.

sprite skull_1 {
	size	"29 25"
	image "ui/icon_pack2"
	texl	"80 1"
}

We can define another state, for example a disabled state from the same image witch is contained inside the same image.

sprite skull_1 {
	size	"29 25"
	image "ui/icon_pack2"
	texl	"80 1"
	disabledtexl "80 129"
}

Properties

size V_POS Size of the sprite (in pixel, which is also in UI script unit). All stats of the sprite must use the same size
single V_BOOL Deprecated
blend V_BOOL Blend images with a definied color. Activate properties color, hoveredcolor, disabledcolor, clickedcolor. Image should use pure black/white level with transparency. A pure white color is transformed to the exact requested color, and a pure black is transformed to black.
pack64 V_BOOL
Example of pack64

If true, the sprite come from a pack64 structure. All sprites are computed using an only one image, a main position (texl), a size, and a vertical displacement according to the status. Normal status use texl, hovered status will use texl + 64, disabled status will use texl + 128, and clicked status will use texl + 192. Usually the image packing sprites is a texture of 256x256. In this case, texl.y + size.y must be smaller tha 64px.

This property only exists for facility. It is possible to describe the same thing with default properties.

texl V_POS Upper-left corner of the normal sprite inside image.
hoveredtexl V_POS Upper-left corner of the hovered sprite inside hoveredimage.
disabledtexl V_POS Upper-left corner of the disabled sprite inside disabledimage.
clickedtexl V_POS Upper-left corner of the clicked sprite inside disabledimage.
image V_REF_OF_STRING Image name relative to ./base/pics containing the normal sprite.
hoveredimage V_REF_OF_STRING Image name relative to ./base/pics containing the hovered sprite. If no image, but a position is defined, it use the default image property.
disabledimage V_REF_OF_STRING Image name relative to ./base/pics containing the disabled sprite. If no image, but a position is defined, it use the default image property.
clickedimage V_REF_OF_STRING Image name relative to ./base/pics containing the clicked sprite. If no image, but a position is defined, it use the default image property.
color V_COLOR Blended color for the normal sprite. To use it, blend property must be true.
hoveredcolor V_COLOR Blended color for the hovered sprite. To use it, blend property must be true.
disabledcolor V_COLOR Blended color for the disabled sprite. To use it, blend property must be true.
clickedcolor V_COLOR Blended color for the clicked sprite. To use it, blend property must be true.