Livery Editor – Layers
Manages the UI-side layer data model - parsing, caching, and notifying the UI of layer stack changes.
Manages the UI-side layer data model - parsing, caching, and notifying the UI of layer stack changes.
Overview
ui_liveryEditor_layers transforms the raw API layer stack into a UI-friendly format with order indices, parent references, paths, and visibility flags. It maintains a layerMap keyed by UID for fast lookup and fires guihooks when layers change.
Extension path: lua/ge/extensions/ui/liveryEditor/layers.lua
Exports (M)
| Function | Signature | Description |
|---|---|---|
parseLayersData | (layersData, parentLayer) → uiLayers[] | Recursively transforms raw API layers into UI-formatted layer objects. |
rebuildLayerData | () | Re-parses the full layer stack from the API and triggers UI updates. |
getLayers | () → layers[] | Returns the cached flat layers array. |
getLayerByUid | (layerUid) → layer | Looks up a UI-formatted layer by UID from the layer map. |
getLayerByOrder | (order, parentUid) → layer | Finds a layer by its order index within a parent. |
getChildrenCount | (layerUid) → number | Returns child count for a layer, or root layer count if no UID given. |
getVisibleLayersCount | () → number | Counts layers not marked as hidden. |
requestInitialData | () | Triggers a full rebuild and UI notification. |
Data Fields
| Field | Type | Description |
|---|---|---|
M.layers | table | Reference to the cached flat layers array. |
M.layerMap | table | UID-keyed map of {order, parentUid, layer, hidden} for O(1) lookups. |
Hook Listener Exports
| Export | Signature | Description |
|---|---|---|
dynamicDecals_onLayerAdded | (layerUid) | Rebuilds data, fires liveryEditor_OnLayerAdded. |
dynamicDecals_onLayerDeleted | (layerUid) | Rebuilds data, fires liveryEditor_OnLayerDeleted. |
dynamicDecals_onLayerUpdated | (layerUid) | Rebuilds data, fires liveryEditor_onLayersUpdated. |
dynamicDecals_moveLayer | (from, fromParentUid, to, toParentUid) | Rebuilds data after layer reorder. |
Internals
UI Layer Format
Each layer is transformed into:
{
uid = "...",
id = "...",
name = "Layer Name",
type = "decal", -- decal, fill, linkedSet
enabled = true,
locked = false,
order = 3, -- 1-based index within parent
parentUid = "...", -- nil for root layers
path = {"uid1", "uid2"}, -- ancestry chain
pathIndices = {1, 3}, -- index ancestry chain
siblingCount = 5,
childrenCount = 0,
hidden = false, -- true for non-decal/non-linkedSet types
-- type-specific fields:
preview = "texture/path", -- decal
rotation = 45.0, -- decal (degrees)
color = {r, g, b, a}, -- decal/fill
mirrored = false, -- decal
scale = {x, y}, -- decal
skew = {x, y}, -- decal
colorPaletteMapId = 0, -- fill
}Layer Map
M.layerMap[uid] stores {order, parentUid, layer, hidden} for O(1) lookups.
Layer Ordering
Layers are inserted in reverse order (table.insert(uiLayers, 1, uiLayer)) so the UI displays top-to-bottom matching the visual stacking order.
Hook Listeners
| Hook | Behaviour |
|---|---|
dynamicDecals_onLayerAdded(layerUid) | Rebuilds data, fires liveryEditor_OnLayerAdded |
dynamicDecals_onLayerDeleted(layerUid) | Rebuilds data, fires liveryEditor_OnLayerDeleted |
dynamicDecals_onLayerUpdated(layerUid) | Rebuilds data, fires liveryEditor_onLayersUpdated |
dynamicDecals_moveLayer(from, fromParentUid, to, toParentUid) | Rebuilds data, fires liveryEditor_onLayersUpdated |
How It Works
- Any layer mutation triggers
rebuildLayerData() - The full API layer stack is recursively parsed into UI format
layerMapis rebuilt for fast UID lookupsliveryEditor_OnLayersUpdatedandliveryEditor_Layers_OnVisibleCountChangedare triggered to the UI
Additional Exports
The following exports are available but not yet documented in detail:
M.dynamicDecals_moveLayerM.dynamicDecals_onLayerAddedM.dynamicDecals_onLayerDeletedM.dynamicDecals_onLayerUpdatedM.getChildrenCountM.getLayerByOrderM.getLayerByUidM.getLayersM.getVisibleLayersCountM.parseLayersDataM.rebuildLayerDataM.requestInitialData
Livery Editor – Layer Edit
Manages the full edit lifecycle for a single decal layer - transform (translate, rotate, scale, skew), material properties, and gamepad/controller hold-repeat input.
Livery Editor – Resources
Loads and categorises decal textures from the dynamic decals texture registry for the UI resource browser.