Skip to content

ui_liveries_routeLifecycleCallbacks

File: lua/ge/extensions/ui/liveries/routeLifecycleCallbacks.lua · VM: Game Engine (GE) · 273 lines · BeamNG.drive 0.40.5 (buildbot 302427 on GitLab)

Access: extension ui_liveries_routeLifecycleCallbacks: extensions.load("ui_liveries_routeLifecycleCallbacks"), then the global ui_liveries_routeLifecycleCallbacks

Links the livery editor's UI routes (liveries, liveries.edit, liveries.edit.decals...) to Lua code. The UI router calls these Enter, Mount and Leave hooks when the user changes screen; they start and stop the sessions (ui_liveries, ui_liveries_decal), freeze the simulation, drive the camera and the decal cursor, and fill data.liveries with the destination screen's data.

Notes

  • All hooks have the same signature (context, toRoute, fromRoute, data). toRoute and fromRoute are tables with name and params; data is the data table returned to the UI (key data.liveries).
  • The simulation stays paused in all routes whose name is "liveries" or starts with "liveries.": an "ui_liveries" pause request is pushed on entry and removed on exit via simTimeAuthority, so that the vehicle's triggers (doors, hood, trunk) do not activate.
  • The Leave hooks chain (onDecalTransformLeave calls onDecalsLeave, which calls onLiveriesLeave); the pauseRequestActive state keeps pause pushes and pops balanced.
  • Sessions are only started or stopped when entering or leaving a branch: navigating within liveries.edit or liveries.edit.decals keeps the session.
  • Routes used: liveries.edit.decals.camera.selector.transform (new decal) and liveries.edit.decals.transform (existing decal), each with a .settings sub-route.
  • onLiveriesMount is empty: it does nothing.

Dependencies (loaded first): ui_liveries_saves, ui_liveries, ui_liveries_fill, ui_liveries_decal, ui_liveries_textures, ui_liveries_camera

Functions

