@defold-typescript/types 0.51.0 → 0.52.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 (130) hide show
  1. package/api-availability.json +4 -58
  2. package/api-signatures.json +878 -1356
  3. package/api-targets.json +15 -5
  4. package/examples/translations.json +4 -56
  5. package/generated/b2d_world.d.ts +10 -10
  6. package/generated/buffer.d.ts +9 -9
  7. package/generated/bullet3d_collision_object.d.ts +1 -1
  8. package/generated/bullet3d_constraint.d.ts +109 -7
  9. package/generated/bullet3d_shape.d.ts +2 -2
  10. package/generated/go.d.ts +114 -220
  11. package/generated/graphics.d.ts +1 -0
  12. package/generated/gui.d.ts +148 -371
  13. package/generated/http.d.ts +2 -2
  14. package/generated/image.d.ts +55 -3
  15. package/generated/kinds/gui-script.d.ts +2 -0
  16. package/generated/kinds/render-script.d.ts +14 -15
  17. package/generated/liveupdate.d.ts +5 -1
  18. package/generated/material.d.ts +3 -3
  19. package/generated/particlefx.d.ts +20 -1
  20. package/generated/physics.d.ts +45 -1
  21. package/generated/render-script-modules/b2d.d.ts +711 -0
  22. package/generated/render-script-modules/bullet3d.d.ts +73 -0
  23. package/generated/render-script-modules/collectionfactory.d.ts +25 -0
  24. package/generated/render-script-modules/collectionproxy.d.ts +39 -0
  25. package/generated/render-script-modules/factory.d.ts +25 -0
  26. package/generated/render-script-modules/go.d.ts +436 -0
  27. package/generated/render-script-modules/label.d.ts +105 -0
  28. package/generated/render-script-modules/model.d.ts +89 -0
  29. package/generated/render-script-modules/particlefx.d.ts +59 -0
  30. package/generated/render-script-modules/physics.d.ts +333 -0
  31. package/generated/render-script-modules/resource.d.ts +1233 -0
  32. package/generated/render-script-modules/sound.d.ts +227 -0
  33. package/generated/render-script-modules/sprite.d.ts +68 -0
  34. package/generated/render-script-modules/tilemap.d.ts +43 -0
  35. package/generated/render.d.ts +134 -8
  36. package/generated/resource.d.ts +31 -10
  37. package/generated/sprite.d.ts +49 -1
  38. package/generated/sys.d.ts +70 -6
  39. package/generated/versions/defold-1.12.4/buffer.d.ts +8 -8
  40. package/generated/versions/defold-1.12.4/go.d.ts +115 -343
  41. package/generated/versions/defold-1.12.4/graphics.d.ts +1 -0
  42. package/generated/versions/defold-1.12.4/gui.d.ts +151 -513
  43. package/generated/versions/defold-1.12.4/http.d.ts +2 -2
  44. package/generated/versions/defold-1.12.4/image.d.ts +82 -2
  45. package/generated/versions/defold-1.12.4/index.d.ts +1 -0
  46. package/generated/versions/defold-1.12.4/liveupdate.d.ts +4 -0
  47. package/generated/versions/defold-1.12.4/particlefx.d.ts +22 -1
  48. package/generated/versions/defold-1.12.4/physics.d.ts +45 -1
  49. package/generated/versions/defold-1.12.4/render.d.ts +78 -2
  50. package/generated/versions/defold-1.12.4/resource.d.ts +43 -10
  51. package/generated/versions/defold-1.12.4/sprite.d.ts +58 -1
  52. package/generated/versions/defold-1.12.4/sys.d.ts +101 -6
  53. package/generated/versions/defold-1.12.4/vmath.d.ts +0 -24
  54. package/generated/versions/defold-1.13.0/buffer.d.ts +8 -8
  55. package/generated/versions/defold-1.13.0/go.d.ts +115 -370
  56. package/generated/versions/defold-1.13.0/graphics.d.ts +1 -0
  57. package/generated/versions/defold-1.13.0/gui.d.ts +151 -513
  58. package/generated/versions/defold-1.13.0/http.d.ts +2 -2
  59. package/generated/versions/defold-1.13.0/image.d.ts +82 -2
  60. package/generated/versions/defold-1.13.0/index.d.ts +1 -0
  61. package/generated/versions/defold-1.13.0/liveupdate.d.ts +4 -0
  62. package/generated/versions/defold-1.13.0/material.d.ts +3 -1
  63. package/generated/versions/defold-1.13.0/particlefx.d.ts +22 -1
  64. package/generated/versions/defold-1.13.0/physics.d.ts +45 -1
  65. package/generated/versions/defold-1.13.0/render.d.ts +142 -4
  66. package/generated/versions/defold-1.13.0/resource.d.ts +43 -10
  67. package/generated/versions/defold-1.13.0/sprite.d.ts +58 -1
  68. package/generated/versions/defold-1.13.0/sys.d.ts +101 -6
  69. package/generated/versions/defold-1.13.0/vmath.d.ts +0 -24
  70. package/generated/versions/defold-1.13.1/buffer.d.ts +8 -8
  71. package/generated/versions/defold-1.13.1/go.d.ts +115 -370
  72. package/generated/versions/defold-1.13.1/graphics.d.ts +1 -0
  73. package/generated/versions/defold-1.13.1/gui.d.ts +151 -529
  74. package/generated/versions/defold-1.13.1/http.d.ts +2 -2
  75. package/generated/versions/defold-1.13.1/image.d.ts +82 -2
  76. package/generated/versions/defold-1.13.1/index.d.ts +2 -0
  77. package/generated/versions/defold-1.13.1/liveupdate.d.ts +4 -0
  78. package/generated/versions/defold-1.13.1/material.d.ts +3 -1
  79. package/generated/versions/defold-1.13.1/particlefx.d.ts +22 -1
  80. package/generated/versions/defold-1.13.1/physics.d.ts +45 -1
  81. package/generated/versions/defold-1.13.1/render.d.ts +142 -4
  82. package/generated/versions/defold-1.13.1/resource.d.ts +43 -10
  83. package/generated/versions/defold-1.13.1/sprite.d.ts +58 -1
  84. package/generated/versions/defold-1.13.1/sys.d.ts +101 -6
  85. package/generated/versions/defold-1.13.1/vmath.d.ts +0 -24
  86. package/generated/versions/defold-1.13.2/b2d_world.d.ts +10 -10
  87. package/generated/versions/defold-1.13.2/buffer.d.ts +9 -9
  88. package/generated/versions/defold-1.13.2/bullet3d_collision_object.d.ts +1 -1
  89. package/generated/versions/defold-1.13.2/bullet3d_constraint.d.ts +109 -7
  90. package/generated/versions/defold-1.13.2/bullet3d_shape.d.ts +2 -2
  91. package/generated/versions/defold-1.13.2/go.d.ts +114 -220
  92. package/generated/versions/defold-1.13.2/graphics.d.ts +1 -0
  93. package/generated/versions/defold-1.13.2/gui.d.ts +148 -371
  94. package/generated/versions/defold-1.13.2/http.d.ts +2 -2
  95. package/generated/versions/defold-1.13.2/image.d.ts +55 -3
  96. package/generated/versions/defold-1.13.2/index.d.ts +2 -0
  97. package/generated/versions/defold-1.13.2/liveupdate.d.ts +5 -1
  98. package/generated/versions/defold-1.13.2/material.d.ts +3 -3
  99. package/generated/versions/defold-1.13.2/particlefx.d.ts +20 -1
  100. package/generated/versions/defold-1.13.2/physics.d.ts +45 -1
  101. package/generated/versions/defold-1.13.2/render.d.ts +123 -7
  102. package/generated/versions/defold-1.13.2/resource.d.ts +31 -10
  103. package/generated/versions/defold-1.13.2/sprite.d.ts +49 -1
  104. package/generated/versions/defold-1.13.2/sys.d.ts +70 -6
  105. package/generated/versions/defold-1.13.2/vmath.d.ts +0 -24
  106. package/generated/vmath.d.ts +0 -24
  107. package/identity-vocabulary.json +52 -7
  108. package/index.d.ts +2 -0
  109. package/package.json +2 -1
  110. package/scripts/generate-api-availability.ts +1 -21
  111. package/scripts/generate-api-signatures.ts +75 -14
  112. package/scripts/materialize-version.ts +48 -7
  113. package/scripts/regen.ts +214 -19
  114. package/scripts/signature-store-fs.ts +1 -0
  115. package/scripts/target-version.ts +26 -0
  116. package/src/api-doc.ts +26 -0
  117. package/src/component-properties.d.ts +89 -0
  118. package/src/core-types.ts +42 -15
  119. package/src/doc-corrections.ts +53 -5
  120. package/src/emit-dts.ts +758 -198
  121. package/src/engine-globals.d.ts +5 -1
  122. package/src/go-overloads.d.ts +68 -13
  123. package/src/gui-overloads.d.ts +489 -0
  124. package/src/gui-texture-removal.d.ts +41 -0
  125. package/src/index.ts +2 -0
  126. package/src/lifecycle.ts +30 -21
  127. package/src/msg-overloads.d.ts +25 -13
  128. package/src/signature-store.ts +50 -0
  129. package/src/timers.d.ts +2 -1
  130. 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
  /**
@@ -518,83 +518,6 @@ declare global {
518
518
  * text type
519
519
  */
