@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
  /**
@@ -443,120 +443,6 @@ declare global {
443
443
  * text type
444
444
  */
445
445
  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
446
  /**
561
447
  * If one or more animations of the specified node is currently running (started by `gui.animate`), they will immediately be canceled.
562
448
  *
@@ -627,10 +513,10 @@ declare global {
627
513
  * Make a clone instance of a node and all its children.
628
514
  * Use gui.clone to clone a node excluding its children.
629
515
  *
630
- * @param node - root node to clone
516
+ * @param node - root node to clone, or `nil` to clone the whole scene; leaving the argument out raises an error
631
517
  * @returns a table mapping node ids to the corresponding cloned nodes
632
518
  */
633
- function clone_tree(node: Opaque<"node">): LuaTable<Hash, Opaque<"node">> & { get: LuaTableGetMethod<string, Opaque<"node">> };
519
+ function clone_tree(node: Opaque<"node"> | undefined): LuaTable<Hash, Opaque<"node">> & { get: LuaTableGetMethod<string, Opaque<"node">> };
634
520
  /**
635
521
  * Deletes the specified node. Any child nodes of the specified node will be
636
522
  * recursively deleted.
@@ -665,66 +551,6 @@ declare global {
665
551
  * ```
666
552
  */
667
553
  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
554
  /**
729
555
  * Returns the adjust mode of a node.
730
556
  * The adjust mode defines how the node will adjust itself to screen
@@ -1143,10 +969,10 @@ declare global {
1143
969
  /**
1144
970
  * Get a node and all its children as a Lua table.
1145
971
  *
1146
- * @param node - root node to get node tree from
972
+ * @param node - root node to get node tree from, or `nil` to get the whole scene; leaving the argument out raises an error
1147
973
  * @returns a table mapping node ids to the corresponding nodes
1148
974
  */
1149
- function get_tree(node: Opaque<"node">): LuaTable<Hash, Opaque<"node">> & { get: LuaTableGetMethod<string, Opaque<"node">> };
975
+ function get_tree(node: Opaque<"node"> | undefined): LuaTable<Hash, Opaque<"node">> & { get: LuaTableGetMethod<string, Opaque<"node">> };
1150
976
  /**
1151
977
  * gets the node type
1152
978
  *
@@ -1193,22 +1019,6 @@ declare global {
1193
1019
  * Hides the on-display touch keyboard on the device.
1194
1020
  */
1195
1021
  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
1022
  /**
1213
1023
  * Returns `true` if a node is enabled and `false` if it's not.
1214
1024
  * Disabled nodes are not rendered and animations acting on them are not evaluated.
@@ -1326,197 +1136,66 @@ declare global {
1326
1136
  * }
1327
1137
  * ```
1328
1138
  */
