Livery Editor - Edit Mode
Edit mode state machine for the livery editor - manages layer application, reapplication, selection, and undo within an editing session.
Edit mode state machine for the livery editor - manages layer application, reapplication, selection, and undo within an editing session.
Overview
ui_liveryEditor_editMode controls the state machine for applying, reapplying, and managing decal layers during an active livery editing session. It tracks applied layers, handles cursor properties, and provides save/cancel operations.
Extension path: lua/ge/extensions/ui/liveryEditor/editMode.lua
Note: This file is entirely commented out in the current codebase, indicating it is either deprecated, in development, or being refactored. The documented API reflects the commented implementation.
Commented API
State Fields
| Field | Type | Description |
|---|---|---|
active | boolean | Whether edit mode is currently active. |
applyActive | boolean | Whether a new decal application is pending. |
reapplyActive | boolean | Whether reapplying an existing layer. |
allowApply | boolean | Whether apply action is permitted. |
activeLayerUid | string | UID of the currently selected layer. |
appliedLayers | table | List of layer UIDs applied in this session. |
isDuplicateActiveLayer | boolean | Flag during layer duplication. |
Core Functions
| Function | Description |
|---|---|
activate() | Enters edit mode, pushes action map, starts apply request. |
deactivate() | Exits edit mode, clears state, pops action map. |
apply() | Applies current decal if allowed. |
onApply(layer) | Callback after decal application - handles continuous/single apply. |
requestApply() | Starts a new apply operation. |
cancelRequestApply() | Cancels pending apply. |
requestReapply() | Begins reapplying an existing layer (disables original). |
cancelReapply() | Cancels reapply, re-enables original layer. |
saveChanges(params) | Finalizes applied layers, optionally grouping them. |
cancelChanges() | Removes all applied layers and resets state. |
Layer Management
| Function | Description |
|---|---|
setActiveLayer(uid) | Selects a layer, updates highlighting and UI. |
setActiveLayerDirection(dir) | Navigates between applied layers (+1/-1). |
duplicateActiveLayer() | Creates a copy of the active layer. |
removeAppliedLayer(uid) | Removes a layer and updates applied list. |
getActiveLayer() | Returns the current active layer data. |
toggleHighlightActive() | Toggles decal highlighting on the active layer. |
Internals
State Machine Flow
deactivate → activate → requestApply → apply → onApply
↓
(continuous) → cursor stays active
(single) → setActiveLayer → edit/reapply
↓
requestReapply → apply → onApply → setActiveLayer
↓
saveChanges / cancelChanges → deactivateContinuous vs Single Apply
When api.isUseMousePos() is true (mouse projection), apply is continuous - each click adds a decal and the cursor stays active. In cursor mode, apply is single-shot and selects the new layer.
Layer Grouping
saveChanges({grouped = true}) creates a linked set and moves all applied layers into it:
local group = api.addLinkedSet()
for k, v in ipairs(M.appliedLayers) do
api.moveLayer(lastPos, nil, index, group.uid)
endHooks
| Hook | Description |
|---|---|
liveryEditor_OnLayerAdded | Tracks new layers, handles reapply replacement. |
liveryEditor_onLayersUpdated | Updates highlighting when layers change. |
liveryEditor_editMode_onStateChanged | Broadcasts state changes to other modules. |
How It Works
- User enters edit mode →
activate()pushes action map and starts apply - Decal cursor becomes visible, user positions and clicks to apply
onApplyrecords the layer and either continues or enters selection- User can reapply (modify position of existing layer) or add more
saveChangesfinalizes;cancelChangesremoves all applied layersdeactivateclears everything and restores normal mode
Additional Exports
The following exports are available but not yet documented in detail:
M.activateM.activeM.activeLayerUidM.allowApplyM.applyM.applyActiveM.cancelChangesM.cancelReapplyM.cancelRequestApplyM.deactivateM.duplicateActiveLayerM.editModeStateChangedM.getActiveLayerM.getAppliedLayersDataM.highlightTimerM.isApplyActiveM.isContinuousApplyM.isDuplicateActiveLayerM.isReapplyActiveM.lastLayerPositionM.liveryEditor_OnLayerAddedM.liveryEditor_OnLayerDeletedM.liveryEditor_onLayersUpdatedM.onApplyM.onUpdateM.reapplyActiveM.removeAppliedLayerM.requestApplyM.requestReapplyM.resetCursorPropertiesM.saveChangesM.setActiveM.setActiveLayerM.setActiveLayerDirectionM.setAllowApplyM.setAppliedLayersM.setApplyActiveM.setReapplyActiveM.setupM.toggleHighlightActiveM.toggleRequestApply