520
520
  const TYPE_TEXT: number & { readonly __brand: "gui.TYPE_TEXT" };
521
- /**
522
- * This starts an animation of a node property according to the specified parameters.
523
- * If the node property is already being animated, that animation will be canceled and
524
- * replaced by the new one. Note however that several different node properties
525
- * can be animated simultaneously. Use `gui.cancel_animations` to stop the animation
526
- * before it has completed.
527
- * Composite properties of type vector3, vector4 or quaternion
528
- * also expose their sub-components (x, y, z and w).
529
- * You can address the components individually by suffixing the name with a dot '.'
530
- * and the name of the component.
531
- * For instance, `"position.x"` (the position x coordinate) or `"color.w"`
532
- * (the color alpha value).
533
- * If a `complete_function` (Lua function) is specified, that function will be called
534
- * when the animation has completed.
535
- * By starting a new animation in that function, several animations can be sequenced
536
- * together. See the examples below for more information.
537
- *
538
- * @param node - node to animate
539
- * @param property - property to animate; each gui.PROP member equals its corresponding property name string
540
- * @param to - target property value
541
- * @param easing - easing to use during animation.
542
- * Either specify one of the `gui.EASING_*` constants or provide a
543
- * vector with a custom curve. See the animation guide for more information.
544
- * @param duration - duration of the animation in seconds.
545
- * @param delay - delay before the animation starts in seconds.
546
- * @param complete_function - function to call when the
547
- * animation has completed
548
- * @param playback - playback mode
549
- * @example
550
- * How to start a simple color animation, where the node fades in to white during 0.5 seconds:
551
- * ```ts
552
- * // How to start a simple color animation, where the node fades in to white during 0.5 seconds:
553
- * const node = gui.get_node("my_node");
554
- * gui.set_color(node, vmath.vector4(0, 0, 0, 0)); // node is fully transparent
555
- * gui.animate(node, gui.PROP_COLOR, vmath.vector4(1, 1, 1, 1), gui.EASING_INOUTQUAD, 0.5); // start animation
556
- * ```
557
- * @example
558
- * 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:
559
- * ```ts
560
- * // How to start a sequenced animation where the node fades in to white during 0.5
561
- * // seconds, stays visible for 2 seconds and then fades out:
562
- * function on_animation_done(self: unknown, node: unknown) {
563
- * // fade out node, but wait 2 seconds before the animation starts
564
- * gui.animate(node as Opaque<"node">, gui.PROP_COLOR, vmath.vector4(0, 0, 0, 0), gui.EASING_OUTQUAD, 0.5, 2.0);
565
- * }
566
- *
567
- * export default defineGuiScript({
568
- * init(self) {
569
- * // fetch the node we want to animate
570
- * const my_node = gui.get_node("my_node");
571
- * // node is initially set to fully transparent
572
- * gui.set_color(my_node, vmath.vector4(0, 0, 0, 0));
573
- * // animate the node immediately and call on_animation_done when the animation has completed
574
- * gui.animate(my_node, gui.PROP_COLOR, vmath.vector4(1, 1, 1, 1), gui.EASING_INOUTQUAD, 0.5, 0.0, on_animation_done);
575
- * },
576
- * });
577
- * ```
578
- * @example
579
- * How to animate a node's y position using a crazy custom easing curve:
580
- * ```ts
581
- * // How to animate a node's y position using a crazy custom easing curve:
582
- * export default defineGuiScript({
583
- * init(self) {
584
- * const values = [
585
- * 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
586
- * 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
587
- * 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
588
- * 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
589
- * ];
590
- * const vec = vmath.vector(values);
591
- * const node = gui.get_node("box");
592
- * gui.animate(node, "position.y", 100, vec, 4.0, 0, undefined, gui.PLAYBACK_LOOP_PINGPONG);
593
- * },
594
- * });
595
- * ```
596
- */
597
- function animate(node: Opaque<"node">, property: string | Hash | gui.PROP, to: number | Vector3 | Vector4 | Quaternion, easing: gui.EASING | Vector, duration: number, delay?: number, complete_function?: (self: unknown, node: Opaque<"node">) => void, playback?: gui.PLAYBACK): void;
598
521
  /**
599
522
  * If one or more animations of the specified node is currently running (started by `gui.animate`), they will immediately be canceled.
600
523
  *
@@ -665,10 +588,10 @@ declare global {
665
588
  * Make a clone instance of a node and all its children.
666
589
  * Use gui.clone to clone a node excluding its children.
667
590
  *
668
- * @param node - root node to clone
591
+ * @param node - root node to clone, or `nil` to clone the whole scene; leaving the argument out raises an error
669
592
  * @returns a table mapping node ids to the corresponding cloned nodes
670
593
  */