Function Description Line
ui_liveries_routeLifecycleCallbacks.onDecalCameraEnter(context, toRoute, fromRoute, data) Called when entering the view selection screen. Runs onDecalsEnter and puts the ui_liveries_camera.getViews() list in data.liveries.cameraViews. (internal) (hook) 137
ui_liveries_routeLifecycleCallbacks.onDecalMaterialEnter(context, toRoute, fromRoute, data) Called when entering a decal's material screen. Runs onDecalsEnter, moves the free camera to the decal (params.layerUid) and puts its paint in data.liveries.layerPaint. (internal) (hook) 144
ui_liveries_routeLifecycleCallbacks.onDecalMirrorEnter(context, toRoute, fromRoute, data) Called when entering a decal's mirror screen. Runs onDecalsEnter, warns if params.layerUid is missing, frames the orbit camera on the decal and puts its mirror settings in data.liveries.decalMirror. (internal) (hook) 155
ui_liveries_routeLifecycleCallbacks.onDecalSelectorMount(context, toRoute, fromRoute, data) Called when the decal selector is mounted. Loads the textures with ui_liveries_textures.loadTextures. (internal) (hook) 170
ui_liveries_routeLifecycleCallbacks.onDecalTransformLeave(context, toRoute, fromRoute, data) Called when leaving the new decal transform screen. Hides the cursor unless going to the settings, then runs onDecalsLeave. (internal) (hook) 196
ui_liveries_routeLifecycleCallbacks.onDecalTransformMount(context, toRoute, fromRoute, data) Called when the new decal transform screen is mounted. Notifies the UI, resumes the action map if returning from the settings, otherwise shows the selected decal's cursor, then puts decalTransform and decalMouseMode in data.liveries. (internal) (hook) 174
ui_liveries_routeLifecycleCallbacks.onDecalTransformSettingsEnter(context, toRoute, fromRoute, data) Called when entering the new decal transform settings. Runs onDecalsEnter, suspends the transform action map and puts decalMirror and layerPaint in data.liveries. (internal) (hook) 203
ui_liveries_routeLifecycleCallbacks.onDecalTransformSettingsLeave(context, toRoute, fromRoute, data) Called when leaving the transform settings. If returning to a transform route, resumes the action map; otherwise runs onDecalsLeave. (internal) (hook) 212
ui_liveries_routeLifecycleCallbacks.onDecalsEnter(context, toRoute, fromRoute, data) Called when entering the liveries.edit.decals branch. Starts ui_liveries_decal.setup only if coming from outside this branch. (internal) (hook) 124
ui_liveries_routeLifecycleCallbacks.onDecalsLeave(context, toRoute, fromRoute, data) Called when leaving the decals branch. If the destination stays within this branch, does nothing; otherwise calls ui_liveries_decal.teardown then onLiveriesLeave. (internal) (hook) 187
ui_liveries_routeLifecycleCallbacks.onDecalsMount(context, toRoute, fromRoute, data) Called when the decals screen is mounted. Asks ui_liveries_decal.notifyUi to send the state to the UI. (internal) (hook) 133
ui_liveries_routeLifecycleCallbacks.onExistingDecalTransformEnter(context, toRoute, fromRoute, data) Called when entering the existing decal transform screen. Runs onDecalsEnter then ui_liveries_decal.beginExistingTransform(params.layerUid); warns if layerUid is missing. (internal) (hook) 220
ui_liveries_routeLifecycleCallbacks.onExistingDecalTransformLeave(context, toRoute, fromRoute, data) Called when leaving the existing decal transform. Ends the transform (endExistingTransform) unless going to the settings, then runs onDecalsLeave. (internal) (hook) 245
ui_liveries_routeLifecycleCallbacks.onExistingDecalTransformMount(context, toRoute, fromRoute, data) Called when the existing decal transform screen is mounted. Resumes the action map if returning from the settings, otherwise shows the existing decal's cursor, then puts decalTransform and decalMouseMode in data.liveries. (internal) (hook) 233
ui_liveries_routeLifecycleCallbacks.onLiveriesEditEnter(context, toRoute, fromRoute, data) Called when entering liveries.edit. If coming from outside the edit branch, starts the session with ui_liveries.setup(params.saveName) (no saveName: new livery) and logs a warning on failure. Sets data.liveries.currentSaveName so that the save form offers to overwrite. (internal) (hook) 81
ui_liveries_routeLifecycleCallbacks.onLiveriesEnter(context, toRoute, fromRoute, data) Called when entering the liveries route. Pauses the simulation and puts the list of saved liveries (ui_liveries_saves.getAll) in data.liveries.saveFiles. (internal) (hook) 70
ui_liveries_routeLifecycleCallbacks.onLiveriesLeave(context, toRoute, fromRoute, data) Called when leaving a liveries route. If the destination stays within the edit branch, does nothing more; otherwise calls ui_liveries.teardown then applies the pending skin (ui_liveries_saves.consumeStagedApplySkin) with core_vehicle_partmgmt.setSkin. (internal) (hook) 110
ui_liveries_routeLifecycleCallbacks.onLiveriesMount(context, toRoute, fromRoute, data) Called when the liveries route is mounted. Does nothing. (internal) (hook) 78
ui_liveries_routeLifecycleCallbacks.onLiveriesPaintEnter(context, toRoute, fromRoute, data) Called when entering the paint screen. Puts the base layer's paint (ui_liveries_fill.getPaint) in data.liveries.layerPaint. (internal) (hook) 100
ui_liveries_routeLifecycleCallbacks.onLiveriesRootLeave(context, toRoute, fromRoute, data) Called when leaving the liveries home screen. Removes the simulation pause request (no other Leave hook exists for this screen). (internal) (hook) 106

Fields

Field Type Description
dependencies string[] Extensions loaded before this one: ui_liveries_saves, ui_liveries, ui_liveries_fill, ui_liveries_decal, ui_liveries_textures, ui_liveries_camera.

tim19Atlas (Tim0219800) — derived from BeamNG GmbH Lua code (bCDDL 1.1, see LICENSE). Source: lua/ge/extensions/ui/liveries/routeLifecycleCallbacks.lua.