Moduprint/API/Registries: Difference between revisions

From Resonite Wiki
< Moduprint‎ | API
→‎Theme: supported types
→‎Events: OnSnapped, OnModuleInstalled, OnModuleUninstalled, OnSearchUnpackHandler
Line 47: Line 47:
The intention can be used for optimization. When a tab is about to be deleted, some actions may be unnecessary.
The intention can be used for optimization. When a tab is about to be deleted, some actions may be unnecessary.


==== OnModuleInstalled ====
{| class="wikitable"
|+Event Data
|-
! Name !! Type !! Purpose
|-
| <code>Module</code> || {{Template:TypeColorCard|Slot}} || The module.
|}
==== OnModuleUninstalled ====
{| class="wikitable"
|+Event Data
|-
! Name !! Type !! Purpose
|-
| <code>Module</code> || {{Template:TypeColorCard|Slot}} || The module.
|}


==== OnPrintCreated ====
==== OnPrintCreated ====
Line 56: Line 75:
|-
|-
| <code>Print</code> || {{Template:TypeColorCard|Slot}} || The new print.
| <code>Print</code> || {{Template:TypeColorCard|Slot}} || The new print.
|}
==== OnSearchUnpackHandler ====
If a module can unpack the target, it should assign an unpack handler. The fallback option is used for vanilla packing because the unpacked slot cannot be confidently identified as a slot containing only packed ProtoFlux. The displayed name can be overridden.
{| class="wikitable"
|+Event Data
|-
! Name !! Type !! Purpose
|-
| <code>UnpackTarget</code> || {{Template:TypeColorCard|Slot}} || The slot to be unpacked.
|-
| <code>Print</code> || {{Template:TypeColorCard|Slot}} || The print onto which it should be unpacked.
|-
| <code>DisplayName</code> || {{Template:TypeColorCard|String}} || The displayed name for the unpack option.
|-
| <code>UnpackHandler</code> || {{Template:TypeColorCard|Slot}} || The dynamic impulse used for unpacking.
|-
| <code>Fallback</code> || {{Template:TypeColorCard|bool}} || If the handler should only be used if no other options are available.
|-
| <code>IsDummy</code> || {{Template:TypeColorCard|bool}} || If the handler is not an actual unpacking function and instead performs some other action.
|}
|}


Line 84: Line 125:
|-
|-
| <code>Result</code> || {{Template:TypeColorCard|String}} || <code>Default</code>, <code>Handled</code>, <code>Drop</code>.
| <code>Result</code> || {{Template:TypeColorCard|String}} || <code>Default</code>, <code>Handled</code>, <code>Drop</code>.
|}
==== OnSnapped ====
After an object has been snapped.
{| class="wikitable"
|+Event Data
|-
! Name !! Type !! Purpose
|-
| <code>Print</code> || {{Template:TypeColorCard|Slot}} || The print onto which something was snapped.
|-
| <code>Target</code> || {{Template:TypeColorCard|Slot}} || The object that was snapped.
|-
| <code>OriginalPosition</code> || {{Template:TypeColorCard|float3}} || The object's local positoin before it was snapped.
|-
| <code>WasHandled</code> || {{Template:TypeColorCard|bool}} || If the result of the snapping event was <code>Handled</code>, otherwise it was <code>Default</code>.
|}
|}

Revision as of 18:56, 5 August 2025

Theme

The theme registry is used by the Theming Module to generate Manager/Theme.Key dynamic variables. It is used for styling the user interface as well as providing the default assets such as sprites or textures. When multiple entries define a key, the highest priority wins.

Each entry has a Theme Dynamic Variable Space and each child has the name (without namespace) of a key it defines or overrides. A key has the dynamic variables Theme/Key of any of the supported types.

  • IAssetProvider<Sprite>
  • IAssetProvider<ITexture2D>
  • IAssetProvider<Material>
  • Rect
  • float

Events

All events on a manager are defined as Dynamic Reference Variables of the data slot following the naming scheme Manager/EventData.EventName.

OnBeforePrintCreated

All event data can be modified by events.

Event Data
Name Type Purpose
Parent Slot The parent slot where it should be created.
Position float3 The global position.
Rotation floatQ The global rotation.
Scale float3 The global scale.

OnHideTabContent

Event Data
Name Type Purpose
Tab Slot The tab whose content is about to be hidden.
Intention String DeleteTab or null.

The intention can be used for optimization. When a tab is about to be deleted, some actions may be unnecessary.

OnModuleInstalled

Event Data
Name Type Purpose
Module Slot The module.

OnModuleUninstalled

Event Data
Name Type Purpose
Module Slot The module.

OnPrintCreated

Event Data
Name Type Purpose
Print Slot The new print.

OnSearchUnpackHandler

If a module can unpack the target, it should assign an unpack handler. The fallback option is used for vanilla packing because the unpacked slot cannot be confidently identified as a slot containing only packed ProtoFlux. The displayed name can be overridden.

Event Data
Name Type Purpose
UnpackTarget Slot The slot to be unpacked.
Print Slot The print onto which it should be unpacked.
DisplayName String The displayed name for the unpack option.
UnpackHandler Slot The dynamic impulse used for unpacking.
Fallback bool If the handler should only be used if no other options are available.
IsDummy bool If the handler is not an actual unpacking function and instead performs some other action.

OnShowTabContent

Event Data
Name Type Purpose
Tab Slot The tab whose content is about to be shown.
Intention String DeleteTab or null.

OnSnap

Modify the result accordingly. Only the local transform should be changed, the object will be reparented (keeping the transform) based on the result.

Event Data
Name Type Purpose
Print Slot The print onto which something is snapped.
Target Slot The object to be snapped.
Result String Default, Handled, Drop.


OnSnapped

After an object has been snapped.

Event Data
Name Type Purpose
Print Slot The print onto which something was snapped.
Target Slot The object that was snapped.
OriginalPosition float3 The object's local positoin before it was snapped.
WasHandled bool If the result of the snapping event was Handled, otherwise it was Default.