671
- function clone_tree(node: Opaque<"node">): LuaTable<Hash, Opaque<"node">> & { get: LuaTableGetMethod<string, Opaque<"node">> };
594
+ function clone_tree(node: Opaque<"node"> | undefined): LuaTable<Hash, Opaque<"node">> & { get: LuaTableGetMethod<string, Opaque<"node">> };
672
595
  /**
673
596
  * Deletes the specified node. Any child nodes of the specified node will be
674
597
  * recursively deleted.
@@ -703,66 +626,6 @@ declare global {
703
626
  * ```
704
627
  */
705
628
  function delete_texture(texture: string | Hash): void;
706
- /**
707
- * This is a callback-function, which is called by the engine when a gui component is finalized (destroyed). It can
708
- * be used to e.g. take some last action, report the finalization to other game object instances
709
- * or release user input focus (see `release_input_focus`). There is no use in starting any animations or similar
710
- * from this function since the gui component is about to be destroyed.
711
- *
712
- * @param self - script instance used for storing state
713
- * @example
714
- * ```ts
715
- * export default defineScript({
716
- * init() {
717
- * return { some_value: 0 };
718
- * },
719
- *
720
- * final(self) {
721
- * // report finalization
722
- * msg.post("my_friend_instance", "im_dead", { my_stats: self.some_value });
723
- * },
724
- * });
725
- * ```
726
- */
727
- function final(self: unknown): void;
728
- /**
729
- * Instead of using specific getters such as gui.get_position or gui.get_scale,
730
- * you can use gui.get instead and supply the property as a string or a hash.
731
- * While this function is similar to go.get, there are a few more restrictions
732
- * when operating in the gui namespace. Most notably, only these explicitly named properties are supported:
733
- *
734
- * - `"position"`
735
- * - `"rotation"`
736
- * - `"euler"`
737
- * - `"scale"`
738
- * - `"color"`
739
- * - `"outline"`
740
- * - `"shadow"`
741
- * - `"size"`
742
- * - `"fill_angle"` (pie)
743
- * - `"inner_radius"` (pie)
744
- * - `"leading"` (text)
745
- * - `"tracking"` (text)
746
- * - `"slice9"` (slice9)
747
- *
748
- * The value returned will either be a vmath.vector4 or a single number, i.e getting the "position"
749
- * property will return a vec4 while getting the "position.x" property will return a single value.
750
- * You can also use this function to get material constants.
751
- *
752
- * @param node - node to get the property for
753
- * @param property - the property to retrieve
754
- * @param options - optional options table (only applicable for material constants)
755
- * - `index` integer index into array property (1 based)
756
- *
757
- * **⚠️ `index` is 1-based; passed to Defold unchanged.**
758
- * @example
759
- * ```ts
760
- * // Get properties on existing nodes:
761
- * const node = gui.get_node("my_box_node");
762
- * const node_position = gui.get(node, "position");
763
- * ```
764
- */
765
- function get(node: Opaque<"node">, property: string | Hash | gui.PROP, options?: { index?: number; key?: string | Hash; keys?: (Hash | string)[] }): unknown;
766
629
  /**
767
630
  * Returns the adjust mode of a node.
768
631
  * The adjust mode defines how the node will adjust itself to screen
@@ -1174,10 +1037,10 @@ declare global {
1174
1037
  /**
1175
1038
  * Get a node and all its children as a Lua table.
1176
1039
  *
1177
- * @param node - root node to get node tree from
1040
+ * @param node - root node to get node tree from, or `nil` to get the whole scene; leaving the argument out raises an error
1178
1041
  * @returns a table mapping node ids to the corresponding nodes
1179
1042
  */
