Skip to content
nyfrk edited this page Sep 1, 2020 · 3 revisions

S4CustomUiElement structure

The S4CustomUiElement structure defines a custom ui element for the settlers 4. It is used to create a custom UI element by the ISettlers4Api::CreateCustomUiElement method.

The LPCS4CUSTOMUIELEMENT type defines a pointer to a const struct.

Syntax

typedef struct S4CustomUiElement {
	SIZE_T size;
	HMODULE mod;
	LPCWSTR szImg;
	LPCWSTR szImgHover;
	LPCWSTR szImgSelected;
	LPCWSTR szImgSelectedHover;
	DWORD flags;
	INT x;
	INT y;
	S4_GUI_ENUM screen;
	LPS4UICALLBACK actionHandler;
}  * LPS4CUSTOMUIELEMENT;

Members

size

The size of the struct. Assign sizeof(S4CustomUiElement) to this member.

mod

This is a handle to a module that is used for images that are loaded from a resource section. See flags for details on this. You can set it to NULL, if you are not loading from a resource section.

szImg

A fully qualified filename of a bitmap that is used for rendering the custom ui element in the unselected state. You should always specify this.

szImgHover

A fully qualified filename of a bitmap that is used for rendering the custom ui element in the hovering state. You can set the to NULL if you do not want to change the rendering when the cursor hovers over the element.

szImgSelected

A fully qualified filename of a bitmap that is used for rendering the custom ui element in the selected state. You can set the to NULL if you do not want to change the rendering when the element is in that state.

szImgSelectedHover

A fully qualified filename of a bitmap that is used for rendering a selected custom ui element in the hovering state. You can set the to NULL if you do not want to change the rendering when the cursor hovers over the selected element.

flags

The flags member can be one or more of the following values.

Value Meaning
S4_CUSTOMUIFLAGS_FROMRES_IMG
1
If used the szImg will not be a file path but a resource identifier. Use MAKEINTRESOURCE to specify the resource. Note that you must specify the module from where the resource will be loaded in the mod member.
S4_CUSTOMUIFLAGS_FROMRES_IMGHOVER
2
If used the szImgHover will not be a file path but a resource identifier. Use MAKEINTRESOURCE to specify the resource. Note that you must specify the module from where the resource will be loaded in the mod member.
S4_CUSTOMUIFLAGS_FROMRES_IMGSELECTED
4
If used the szImgSelected will not be a file path but a resource identifier. Use MAKEINTRESOURCE to specify the resource. Note that you must specify the module from where the resource will be loaded in the mod member.
S4_CUSTOMUIFLAGS_FROMRES_IMGSELECTEDHOVER
8
If used the szImgSelectedHover will not be a file path but a resource identifier. Use MAKEINTRESOURCE to specify the resource. Note that you must specify the module from where the resource will be loaded in the mod member.
S4_CUSTOMUIFLAGS_TYPE_TOGGLE
16
If specified the custom UI element will be a toggle button.
S4_CUSTOMUIFLAGS_RESET_ON_HIDE
32
If specified the custom UI element will reset its state to S4_CUSTOM_UI_UNSELECTED whenever it becomes shown.
S4_CUSTOMUIFLAGS_NO_PILLARBOX
64
If specified the renderer will ignore the pillarboxes and draw directly onto the client area at the specified x and y coordinates.
S4_CUSTOMUIFLAGS_TRANSPARENT
128
If specified the images are expected to be ARGB32 images with premultiplied alpha channel. They will be alpha blended. See Remarks section on how to create these images.

x

Specifies the x-coordinate in the client area of the upper-left corner of the ui element.

y

Specifies the y-coordinate in the client area of the upper-left corner of the ui element.

screen

A UI filter that makes the custom UI element show if and only if the specified ui element is also visible. See ISettlers4Api::IsCurrentlyOnScreen for a complete list of values that you can use.

actionHandler

A pointer to a S4UiCallbackProc that is called whenever the state of the custom control changes. Set it to NULL if you do not need it.

Remarks

When S4_CUSTOMUIFLAGS_TRANSPARENT is used you must provide an ARGB32 bitmap with premultiplied alpha channel instead of a RGB24 bitmap. To create such an image you cannot use Microsoft Paint as it only supports up to 24 bits per pixel. You can use the free Software Pixelformer instead to quickly convert a wide range of image types to premultiplied ARGB32 bitmaps.

Requirements

Minimum API Level 1
Header S4ModApi.h

See also

ISettlers4Api

ISettlers4Api::CreateCustomUiElement

S4UiCallbackProc

Clone this wiki locally