@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
  /**
@@ -441,120 +441,6 @@ declare global {
441
441
  * text type
442
442
  */
443
443
  const TYPE_TEXT: number & { readonly __brand: "gui.TYPE_TEXT" };
444
- /**
445
- * This starts an animation of a node property according to the specified parameters.
446
- * If the node property is already being animated, that animation will be canceled and
447
- * replaced by the new one. Note however that several different node properties
448
- * can be animated simultaneously. Use `gui.cancel_animations` to stop the animation
449
- * before it has completed.
450
- * Composite properties of type vector3, vector4 or quaternion
451
- * also expose their sub-components (x, y, z and w).
452
- * You can address the components individually by suffixing the name with a dot '.'
453
- * and the name of the component.
454
- * For instance, `"position.x"` (the position x coordinate) or `"color.w"`
455
- * (the color alpha value).
456
- * If a `complete_function` (Lua function) is specified, that function will be called
457
- * when the animation has completed.
458
- * By starting a new animation in that function, several animations can be sequenced
459
- * together. See the examples below for more information.
460
- *
461
- * @param node - node to animate
462
- * @param property - property to animate
463
- *
464
- * - `"position"`
465
- * - `"rotation"`
466
- * - `"euler"`
467
- * - `"scale"`
468
- * - `"color"`
469
- * - `"outline"`
470
- * - `"shadow"`
471
- * - `"size"`
472
- * - `"fill_angle"` (pie)
473
- * - `"inner_radius"` (pie)
474
- * - `"leading"` (text)
475
- * - `"tracking"` (text)
476
- * - `"slice9"` (slice9)
477
- *
478
- * The following property constants are defined equaling the corresponding property string names.
479
- *
480
- * - `gui.PROP_POSITION`
481
- * - `gui.PROP_ROTATION`
482
- * - `gui.PROP_EULER`
483
- * - `gui.PROP_SCALE`
484
- * - `gui.PROP_COLOR`
485
- * - `gui.PROP_OUTLINE`
486
- * - `gui.PROP_SHADOW`
487
- * - `gui.PROP_SIZE`
488
- * - `gui.PROP_FILL_ANGLE`
489
- * - `gui.PROP_INNER_RADIUS`
490
- * - `gui.PROP_LEADING`
491
- * - `gui.PROP_TRACKING`
492
- * - `gui.PROP_SLICE9`
493
- * @param to - target property value
494
- * @param easing - easing to use during animation.
495
- * Either specify one of the `gui.EASING_*` constants or provide a
496
- * vector with a custom curve. See the animation guide for more information.
497
- * @param duration - duration of the animation in seconds.
498
- * @param delay - delay before the animation starts in seconds.
499
- * @param complete_function - function to call when the
500
- * animation has completed
501
- * @param playback - playback mode
502
- *
503
- * - `gui.PLAYBACK_ONCE_FORWARD`
504
- * - `gui.PLAYBACK_ONCE_BACKWARD`
505
- * - `gui.PLAYBACK_ONCE_PINGPONG`
506
- * - `gui.PLAYBACK_LOOP_FORWARD`
507
- * - `gui.PLAYBACK_LOOP_BACKWARD`
508
- * - `gui.PLAYBACK_LOOP_PINGPONG`
509
- * @example
510
- * How to start a simple color animation, where the node fades in to white during 0.5 seconds:
511
- * ```ts
512
- * // How to start a simple color animation, where the node fades in to white during 0.5 seconds:
513
- * const node = gui.get_node("my_node");
514
- * gui.set_color(node, vmath.vector4(0, 0, 0, 0)); // node is fully transparent
515
- * gui.animate(node, gui.PROP_COLOR, vmath.vector4(1, 1, 1, 1), gui.EASING_INOUTQUAD, 0.5); // start animation
516
- * ```
517
- * @example
518
- * 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:
519
- * ```ts
520
- * // How to start a sequenced animation where the node fades in to white during 0.5
521
- * // seconds, stays visible for 2 seconds and then fades out:
522
- * function on_animation_done(self: unknown, node: unknown) {
523
- * // fade out node, but wait 2 seconds before the animation starts
524
- * gui.animate(node as Opaque<"node">, gui.PROP_COLOR, vmath.vector4(0, 0, 0, 0), gui.EASING_OUTQUAD, 0.5, 2.0);
525
- * }
526
- *
527
- * export default defineGuiScript({
528
- * init(self) {
529
- * // fetch the node we want to animate
530
- * const my_node = gui.get_node("my_node");
531
- * // node is initially set to fully transparent
532
- * gui.set_color(my_node, vmath.vector4(0, 0, 0, 0));
533
- * // animate the node immediately and call on_animation_done when the animation has completed
534
- * gui.animate(my_node, gui.PROP_COLOR, vmath.vector4(1, 1, 1, 1), gui.EASING_INOUTQUAD, 0.5, 0.0, on_animation_done);
535
- * },
536
- * });
537
- * ```
538
- * @example
539
- * How to animate a node's y position using a crazy custom easing curve:
540
- * ```ts
541
- * // How to animate a node's y position using a crazy custom easing curve:
542
- * export default defineGuiScript({
543
- * init(self) {
544
- * const values = [
545
- * 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
546
- * 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
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
- * ];
550
- * const vec = vmath.vector(values);
551
- * const node = gui.get_node("box");
552
- * gui.animate(node, "position.y", 100, vec, 4.0, 0, undefined, gui.PLAYBACK_LOOP_PINGPONG);
553
- * },
554
- * });
555
- * ```
556
- */
557
- 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;
558
444
  /**
559
445
  * If one or more animations of the specified node is currently running (started by `gui.animate`), they will immediately be canceled.
560
446
  *
@@ -625,10 +511,10 @@ declare global {
625
511
  * Make a clone instance of a node and all its children.
626
512
  * Use gui.clone to clone a node excluding its children.
627
513
  *
628
- * @param node - root node to clone
514
+ * @param node - root node to clone, or `nil` to clone the whole scene; leaving the argument out raises an error
629
515
  * @returns a table mapping node ids to the corresponding cloned nodes
630
516
  */
