@defold-typescript/types 0.51.0 → 0.53.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (228) hide show
  1. package/api-availability.json +4 -58
  2. package/api-signatures.json +2804 -3172
  3. package/api-targets.json +15 -5
  4. package/examples/translations.json +19 -71
  5. package/generated/b2d.d.ts +39 -39
  6. package/generated/b2d_body.d.ts +11 -11
  7. package/generated/b2d_chain.d.ts +3 -3
  8. package/generated/b2d_fixture.d.ts +5 -5
  9. package/generated/b2d_joint.d.ts +29 -29
  10. package/generated/b2d_shape.d.ts +13 -13
  11. package/generated/b2d_world.d.ts +15 -15
  12. package/generated/buffer.d.ts +10 -11
  13. package/generated/bullet3d.d.ts +6 -6
  14. package/generated/bullet3d_collision_object.d.ts +10 -10
  15. package/generated/bullet3d_constraint.d.ts +173 -71
  16. package/generated/bullet3d_rigid_body.d.ts +3 -3
  17. package/generated/bullet3d_shape.d.ts +11 -11
  18. package/generated/bullet3d_world.d.ts +20 -20
  19. package/generated/camera.d.ts +4 -4
  20. package/generated/collectionfactory.d.ts +2 -3
  21. package/generated/collectionproxy.d.ts +5 -5
  22. package/generated/compute.d.ts +5 -5
  23. package/generated/crash.d.ts +7 -7
  24. package/generated/editor-vm/http.d.ts +13 -13
  25. package/generated/editor-vm/image.d.ts +4 -4
  26. package/generated/editor-vm/json.d.ts +1 -1
  27. package/generated/editor-vm/tilemap_tiles.d.ts +9 -9
  28. package/generated/editor-vm/zip.d.ts +4 -4
  29. package/generated/editor.d.ts +183 -183
  30. package/generated/factory.d.ts +2 -3
  31. package/generated/font.d.ts +4 -4
  32. package/generated/go.d.ts +122 -230
  33. package/generated/graphics.d.ts +23 -25
  34. package/generated/gui.d.ts +186 -423
  35. package/generated/http.d.ts +3 -3
  36. package/generated/image.d.ts +63 -11
  37. package/generated/json.d.ts +4 -4
  38. package/generated/kinds/gui-script.d.ts +2 -0
  39. package/generated/kinds/render-script.d.ts +14 -15
  40. package/generated/label.d.ts +5 -5
  41. package/generated/liveupdate.d.ts +7 -3
  42. package/generated/material.d.ts +49 -49
  43. package/generated/model.d.ts +46 -14
  44. package/generated/particlefx.d.ts +24 -5
  45. package/generated/physics.d.ts +64 -20
  46. package/generated/profiler.d.ts +3 -5
  47. package/generated/render-script-modules/b2d.d.ts +711 -0
  48. package/generated/render-script-modules/bullet3d.d.ts +73 -0
  49. package/generated/render-script-modules/collectionfactory.d.ts +24 -0
  50. package/generated/render-script-modules/collectionproxy.d.ts +39 -0
  51. package/generated/render-script-modules/factory.d.ts +24 -0
  52. package/generated/render-script-modules/go.d.ts +434 -0
  53. package/generated/render-script-modules/label.d.ts +105 -0
  54. package/generated/render-script-modules/model.d.ts +121 -0
  55. package/generated/render-script-modules/particlefx.d.ts +59 -0
  56. package/generated/render-script-modules/physics.d.ts +333 -0
  57. package/generated/render-script-modules/resource.d.ts +1232 -0
  58. package/generated/render-script-modules/sound.d.ts +227 -0
  59. package/generated/render-script-modules/sprite.d.ts +68 -0
  60. package/generated/render-script-modules/tilemap.d.ts +43 -0
  61. package/generated/render.d.ts +172 -47
  62. package/generated/resource.d.ts +81 -61
  63. package/generated/socket.d.ts +18 -23
  64. package/generated/sound.d.ts +6 -6
  65. package/generated/sprite.d.ts +51 -3
  66. package/generated/sys.d.ts +87 -24
  67. package/generated/tilemap.d.ts +3 -3
  68. package/generated/timer.d.ts +3 -3
  69. package/generated/versions/defold-1.12.4/b2d.d.ts +2 -2
  70. package/generated/versions/defold-1.12.4/b2d_body.d.ts +2 -2
  71. package/generated/versions/defold-1.12.4/buffer.d.ts +8 -8
  72. package/generated/versions/defold-1.12.4/go.d.ts +117 -345
  73. package/generated/versions/defold-1.12.4/graphics.d.ts +2 -1
  74. package/generated/versions/defold-1.12.4/gui.d.ts +169 -532
  75. package/generated/versions/defold-1.12.4/http.d.ts +2 -2
  76. package/generated/versions/defold-1.12.4/image.d.ts +82 -2
  77. package/generated/versions/defold-1.12.4/index.d.ts +1 -0
  78. package/generated/versions/defold-1.12.4/label.d.ts +1 -1
  79. package/generated/versions/defold-1.12.4/liveupdate.d.ts +4 -0
  80. package/generated/versions/defold-1.12.4/model.d.ts +42 -10
  81. package/generated/versions/defold-1.12.4/particlefx.d.ts +23 -2
  82. package/generated/versions/defold-1.12.4/physics.d.ts +46 -2
  83. package/generated/versions/defold-1.12.4/render.d.ts +83 -7
  84. package/generated/versions/defold-1.12.4/resource.d.ts +50 -17
  85. package/generated/versions/defold-1.12.4/socket.d.ts +12 -12
  86. package/generated/versions/defold-1.12.4/sound.d.ts +1 -1
  87. package/generated/versions/defold-1.12.4/sprite.d.ts +59 -2
  88. package/generated/versions/defold-1.12.4/sys.d.ts +103 -8
  89. package/generated/versions/defold-1.12.4/tilemap.d.ts +1 -1
  90. package/generated/versions/defold-1.12.4/vmath.d.ts +0 -24
  91. package/generated/versions/defold-1.12.4/window.d.ts +3 -4
  92. package/generated/versions/defold-1.13.0/b2d.d.ts +2 -2
  93. package/generated/versions/defold-1.13.0/b2d_body.d.ts +2 -2
  94. package/generated/versions/defold-1.13.0/b2d_chain.d.ts +1 -1
  95. package/generated/versions/defold-1.13.0/b2d_joint.d.ts +1 -1
  96. package/generated/versions/defold-1.13.0/b2d_shape.d.ts +1 -1
  97. package/generated/versions/defold-1.13.0/buffer.d.ts +8 -8
  98. package/generated/versions/defold-1.13.0/camera.d.ts +1 -1
  99. package/generated/versions/defold-1.13.0/go.d.ts +117 -372
  100. package/generated/versions/defold-1.13.0/graphics.d.ts +2 -1
  101. package/generated/versions/defold-1.13.0/gui.d.ts +169 -532
  102. package/generated/versions/defold-1.13.0/http.d.ts +2 -2
  103. package/generated/versions/defold-1.13.0/image.d.ts +82 -2
  104. package/generated/versions/defold-1.13.0/index.d.ts +1 -0
  105. package/generated/versions/defold-1.13.0/label.d.ts +1 -1
  106. package/generated/versions/defold-1.13.0/liveupdate.d.ts +4 -0
  107. package/generated/versions/defold-1.13.0/material.d.ts +3 -1
  108. package/generated/versions/defold-1.13.0/model.d.ts +42 -10
  109. package/generated/versions/defold-1.13.0/particlefx.d.ts +23 -2
  110. package/generated/versions/defold-1.13.0/physics.d.ts +46 -2
  111. package/generated/versions/defold-1.13.0/render.d.ts +147 -9
  112. package/generated/versions/defold-1.13.0/resource.d.ts +50 -17
  113. package/generated/versions/defold-1.13.0/socket.d.ts +12 -12
  114. package/generated/versions/defold-1.13.0/sound.d.ts +1 -1
  115. package/generated/versions/defold-1.13.0/sprite.d.ts +59 -2
  116. package/generated/versions/defold-1.13.0/sys.d.ts +103 -8
  117. package/generated/versions/defold-1.13.0/tilemap.d.ts +1 -1
  118. package/generated/versions/defold-1.13.0/vmath.d.ts +0 -24
  119. package/generated/versions/defold-1.13.0/window.d.ts +3 -4
  120. package/generated/versions/defold-1.13.1/b2d.d.ts +2 -2
  121. package/generated/versions/defold-1.13.1/b2d_body.d.ts +2 -2
  122. package/generated/versions/defold-1.13.1/b2d_chain.d.ts +1 -1
  123. package/generated/versions/defold-1.13.1/b2d_joint.d.ts +1 -1
  124. package/generated/versions/defold-1.13.1/b2d_shape.d.ts +1 -1
  125. package/generated/versions/defold-1.13.1/buffer.d.ts +8 -8
  126. package/generated/versions/defold-1.13.1/camera.d.ts +1 -1
  127. package/generated/versions/defold-1.13.1/go.d.ts +117 -372
  128. package/generated/versions/defold-1.13.1/graphics.d.ts +2 -1
  129. package/generated/versions/defold-1.13.1/gui.d.ts +169 -548
  130. package/generated/versions/defold-1.13.1/http.d.ts +2 -2
  131. package/generated/versions/defold-1.13.1/image.d.ts +82 -2
  132. package/generated/versions/defold-1.13.1/index.d.ts +2 -0
  133. package/generated/versions/defold-1.13.1/label.d.ts +1 -1
  134. package/generated/versions/defold-1.13.1/liveupdate.d.ts +4 -0
  135. package/generated/versions/defold-1.13.1/material.d.ts +3 -1
  136. package/generated/versions/defold-1.13.1/model.d.ts +42 -10
  137. package/generated/versions/defold-1.13.1/particlefx.d.ts +23 -2
  138. package/generated/versions/defold-1.13.1/physics.d.ts +46 -2
  139. package/generated/versions/defold-1.13.1/render.d.ts +147 -9
  140. package/generated/versions/defold-1.13.1/resource.d.ts +50 -17
  141. package/generated/versions/defold-1.13.1/socket.d.ts +12 -12
  142. package/generated/versions/defold-1.13.1/sound.d.ts +1 -1
  143. package/generated/versions/defold-1.13.1/sprite.d.ts +59 -2
  144. package/generated/versions/defold-1.13.1/sys.d.ts +103 -8
  145. package/generated/versions/defold-1.13.1/tilemap.d.ts +1 -1
  146. package/generated/versions/defold-1.13.1/vmath.d.ts +0 -24
  147. package/generated/versions/defold-1.13.1/window.d.ts +3 -4
  148. package/generated/versions/defold-1.13.2/b2d.d.ts +39 -39
  149. package/generated/versions/defold-1.13.2/b2d_body.d.ts +11 -11
  150. package/generated/versions/defold-1.13.2/b2d_chain.d.ts +3 -3
  151. package/generated/versions/defold-1.13.2/b2d_fixture.d.ts +5 -5
  152. package/generated/versions/defold-1.13.2/b2d_joint.d.ts +29 -29
  153. package/generated/versions/defold-1.13.2/b2d_shape.d.ts +13 -13
  154. package/generated/versions/defold-1.13.2/b2d_world.d.ts +15 -15
  155. package/generated/versions/defold-1.13.2/buffer.d.ts +10 -11
  156. package/generated/versions/defold-1.13.2/bullet3d.d.ts +6 -6
  157. package/generated/versions/defold-1.13.2/bullet3d_collision_object.d.ts +10 -10
  158. package/generated/versions/defold-1.13.2/bullet3d_constraint.d.ts +173 -71
  159. package/generated/versions/defold-1.13.2/bullet3d_rigid_body.d.ts +3 -3
  160. package/generated/versions/defold-1.13.2/bullet3d_shape.d.ts +11 -11
  161. package/generated/versions/defold-1.13.2/bullet3d_world.d.ts +20 -20
  162. package/generated/versions/defold-1.13.2/camera.d.ts +4 -4
  163. package/generated/versions/defold-1.13.2/collectionfactory.d.ts +2 -3
  164. package/generated/versions/defold-1.13.2/collectionproxy.d.ts +5 -5
  165. package/generated/versions/defold-1.13.2/compute.d.ts +5 -5
  166. package/generated/versions/defold-1.13.2/crash.d.ts +7 -7
  167. package/generated/versions/defold-1.13.2/editor-vm/http.d.ts +13 -13
  168. package/generated/versions/defold-1.13.2/editor-vm/image.d.ts +4 -4
  169. package/generated/versions/defold-1.13.2/editor-vm/json.d.ts +1 -1
  170. package/generated/versions/defold-1.13.2/editor-vm/tilemap_tiles.d.ts +9 -9
  171. package/generated/versions/defold-1.13.2/editor-vm/zip.d.ts +4 -4
  172. package/generated/versions/defold-1.13.2/editor.d.ts +183 -183
  173. package/generated/versions/defold-1.13.2/factory.d.ts +2 -3
  174. package/generated/versions/defold-1.13.2/font.d.ts +4 -4
  175. package/generated/versions/defold-1.13.2/go.d.ts +122 -230
  176. package/generated/versions/defold-1.13.2/graphics.d.ts +22 -24
  177. package/generated/versions/defold-1.13.2/gui.d.ts +186 -423
  178. package/generated/versions/defold-1.13.2/http.d.ts +3 -3
  179. package/generated/versions/defold-1.13.2/image.d.ts +63 -11
  180. package/generated/versions/defold-1.13.2/index.d.ts +2 -0
  181. package/generated/versions/defold-1.13.2/json.d.ts +4 -4
  182. package/generated/versions/defold-1.13.2/label.d.ts +5 -5
  183. package/generated/versions/defold-1.13.2/liveupdate.d.ts +7 -3
  184. package/generated/versions/defold-1.13.2/material.d.ts +49 -49
  185. package/generated/versions/defold-1.13.2/model.d.ts +46 -14
  186. package/generated/versions/defold-1.13.2/particlefx.d.ts +24 -5
  187. package/generated/versions/defold-1.13.2/physics.d.ts +64 -20
  188. package/generated/versions/defold-1.13.2/profiler.d.ts +3 -5
  189. package/generated/versions/defold-1.13.2/render.d.ts +161 -46
  190. package/generated/versions/defold-1.13.2/resource.d.ts +81 -61
  191. package/generated/versions/defold-1.13.2/socket.d.ts +18 -23
  192. package/generated/versions/defold-1.13.2/sound.d.ts +6 -6
  193. package/generated/versions/defold-1.13.2/sprite.d.ts +51 -3
  194. package/generated/versions/defold-1.13.2/sys.d.ts +87 -24
  195. package/generated/versions/defold-1.13.2/tilemap.d.ts +3 -3
  196. package/generated/versions/defold-1.13.2/timer.d.ts +3 -3
  197. package/generated/versions/defold-1.13.2/vmath.d.ts +0 -25
  198. package/generated/versions/defold-1.13.2/window.d.ts +8 -10
  199. package/generated/vmath.d.ts +0 -25
  200. package/generated/window.d.ts +8 -10
  201. package/identity-vocabulary.json +86 -34
  202. package/index.d.ts +2 -0
  203. package/package.json +3 -1
  204. package/scripts/generate-api-availability.ts +10 -24
  205. package/scripts/generate-api-signatures.ts +75 -14
  206. package/scripts/materialize-version.ts +48 -7
  207. package/scripts/regen.ts +214 -19
  208. package/scripts/shared-handle-methods.ts +3 -2
  209. package/scripts/signature-store-fs.ts +1 -0
  210. package/scripts/target-version.ts +26 -0
  211. package/src/api-doc.ts +34 -0
  212. package/src/api-identity.ts +32 -1
  213. package/src/component-properties.d.ts +96 -7
  214. package/src/core-types.ts +71 -28
  215. package/src/doc-corrections.ts +62 -5
  216. package/src/emit-dts.ts +1423 -401
  217. package/src/engine-globals.d.ts +5 -1
  218. package/src/engine-type-name.ts +33 -0
  219. package/src/go-overloads.d.ts +74 -19
  220. package/src/gui-overloads.d.ts +489 -0
  221. package/src/gui-texture-removal.d.ts +41 -0
  222. package/src/index.ts +3 -0
  223. package/src/lifecycle.ts +32 -23
  224. package/src/msg-overloads.d.ts +25 -13
  225. package/src/signature-store.ts +50 -0
  226. package/src/socket-types.d.ts +3 -3
  227. package/src/timers.d.ts +2 -1
  228. package/src/vmath-overloads.d.ts +26 -0
