API ReferenceGE ExtensionsuiliveryEditor
Livery Editor – Selection
Manages the layer selection state - single/multi-select, available actions, highlight toggling, and UI notifications.
Manages the layer selection state - single/multi-select, available actions, highlight toggling, and UI notifications.
Overview
ui_liveryEditor_selection tracks which layers are currently selected, computes available actions based on selection type and count, and notifies the UI of changes. It also provides duplicate and reapply workflows.
Extension path: lua/ge/extensions/ui/liveryEditor/selection.lua
Exports (M)
| Function | Signature | Description |
|---|---|---|
select | (layerIds, highlight) | Sets the selection to one or more layer UIDs. Optionally highlights. |
clearSelection | () | Clears all selected layers and disables highlighting. |
toggleSelection | (layerUid) | Adds/removes a layer from the multi-selection. |
addToSelection | (layerUid) | Adds a layer UID to the selection. |
removeFromSelection | (layerUid) → bool | Removes a UID; returns true if found. |
getSelectedLayers | () → uid[] | Returns the array of selected UIDs. |
getFirstSelectedLayer | () → uid | Returns the first selected UID. |
getSelectedLayersData | () → layer[] | Returns UI-formatted layer objects with highlight flags. |
isLayerSelected | (layerUid) → bool | Checks if a UID is in the selection. |
getAvailableActions | () → actions[] | Returns context-appropriate actions for the current selection. |
toggleHighlightSelectedLayer | () | Toggles API highlighting on the first selected layer. |
duplicateSelectedLayer | () | Duplicates the first selected layer. |
reapplySelectedLayer | () | Enters reapply mode - hides layer, shows cursor with its properties. |
cancelReapplySelectedLayer | () | Cancels reapply mode and restores the layer. |
setup | () | Clears selection and notifies UI. |
notifyUiListeners | () | Pushes selection state, actions, and data to UI. |
requestInitialData | () | Alias for notifyUiListeners. |
Data Fields
| Field | Description |
|---|---|
M.selectedLayers | Table of currently selected layer UIDs. |
Internals
Multi-Selection Action Rules
| Selection | Available Actions |
|---|---|
| Single decal | Full action set from ui_liveryEditor_layers_decal |
| Single fill | Full action set from ui_liveryEditor_layers_fill |
| Single linkedSet | Full action set from ui_liveryEditor_layers_group |
| Multiple decals | group, material, duplicate, mirror, visibility, delete |
| Multiple fills | duplicate, visibility, delete |
| Mixed types | visibility only |
UI Events Triggered
On any selection change, these guihooks fire:
liveryEditor_selection_actionsUpdatedliveryEditor_selection_selectedChangedLiveryEditor_SelectedLayersChangedLiverEditorLayerActionsUpdatedLiveryEditor_SelectedLayersDataUpdated
Hook Listener Exports
| Export | Description |
|---|---|
liveryEditor_OnLayerAdded | (layer) - If duplicate was active, selects the new layer. |
dynamicDecals_onLayerDeleted | (layerUid) - Removes deleted layer from selection. |
liveryEditor_onLayersUpdated | (layerUid) - Re-sends selected layer data if the updated layer is selected. |
How It Works
- UI calls
select(uid, true)when user clicks a layer - sets selection and highlights - Shift-click calls
toggleSelection(uid)for multi-select getAvailableActions()computes which operations are valid for the current mix- Action buttons in the UI are enabled/disabled based on the returned actions
- Duplicate and reapply use flags (
duplicateLayerActive,reapplyLayerActive) to handle async callbacks
Example Usage
local sel = extensions.ui_liveryEditor_selection
-- Select a layer with highlighting
sel.select(layerUid, true)
-- Check available actions
local actions = sel.getAvailableActions()
-- Multi-select
sel.addToSelection(anotherUid)
-- Clear
sel.clearSelection()Additional Exports
The following exports are available but not yet documented in detail:
M.addToSelectionM.cancelReapplySelectedLayerM.clearSelectionM.duplicateLayerActiveM.duplicateSelectedLayerM.dynamicDecals_onLayerDeletedM.getAvailableActionsM.getFirstSelectedLayerM.getSelectedLayersM.getSelectedLayersDataM.isLayerSelectedM.liveryEditor_OnLayerAddedM.liveryEditor_onLayersUpdatedM.notifyUiListenersM.reapplyLayerActiveM.reapplySelectedLayerM.removeFromSelectionM.requestInitialDataM.selectM.setupM.toggleHighlightSelectedLayerM.toggleSelection