631
- function clone_tree(node: Opaque<"node">): LuaTable<Hash, Opaque<"node">> & { get: LuaTableGetMethod<string, Opaque<"node">> };
517
+ function clone_tree(node: Opaque<"node"> | undefined): LuaTable<Hash, Opaque<"node">> & { get: LuaTableGetMethod<string, Opaque<"node">> };
632
518
  /**
633
519
  * Deletes the specified node. Any child nodes of the specified node will be
634
520
  * recursively deleted.
@@ -663,66 +549,6 @@ declare global {
663
549
  * ```
664
550
  */
665
551
  function delete_texture(texture: string | Hash): void;
666
- /**
667
- * This is a callback-function, which is called by the engine when a gui component is finalized (destroyed). It can
668
- * be used to e.g. take some last action, report the finalization to other game object instances
669
- * or release user input focus (see `release_input_focus`). There is no use in starting any animations or similar
670
- * from this function since the gui component is about to be destroyed.
671
- *
672
- * @param self - reference to the script state to be used for storing data
673
- * @example
674
- * ```ts
675
- * export default defineScript({
676
- * init() {
677
- * return { some_value: 0 };
678
- * },
679
- *
680
- * final(self) {
681
- * // report finalization
682
- * msg.post("my_friend_instance", "im_dead", { my_stats: self.some_value });
683
- * },
684
- * });
685
- * ```
686
- */
687
- function final(self: Opaque<"userdata">): void;
688
- /**
689
- * Instead of using specific getters such as gui.get_position or gui.get_scale,
690
- * you can use gui.get instead and supply the property as a string or a hash.
691
- * While this function is similar to go.get, there are a few more restrictions
692
- * when operating in the gui namespace. Most notably, only these explicitly named properties are supported:
693
- *
694
- * - `"position"`
695
- * - `"rotation"`
696
- * - `"euler"`
697
- * - `"scale"`
698
- * - `"color"`
699
- * - `"outline"`
700
- * - `"shadow"`
701
- * - `"size"`
702
- * - `"fill_angle"` (pie)
703
- * - `"inner_radius"` (pie)
704
- * - `"leading"` (text)
705
- * - `"tracking"` (text)
706
- * - `"slice9"` (slice9)
707
- *
708
- * The value returned will either be a vmath.vector4 or a single number, i.e getting the "position"
709
- * property will return a vec4 while getting the "position.x" property will return a single value.
710
- * You can also use this function to get material constants.
711
- *
712
- * @param node - node to get the property for
713
- * @param property - the property to retrieve
714
- * @param options - optional options table (only applicable for material constants)
715
- * - `index` number index into array property (1 based)
716
- *
717
- * **⚠️ `index` is 1-based; passed to Defold unchanged.**
718
- * @example
719
- * ```ts
720
- * // Get properties on existing nodes:
721
- * const node = gui.get_node("my_box_node");
722
- * const node_position = gui.get(node, "position");
723
- * ```
724
- */
725
- function get(node: Opaque<"node">, property: string | Hash | gui.Property, options?: { index?: number; key?: string | Hash; keys?: (Hash | string)[] }): unknown;
726
552
  /**
727
553
  * Returns the adjust mode of a node.
728
554
  * The adjust mode defines how the node will adjust itself to screen
@@ -1141,10 +967,10 @@ declare global {
1141
967
  /**
1142
968
  * Get a node and all its children as a Lua table.
1143
969
  *
1144
- * @param node - root node to get node tree from
970
+ * @param node - root node to get node tree from, or `nil` to get the whole scene; leaving the argument out raises an error
1145
971
  * @returns a table mapping node ids to the corresponding nodes
1146
972
  */