@@ -1,5 +1,5 @@
1
1
  /** @noSelfInFile */
2
- import type { Hash, Matrix4, Opaque, Quaternion, Url, Vector, Vector3, Vector4 } from "../../../src/core-types";
2
+ import type { Hash, Opaque, Quaternion, Vector3, Vector4 } from "../../../src/core-types";
3
3
 
4
4
  declare global {
5
5
  /**
@@ -8,20 +8,19 @@ declare global {
8
8
  * accessible only from gui scripts.
9
9
  */
10
10
  namespace gui {
11
- type AdjustMode = typeof gui.ADJUST_FIT | typeof gui.ADJUST_ZOOM | typeof gui.ADJUST_STRETCH;
12
- type BlendMode = typeof gui.BLEND_ALPHA | typeof gui.BLEND_ADD | typeof gui.BLEND_ADD_ALPHA | typeof gui.BLEND_MULT | typeof gui.BLEND_SCREEN;
11
+ type Adjust = typeof gui.ADJUST_FIT | typeof gui.ADJUST_ZOOM | typeof gui.ADJUST_STRETCH;
12
+ type Anchor = typeof gui.ANCHOR_BOTTOM | typeof gui.ANCHOR_LEFT | typeof gui.ANCHOR_NONE | typeof gui.ANCHOR_RIGHT | typeof gui.ANCHOR_TOP;
13
+ type Blend = typeof gui.BLEND_ALPHA | typeof gui.BLEND_ADD | typeof gui.BLEND_ADD_ALPHA | typeof gui.BLEND_MULT | typeof gui.BLEND_SCREEN;
13
14
  type ClippingMode = typeof gui.CLIPPING_MODE_NONE | typeof gui.CLIPPING_MODE_STENCIL;
14
15
  type Easing = typeof gui.EASING_INBACK | typeof gui.EASING_INBOUNCE | typeof gui.EASING_INCIRC | typeof gui.EASING_INCUBIC | typeof gui.EASING_INELASTIC | typeof gui.EASING_INEXPO | typeof gui.EASING_INOUTBACK | typeof gui.EASING_INOUTBOUNCE | typeof gui.EASING_INOUTCIRC | typeof gui.EASING_INOUTCUBIC | typeof gui.EASING_INOUTELASTIC | typeof gui.EASING_INOUTEXPO | typeof gui.EASING_INOUTQUAD | typeof gui.EASING_INOUTQUART | typeof gui.EASING_INOUTQUINT | typeof gui.EASING_INOUTSINE | typeof gui.EASING_INQUAD | typeof gui.EASING_INQUART | typeof gui.EASING_INQUINT | typeof gui.EASING_INSINE | typeof gui.EASING_LINEAR | typeof gui.EASING_OUTBACK | typeof gui.EASING_OUTBOUNCE | typeof gui.EASING_OUTCIRC | typeof gui.EASING_OUTCUBIC | typeof gui.EASING_OUTELASTIC | typeof gui.EASING_OUTEXPO | typeof gui.EASING_OUTINBACK | typeof gui.EASING_OUTINBOUNCE | typeof gui.EASING_OUTINCIRC | typeof gui.EASING_OUTINCUBIC | typeof gui.EASING_OUTINELASTIC | typeof gui.EASING_OUTINEXPO | typeof gui.EASING_OUTINQUAD | typeof gui.EASING_OUTINQUART | typeof gui.EASING_OUTINQUINT | typeof gui.EASING_OUTINSINE | typeof gui.EASING_OUTQUAD | typeof gui.EASING_OUTQUART | typeof gui.EASING_OUTQUINT | typeof gui.EASING_OUTSINE;
15
16
  type KeyboardType = typeof gui.KEYBOARD_TYPE_DEFAULT | typeof gui.KEYBOARD_TYPE_EMAIL | typeof gui.KEYBOARD_TYPE_NUMBER_PAD | typeof gui.KEYBOARD_TYPE_PASSWORD;
16
- type NodeType = typeof gui.TYPE_BOX | typeof gui.TYPE_TEXT | typeof gui.TYPE_PIE | typeof gui.TYPE_PARTICLEFX | typeof gui.TYPE_CUSTOM;
17
17
  type PieBounds = typeof gui.PIEBOUNDS_RECTANGLE | typeof gui.PIEBOUNDS_ELLIPSE;
18
18
  type Pivot = typeof gui.PIVOT_CENTER | typeof gui.PIVOT_N | typeof gui.PIVOT_NE | typeof gui.PIVOT_E | typeof gui.PIVOT_SE | typeof gui.PIVOT_S | typeof gui.PIVOT_SW | typeof gui.PIVOT_W | typeof gui.PIVOT_NW;
19
19
  type Playback = typeof gui.PLAYBACK_ONCE_FORWARD | typeof gui.PLAYBACK_ONCE_BACKWARD | typeof gui.PLAYBACK_ONCE_PINGPONG | typeof gui.PLAYBACK_LOOP_FORWARD | typeof gui.PLAYBACK_LOOP_BACKWARD | typeof gui.PLAYBACK_LOOP_PINGPONG;
20
- type Property = typeof gui.PROP_POSITION | typeof gui.PROP_ROTATION | typeof gui.PROP_EULER | typeof gui.PROP_SCALE | typeof gui.PROP_COLOR | typeof gui.PROP_OUTLINE | typeof gui.PROP_SHADOW | typeof gui.PROP_SIZE | typeof gui.PROP_FILL_ANGLE | typeof gui.PROP_INNER_RADIUS | typeof gui.PROP_LEADING | typeof gui.PROP_TRACKING | typeof gui.PROP_SLICE9;
21
- type SafeAreaMode = typeof gui.SAFE_AREA_NONE | typeof gui.SAFE_AREA_LONG | typeof gui.SAFE_AREA_SHORT | typeof gui.SAFE_AREA_BOTH;
20
+ type Prop = typeof gui.PROP_POSITION | typeof gui.PROP_ROTATION | typeof gui.PROP_EULER | typeof gui.PROP_SCALE | typeof gui.PROP_COLOR | typeof gui.PROP_OUTLINE | typeof gui.PROP_SHADOW | typeof gui.PROP_SIZE | typeof gui.PROP_FILL_ANGLE | typeof gui.PROP_INNER_RADIUS | typeof gui.PROP_LEADING | typeof gui.PROP_TRACKING | typeof gui.PROP_SLICE9;
21
+ type SafeArea = typeof gui.SAFE_AREA_NONE | typeof gui.SAFE_AREA_LONG | typeof gui.SAFE_AREA_SHORT | typeof gui.SAFE_AREA_BOTH;
22
22
  type SizeMode = typeof gui.SIZE_MODE_MANUAL | typeof gui.SIZE_MODE_AUTO;
23
- type XAnchor = typeof gui.ANCHOR_NONE | typeof gui.ANCHOR_LEFT | typeof gui.ANCHOR_RIGHT;
24
- type YAnchor = typeof gui.ANCHOR_NONE | typeof gui.ANCHOR_TOP | typeof gui.ANCHOR_BOTTOM;
23
+ type Type = typeof gui.TYPE_BOX | typeof gui.TYPE_TEXT | typeof gui.TYPE_PIE | typeof gui.TYPE_PARTICLEFX | typeof gui.TYPE_CUSTOM;
25
24
  /**
26
25
  * Adjust mode is used when the screen resolution differs from the project settings.
27
26
  * The fit mode ensures that the entire node is visible in the adjusted gui scene.
@@ -443,120 +442,6 @@ declare global {
443
442
  * text type
444
443
  */
445
444
  const TYPE_TEXT: number & { readonly __brand: "gui.TYPE_TEXT" };
446
- /**
447
- * This starts an animation of a node property according to the specified parameters.
448
- * If the node property is already being animated, that animation will be canceled and
449
- * replaced by the new one. Note however that several different node properties
450
- * can be animated simultaneously. Use `gui.cancel_animations` to stop the animation
451
- * before it has completed.
452
- * Composite properties of type vector3, vector4 or quaternion
453
- * also expose their sub-components (x, y, z and w).
454
- * You can address the components individually by suffixing the name with a dot '.'
455
- * and the name of the component.
456
- * For instance, `"position.x"` (the position x coordinate) or `"color.w"`
457
- * (the color alpha value).
458
- * If a `complete_function` (Lua function) is specified, that function will be called
459
- * when the animation has completed.
460
- * By starting a new animation in that function, several animations can be sequenced
461
- * together. See the examples below for more information.
462
- *
463
- * @param node - node to animate
464
- * @param property - property to animate
465
- *
466
- * - `"position"`
467
- * - `"rotation"`
468
- * - `"euler"`
469
- * - `"scale"`
470
- * - `"color"`
471
- * - `"outline"`
472
- * - `"shadow"`
473
- * - `"size"`
474
- * - `"fill_angle"` (pie)
475
- * - `"inner_radius"` (pie)
476
- * - `"leading"` (text)
477
- * - `"tracking"` (text)
478
- * - `"slice9"` (slice9)
479
- *
480
- * The following property constants are defined equaling the corresponding property string names.
481
- *
482
- * - `gui.PROP_POSITION`
483
- * - `gui.PROP_ROTATION`
484
- * - `gui.PROP_EULER`
485
- * - `gui.PROP_SCALE`
486
- * - `gui.PROP_COLOR`
487
- * - `gui.PROP_OUTLINE`
488
- * - `gui.PROP_SHADOW`
489
- * - `gui.PROP_SIZE`
490
- * - `gui.PROP_FILL_ANGLE`
491
- * - `gui.PROP_INNER_RADIUS`
492
- * - `gui.PROP_LEADING`
493
- * - `gui.PROP_TRACKING`
494
- * - `gui.PROP_SLICE9`
495
- * @param to - target property value
496
- * @param easing - easing to use during animation.
497
- * Either specify one of the `gui.EASING_*` constants or provide a
498
- * vector with a custom curve. See the animation guide for more information.
499
- * @param duration - duration of the animation in seconds.
500
- * @param delay - delay before the animation starts in seconds.
501
- * @param complete_function - function to call when the
502
- * animation has completed
503
- * @param playback - playback mode
504
- *
505
- * - `gui.PLAYBACK_ONCE_FORWARD`
506
- * - `gui.PLAYBACK_ONCE_BACKWARD`
507
- * - `gui.PLAYBACK_ONCE_PINGPONG`
508
- * - `gui.PLAYBACK_LOOP_FORWARD`
509
- * - `gui.PLAYBACK_LOOP_BACKWARD`
510
- * - `gui.PLAYBACK_LOOP_PINGPONG`
511
- * @example
512
- * How to start a simple color animation, where the node fades in to white during 0.5 seconds:
513
- * ```ts
514
- * // How to start a simple color animation, where the node fades in to white during 0.5 seconds:
515
- * const node = gui.get_node("my_node");
516
- * gui.set_color(node, vmath.vector4(0, 0, 0, 0)); // node is fully transparent
517
- * gui.animate(node, gui.PROP_COLOR, vmath.vector4(1, 1, 1, 1), gui.EASING_INOUTQUAD, 0.5); // start animation
518
- * ```
519
- * @example
520
- * How to start a sequenced animation where the node fades in to white during 0.5 seconds, stays visible for 2 seconds and then fades out:
521
- * ```ts
522
- * // How to start a sequenced animation where the node fades in to white during 0.5
523
- * // seconds, stays visible for 2 seconds and then fades out:
524
- * function on_animation_done(self: unknown, node: unknown) {
525
- * // fade out node, but wait 2 seconds before the animation starts
526
- * gui.animate(node as Opaque<"node">, gui.PROP_COLOR, vmath.vector4(0, 0, 0, 0), gui.EASING_OUTQUAD, 0.5, 2.0);
527
- * }
528
- *
529
- * export default defineGuiScript({
530
- * init(self) {
531
- * // fetch the node we want to animate
532
- * const my_node = gui.get_node("my_node");
533
- * // node is initially set to fully transparent
534
- * gui.set_color(my_node, vmath.vector4(0, 0, 0, 0));
535
- * // animate the node immediately and call on_animation_done when the animation has completed
536
- * gui.animate(my_node, gui.PROP_COLOR, vmath.vector4(1, 1, 1, 1), gui.EASING_INOUTQUAD, 0.5, 0.0, on_animation_done);
537
- * },
538
- * });
539
- * ```
540
- * @example
541
- * How to animate a node's y position using a crazy custom easing curve:
542
- * ```ts
543
- * // How to animate a node's y position using a crazy custom easing curve:
544
- * export default defineGuiScript({
545
- * init(self) {
546
- * const values = [
547
- * 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
548
- * 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
549
- * 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
550
- * 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
551
- * ];
552
- * const vec = vmath.vector(values);
553
- * const node = gui.get_node("box");
554
- * gui.animate(node, "position.y", 100, vec, 4.0, 0, undefined, gui.PLAYBACK_LOOP_PINGPONG);
555
- * },
556
- * });
557
- * ```
558
- */
559
- function animate(node: Opaque<"node">, property: string | gui.Property | Hash, to: number | Vector3 | Vector4 | Quaternion, easing: gui.Easing | Vector, duration: number, delay?: number, complete_function?: (self: unknown, node: unknown) => void, playback?: gui.Playback): void;
560
445
  /**
561
446
  * If one or more animations of the specified node is currently running (started by `gui.animate`), they will immediately be canceled.
562
447
  *
@@ -600,7 +485,7 @@ declare global {
600
485
  * gui.cancel_animations(node);
601
486
  * ```
602
487
  */
603
- function cancel_animations(node: Opaque<"node">, property?: string | gui.Property | Hash): void;
488
+ function cancel_animations(node: Opaque<"node">, property?: string | gui.Prop | Hash): void;
604
489
  /**
605
490
  * Cancels any running flipbook animation on the specified node.
606
491
  *
@@ -627,10 +512,10 @@ declare global {
627
512
  * Make a clone instance of a node and all its children.
628
513
  * Use gui.clone to clone a node excluding its children.
629
514
  *
630
- * @param node - root node to clone
515
+ * @param node - root node to clone, or `nil` to clone the whole scene; leaving the argument out raises an error
631
516
  * @returns a table mapping node ids to the corresponding cloned nodes
632
517
  */
633
- function clone_tree(node: Opaque<"node">): LuaTable<Hash, Opaque<"node">> & { get: LuaTableGetMethod<string, Opaque<"node">> };
518
+ function clone_tree(node: Opaque<"node"> | undefined): LuaTable<Hash, Opaque<"node">> & { get: LuaTableGetMethod<string, Opaque<"node">> };
634
519
  /**
635
520
  * Deletes the specified node. Any child nodes of the specified node will be
636
521
  * recursively deleted.
@@ -665,66 +550,6 @@ declare global {
665
550
  * ```
666
551
  */
667
552
  function delete_texture(texture: string | Hash): void;
668
- /**
669
- * This is a callback-function, which is called by the engine when a gui component is finalized (destroyed). It can
670
- * be used to e.g. take some last action, report the finalization to other game object instances
671
- * or release user input focus (see `release_input_focus`). There is no use in starting any animations or similar
672
- * from this function since the gui component is about to be destroyed.
673
- *
674
- * @param self - reference to the script state to be used for storing data
675
- * @example
676
- * ```ts
677
- * export default defineScript({
678
- * init() {
679
- * return { some_value: 0 };
680
- * },
681
- *
682
- * final(self) {
683
- * // report finalization
684
- * msg.post("my_friend_instance", "im_dead", { my_stats: self.some_value });
685
- * },
686
- * });
687
- * ```
688
- */
689
- function final(self: Opaque<"userdata">): void;
690
- /**
691
- * Instead of using specific getters such as gui.get_position or gui.get_scale,
692
- * you can use gui.get instead and supply the property as a string or a hash.
693
- * While this function is similar to go.get, there are a few more restrictions
694
- * when operating in the gui namespace. Most notably, only these explicitly named properties are supported:
695
- *
696
- * - `"position"`
697
- * - `"rotation"`
698
- * - `"euler"`
699
- * - `"scale"`
700
- * - `"color"`
701
- * - `"outline"`
702
- * - `"shadow"`
703
- * - `"size"`
704
- * - `"fill_angle"` (pie)
705
- * - `"inner_radius"` (pie)
706
- * - `"leading"` (text)
707
- * - `"tracking"` (text)
708
- * - `"slice9"` (slice9)
709
- *
710
- * The value returned will either be a vmath.vector4 or a single number, i.e getting the "position"
711
- * property will return a vec4 while getting the "position.x" property will return a single value.
712
- * You can also use this function to get material constants.
713
- *
714
- * @param node - node to get the property for
715
- * @param property - the property to retrieve
716
- * @param options - optional options table (only applicable for material constants)
717
- * - `index` number index into array property (1 based)
718
- *
719
- * **⚠️ `index` is 1-based; passed to Defold unchanged.**
720
- * @example
721
- * ```ts
722
- * // Get properties on existing nodes:
723
- * const node = gui.get_node("my_box_node");
724
- * const node_position = gui.get(node, "position");
725
- * ```
726
- */
727
- function get(node: Opaque<"node">, property: string | Hash | gui.Property, options?: { index?: number; key?: string | Hash; keys?: (Hash | string)[] }): unknown;
728
553
  /**
729
554
  * Returns the adjust mode of a node.
730
555
  * The adjust mode defines how the node will adjust itself to screen
@@ -737,7 +562,7 @@ declare global {
737
562
  * - `gui.ADJUST_ZOOM`
738
563
  * - `gui.ADJUST_STRETCH`
739
564
  */
740
- function get_adjust_mode(node: Opaque<"node">): gui.AdjustMode;
565
+ function get_adjust_mode(node: Opaque<"node">): gui.Adjust;
741
566
  /**
742
567
  * gets the node alpha
743
568
  *
@@ -758,7 +583,7 @@ declare global {
758
583
  * - `gui.BLEND_MULT`
759
584
  * - `gui.BLEND_SCREEN`
760
585
  */
761
- function get_blend_mode(node: Opaque<"node">): gui.BlendMode;
586
+ function get_blend_mode(node: Opaque<"node">): gui.Blend;
762
587
  /**
763
588
  * If node is set as an inverted clipping node, it will clip anything inside as opposed to outside.
764
589
  *
@@ -1143,16 +968,16 @@ declare global {
1143
968
  /**
1144
969
  * Get a node and all its children as a Lua table.
1145
970
  *
1146
- * @param node - root node to get node tree from
971
+ * @param node - root node to get node tree from, or `nil` to get the whole scene; leaving the argument out raises an error
1147
972
  * @returns a table mapping node ids to the corresponding nodes
1148
973
  */
1149
- function get_tree(node: Opaque<"node">): LuaTable<Hash, Opaque<"node">> & { get: LuaTableGetMethod<string, Opaque<"node">> };
974
+ function get_tree(node: Opaque<"node"> | undefined): LuaTable<Hash, Opaque<"node">> & { get: LuaTableGetMethod<string, Opaque<"node">> };
1150
975
  /**
1151
976
  * gets the node type
1152
977
  *
1153
978
  * @param node - node from which to get the type
1154
979
  */
1155
- function get_type(node: Opaque<"node">): LuaMultiReturn<[gui.NodeType, number | undefined]>;
980
+ function get_type(node: Opaque<"node">): LuaMultiReturn<[gui.Type, number | undefined]>;
1156
981
  /**
1157
982
  * Returns `true` if a node is visible and `false` if it's not.
1158
983
  * Invisible nodes are not rendered.
@@ -1177,7 +1002,7 @@ declare global {
1177
1002
  * - `gui.ANCHOR_LEFT`
1178
1003
  * - `gui.ANCHOR_RIGHT`
1179
1004
  */
1180
- function get_xanchor(node: Opaque<"node">): gui.XAnchor;
1005
+ function get_xanchor(node: Opaque<"node">): Exclude<gui.Anchor, typeof gui.ANCHOR_BOTTOM | typeof gui.ANCHOR_TOP>;
1181
1006
  /**
1182
1007
  * The y-anchor specifies how the node is moved when the game is run in a different resolution.
1183
1008
  *
@@ -1188,27 +1013,11 @@ declare global {
1188
1013
  * - `gui.ANCHOR_TOP`
1189
1014
  * - `gui.ANCHOR_BOTTOM`
1190
1015
  */
1191
- function get_yanchor(node: Opaque<"node">): gui.YAnchor;
1016
+ function get_yanchor(node: Opaque<"node">): Exclude<gui.Anchor, typeof gui.ANCHOR_LEFT | typeof gui.ANCHOR_RIGHT>;
1192
1017
  /**
1193
1018
  * Hides the on-display touch keyboard on the device.
1194
1019
  */
1195
1020
  function hide_keyboard(): void;
1196
- /**
1197
- * This is a callback-function, which is called by the engine when a gui component is initialized. It can be used
1198
- * to set the initial state of the script and gui scene.
1199
- *
1200
- * @param self - reference to the script state to be used for storing data
1201
- * @example
1202
- * ```ts
1203
- * export default defineScript({
1204
- * init() {
1205
- * // set up useful data
1206
- * return { my_value: 1 };
1207
- * },
1208
- * });
1209
- * ```
1210
- */
1211
- function init(self: Opaque<"userdata">): void;
1212
1021
  /**
1213
1022
  * Returns `true` if a node is enabled and `false` if it's not.
1214
1023
  * Disabled nodes are not rendered and animations acting on them are not evaluated.
@@ -1326,197 +1135,66 @@ declare global {
1326
1135
  * }
1327
1136
  * ```
1328
1137
  */
1329
- function new_texture(texture_id: string | Hash, width: number, height: number, type: string | Opaque<"constant">, buffer: string, flip?: boolean): LuaMultiReturn<[boolean, number | undefined]>;
1138
+ function new_texture(texture_id: string | Hash, width: number, height: number, type: string | Opaque<"constant">, buffer: string): LuaMultiReturn<[boolean, number | undefined]>;
1330
1139
  /**
1331
- * This is a callback-function, which is called by the engine when user input is sent to the instance of the gui component.
1332
- * It can be used to take action on the input, e.g. modify the gui according to the input.
1333
- * For an instance to obtain user input, it must first acquire input
1334
- * focus through the message `acquire_input_focus`.
1335
- * Any instance that has obtained input will be put on top of an
1336
- * input stack. Input is sent to all listeners on the stack until the
1337
- * end of stack is reached, or a listener returns `true`
1338
- * to signal that it wants input to be consumed.
1339
- * See the documentation of acquire_input_focus for more
1340
- * information.
1341
- * The `action` parameter is a table containing data about the input mapped to the
1342
- * `action_id`.
1343
- * For mapped actions it specifies the value of the input and if it was just pressed or released.
1344
- * Actions are mapped to input in an input_binding-file.
1345
- * Mouse movement is specifically handled and uses `nil` as its `action_id`.
1346
- * The `action` only contains positional parameters in this case, such as x and y of the pointer.
1347
- * Here is a brief description of the available table fields:
1348
- *
1349
- * Field
1350
- * Description
1351
- *
1352
- * `value`
1353
- * The amount of input given by the user. This is usually 1 for buttons and 0-1 for analogue inputs. This is not present for mouse movement and text input.
1354
- *
1355
- * `pressed`
1356
- * If the input was pressed this frame. This is not present for mouse movement and text input.
1357
- *
1358
- * `released`
1359
- * If the input was released this frame. This is not present for mouse movement and text input.
1360
- *
1361
- * `repeated`
1362
- * If the input was repeated this frame. This is similar to how a key on a keyboard is repeated when you hold it down. This is not present for mouse movement and text input.
1363
- *
1364
- * `x`
1365
- * The x value of a pointer device, if present. This is not present for gamepad, key and text input.
1366
- *
1367
- * `y`
1368
- * The y value of a pointer device, if present. This is not present for gamepad, key and text input.
1369
- *
1370
- * `screen_x`
1371
- * The screen space x value of a pointer device, if present. This is not present for gamepad, key and text input.
1372
- *
1373
- * `screen_y`
1374
- * The screen space y value of a pointer device, if present. This is not present for gamepad, key and text input.
1375
- *
1376
- * `dx`
1377
- * The change in x value of a pointer device, if present. This is not present for gamepad, key and text input.
1378
- *
1379
- * `dy`
1380
- * The change in y value of a pointer device, if present. This is not present for gamepad, key and text input.
1381
- *
1382
- * `screen_dx`
1383
- * The change in screen space x value of a pointer device, if present. This is not present for gamepad, key and text input.
1384
- *
1385
- * `screen_dy`
1386
- * The change in screen space y value of a pointer device, if present. This is not present for gamepad, key and text input.
1387
- *
1388
- * `gamepad`
1389
- * The index of the gamepad device that provided the input. See table below about gamepad input.
1390
- *
1391
- * `touch`
1392
- * List of touch input, one element per finger, if present. See table below about touch input
1393
- *
1394
- * `text`
1395
- * Text input from a (virtual) keyboard or similar.
1396
- *
1397
- * `marked_text`
1398
- * Sequence of entered symbols while entering a symbol combination, for example Japanese Kana.
1399
- *
1400
- * Gamepad specific fields:
1401
- *
1402
- * Field
1403
- * Description
1404
- *
1405
- * `gamepad`
1406
- * The index of the gamepad device that provided the input.
1407
- *
1408
- * `userid`
1409
- * Id of the user associated with the controller. Usually only relevant on consoles.
1410
- *
1411
- * `gamepad_unknown`
1412
- * True if the inout originated from an unknown/unmapped gamepad.
1413
- *
1414
- * `gamepad_name`
1415
- * Name of the gamepad
1416
- *
1417
- * `gamepad_axis`
1418
- * List of gamepad axis values. For raw gamepad input only.
1419
- *
1420
- * `gamepadhats`
1421
- * List of gamepad hat values. For raw gamepad input only.
1422
- *
1423
- * `gamepad_buttons`
1424
- * List of gamepad button values. For raw gamepad input only.
1425
- *
1426
- * Touch input table:
1427
- *
1428
- * Field
1429
- * Description
1430
- *
1431
- * `id`
1432
- * A number identifying the touch input during its duration.
1433
- *
1434
- * `pressed`
1435
- * True if the finger was pressed this frame.
1436
- *
1437
- * `released`
1438
- * True if the finger was released this frame.
1439
- *
1440
- * `tap_count`
1441
- * Number of taps, one for single, two for double-tap, etc
1442
- *
1443
- * `x`
1444
- * The x touch location.
1445
- *
1446
- * `y`
1447
- * The y touch location.
1448
- *
1449
- * `dx`
1450
- * The change in x value.
1451
- *
1452
- * `dy`
1453
- * The change in y value.
1454
- *
1455
- * `acc_x`
1456
- * Accelerometer x value (if present).
1457
- *
1458
- * `acc_y`
1459
- * Accelerometer y value (if present).
1140
+ * Dynamically create a new texture.
1460
1141
  *
1461
- * `acc_z`
1462
- * Accelerometer z value (if present).
1142
+ * @param texture_id - texture id
1143
+ * @param width - texture width
1144
+ * @param height - texture height
1145
+ * @param type - texture type
1463
1146
  *
1464
- * @param self - reference to the script state to be used for storing data
1465
- * @param action_id - id of the received input action, as mapped in the input_binding-file
1466
- * @param action - a table containing the input data, see above for a description. **0️⃣ `gamepad` is 0-based; passed to Defold unchanged.**
1467
- * @returns optional boolean to signal if the input should be consumed (not passed on to others) or not, default is false
1147
+ * - `"rgb"` - RGB
1148
+ * - `"rgba"` - RGBA
1149
+ * - `"l"` - LUMINANCE
1150
+ * - `"astc"` - ASTC compressed format
1151
+ * @param buffer - texture data
1152
+ * @param flip - flip texture vertically
1468
1153
  * @example
1154
+ * How to create a texture and apply it to a new box node:
1469
1155
  * ```ts
1470
1156
  * export default defineGuiScript({
1471
- * init(): { my_value: number | undefined } {
1472
- * return { my_value: undefined };
1473
- * },
1157
+ * init(self) {
1158
+ * const w = 200;
1159
+ * const h = 300;
1474
1160
  *
1475
- * on_input(self, action_id, action) {
1476
- * // check for input
1477
- * if (action_id === hash("my_action")) {
1478
- * // take appropriate action
1479
- * self.my_value = action.value;
1161
+ * // A nice orange. String with the RGB values.
1162
+ * const orange = String.fromCharCode(0xff, 0x80, 0x10);
1163
+ *
1164
+ * // Create the texture. Repeat the color string for each pixel.
1165
+ * const [ok, reason] = gui.new_texture("orange_tx", w, h, "rgb", orange.repeat(w * h));
1166
+ * if (ok) {
1167
+ * // Create a box node and apply the texture to it.
1168
+ * const n = gui.new_box_node(vmath.vector3(200, 200, 0), vmath.vector3(w, h, 0));
1169
+ * gui.set_texture(n, "orange_tx");
1170
+ * } else {
1171
+ * // Could not create texture for some reason...
1172
+ * if (reason === gui.RESULT_TEXTURE_ALREADY_EXISTS) {
1173
+ * // ...
1174
+ * } else {
1175
+ * // ...
1176
+ * }
1480
1177
  * }
1481
- * // consume input
1482
- * return true;
1483
1178
  * },
1484
1179
  * });
1485
1180
  * ```
1486
- */
1487
- function on_input(self: Opaque<"userdata">, action_id: Hash, action: { value?: number; pressed?: boolean; released?: boolean; repeated?: boolean; x?: number; y?: number; screen_x?: number; screen_y?: number; dx?: number; dy?: number; screen_dx?: number; screen_dy?: number; gamepad?: number; gamepad_axis?: Vector3; touch?: { id?: number; pressed?: boolean; released?: boolean; tap_count?: number; x?: number; y?: number; dx?: number; dy?: number; acc_x?: number; acc_y?: number; acc_z?: number }[]; text?: string }): boolean | undefined;
1488
- /**
1489
- * This is a callback-function, which is called by the engine whenever a message has been sent to the gui component.
1490
- * It can be used to take action on the message, e.g. update the gui or send a response back to the sender of the message.
1491
- * The `message` parameter is a table containing the message data. If the message is sent from the engine, the
1492
- * documentation of the message specifies which data is supplied.
1493
- * See the update function for examples on how to use this callback-function.
1494
- *
1495
- * @param self - reference to the script state to be used for storing data
1496
- * @param message_id - id of the received message
1497
- * @param message - a table containing the message data
1498
- */
1499
- function on_message(self: Opaque<"userdata">, message_id: Hash, message: Record<string | number, unknown>): void;
1500
- /**
1501
- * This is a callback-function, which is called by the engine when the gui script is reloaded, e.g. from the editor.
1502
- * It can be used for live development, e.g. to tweak constants or set up the state properly for the script.
1503
- *
1504
- * @param self - reference to the script state to be used for storing data
1505
1181
  * @example
1182
+ * How to create a texture using .astc format
1506
1183
  * ```ts
1507
- * export default defineGuiScript({
1508
- * init() {
1509
- * return { my_original_color: gui.get_color(gui.get_node("my_node")) };
1510
- * },
1511
- *
1512
- * on_reload(self) {
1513
- * // restore some color (or similar)
1514
- * gui.set_color(gui.get_node("my_node"), self.my_original_color);
1515
- * },
1516
- * });
1184
+ * const size = 4;
1185
+ * const pos = vmath.vector3(200, 200, 0);
1186
+ * const path = "/assets/images/logo_4x4.astc";
1187
+ * const [data] = sys.load_resource(path);
1188
+ * if (data !== undefined) {
1189
+ * const n = gui.new_box_node(pos, vmath.vector3(size, size, 0));
1190
+ * // size is read from the .astc buffer
1191
+ * // flip is not supported
1192
+ * gui.new_texture(path, 0, 0, "astc", data, false);
1193
+ * gui.set_texture(n, path);
1194
+ * }
1517
1195
  * ```
1518
1196
  */
1519
- function on_reload(self: Opaque<"userdata">): void;
1197
+ function new_texture(texture_id: string | Hash, width: number, height: number, type: string | Opaque<"constant">, buffer: string, flip: boolean): LuaMultiReturn<[boolean, number | undefined]>;
1520
1198
  /**
1521
1199
  * Tests whether a coordinate is within the bounding box of a
1522
1200
  * node.
@@ -1574,7 +1252,55 @@ declare global {
1574
1252
  * gui.play_flipbook(node, "button");
1575
1253
  * ```
1576
1254
  */
1577
- function play_flipbook(node: Opaque<"node">, animation: string | Hash, complete_function?: (self: unknown, node: unknown) => void, play_properties?: { offset?: number; playback_rate?: number }): void;
1255
+ function play_flipbook(node: Opaque<"node">, animation: string | Hash, complete_function?: (self: unknown, node: unknown) => void): void;
1256
+ /**
1257
+ * Play flipbook animation on a box or pie node.
1258
+ * The current node texture must contain the animation.
1259
+ * Use this function to set one-frame still images on the node.
1260
+ *
1261
+ * @param node - node to set animation for
1262
+ * @param animation - animation id
1263
+ * @param complete_function - optional function to call when the animation has completed
1264
+ *
1265
+ * `self`
1266
+ *
1267
+ * object The current object.
1268
+ *
1269
+ * `node`
1270
+ *
1271
+ * node The node that is animated.
1272
+ * @param play_properties - optional table with properties
1273
+ *
1274
+ * `offset`
1275
+ * number The normalized initial value of the animation cursor when the animation starts playing
1276
+ * `playback_rate`
1277
+ * number The rate with which the animation will be played. Must be positive
1278
+ * @example
1279
+ * Set the texture of a node to a flipbook animation from an atlas:
1280
+ * ```ts
1281
+ * function anim_callback(self: unknown, node: unknown) {
1282
+ * // Take action after animation has played.
1283
+ * }
1284
+ *
1285
+ * export default defineGuiScript({
1286
+ * init(self) {
1287
+ * // Create a new node and set the texture to a flipbook animation
1288
+ * const node = gui.get_node("button_node");
1289
+ * gui.set_texture(node, "gui_sprites");
1290
+ * gui.play_flipbook(node, "animated_button");
1291
+ * },
1292
+ * });
1293
+ * ```
1294
+ * @example
1295
+ * Set the texture of a node to an image from an atlas:
1296
+ * ```ts
1297
+ * // Create a new node and set the texture to a "button.png" from atlas
1298
+ * const node = gui.get_node("button_node");
1299
+ * gui.set_texture(node, "gui_sprites");
1300
+ * gui.play_flipbook(node, "button");
1301
+ * ```
1302
+ */
1303
+ function play_flipbook(node: Opaque<"node">, animation: string | Hash, complete_function: ((self: unknown, node: unknown) => void) | undefined, play_properties: { offset?: number; playback_rate?: number }): void;
1578
1304
  /**
1579
1305
  * Plays the paricle fx for a gui node
1580
1306
  *
@@ -1641,100 +1367,6 @@ declare global {
1641
1367
  * @returns local position
1642
1368
  */
1643
1369
  function screen_to_local(node: Opaque<"node">, screen_position: Vector3 | Vector4): Vector3;
1644
- /**
1645
- * Instead of using specific setteres such as gui.set_position or gui.set_scale,
1646
- * you can use gui.set instead and supply the property as a string or a hash.
1647
- * While this function is similar to go.get and go.set, there are a few more restrictions
1648
- * when operating in the gui namespace. Most notably, only these named properties identifiers are supported:
1649
- *
1650
- * - `"position"`
1651
- * - `"rotation"`
1652
- * - `"euler"`
1653
- * - `"scale"`
1654
- * - `"color"`
1655
- * - `"outline"`
1656
- * - `"shadow"`
1657
- * - `"size"`
1658
- * - `"fill_angle"` (pie)
1659
- * - `"inner_radius"` (pie)
1660
- * - `"leading"` (text)
1661
- * - `"tracking"` (text)
1662
- * - `"slice9"` (slice9)
1663
- *
1664
- * The value to set must either be a vmath.vector4, vmath.vector3, vmath.quat or a single number and depends on the property name you want to set.
1665
- * I.e when setting the "position" property, you need to use a vmath.vector4 and when setting a single component of the property,
1666
- * such as "position.x", you need to use a single value.
1667
- * Note: When setting the rotation using the "rotation" property, you need to pass in a vmath.quat. This behaviour is different than from the gui.set_rotation function,
1668
- * the intention is to move new functionality closer to go namespace so that migrating between gui and go is easier. To set the rotation using degrees instead,
1669
- * use the "euler" property instead. The rotation and euler properties are linked, changing one of them will change the backing data of the other.
1670
- * Similar to go.set, you can also use gui.set for setting material constant values on a node. E.g if a material has specified a constant called `tint` in
1671
- * the .material file, you can use gui.set to set the value of that constant by calling `gui.set(node, "tint", vmath.vec4(1,0,0,1))`, or `gui.set(node, "matrix", vmath.matrix4())`
1672
- * if the constant is a matrix. Arrays are also supported by gui.set - to set an array constant, you need to pass in an options table with the 'index' key set.
1673
- * If the material has a constant array called 'tint_array' specified in the material, you can use `gui.set(node, "tint_array", vmath.vec4(1,0,0,1), { index = 4})` to set the fourth array element to a different value.
1674
- *
1675
- * @param node - node to set the property for, or msg.url() to the gui itself
1676
- * @param property - the property to set
1677
- * @param value - the property to set
1678
- * @param options - optional options table (only applicable for material constants)
1679
- * - `index` number index into array property (1 based)
1680
- * - `key` hash name of internal property
1681
- *
1682
- * **⚠️ `index` is 1-based; passed to Defold unchanged.**
1683
- * @example
1684
- * Updates the position property on an existing node:
1685
- * ```ts
1686
- * const node = gui.get_node("my_box_node");
1687
- * const node_position = gui.get(node, "position") as Vector3;
1688
- * gui.set(node, "position.x", node_position.x + 128);
1689
- * ```
1690
- * @example
1691
- * Updates the rotation property on an existing node:
1692
- * ```ts
1693
- * const node = gui.get_node("my_box_node");
1694
- * gui.set(node, "rotation", vmath.quat_rotation_z(math.rad(45)));
1695
- * // this is equivalent to:
1696
- * gui.set(node, "euler.z", 45);
1697
- * // or using the entire vector:
1698
- * gui.set(node, "euler", vmath.vector3(0, 0, 45));
1699
- * // or using the set_rotation
1700
- * gui.set_rotation(node, vmath.vector3(0, 0, 45));
1701
- * ```
1702
- * @example
1703
- * Sets various material constants for a node:
1704
- * ```ts
1705
- * const node = gui.get_node("my_box_node");
1706
- * gui.set(node, "tint", vmath.vector4(1, 0, 0, 1));
1707
- * // matrix4 is also supported
1708
- * gui.set(node, "light_matrix", vmath.matrix4());
1709
- * // update a constant in an array at position 4. the array is specified in the shader as:
1710
- * // uniform vec4 tint_array[4]; // lua is 1 based, shader is 0 based
1711
- * gui.set(node, "tint_array", vmath.vector4(1, 0, 0, 1), { index: 4 });
1712
- * // update a matrix constant in an array at position 4. the array is specified in the shader as:
1713
- * // uniform mat4 light_matrix_array[4];
1714
- * gui.set(node, "light_matrix_array", vmath.matrix4(), { index: 4 });
1715
- * // update a sub-element in a constant
1716
- * gui.set(node, "tint.x", 1);
1717
- * // update a sub-element in an array constant at position 4
1718
- * gui.set(node, "tint_array.x", 1, { index: 4 });
1719
- * ```
1720
- * @example
1721
- * Set a named property
1722
- * ```ts
1723
- * export default defineGuiScript({
1724
- * on_message(self, message_id, message) {
1725
- * if (message_id === hash("set_font") && types.is_hash(message.font)) {
1726
- * gui.set(msg.url(), "fonts", message.font, { key: "my_font_name" });
1727
- * gui.set_font(gui.get_node("text"), "my_font_name");
1728
- * } else if (message_id === hash("set_texture") && types.is_hash(message.texture)) {
1729
- * gui.set(msg.url(), "textures", message.texture, { key: "my_texture" });
1730
- * gui.set_texture(gui.get_node("box"), "my_texture");
1731
- * gui.play_flipbook(gui.get_node("box"), "logo_256");
1732
- * }
1733
- * },
1734
- * });
1735
- * ```
1736
- */
1737
- function set(node: Opaque<"node"> | Url, property: string | Hash | gui.Property, value: number | Vector4 | Vector3 | Quaternion | Matrix4 | Hash, options?: { index?: number; key?: string | Hash; keys?: (Hash | string)[] }): void;
1738
1370
  /**
1739
1371
  * Sets the adjust mode on a node.
1740
1372
  * The adjust mode defines how the node will adjust itself to screen
@@ -1747,7 +1379,7 @@ declare global {
1747
1379
  * - `gui.ADJUST_ZOOM`
1748
1380
  * - `gui.ADJUST_STRETCH`
1749
1381
  */
1750
- function set_adjust_mode(node: Opaque<"node">, adjust_mode: gui.AdjustMode): void;
1382
+ function set_adjust_mode(node: Opaque<"node">, adjust_mode: gui.Adjust): void;
1751
1383
  /**
1752
1384
  * sets the node alpha
1753
1385
  *
@@ -1768,7 +1400,7 @@ declare global {
1768
1400
  * - `gui.BLEND_MULT`
1769
1401
  * - `gui.BLEND_SCREEN`
1770
1402
  */
1771
- function set_blend_mode(node: Opaque<"node">, blend_mode: gui.BlendMode): void;
1403
+ function set_blend_mode(node: Opaque<"node">, blend_mode: gui.Blend): void;
1772
1404
  /**
1773
1405
  * If node is set as an inverted clipping node, it will clip anything inside as opposed to outside.
1774
1406
  *
@@ -2035,7 +1667,7 @@ declare global {
2035
1667
  * - `gui.SAFE_AREA_SHORT`
2036
1668
  * - `gui.SAFE_AREA_BOTH`
2037
1669
  */
2038
- function set_safe_area_mode(mode: gui.SafeAreaMode): void;
1670
+ function set_safe_area_mode(mode: gui.SafeArea): void;
2039
1671
  /**
2040
1672
  * Sets the scaling of the supplied node.
2041
1673
  *
@@ -2174,7 +1806,52 @@ declare global {
2174
1806
  * });
2175
1807
  * ```
2176
1808
  */
2177
- function set_texture_data(texture: string | Hash, width: number, height: number, type: string | Opaque<"constant">, buffer: string, flip?: boolean): boolean;
1809
+ function set_texture_data(texture: string | Hash, width: number, height: number, type: string | Opaque<"constant">, buffer: string): boolean;
1810
+ /**
1811
+ * Set the texture buffer data for a dynamically created texture.
1812
+ *
1813
+ * @param texture - texture id
1814
+ * @param width - texture width
1815
+ * @param height - texture height
1816
+ * @param type - texture type
1817
+ *
1818
+ * - `"rgb"` - RGB
1819
+ * - `"rgba"` - RGBA
1820
+ * - `"l"` - LUMINANCE
1821
+ * - `"astc"` - ASTC compressed format
1822
+ * @param buffer - texture data
1823
+ * @param flip - flip texture vertically
1824
+ * @returns setting the data was successful
1825
+ * @example
1826
+ * ```ts
1827
+ * export default defineGuiScript({
1828
+ * init(self) {
1829
+ * const w = 200;
1830
+ * const h = 300;
1831
+ *
1832
+ * // Create a dynamic texture, all white.
1833
+ * if (gui.new_texture("dynamic_tx", w, h, "rgb", String.fromCharCode(0xff).repeat(w * h * 3))) {
1834
+ * // Create a box node and apply the texture to it.
1835
+ * const n = gui.new_box_node(vmath.vector3(200, 200, 0), vmath.vector3(w, h, 0));
1836
+ * gui.set_texture(n, "dynamic_tx");
1837
+ *
1838
+ * // ...
1839
+ *
1840
+ * // Change the data in the texture to a nice orange.
1841
+ * const orange = String.fromCharCode(0xff, 0x80, 0x10);
1842
+ * if (gui.set_texture_data("dynamic_tx", w, h, "rgb", orange.repeat(w * h))) {
1843
+ * // Go on and to more stuff
1844
+ * // ...
1845
+ * }
1846
+ * } else {
1847
+ * // Something went wrong
1848
+ * // ...
1849
+ * }
1850
+ * },
1851
+ * });
1852
+ * ```
1853
+ */
1854
+ function set_texture_data(texture: string | Hash, width: number, height: number, type: string | Opaque<"constant">, buffer: string, flip: boolean): boolean;
2178
1855
  /**
2179
1856
  * Sets the tracking value of a text node. This value is used to
2180
1857
  * adjust the vertical spacing of characters in the text.
@@ -2200,7 +1877,7 @@ declare global {
2200
1877
  * - `gui.ANCHOR_LEFT`
2201
1878
  * - `gui.ANCHOR_RIGHT`
2202
1879
  */
2203
- function set_xanchor(node: Opaque<"node">, anchor: gui.XAnchor): void;
1880
+ function set_xanchor(node: Opaque<"node">, anchor: Exclude<gui.Anchor, typeof gui.ANCHOR_BOTTOM | typeof gui.ANCHOR_TOP>): void;
2204
1881
  /**
2205
1882
  * The y-anchor specifies how the node is moved when the game is run in a different resolution.
2206
1883
  *
@@ -2211,7 +1888,7 @@ declare global {
2211
1888
  * - `gui.ANCHOR_TOP`
2212
1889
  * - `gui.ANCHOR_BOTTOM`
2213
1890
  */
2214
- function set_yanchor(node: Opaque<"node">, anchor: gui.YAnchor): void;
1891
+ function set_yanchor(node: Opaque<"node">, anchor: Exclude<gui.Anchor, typeof gui.ANCHOR_LEFT | typeof gui.ANCHOR_RIGHT>): void;
2215
1892
  /**
2216
1893
  * Shows the on-display touch keyboard.
2217
1894
  * The specified type of keyboard is displayed if it is available on
@@ -2235,57 +1912,17 @@ declare global {
2235
1912
  *
2236
1913
  * - boolean `clear`: instantly clear spawned particles
2237
1914
  */
2238
- function stop_particlefx(node: Opaque<"node">, options?: { clear?: boolean }): void;
1915
+ function stop_particlefx(node: Opaque<"node">): void;
2239
1916
  /**
2240
- * This is a callback-function, which is called by the engine every frame to update the state of a gui component.
2241
- * It can be used to perform any kind of gui related tasks, e.g. animating nodes.
2242
- *
2243
- * @param self - reference to the script state to be used for storing data
2244
- * @param dt - the time-step of the frame update
2245
- * @example
2246
- * ```ts
2247
- * // This example demonstrates how to update a text node that displays game score
2248
- * // in a counting fashion. It is assumed that the gui component receives messages
2249
- * // from the game when a new score is to be shown.
2250
- * export default defineGuiScript({
2251
- * init() {
2252
- * return {
2253
- * // fetch the score text node for later use (assumes it is called "score")
2254
- * score_node: gui.get_node("score"),
2255
- * // keep track of the current score counted up so far
2256
- * current_score: 0,
2257
- * // keep track of the target score we should count up to
2258
- * target_score: 0,
2259
- * // how fast we will update the score, in score/second
2260
- * score_update_speed: 1,
2261
- * };
2262
- * },
1917
+ * Stops the particle fx for a gui node
2263
1918
  *
2264
- * update(self, dt) {
2265
- * // check if target score is more than current score
2266
- * if (self.current_score < self.target_score) {
2267
- * // increment current score according to the speed
2268
- * self.current_score = self.current_score + dt * self.score_update_speed;
2269
- * // check if we went past the target score, clamp current score in that case
2270
- * if (self.current_score > self.target_score) {
2271
- * self.current_score = self.target_score;
2272
- * }
2273
- * // update the score text node
2274
- * gui.set_text(self.score_node, "" + math.floor(self.current_score));
2275
- * }
2276
- * },
1919
+ * @param node - node to stop particle fx for
1920
+ * @param options - options when stopping the particle fx. Supported options:
2277
1921
  *
2278
- * on_message(self, message_id, message) {
2279
- * // check the message
2280
- * if (message_id === hash("set_score") && typeof message.score === "number") {
2281
- * self.target_score = message.score;
2282
- * }
2283
- * },
2284
- * });
2285
- * ```
1922
+ * - boolean `clear`: instantly clear spawned particles
2286
1923
  */
2287
- function update(self: Opaque<"userdata">, dt: number): void;
2288
- interface properties {
1924
+ function stop_particlefx(node: Opaque<"node">, options: { clear?: boolean }): void;
1925
+ interface Properties {
2289
1926
  /**
2290
1927
  * The fonts used in the gui. The type of the property is hash.
2291
1928
  * Key must be specified in options table.