1180
- function get_tree(node: Opaque<"node">): LuaTable<Hash, Opaque<"node">> & { get: LuaTableGetMethod<string, Opaque<"node">> };
1043
+ function get_tree(node: Opaque<"node"> | undefined): LuaTable<Hash, Opaque<"node">> & { get: LuaTableGetMethod<string, Opaque<"node">> };
1181
1044
  /**
1182
1045
  * gets the node type
1183
1046
  *
@@ -1224,22 +1087,6 @@ declare global {
1224
1087
  * Hides the on-display touch keyboard on the device.
1225
1088
  */
1226
1089
  function hide_keyboard(): void;
1227
- /**
1228
- * This is a callback-function, which is called by the engine when a gui component is initialized. It can be used
1229
- * to set the initial state of the script and gui scene.
1230
- *
1231
- * @param self - script instance used for storing state
1232
- * @example
1233
- * ```ts
1234
- * export default defineScript({
1235
- * init() {
1236
- * // set up useful data
1237
- * return { my_value: 1 };
1238
- * },
1239
- * });
1240
- * ```
1241
- */
1242
- function init(self: unknown): void;
1243
1090
  /**
1244
1091
  * Returns `true` if a node is enabled and `false` if it's not.
1245
1092
  * Disabled nodes are not rendered and animations acting on them are not evaluated.
@@ -1357,76 +1204,66 @@ declare global {
1357
1204
  * }
1358
1205
  * ```
1359
1206
  */