1329
- function new_texture(texture_id: string | Hash, width: number, height: number, type: string | Opaque<"constant">, buffer: string, flip?: boolean): LuaMultiReturn<[boolean, number | undefined]>;
1139
+ function new_texture(texture_id: string | Hash, width: number, height: number, type: string | Opaque<"constant">, buffer: string): LuaMultiReturn<[boolean, number | undefined]>;
1330
1140
  /**
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).
1141
+ * Dynamically create a new texture.
1460
1142
  *
1461
- * `acc_z`
1462
- * Accelerometer z value (if present).
1143
+ * @param texture_id - texture id
1144
+ * @param width - texture width
1145
+ * @param height - texture height
1146
+ * @param type - texture type
1463
1147
  *
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
1148
+ * - `"rgb"` - RGB
1149
+ * - `"rgba"` - RGBA
1150
+ * - `"l"` - LUMINANCE
1151
+ * - `"astc"` - ASTC compressed format
1152
+ * @param buffer - texture data
1153
+ * @param flip - flip texture vertically
1468
1154
  * @example
1155
+ * How to create a texture and apply it to a new box node:
1469
1156
  * ```ts
1470
1157
  * export default defineGuiScript({
1471
- * init(): { my_value: number | undefined } {
1472
- * return { my_value: undefined };
1473
- * },
1158
+ * init(self) {
1159
+ * const w = 200;
1160
+ * const h = 300;
1474
1161
  *
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;
1162
+ * // A nice orange. String with the RGB values.
1163
+ * const orange = String.fromCharCode(0xff, 0x80, 0x10);
1164
+ *
1165
+ * // Create the texture. Repeat the color string for each pixel.
1166
+ * const [ok, reason] = gui.new_texture("orange_tx", w, h, "rgb", orange.repeat(w * h));
1167
+ * if (ok) {
1168
+ * // Create a box node and apply the texture to it.
1169
+ * const n = gui.new_box_node(vmath.vector3(200, 200, 0), vmath.vector3(w, h, 0));
1170
+ * gui.set_texture(n, "orange_tx");
1171
+ * } else {
1172
+ * // Could not create texture for some reason...
1173
+ * if (reason === gui.RESULT_TEXTURE_ALREADY_EXISTS) {
1174
+ * // ...
1175
+ * } else {
1176
+ * // ...
1177
+ * }
1480
1178
  * }
1481
- * // consume input
1482
- * return true;
1483
1179
  * },
1484
1180
  * });
1485
1181
  * ```
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
1182
  * @example
1183
+ * How to create a texture using .astc format
1506
1184
  * ```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
- * });
1185
+ * const size = 4;
1186
+ * const pos = vmath.vector3(200, 200, 0);
1187
+ * const path = "/assets/images/logo_4x4.astc";
1188
+ * const [data] = sys.load_resource(path);
1189
+ * if (data !== undefined) {
1190
+ * const n = gui.new_box_node(pos, vmath.vector3(size, size, 0));
1191
+ * // size is read from the .astc buffer
1192
+ * // flip is not supported
1193
+ * gui.new_texture(path, 0, 0, "astc", data, false);
1194
+ * gui.set_texture(n, path);
1195
+ * }
1517
1196
  * ```
1518
1197
  */
1519
- function on_reload(self: Opaque<"userdata">): void;
1198
+ function new_texture(texture_id: string | Hash, width: number, height: number, type: string | Opaque<"constant">, buffer: string, flip: boolean): LuaMultiReturn<[boolean, number | undefined]>;
1520
1199
  /**
1521
1200
  * Tests whether a coordinate is within the bounding box of a
1522
1201
  * node.
@@ -1574,7 +1253,55 @@ declare global {
1574
1253
  * gui.play_flipbook(node, "button");
1575
1254
  * ```
1576
1255
  */
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;
1256
+ function play_flipbook(node: Opaque<"node">, animation: string | Hash, complete_function?: (self: unknown, node: unknown) => void): void;
1257
+ /**
1258
+ * Play flipbook animation on a box or pie node.
1259
+ * The current node texture must contain the animation.
1260
+ * Use this function to set one-frame still images on the node.
1261
+ *
1262
+ * @param node - node to set animation for
1263
+ * @param animation - animation id
1264
+ * @param complete_function - optional function to call when the animation has completed
1265
+ *
1266
+ * `self`
1267
+ *
1268
+ * object The current object.
1269
+ *
1270
+ * `node`
1271
+ *
1272
+ * node The node that is animated.
1273
+ * @param play_properties - optional table with properties
1274
+ *
1275
+ * `offset`
1276
+ * number The normalized initial value of the animation cursor when the animation starts playing
1277
+ * `playback_rate`
1278
+ * number The rate with which the animation will be played. Must be positive
1279
+ * @example
1280
+ * Set the texture of a node to a flipbook animation from an atlas:
1281
+ * ```ts
1282
+ * function anim_callback(self: unknown, node: unknown) {
1283
+ * // Take action after animation has played.
1284
+ * }
1285
+ *
1286
+ * export default defineGuiScript({
1287
+ * init(self) {
1288
+ * // Create a new node and set the texture to a flipbook animation
1289
+ * const node = gui.get_node("button_node");
1290
+ * gui.set_texture(node, "gui_sprites");
1291
+ * gui.play_flipbook(node, "animated_button");
1292
+ * },
1293
+ * });
1294
+ * ```
1295
+ * @example
1296
+ * Set the texture of a node to an image from an atlas:
1297
+ * ```ts
1298
+ * // Create a new node and set the texture to a "button.png" from atlas
1299
+ * const node = gui.get_node("button_node");
1300
+ * gui.set_texture(node, "gui_sprites");
1301
+ * gui.play_flipbook(node, "button");
1302
+ * ```
1303
+ */
1304
+ 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
1305
  /**
1579
1306
  * Plays the paricle fx for a gui node
1580
1307
  *
@@ -1641,100 +1368,6 @@ declare global {
1641
1368
  * @returns local position
1642
1369
  */
