Universal Property Enhancer Help

Palette Icons

Feature

You can add custom palette icons with this feature, like Creepy & Cute and Bot Parts do.

API

Palette Icons exposes the following API:

AddPaletteIcon(palette_icon)

Adds a new palette icon to the list of palette icons.

palette_icon

PaletteIcon required

And binds the PaletteIcon C++ object:

PaletteIcon(id)

Constructs a new palette icon with an id of `id` and a layout of `0x98F661C7`.

id

FNVHash required

PaletteIcon:SetSequence(sequence)

Sets the sequence of a palette icon. This controls the order in which your palette icon appears relative to other palette icons.

sequence

integer required

PaletteIcon:SetLayoutID(layout_id)

Sets the layout id of a palette icon. Usually, you don't need to change this.

layout_id

FNVHash required

PaletteIcon:SetIcon(button_icon, button_bgicon)

Sets the icon of a palette icon.

button_icon

ResourceKey required

button_bgicon

ResourceKey required

PaletteIcon:SetName(name)

Sets the name (visible on hovering) of the palette icon with a LocalizedString.

name

LocalizedString required

PaletteIcon:SetName(tableID, instanceID, fallback_name)

Sets the name (visible on hovering) of the palette icon with a lookup into the locale strings.

tableID

FNVHash required

instanceID

FNVHash required

fallback_name

string optional - only used if the provided tableID and instanceID can't find a valid locale string.

PaletteIcon:SetName(text_property)

Sets the name (visible on hovering) of the palette icon from a App::Property::TextProperty stored in a Property object.

text_property

App::Property::TextProperty required

Usage

The following is an example of how you might add a custom palette icon:

Create our new palette icon:

local palette_icon = PaletteIcon("MyCoolMod")

Set the sequence:

palette_icon:SetSequence(1025)

Set the icon:

palette_icon:SetIcon(ResourceKey(0x011C0BDE, "MyCoolModIcon", "png"), ResourceKey(0x011C0BDE, "MyCoolModBGIcon", "png"))

this makes the game look at common~!mycoolmodicon.png and common~!mycoolmodbgicon.png for the icons.

Set the name of the icon:

palette_icon:SetName("MyCoolMod", "IconName", "MyCoolIcon")

This looks for a mycoolmod.locale with an entry 0xC3CDE5FF (hash of IconName) to use for the name of this palette_icon, if this entry doesn't exist, it will fallback to "MyCoolIcon" as the name.

You can directly set the name: palette_icon:SetName("MyCoolIcon"), but this prevents people from localizing your mod.

You can also read the name from a TextProperty to set the name: palette_icon:SetName(prop:Get()), where prop contains a text property.

And finally add it to the game:

AddPaletteIcon(palette_icon)

Lastly add this property to any page you want to use your icon:

int32 palettePageSetId hash(MyCoolMod)
Last modified: 05 September 2024