1360
- function new_texture(texture_id: string | Hash, width: number, height: number, type: string | image.TYPE, buffer: string, flip?: boolean): LuaMultiReturn<[boolean, gui.RESULT | undefined]>;
1361
- /**
1362
- * This is a callback-function, which is called by the engine when user input is sent to the instance of the gui component.
1363
- * It can be used to take action on the input, e.g. modify the gui according to the input.
1364
- * For an instance to obtain user input, it must first acquire input
1365
- * focus through the message `acquire_input_focus`.
1366
- * Any instance that has obtained input will be put on top of an
1367
- * input stack. Input is sent to all listeners on the stack until the
1368
- * end of stack is reached, or a listener returns `true`
1369
- * to signal that it wants input to be consumed.
1370
- * See the documentation of acquire_input_focus for more
1371
- * information.
1372
- *
1373
- * @param self - script instance used for storing state
1374
- * @param action_id - id of the received input action, as mapped in the input_binding-file, or `nil` for mouse movement
1375
- * @param action - input data for the action. **0️⃣ `gamepad` is 0-based; passed to Defold unchanged.**
1376
- * @returns optional boolean to signal if the input should be consumed (not passed on to others) or not, default is false
1207
+ function new_texture(texture_id: string | Hash, width: number, height: number, type: string | image.TYPE, buffer: string): LuaMultiReturn<[boolean, gui.RESULT | undefined]>;
1208
+ /**
1209
+ * Dynamically create a new texture.
1210
+ *
1211
+ * @param texture_id - texture id
1212
+ * @param width - texture width
1213
+ * @param height - texture height
1214
+ * @param type - texture type
1215
+ *
1216
+ * - `"rgb"` or `image.TYPE_RGB` - RGB
1217
+ * - `"rgba"` or `image.TYPE_RGBA` - RGBA
1218
+ * - `"l"` or `image.TYPE_LUMINANCE` - LUMINANCE
1219
+ * - `"astc"` - ASTC compressed format
1220
+ * @param buffer - texture data
1221
+ * @param flip - flip texture vertically
1377
1222
  * @example
1223
+ * How to create a texture and apply it to a new box node:
1378
1224
  * ```ts
1379
1225
  * export default defineGuiScript({
1380
- * init(): { my_value: number | undefined } {
1381
- * return { my_value: undefined };
1382
- * },
1226
+ * init(self) {
1227
+ * const w = 200;
1228
+ * const h = 300;
1383
1229
  *
1384
- * on_input(self, action_id, action) {
1385
- * // check for input
1386
- * if (action_id === hash("my_action")) {
1387
- * // take appropriate action
1388
- * self.my_value = action.value;
1230
+ * // A nice orange. String with the RGB values.
1231
+ * const orange = String.fromCharCode(0xff, 0x80, 0x10);
1232
+ *
1233
+ * // Create the texture. Repeat the color string for each pixel.
1234
+ * const [ok, reason] = gui.new_texture("orange_tx", w, h, "rgb", orange.repeat(w * h));
1235
+ * if (ok) {
1236
+ * // Create a box node and apply the texture to it.
1237
+ * const n = gui.new_box_node(vmath.vector3(200, 200, 0), vmath.vector3(w, h, 0));
1238
+ * gui.set_texture(n, "orange_tx");
1239
+ * } else {
1240
+ * // Could not create texture for some reason...
1241
+ * if (reason === gui.RESULT_TEXTURE_ALREADY_EXISTS) {
1242
+ * // ...
1243
+ * } else {
1244
+ * // ...
1245
+ * }
1389
1246
  * }
1390
- * // consume input
1391
- * return true;
1392
1247
  * },
1393
1248
  * });
1394
1249
  * ```
1395
- */
1396
- function on_input(self: unknown, action_id: Hash | undefined, action: go.on_input.action): boolean | undefined;
1397
- /**
1398
- * This is a callback-function, which is called by the engine whenever a message has been sent to the gui component.
1399
- * 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.
1400
- * The `message` parameter is a table containing the message data. If the message is sent from the engine, the
1401
- * documentation of the message specifies which data is supplied.
1402
- * See the update function for examples on how to use this callback-function.
1403
- *
1404
- * @param self - script instance used for storing state
1405
- * @param message_id - id of the received message
1406
- * @param message - a table containing the message data
1407
- * @param sender - address of the sender
1408
- */
1409
- function on_message(self: unknown, message_id: Hash, message: LuaMap<AnyNotNil, unknown> | Record<string, unknown>, sender: Url): void;
1410
- /**
1411
- * This is a callback-function, which is called by the engine when the gui script is reloaded, e.g. from the editor.
1412
- * It can be used for live development, e.g. to tweak constants or set up the state properly for the script.
1413
- *
1414
- * @param self - script instance used for storing state
1415
1250
  * @example
1251
+ * How to create a texture using .astc format
1416
1252
  * ```ts
1417
- * export default defineGuiScript({
1418
- * init() {
1419
- * return { my_original_color: gui.get_color(gui.get_node("my_node")) };
1420
- * },
1421
- *
1422
- * on_reload(self) {
1423
- * // restore some color (or similar)
1424
- * gui.set_color(gui.get_node("my_node"), self.my_original_color);
1425
- * },
1426
- * });
1253
+ * const size = 4;
1254
+ * const pos = vmath.vector3(200, 200, 0);
1255
+ * const path = "/assets/images/logo_4x4.astc";
1256
+ * const [data] = sys.load_resource(path);
1257
+ * if (data !== undefined) {
1258
+ * const n = gui.new_box_node(pos, vmath.vector3(size, size, 0));
1259
+ * // size is read from the .astc buffer
1260
+ * // flip is not supported
1261
+ * gui.new_texture(path, 0, 0, "astc", data, false);
1262
+ * gui.set_texture(n, path);
1263
+ * }
1427
1264
  * ```
1428
1265
  */
1429
- function on_reload(self: unknown): void;
1266
+ function new_texture(texture_id: string | Hash, width: number, height: number, type: string | image.TYPE, buffer: string, flip: boolean): LuaMultiReturn<[boolean, gui.RESULT | undefined]>;
1430
1267
  /**
1431
1268
  * Tests whether a coordinate is within the bounding box of a
1432
1269
  * node.
@@ -1479,7 +1316,50 @@ declare global {
1479
1316
  * gui.play_flipbook(node, "button");
1480
1317
  * ```
1481
1318
  */