1147
- function get_tree(node: Opaque<"node">): LuaTable<Hash, Opaque<"node">> & { get: LuaTableGetMethod<string, Opaque<"node">> };
973
+ function get_tree(node: Opaque<"node"> | undefined): LuaTable<Hash, Opaque<"node">> & { get: LuaTableGetMethod<string, Opaque<"node">> };
1148
974
  /**
1149
975
  * gets the node type
1150
976
  *
@@ -1191,22 +1017,6 @@ declare global {
1191
1017
  * Hides the on-display touch keyboard on the device.
1192
1018
  */
1193
1019
  function hide_keyboard(): void;
1194
- /**
1195
- * This is a callback-function, which is called by the engine when a gui component is initialized. It can be used
1196
- * to set the initial state of the script and gui scene.
1197
- *
1198
- * @param self - reference to the script state to be used for storing data
1199
- * @example
1200
- * ```ts
1201
- * export default defineScript({
1202
- * init() {
1203
- * // set up useful data
1204
- * return { my_value: 1 };
1205
- * },
1206
- * });
1207
- * ```
1208
- */
1209
- function init(self: Opaque<"userdata">): void;
1210
1020
  /**
1211
1021
  * Returns `true` if a node is enabled and `false` if it's not.
1212
1022
  * Disabled nodes are not rendered and animations acting on them are not evaluated.
@@ -1324,197 +1134,66 @@ declare global {
1324
1134
  * }
1325
1135
  * ```
1326
1136
  */