1643
1370
  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
1371
  /**
1739
1372
  * Sets the adjust mode on a node.
1740
1373
  * The adjust mode defines how the node will adjust itself to screen
@@ -2174,7 +1807,52 @@ declare global {
2174
1807
  * });
2175
1808
  * ```
2176
1809
  */
2177
- function set_texture_data(texture: string | Hash, width: number, height: number, type: string | Opaque<"constant">, buffer: string, flip?: boolean): boolean;
1810
+ function set_texture_data(texture: string | Hash, width: number, height: number, type: string | Opaque<"constant">, buffer: string): boolean;
1811
+ /**
1812
+ * Set the texture buffer data for a dynamically created texture.
1813
+ *
1814
+ * @param texture - texture id
1815
+ * @param width - texture width
1816
+ * @param height - texture height
1817
+ * @param type - texture type
1818
+ *
1819
+ * - `"rgb"` - RGB
1820
+ * - `"rgba"` - RGBA
1821
+ * - `"l"` - LUMINANCE
1822
+ * - `"astc"` - ASTC compressed format
1823
+ * @param buffer - texture data
1824
+ * @param flip - flip texture vertically
1825
+ * @returns setting the data was successful
1826
+ * @example
1827
+ * ```ts
1828
+ * export default defineGuiScript({
1829
+ * init(self) {
1830
+ * const w = 200;
1831
+ * const h = 300;
1832
+ *
1833
+ * // Create a dynamic texture, all white.
1834
+ * if (gui.new_texture("dynamic_tx", w, h, "rgb", String.fromCharCode(0xff).repeat(w * h * 3))) {
1835
+ * // Create a box node and apply the texture to it.
1836
+ * const n = gui.new_box_node(vmath.vector3(200, 200, 0), vmath.vector3(w, h, 0));
1837
+ * gui.set_texture(n, "dynamic_tx");
1838
+ *
1839
+ * // ...
1840
+ *
1841
+ * // Change the data in the texture to a nice orange.
1842
+ * const orange = String.fromCharCode(0xff, 0x80, 0x10);
1843
+ * if (gui.set_texture_data("dynamic_tx", w, h, "rgb", orange.repeat(w * h))) {
1844
+ * // Go on and to more stuff
1845
+ * // ...
1846
+ * }
1847
+ * } else {
1848
+ * // Something went wrong
1849
+ * // ...
1850
+ * }
1851
+ * },
1852
+ * });
1853
+ * ```
1854
+ */
1855
+ function set_texture_data(texture: string | Hash, width: number, height: number, type: string | Opaque<"constant">, buffer: string, flip: boolean): boolean;
2178
1856
  /**
2179
1857
  * Sets the tracking value of a text node. This value is used to
2180
1858
  * adjust the vertical spacing of characters in the text.
@@ -2235,56 +1913,16 @@ declare global {
2235
1913
  *
2236
1914
  * - boolean `clear`: instantly clear spawned particles
2237
1915
  */
2238
- function stop_particlefx(node: Opaque<"node">, options?: { clear?: boolean }): void;
1916
+ function stop_particlefx(node: Opaque<"node">): void;
2239
1917
  /**
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
- * },
1918
+ * Stops the particle fx for a gui node
2263
1919
  *
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
- * },
1920
+ * @param node - node to stop particle fx for
1921
+ * @param options - options when stopping the particle fx. Supported options:
2277
1922
  *
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
- * ```
1923
+ * - boolean `clear`: instantly clear spawned particles
2286
1924
  */
2287
- function update(self: Opaque<"userdata">, dt: number): void;
1925
+ function stop_particlefx(node: Opaque<"node">, options: { clear?: boolean }): void;
2288
1926
  interface properties {
2289
1927
  /**
2290
1928
  * The fonts used in the gui. The type of the property is hash.