1482
- function play_flipbook(node: Opaque<"node">, animation: string | Hash, complete_function?: (self: unknown, node: Opaque<"node">) => void, play_properties?: gui.play_properties): void;
1319
+ function play_flipbook(node: Opaque<"node">, animation: string | Hash, complete_function?: (self: unknown, node: Opaque<"node">) => void): void;
1320
+ /**
1321
+ * Play flipbook animation on a box or pie node.
1322
+ * The current node texture must contain the animation.
1323
+ * Use this function to set one-frame still images on the node.
1324
+ *
1325
+ * @param node - node to set animation for
1326
+ * @param animation - animation id
1327
+ * @param complete_function - optional function to call when the animation has completed
1328
+ *
1329
+ * `self`
1330
+ *
1331
+ * script_instance The current script instance.
1332
+ *
1333
+ * `node`
1334
+ *
1335
+ * node The node that is animated.
1336
+ * @param play_properties - optional playback properties
1337
+ * @example
1338
+ * Set the texture of a node to a flipbook animation from an atlas:
1339
+ * ```ts
1340
+ * function anim_callback(self: unknown, node: unknown) {
1341
+ * // Take action after animation has played.
1342
+ * }
1343
+ *
1344
+ * export default defineGuiScript({
1345
+ * init(self) {
1346
+ * // Create a new node and set the texture to a flipbook animation
1347
+ * const node = gui.get_node("button_node");
1348
+ * gui.set_texture(node, "gui_sprites");
1349
+ * gui.play_flipbook(node, "animated_button");
1350
+ * },
1351
+ * });
1352
+ * ```
1353
+ * @example
1354
+ * Set the texture of a node to an image from an atlas:
1355
+ * ```ts
1356
+ * // Create a new node and set the texture to a "button.png" from atlas
1357
+ * const node = gui.get_node("button_node");
1358
+ * gui.set_texture(node, "gui_sprites");
1359
+ * gui.play_flipbook(node, "button");
1360
+ * ```
1361
+ */
1362
+ function play_flipbook(node: Opaque<"node">, animation: string | Hash, complete_function: ((self: unknown, node: Opaque<"node">) => void) | undefined, play_properties: gui.play_properties): void;
1483
1363
  /**
1484
1364
  * Plays the paricle fx for a gui node
1485
1365
  *
@@ -1557,112 +1437,6 @@ declare global {
1557
1437
  * ```
1558
1438
  */
1559
1439
  function screen_to_local(node: Opaque<"node">, screen_position: Vector3 | Vector4): Vector3;