1327
- function new_texture(texture_id: string | Hash, width: number, height: number, type: string | Opaque<"constant">, buffer: string, flip?: boolean): LuaMultiReturn<[boolean, number | undefined]>;
1137
+ function new_texture(texture_id: string | Hash, width: number, height: number, type: string | Opaque<"constant">, buffer: string): LuaMultiReturn<[boolean, number | undefined]>;
1328
1138
  /**
1329
- * This is a callback-function, which is called by the engine when user input is sent to the instance of the gui component.
1330
- * It can be used to take action on the input, e.g. modify the gui according to the input.
1331
- * For an instance to obtain user input, it must first acquire input
1332
- * focus through the message `acquire_input_focus`.
1333
- * Any instance that has obtained input will be put on top of an
1334
- * input stack. Input is sent to all listeners on the stack until the
1335
- * end of stack is reached, or a listener returns `true`
1336
- * to signal that it wants input to be consumed.
1337
- * See the documentation of acquire_input_focus for more
1338
- * information.
1339
- * The `action` parameter is a table containing data about the input mapped to the
1340
- * `action_id`.
1341
- * For mapped actions it specifies the value of the input and if it was just pressed or released.
1342
- * Actions are mapped to input in an input_binding-file.
1343
- * Mouse movement is specifically handled and uses `nil` as its `action_id`.
1344
- * The `action` only contains positional parameters in this case, such as x and y of the pointer.
1345
- * Here is a brief description of the available table fields:
1346
- *
1347
- * Field
1348
- * Description
1349
- *
1350
- * `value`
1351
- * 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.
1352
- *
1353
- * `pressed`
1354
- * If the input was pressed this frame. This is not present for mouse movement and text input.
1355
- *
1356
- * `released`
1357
- * If the input was released this frame. This is not present for mouse movement and text input.
1358
- *
1359
- * `repeated`
1360
- * 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.
1361
- *
1362
- * `x`
1363
- * The x value of a pointer device, if present. This is not present for gamepad, key and text input.
1364
- *
1365
- * `y`
1366
- * The y value of a pointer device, if present. This is not present for gamepad, key and text input.
1367
- *
1368
- * `screen_x`
1369
- * The screen space x value of a pointer device, if present. This is not present for gamepad, key and text input.
1370
- *
1371
- * `screen_y`
1372
- * The screen space y value of a pointer device, if present. This is not present for gamepad, key and text input.
1373
- *
1374
- * `dx`
1375
- * The change in x value of a pointer device, if present. This is not present for gamepad, key and text input.
1376
- *
1377
- * `dy`
1378
- * The change in y value of a pointer device, if present. This is not present for gamepad, key and text input.
1379
- *
1380
- * `screen_dx`
1381
- * The change in screen space x value of a pointer device, if present. This is not present for gamepad, key and text input.
1382
- *
1383
- * `screen_dy`
1384
- * The change in screen space y value of a pointer device, if present. This is not present for gamepad, key and text input.
1385
- *
1386
- * `gamepad`
1387
- * The index of the gamepad device that provided the input. See table below about gamepad input.
1388
- *
1389
- * `touch`
1390
- * List of touch input, one element per finger, if present. See table below about touch input
1391
- *
1392
- * `text`
1393
- * Text input from a (virtual) keyboard or similar.
1394
- *
1395
- * `marked_text`
1396
- * Sequence of entered symbols while entering a symbol combination, for example Japanese Kana.
1397
- *
1398
- * Gamepad specific fields:
1399
- *
1400
- * Field
1401
- * Description
1402
- *
1403
- * `gamepad`
1404
- * The index of the gamepad device that provided the input.
1405
- *
1406
- * `userid`
1407
- * Id of the user associated with the controller. Usually only relevant on consoles.
1408
- *
1409
- * `gamepad_unknown`
1410
- * True if the inout originated from an unknown/unmapped gamepad.
1411
- *
1412
- * `gamepad_name`
1413
- * Name of the gamepad
1414
- *
1415
- * `gamepad_axis`
1416
- * List of gamepad axis values. For raw gamepad input only.
1417
- *
1418
- * `gamepadhats`
1419
- * List of gamepad hat values. For raw gamepad input only.
1420
- *
1421
- * `gamepad_buttons`
1422
- * List of gamepad button values. For raw gamepad input only.
1423
- *
1424
- * Touch input table:
1425
- *
1426
- * Field
1427
- * Description
1428
- *
1429
- * `id`
1430
- * A number identifying the touch input during its duration.
1431
- *
1432
- * `pressed`
1433
- * True if the finger was pressed this frame.
1434
- *
1435
- * `released`
1436
- * True if the finger was released this frame.
1437
- *
1438
- * `tap_count`
1439
- * Number of taps, one for single, two for double-tap, etc
1440
- *
1441
- * `x`
1442
- * The x touch location.
1443
- *
1444
- * `y`
1445
- * The y touch location.
1446
- *
1447
- * `dx`
1448
- * The change in x value.
1449
- *
1450
- * `dy`
1451
- * The change in y value.
1452
- *
1453
- * `acc_x`
1454
- * Accelerometer x value (if present).
1455
- *
1456
- * `acc_y`
1457
- * Accelerometer y value (if present).
1139
+ * Dynamically create a new texture.
1458
1140
  *
1459
- * `acc_z`
1460
- * Accelerometer z value (if present).
1141
+ * @param texture_id - texture id
1142
+ * @param width - texture width
1143
+ * @param height - texture height
1144
+ * @param type - texture type
1461
1145
  *
1462
- * @param self - reference to the script state to be used for storing data
1463
- * @param action_id - id of the received input action, as mapped in the input_binding-file
1464
- * @param action - a table containing the input data, see above for a description. **0️⃣ `gamepad` is 0-based; passed to Defold unchanged.**
1465
- * @returns optional boolean to signal if the input should be consumed (not passed on to others) or not, default is false
1146
+ * - `"rgb"` - RGB
1147
+ * - `"rgba"` - RGBA
1148
+ * - `"l"` - LUMINANCE
1149
+ * - `"astc"` - ASTC compressed format
1150
+ * @param buffer - texture data
1151
+ * @param flip - flip texture vertically
1466
1152
  * @example
1153
+ * How to create a texture and apply it to a new box node:
1467
1154
  * ```ts
1468
1155
  * export default defineGuiScript({
1469
- * init(): { my_value: number | undefined } {
1470
- * return { my_value: undefined };
1471
- * },
1156
+ * init(self) {
1157
+ * const w = 200;
1158
+ * const h = 300;
1472
1159
  *
1473
- * on_input(self, action_id, action) {
1474
- * // check for input
1475
- * if (action_id === hash("my_action")) {
1476
- * // take appropriate action
1477
- * self.my_value = action.value;
1160
+ * // A nice orange. String with the RGB values.
1161
+ * const orange = String.fromCharCode(0xff, 0x80, 0x10);
1162
+ *
1163
+ * // Create the texture. Repeat the color string for each pixel.
1164
+ * const [ok, reason] = gui.new_texture("orange_tx", w, h, "rgb", orange.repeat(w * h));
1165
+ * if (ok) {
1166
+ * // Create a box node and apply the texture to it.
1167
+ * const n = gui.new_box_node(vmath.vector3(200, 200, 0), vmath.vector3(w, h, 0));
1168
+ * gui.set_texture(n, "orange_tx");
1169
+ * } else {
1170
+ * // Could not create texture for some reason...
1171
+ * if (reason === gui.RESULT_TEXTURE_ALREADY_EXISTS) {
1172
+ * // ...
1173
+ * } else {
1174
+ * // ...
1175
+ * }
1478
1176
  * }
1479
- * // consume input
1480
- * return true;
1481
1177
  * },
1482
1178
  * });
1483
1179
  * ```
1484
- */
1485
- 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;
1486
- /**
1487
- * This is a callback-function, which is called by the engine whenever a message has been sent to the gui component.
1488
- * 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.
1489
- * The `message` parameter is a table containing the message data. If the message is sent from the engine, the
1490
- * documentation of the message specifies which data is supplied.
1491
- * See the update function for examples on how to use this callback-function.
1492
- *
1493
- * @param self - reference to the script state to be used for storing data
1494
- * @param message_id - id of the received message
1495
- * @param message - a table containing the message data
1496
- */
1497
- function on_message(self: Opaque<"userdata">, message_id: Hash, message: Record<string | number, unknown>): void;
1498
- /**
1499
- * This is a callback-function, which is called by the engine when the gui script is reloaded, e.g. from the editor.
1500
- * It can be used for live development, e.g. to tweak constants or set up the state properly for the script.
1501
- *
1502
- * @param self - reference to the script state to be used for storing data
1503
1180
  * @example
1181
+ * How to create a texture using .astc format
1504
1182
  * ```ts
1505
- * export default defineGuiScript({
1506
- * init() {
1507
- * return { my_original_color: gui.get_color(gui.get_node("my_node")) };
1508
- * },
1509
- *
1510
- * on_reload(self) {
1511
- * // restore some color (or similar)
1512
- * gui.set_color(gui.get_node("my_node"), self.my_original_color);
1513
- * },
1514
- * });
1183
+ * const size = 4;
1184
+ * const pos = vmath.vector3(200, 200, 0);
1185
+ * const path = "/assets/images/logo_4x4.astc";
1186
+ * const [data] = sys.load_resource(path);
1187
+ * if (data !== undefined) {
1188
+ * const n = gui.new_box_node(pos, vmath.vector3(size, size, 0));
1189
+ * // size is read from the .astc buffer
1190
+ * // flip is not supported
1191
+ * gui.new_texture(path, 0, 0, "astc", data, false);
1192
+ * gui.set_texture(n, path);
1193
+ * }
1515
1194
  * ```
1516
1195
  */
1517
- function on_reload(self: Opaque<"userdata">): void;
1196
+ function new_texture(texture_id: string | Hash, width: number, height: number, type: string | Opaque<"constant">, buffer: string, flip: boolean): LuaMultiReturn<[boolean, number | undefined]>;
1518
1197
  /**
1519
1198
  * Tests whether a coordinate is within the bounding box of a
1520
1199
  * node.
@@ -1572,7 +1251,55 @@ declare global {
1572
1251
  * gui.play_flipbook(node, "button");
1573
1252
  * ```
1574
1253
  */
1575
- function play_flipbook(node: Opaque<"node">, animation: string | Hash, complete_function?: (self: unknown, node: unknown) => void, play_properties?: { offset?: number; playback_rate?: number }): void;
1254
+ function play_flipbook(node: Opaque<"node">, animation: string | Hash, complete_function?: (self: unknown, node: unknown) => void): void;
1255
+ /**
1256
+ * Play flipbook animation on a box or pie node.
1257
+ * The current node texture must contain the animation.
1258
+ * Use this function to set one-frame still images on the node.
1259
+ *
1260
+ * @param node - node to set animation for
1261
+ * @param animation - animation id
1262
+ * @param complete_function - optional function to call when the animation has completed
1263
+ *
1264
+ * `self`
1265
+ *
1266
+ * object The current object.
1267
+ *
1268
+ * `node`
1269
+ *
1270
+ * node The node that is animated.
1271
+ * @param play_properties - optional table with properties
1272
+ *
1273
+ * `offset`
1274
+ * number The normalized initial value of the animation cursor when the animation starts playing
1275
+ * `playback_rate`
1276
+ * number The rate with which the animation will be played. Must be positive
1277
+ * @example
1278
+ * Set the texture of a node to a flipbook animation from an atlas:
1279
+ * ```ts
1280
+ * function anim_callback(self: unknown, node: unknown) {
1281
+ * // Take action after animation has played.
1282
+ * }
1283
+ *
1284
+ * export default defineGuiScript({
1285
+ * init(self) {
1286
+ * // Create a new node and set the texture to a flipbook animation
1287
+ * const node = gui.get_node("button_node");
1288
+ * gui.set_texture(node, "gui_sprites");
1289
+ * gui.play_flipbook(node, "animated_button");
1290
+ * },
1291
+ * });
1292
+ * ```
1293
+ * @example
1294
+ * Set the texture of a node to an image from an atlas:
1295
+ * ```ts
1296
+ * // Create a new node and set the texture to a "button.png" from atlas
1297
+ * const node = gui.get_node("button_node");
1298
+ * gui.set_texture(node, "gui_sprites");
1299
+ * gui.play_flipbook(node, "button");
1300
+ * ```
1301
+ */
1302
+ 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;
1576
1303
  /**
1577
1304
  * Plays the paricle fx for a gui node
1578
1305
  *
@@ -1639,100 +1366,6 @@ declare global {
1639
1366
  * @returns local position
1640
1367
  */