1560
- /**
1561
- * Instead of using specific setteres such as gui.set_position or gui.set_scale,
1562
- * you can use gui.set instead and supply the property as a string or a hash.
1563
- * While this function is similar to go.get and go.set, there are a few more restrictions
1564
- * when operating in the gui namespace. Most notably, only these named properties identifiers are supported:
1565
- *
1566
- * - `"position"`
1567
- * - `"rotation"`
1568
- * - `"euler"`
1569
- * - `"scale"`
1570
- * - `"color"`
1571
- * - `"outline"`
1572
- * - `"shadow"`
1573
- * - `"size"`
1574
- * - `"fill_angle"` (pie)
1575
- * - `"inner_radius"` (pie)
1576
- * - `"leading"` (text)
1577
- * - `"tracking"` (text)
1578
- * - `"slice9"` (slice9)
1579
- *
1580
- * 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.
1581
- * I.e when setting the "position" property, you need to use a vmath.vector4 and when setting a single component of the property,
1582
- * such as "position.x", you need to use a single value.
1583
- * 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,
1584
- * 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,
1585
- * use the "euler" property instead. The rotation and euler properties are linked, changing one of them will change the backing data of the other.
1586
- * 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
1587
- * 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())`
1588
- * 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.
1589
- * 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.
1590
- *
1591
- * @param node - node to set the property for, or msg.url() to the gui itself
1592
- * @param property - the property to set
1593
- * @param value - the property to set. `nil` is only supported for removing runtime texture mappings with `gui.set(msg.url(), "textures", nil, {key = ...})`.
1594
- * @param options - optional material-constant options. **⚠️ `index` is 1-based; passed to Defold unchanged.**
1595
- * @example
1596
- * Updates the position property on an existing node:
1597
- * ```ts
1598
- * const node = gui.get_node("my_box_node");
1599
- * const node_position = gui.get(node, "position") as Vector3;
1600
- * gui.set(node, "position.x", node_position.x + 128);
1601
- * ```
1602
- * @example
1603
- * Updates the rotation property on an existing node:
1604
- * ```ts
1605
- * const node = gui.get_node("my_box_node");
1606
- * gui.set(node, "rotation", vmath.quat_rotation_z(math.rad(45)));
1607
- * // this is equivalent to:
1608
- * gui.set(node, "euler.z", 45);
1609
- * // or using the entire vector:
1610
- * gui.set(node, "euler", vmath.vector3(0, 0, 45));
1611
- * // or using the set_rotation
1612
- * gui.set_rotation(node, vmath.vector3(0, 0, 45));
1613
- * ```
1614
- * @example
1615
- * Sets various material constants for a node:
1616
- * ```ts
1617
- * const node = gui.get_node("my_box_node");
1618
- * gui.set(node, "tint", vmath.vector4(1, 0, 0, 1));
1619
- * // matrix4 is also supported
1620
- * gui.set(node, "light_matrix", vmath.matrix4());
1621
- * // update a constant in an array at position 4. the array is specified in the shader as:
1622
- * // uniform vec4 tint_array[4]; // lua is 1 based, shader is 0 based
1623
- * gui.set(node, "tint_array", vmath.vector4(1, 0, 0, 1), { index: 4 });
1624
- * // update a matrix constant in an array at position 4. the array is specified in the shader as:
1625
- * // uniform mat4 light_matrix_array[4];
1626
- * gui.set(node, "light_matrix_array", vmath.matrix4(), { index: 4 });
1627
- * // update a sub-element in a constant
1628
- * gui.set(node, "tint.x", 1);
1629
- * // update a sub-element in an array constant at position 4
1630
- * gui.set(node, "tint_array.x", 1, { index: 4 });
1631
- * ```
1632
- * @example
1633
- * Set a named property
1634
- * ```ts
1635
- * export default defineGuiScript({
1636
- * on_message(self, message_id, message) {
1637
- * if (message_id === hash("set_font") && types.is_hash(message.font)) {
1638
- * gui.set(msg.url(), "fonts", message.font, { key: "my_font_name" });
1639
- * gui.set_font(gui.get_node("text"), "my_font_name");
1640
- * } else if (message_id === hash("set_texture") && types.is_hash(message.texture)) {
1641
- * gui.set(msg.url(), "textures", message.texture, { key: "my_texture" });
1642
- * gui.set_texture(gui.get_node("box"), "my_texture");
1643
- * gui.play_flipbook(gui.get_node("box"), "logo_256");
1644
- * }
1645
- * },
1646
- * });
1647
- * ```
1648
- * @example
1649
- * Remove a named runtime texture resource mapping:
1650
- * ```ts
1651
- * const atlas_params = {
1652
- * texture: "/runtime.texturec",
1653
- * animations: [{ id: "runtime", width: 1, height: 1, frames: [1] }],
1654
- * geometries: [{ vertices: [0, 0, 0, 1, 1, 1, 1, 0], uvs: [0, 0, 0, 1, 1, 1, 1, 0], indices: [0, 1, 2, 0, 2, 3] }],
1655
- * } satisfies Parameters<typeof resource.create_atlas>[1];
1656
- * const atlas_id = resource.create_atlas("/runtime.texturesetc", atlas_params);
1657
- * gui.set(msg.url(), "textures", atlas_id, { key: "runtime_texture" });
1658
- * gui.set_texture(gui.get_node("box"), "runtime_texture");
1659
- *
1660
- * // Later, remove the GUI mapping before releasing the atlas resource.
1661
- * gui.set(msg.url(), "textures", undefined, { key: "runtime_texture" });
1662
- * resource.release(atlas_id);
1663
- * ```
1664
- */
1665
- function set(node: Opaque<"node"> | Url, property: string | Hash | gui.PROP, value: number | Vector4 | Vector3 | Quaternion | Matrix4 | Hash | undefined, options?: { index?: number; key?: string | Hash; keys?: (Hash | string)[] }): void;
1666
1440
  /**
1667
1441
  * Sets the adjust mode on a node.
1668
1442
  * The adjust mode defines how the node will adjust itself to screen
@@ -2081,7 +1855,52 @@ declare global {
2081
1855
  * });
2082
1856
  * ```
2083
1857
  */
2084
- function set_texture_data(texture: string | Hash, width: number, height: number, type: string | image.TYPE, buffer: string, flip?: boolean): boolean;
1858
+ function set_texture_data(texture: string | Hash, width: number, height: number, type: string | image.TYPE, buffer: string): boolean;
1859
+ /**
1860
+ * Set the texture buffer data for a dynamically created texture.
1861
+ *
1862
+ * @param texture - texture id
1863
+ * @param width - texture width
1864
+ * @param height - texture height
1865
+ * @param type - texture type
1866
+ *
1867
+ * - `"rgb"` or `image.TYPE_RGB` - RGB
1868
+ * - `"rgba"` or `image.TYPE_RGBA` - RGBA
1869
+ * - `"l"` or `image.TYPE_LUMINANCE` - LUMINANCE
1870
+ * - `"astc"` - ASTC compressed format
1871
+ * @param buffer - texture data
1872
+ * @param flip - flip texture vertically
1873
+ * @returns setting the data was successful
1874
+ * @example
1875
+ * ```ts
1876
+ * export default defineGuiScript({
1877
+ * init(self) {
1878
+ * const w = 200;
1879
+ * const h = 300;
1880
+ *
1881
+ * // Create a dynamic texture, all white.
1882
+ * if (gui.new_texture("dynamic_tx", w, h, "rgb", String.fromCharCode(0xff).repeat(w * h * 3))) {
1883
+ * // Create a box node and apply the texture to it.
1884
+ * const n = gui.new_box_node(vmath.vector3(200, 200, 0), vmath.vector3(w, h, 0));
1885
+ * gui.set_texture(n, "dynamic_tx");
1886
+ *
1887
+ * // ...
1888
+ *
1889
+ * // Change the data in the texture to a nice orange.
1890
+ * const orange = String.fromCharCode(0xff, 0x80, 0x10);
1891
+ * if (gui.set_texture_data("dynamic_tx", w, h, "rgb", orange.repeat(w * h))) {
1892
+ * // Go on and to more stuff
1893
+ * // ...
1894
+ * }
1895
+ * } else {
1896
+ * // Something went wrong
1897
+ * // ...
1898
+ * }
1899
+ * },
1900
+ * });
1901
+ * ```
1902
+ */
1903
+ function set_texture_data(texture: string | Hash, width: number, height: number, type: string | image.TYPE, buffer: string, flip: boolean): boolean;
2085
1904
  /**
2086
1905
  * Sets the tracking value of a text node. This value is used to
2087
1906
  * adjust the vertical spacing of characters in the text.
@@ -2135,56 +1954,14 @@ declare global {
2135
1954
  * @param node - node to stop particle fx for
2136
1955
  * @param options - options used when stopping the particle fx
2137
1956
  */