1641
1368
  function screen_to_local(node: Opaque<"node">, screen_position: Vector3 | Vector4): Vector3;
1642
- /**
1643
- * Instead of using specific setteres such as gui.set_position or gui.set_scale,
1644
- * you can use gui.set instead and supply the property as a string or a hash.
1645
- * While this function is similar to go.get and go.set, there are a few more restrictions
1646
- * when operating in the gui namespace. Most notably, only these named properties identifiers are supported:
1647
- *
1648
- * - `"position"`
1649
- * - `"rotation"`
1650
- * - `"euler"`
1651
- * - `"scale"`
1652
- * - `"color"`
1653
- * - `"outline"`
1654
- * - `"shadow"`
1655
- * - `"size"`
1656
- * - `"fill_angle"` (pie)
1657
- * - `"inner_radius"` (pie)
1658
- * - `"leading"` (text)
1659
- * - `"tracking"` (text)
1660
- * - `"slice9"` (slice9)
1661
- *
1662
- * 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.
1663
- * I.e when setting the "position" property, you need to use a vmath.vector4 and when setting a single component of the property,
1664
- * such as "position.x", you need to use a single value.
1665
- * 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,
1666
- * 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,
1667
- * use the "euler" property instead. The rotation and euler properties are linked, changing one of them will change the backing data of the other.
1668
- * 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
1669
- * 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())`
1670
- * 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.
1671
- * 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.
1672
- *
1673
- * @param node - node to set the property for, or msg.url() to the gui itself
1674
- * @param property - the property to set
1675
- * @param value - the property to set
1676
- * @param options - optional options table (only applicable for material constants)
1677
- * - `index` number index into array property (1 based)
1678
- * - `key` hash name of internal property
1679
- *
1680
- * **⚠️ `index` is 1-based; passed to Defold unchanged.**
1681
- * @example
1682
- * Updates the position property on an existing node:
1683
- * ```ts
1684
- * const node = gui.get_node("my_box_node");
1685
- * const node_position = gui.get(node, "position") as Vector3;
1686
- * gui.set(node, "position.x", node_position.x + 128);
1687
- * ```
1688
- * @example
1689
- * Updates the rotation property on an existing node:
1690
- * ```ts
1691
- * const node = gui.get_node("my_box_node");
1692
- * gui.set(node, "rotation", vmath.quat_rotation_z(math.rad(45)));
1693
- * // this is equivalent to:
1694
- * gui.set(node, "euler.z", 45);
1695
- * // or using the entire vector:
1696
- * gui.set(node, "euler", vmath.vector3(0, 0, 45));
1697
- * // or using the set_rotation
1698
- * gui.set_rotation(node, vmath.vector3(0, 0, 45));
1699
- * ```
1700
- * @example
1701
- * Sets various material constants for a node:
1702
- * ```ts
1703
- * const node = gui.get_node("my_box_node");
1704
- * gui.set(node, "tint", vmath.vector4(1, 0, 0, 1));
1705
- * // matrix4 is also supported
1706
- * gui.set(node, "light_matrix", vmath.matrix4());
1707
- * // update a constant in an array at position 4. the array is specified in the shader as:
1708
- * // uniform vec4 tint_array[4]; // lua is 1 based, shader is 0 based
1709
- * gui.set(node, "tint_array", vmath.vector4(1, 0, 0, 1), { index: 4 });
1710
- * // update a matrix constant in an array at position 4. the array is specified in the shader as:
1711
- * // uniform mat4 light_matrix_array[4];
1712
- * gui.set(node, "light_matrix_array", vmath.matrix4(), { index: 4 });
1713
- * // update a sub-element in a constant
1714
- * gui.set(node, "tint.x", 1);
1715
- * // update a sub-element in an array constant at position 4
1716
- * gui.set(node, "tint_array.x", 1, { index: 4 });
1717
- * ```
1718
- * @example
1719
- * Set a named property
1720
- * ```ts
1721
- * export default defineGuiScript({
1722
- * on_message(self, message_id, message) {
1723
- * if (message_id === hash("set_font") && types.is_hash(message.font)) {
1724
- * gui.set(msg.url(), "fonts", message.font, { key: "my_font_name" });
1725
- * gui.set_font(gui.get_node("text"), "my_font_name");
1726
- * } else if (message_id === hash("set_texture") && types.is_hash(message.texture)) {
1727
- * gui.set(msg.url(), "textures", message.texture, { key: "my_texture" });
1728
- * gui.set_texture(gui.get_node("box"), "my_texture");
1729
- * gui.play_flipbook(gui.get_node("box"), "logo_256");
1730
- * }
1731
- * },
1732
- * });
1733
- * ```
1734
- */
1735
- 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;
1736
1369
  /**
1737
1370
  * Sets the adjust mode on a node.
1738
1371
  * The adjust mode defines how the node will adjust itself to screen
@@ -2172,7 +1805,52 @@ declare global {
2172
1805
  * });
2173
1806
  * ```
2174
1807
  */
2175
- function set_texture_data(texture: string | Hash, width: number, height: number, type: string | Opaque<"constant">, buffer: string, flip?: boolean): boolean;
1808
+ function set_texture_data(texture: string | Hash, width: number, height: number, type: string | Opaque<"constant">, buffer: string): boolean;
1809
+ /**
1810
+ * Set the texture buffer data for a dynamically created texture.
1811
+ *
1812
+ * @param texture - texture id
1813
+ * @param width - texture width
1814
+ * @param height - texture height
1815
+ * @param type - texture type
1816
+ *
1817
+ * - `"rgb"` - RGB
1818
+ * - `"rgba"` - RGBA
1819
+ * - `"l"` - LUMINANCE
1820
+ * - `"astc"` - ASTC compressed format
1821
+ * @param buffer - texture data
1822
+ * @param flip - flip texture vertically
1823
+ * @returns setting the data was successful
1824
+ * @example
1825
+ * ```ts
1826
+ * export default defineGuiScript({
1827
+ * init(self) {
1828
+ * const w = 200;
1829
+ * const h = 300;
1830
+ *
1831
+ * // Create a dynamic texture, all white.
1832
+ * if (gui.new_texture("dynamic_tx", w, h, "rgb", String.fromCharCode(0xff).repeat(w * h * 3))) {
1833
+ * // Create a box node and apply the texture to it.
1834
+ * const n = gui.new_box_node(vmath.vector3(200, 200, 0), vmath.vector3(w, h, 0));
1835
+ * gui.set_texture(n, "dynamic_tx");
1836
+ *
1837
+ * // ...
1838
+ *
1839
+ * // Change the data in the texture to a nice orange.
1840
+ * const orange = String.fromCharCode(0xff, 0x80, 0x10);
1841
+ * if (gui.set_texture_data("dynamic_tx", w, h, "rgb", orange.repeat(w * h))) {
1842
+ * // Go on and to more stuff
1843
+ * // ...
1844
+ * }
1845
+ * } else {
1846
+ * // Something went wrong
1847
+ * // ...
1848
+ * }
1849
+ * },
1850
+ * });
1851
+ * ```
1852
+ */
1853
+ function set_texture_data(texture: string | Hash, width: number, height: number, type: string | Opaque<"constant">, buffer: string, flip: boolean): boolean;
2176
1854
  /**
2177
1855
  * Sets the tracking value of a text node. This value is used to
2178
1856
  * adjust the vertical spacing of characters in the text.
@@ -2233,56 +1911,16 @@ declare global {
2233
1911
  *
2234
1912
  * - boolean `clear`: instantly clear spawned particles
2235
1913
  */