2138
- function stop_particlefx(node: Opaque<"node">, options?: particlefx.stop_options): void;
1957
+ function stop_particlefx(node: Opaque<"node">): void;
2139
1958
  /**
2140
- * This is a callback-function, which is called by the engine every frame to update the state of a gui component.
2141
- * It can be used to perform any kind of gui related tasks, e.g. animating nodes.
2142
- *
2143
- * @param self - script instance used for storing state
2144
- * @param dt - the time-step of the frame update
2145
- * @example
2146
- * ```ts
2147
- * // This example demonstrates how to update a text node that displays game score
2148
- * // in a counting fashion. It is assumed that the gui component receives messages
2149
- * // from the game when a new score is to be shown.
2150
- * export default defineGuiScript({
2151
- * init() {
2152
- * return {
2153
- * // fetch the score text node for later use (assumes it is called "score")
2154
- * score_node: gui.get_node("score"),
2155
- * // keep track of the current score counted up so far
2156
- * current_score: 0,
2157
- * // keep track of the target score we should count up to
2158
- * target_score: 0,
2159
- * // how fast we will update the score, in score/second
2160
- * score_update_speed: 1,
2161
- * };
2162
- * },
2163
- *
2164
- * update(self, dt) {
2165
- * // check if target score is more than current score
2166
- * if (self.current_score < self.target_score) {
2167
- * // increment current score according to the speed
2168
- * self.current_score = self.current_score + dt * self.score_update_speed;
2169
- * // check if we went past the target score, clamp current score in that case
2170
- * if (self.current_score > self.target_score) {
2171
- * self.current_score = self.target_score;
2172
- * }
2173
- * // update the score text node
2174
- * gui.set_text(self.score_node, "" + math.floor(self.current_score));
2175
- * }
2176
- * },
1959
+ * Stops the particle fx for a gui node
2177
1960
  *
2178
- * on_message(self, message_id, message) {
2179
- * // check the message
2180
- * if (message_id === hash("set_score") && typeof message.score === "number") {
2181
- * self.target_score = message.score;
2182
- * }
2183
- * },
2184
- * });
2185
- * ```
1961
+ * @param node - node to stop particle fx for
1962
+ * @param options - options used when stopping the particle fx
2186
1963
  */
2187
- function update(self: unknown, dt: number): void;
1964
+ function stop_particlefx(node: Opaque<"node">, options: particlefx.stop_options): void;
2188
1965
  interface properties {
2189
1966
  /**
2190
1967
  * The fonts used in the gui. The type of the property is hash.
@@ -1,5 +1,5 @@
1
1
  /** @noSelfInFile */
2
- import type { Hash } from "../../../src/core-types";
2
+ import type { Hash, Url } from "../../../src/core-types";
3
3
 
4
4
  declare global {
5
5
  /**
@@ -78,7 +78,7 @@ declare global {
78
78
  * });
79
79
  * ```
80
80
  */
81
- function request(url: string, method: string, callback: (self: unknown, id: Hash, response: { status: number; url: string; response?: string; headers?: LuaMap<string, string>; path?: string; error?: string; bytes_sent?: number; bytes_received?: number; bytes_total?: number; range_start?: number; range_end?: number; document_size?: number }) => void, headers?: LuaMap<string, string> | Record<string, string>, post_data?: string, options?: http.request_options): void;
81
+ function request(url: string, method: string, callback: (self: unknown, id: Hash, response: { status: number; url: string; response?: string; headers?: LuaMap<string, string>; path?: string; error?: string; bytes_sent?: number; bytes_received?: number; bytes_total?: number; range_start?: number; range_end?: number; document_size?: number }, sender: Url) => void, headers?: LuaMap<string, string> | Record<string, string>, post_data?: string, options?: http.request_options): void;
82
82
  }
83
83
  }
84
84