2236
- function stop_particlefx(node: Opaque<"node">, options?: { clear?: boolean }): void;
1914
+ function stop_particlefx(node: Opaque<"node">): void;
2237
1915
  /**
2238
- * This is a callback-function, which is called by the engine every frame to update the state of a gui component.
2239
- * It can be used to perform any kind of gui related tasks, e.g. animating nodes.
2240
- *
2241
- * @param self - reference to the script state to be used for storing data
2242
- * @param dt - the time-step of the frame update
2243
- * @example
2244
- * ```ts
2245
- * // This example demonstrates how to update a text node that displays game score
2246
- * // in a counting fashion. It is assumed that the gui component receives messages
2247
- * // from the game when a new score is to be shown.
2248
- * export default defineGuiScript({
2249
- * init() {
2250
- * return {
2251
- * // fetch the score text node for later use (assumes it is called "score")
2252
- * score_node: gui.get_node("score"),
2253
- * // keep track of the current score counted up so far
2254
- * current_score: 0,
2255
- * // keep track of the target score we should count up to
2256
- * target_score: 0,
2257
- * // how fast we will update the score, in score/second
2258
- * score_update_speed: 1,
2259
- * };
2260
- * },
1916
+ * Stops the particle fx for a gui node
2261
1917
  *
2262
- * update(self, dt) {
2263
- * // check if target score is more than current score
2264
- * if (self.current_score < self.target_score) {
2265
- * // increment current score according to the speed
2266
- * self.current_score = self.current_score + dt * self.score_update_speed;
2267
- * // check if we went past the target score, clamp current score in that case
2268
- * if (self.current_score > self.target_score) {
2269
- * self.current_score = self.target_score;
2270
- * }
2271
- * // update the score text node
2272
- * gui.set_text(self.score_node, "" + math.floor(self.current_score));
2273
- * }
2274
- * },
1918
+ * @param node - node to stop particle fx for
1919
+ * @param options - options when stopping the particle fx. Supported options:
2275
1920
  *
2276
- * on_message(self, message_id, message) {
2277
- * // check the message
2278
- * if (message_id === hash("set_score") && typeof message.score === "number") {
2279
- * self.target_score = message.score;
2280
- * }
2281
- * },
2282
- * });
2283
- * ```
1921
+ * - boolean `clear`: instantly clear spawned particles
2284
1922
  */
2285
- function update(self: Opaque<"userdata">, dt: number): void;
1923
+ function stop_particlefx(node: Opaque<"node">, options: { clear?: boolean }): void;
2286
1924
  interface properties {
2287
1925
  /**
2288
1926
  * The fonts used in the gui. The type of the property is hash.