@defold-typescript/types 0.50.1 → 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.
- package/api-availability.json +4 -58
- package/api-signatures.json +1128 -1552
- package/api-targets.json +15 -5
- package/examples/translations.json +19 -71
- package/fixtures/messages_doc.json +20 -39
- package/generated/b2d_world.d.ts +10 -10
- package/generated/buffer.d.ts +9 -9
- package/generated/builtin-messages.d.ts +16 -14
- package/generated/bullet3d_collision_object.d.ts +1 -1
- package/generated/bullet3d_constraint.d.ts +109 -7
- package/generated/bullet3d_shape.d.ts +2 -2
- package/generated/collectionfactory.d.ts +1 -1
- package/generated/collectionproxy.d.ts +2 -2
- package/generated/factory.d.ts +4 -2
- package/generated/go.d.ts +114 -220
- package/generated/graphics.d.ts +5 -0
- package/generated/gui.d.ts +148 -371
- package/generated/http.d.ts +4 -2
- package/generated/image.d.ts +56 -4
- package/generated/kinds/gui-script.d.ts +3 -0
- package/generated/kinds/render-script.d.ts +15 -15
- package/generated/kinds/script.d.ts +1 -0
- package/generated/liveupdate.d.ts +5 -1
- package/generated/material.d.ts +3 -3
- package/generated/model.d.ts +4 -5
- package/generated/particlefx.d.ts +20 -1
- package/generated/physics.d.ts +48 -4
- package/generated/render-script-modules/b2d.d.ts +711 -0
- package/generated/render-script-modules/bullet3d.d.ts +73 -0
- package/generated/render-script-modules/collectionfactory.d.ts +25 -0
- package/generated/render-script-modules/collectionproxy.d.ts +39 -0
- package/generated/render-script-modules/factory.d.ts +25 -0
- package/generated/render-script-modules/go.d.ts +436 -0
- package/generated/render-script-modules/label.d.ts +105 -0
- package/generated/render-script-modules/model.d.ts +89 -0
- package/generated/render-script-modules/particlefx.d.ts +59 -0
- package/generated/render-script-modules/physics.d.ts +333 -0
- package/generated/render-script-modules/resource.d.ts +1233 -0
- package/generated/render-script-modules/sound.d.ts +227 -0
- package/generated/render-script-modules/sprite.d.ts +68 -0
- package/generated/render-script-modules/tilemap.d.ts +43 -0
- package/generated/render.d.ts +175 -21
- package/generated/resource.d.ts +31 -10
- package/generated/sprite.d.ts +49 -1
- package/generated/sys.d.ts +78 -10
- package/generated/tilemap.d.ts +4 -4
- package/generated/versions/defold-1.12.4/buffer.d.ts +8 -8
- package/generated/versions/defold-1.12.4/collectionfactory.d.ts +1 -1
- package/generated/versions/defold-1.12.4/collectionproxy.d.ts +1 -1
- package/generated/versions/defold-1.12.4/factory.d.ts +4 -2
- package/generated/versions/defold-1.12.4/go.d.ts +115 -343
- package/generated/versions/defold-1.12.4/graphics.d.ts +1 -0
- package/generated/versions/defold-1.12.4/gui.d.ts +151 -513
- package/generated/versions/defold-1.12.4/http.d.ts +4 -2
- package/generated/versions/defold-1.12.4/image.d.ts +83 -3
- package/generated/versions/defold-1.12.4/index.d.ts +2 -0
- package/generated/versions/defold-1.12.4/liveupdate.d.ts +4 -0
- package/generated/versions/defold-1.12.4/model.d.ts +4 -5
- package/generated/versions/defold-1.12.4/particlefx.d.ts +22 -1
- package/generated/versions/defold-1.12.4/physics.d.ts +47 -3
- package/generated/versions/defold-1.12.4/render.d.ts +119 -15
- package/generated/versions/defold-1.12.4/resource.d.ts +43 -10
- package/generated/versions/defold-1.12.4/sprite.d.ts +58 -1
- package/generated/versions/defold-1.12.4/sys.d.ts +101 -6
- package/generated/versions/defold-1.12.4/tilemap.d.ts +4 -4
- package/generated/versions/defold-1.12.4/vmath.d.ts +0 -24
- package/generated/versions/defold-1.13.0/buffer.d.ts +8 -8
- package/generated/versions/defold-1.13.0/collectionfactory.d.ts +1 -1
- package/generated/versions/defold-1.13.0/collectionproxy.d.ts +1 -1
- package/generated/versions/defold-1.13.0/factory.d.ts +4 -2
- package/generated/versions/defold-1.13.0/go.d.ts +115 -370
- package/generated/versions/defold-1.13.0/graphics.d.ts +1 -0
- package/generated/versions/defold-1.13.0/gui.d.ts +151 -513
- package/generated/versions/defold-1.13.0/http.d.ts +4 -2
- package/generated/versions/defold-1.13.0/image.d.ts +83 -3
- package/generated/versions/defold-1.13.0/index.d.ts +2 -0
- package/generated/versions/defold-1.13.0/liveupdate.d.ts +4 -0
- package/generated/versions/defold-1.13.0/material.d.ts +3 -1
- package/generated/versions/defold-1.13.0/model.d.ts +4 -5
- package/generated/versions/defold-1.13.0/particlefx.d.ts +22 -1
- package/generated/versions/defold-1.13.0/physics.d.ts +47 -3
- package/generated/versions/defold-1.13.0/render.d.ts +182 -16
- package/generated/versions/defold-1.13.0/resource.d.ts +43 -10
- package/generated/versions/defold-1.13.0/sprite.d.ts +58 -1
- package/generated/versions/defold-1.13.0/sys.d.ts +101 -6
- package/generated/versions/defold-1.13.0/tilemap.d.ts +4 -4
- package/generated/versions/defold-1.13.0/vmath.d.ts +0 -24
- package/generated/versions/defold-1.13.1/buffer.d.ts +8 -8
- package/generated/versions/defold-1.13.1/collectionfactory.d.ts +1 -1
- package/generated/versions/defold-1.13.1/collectionproxy.d.ts +1 -1
- package/generated/versions/defold-1.13.1/factory.d.ts +4 -2
- package/generated/versions/defold-1.13.1/go.d.ts +115 -370
- package/generated/versions/defold-1.13.1/graphics.d.ts +1 -0
- package/generated/versions/defold-1.13.1/gui.d.ts +151 -529
- package/generated/versions/defold-1.13.1/http.d.ts +4 -2
- package/generated/versions/defold-1.13.1/image.d.ts +83 -3
- package/generated/versions/defold-1.13.1/index.d.ts +3 -0
- package/generated/versions/defold-1.13.1/liveupdate.d.ts +4 -0
- package/generated/versions/defold-1.13.1/material.d.ts +3 -1
- package/generated/versions/defold-1.13.1/model.d.ts +4 -5
- package/generated/versions/defold-1.13.1/particlefx.d.ts +22 -1
- package/generated/versions/defold-1.13.1/physics.d.ts +47 -3
- package/generated/versions/defold-1.13.1/render.d.ts +182 -16
- package/generated/versions/defold-1.13.1/resource.d.ts +43 -10
- package/generated/versions/defold-1.13.1/sprite.d.ts +58 -1
- package/generated/versions/defold-1.13.1/sys.d.ts +101 -6
- package/generated/versions/defold-1.13.1/tilemap.d.ts +4 -4
- package/generated/versions/defold-1.13.1/vmath.d.ts +0 -24
- package/generated/versions/defold-1.13.2/b2d_world.d.ts +10 -10
- package/generated/versions/defold-1.13.2/buffer.d.ts +9 -9
- package/generated/versions/defold-1.13.2/bullet3d_collision_object.d.ts +1 -1
- package/generated/versions/defold-1.13.2/bullet3d_constraint.d.ts +109 -7
- package/generated/versions/defold-1.13.2/bullet3d_shape.d.ts +2 -2
- package/generated/versions/defold-1.13.2/collectionfactory.d.ts +1 -1
- package/generated/versions/defold-1.13.2/collectionproxy.d.ts +2 -2
- package/generated/versions/defold-1.13.2/factory.d.ts +4 -2
- package/generated/versions/defold-1.13.2/go.d.ts +114 -220
- package/generated/versions/defold-1.13.2/graphics.d.ts +1 -0
- package/generated/versions/defold-1.13.2/gui.d.ts +148 -371
- package/generated/versions/defold-1.13.2/http.d.ts +4 -2
- package/generated/versions/defold-1.13.2/image.d.ts +56 -4
- package/generated/versions/defold-1.13.2/index.d.ts +3 -0
- package/generated/versions/defold-1.13.2/liveupdate.d.ts +5 -1
- package/generated/versions/defold-1.13.2/material.d.ts +3 -3
- package/generated/versions/defold-1.13.2/model.d.ts +4 -5
- package/generated/versions/defold-1.13.2/particlefx.d.ts +20 -1
- package/generated/versions/defold-1.13.2/physics.d.ts +48 -4
- package/generated/versions/defold-1.13.2/render.d.ts +164 -20
- package/generated/versions/defold-1.13.2/resource.d.ts +31 -10
- package/generated/versions/defold-1.13.2/sprite.d.ts +49 -1
- package/generated/versions/defold-1.13.2/sys.d.ts +78 -10
- package/generated/versions/defold-1.13.2/tilemap.d.ts +4 -4
- package/generated/versions/defold-1.13.2/vmath.d.ts +0 -24
- package/generated/versions/defold-1.13.2/window.d.ts +1 -1
- package/generated/vmath.d.ts +0 -24
- package/generated/window.d.ts +1 -1
- package/identity-vocabulary.json +98 -7
- package/index.d.ts +3 -0
- package/package.json +3 -1
- package/scripts/generate-api-availability.ts +6 -22
- package/scripts/generate-api-signatures.ts +87 -21
- package/scripts/materialize-version.ts +53 -6
- package/scripts/regen.ts +256 -44
- package/scripts/signature-store-fs.ts +1 -0
- package/scripts/target-version.ts +26 -0
- package/src/api-doc.ts +26 -0
- package/src/component-properties.d.ts +226 -6
- package/src/core-types.ts +82 -20
- package/src/doc-corrections.ts +53 -5
- package/src/emit-dts.ts +1300 -269
- package/src/emit-messages.ts +289 -0
- package/src/engine-globals.d.ts +8 -2
- package/src/go-overloads.d.ts +80 -15
- package/src/gui-overloads.d.ts +489 -0
- package/src/gui-texture-removal.d.ts +41 -0
- package/src/index.ts +2 -0
- package/src/lifecycle.ts +46 -37
- package/src/luals-type-expr.ts +6 -1
- package/src/msg-overloads.d.ts +25 -13
- package/src/physics-event-guard.d.ts +39 -0
- package/src/render-overloads.d.ts +2 -2
- package/src/return-correction-provenance.ts +36 -6
- package/src/signature-store.ts +50 -0
- package/src/timers.d.ts +2 -1
- package/src/vmath-overloads.d.ts +26 -0
- package/src/window-event-guard.d.ts +5 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
|
-
import type { Hash,
|
|
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">):
|
|
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">):
|
|
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
|
|
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
|
-
*
|
|
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
|
-
*
|
|
1460
|
-
*
|
|
1141
|
+
* @param texture_id - texture id
|
|
1142
|
+
* @param width - texture width
|
|
1143
|
+
* @param height - texture height
|
|
1144
|
+
* @param type - texture type
|
|
1461
1145
|
*
|
|
1462
|
-
*
|
|
1463
|
-
*
|
|
1464
|
-
*
|
|
1465
|
-
*
|
|
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()
|
|
1470
|
-
*
|
|
1471
|
-
*
|
|
1156
|
+
* init(self) {
|
|
1157
|
+
* const w = 200;
|
|
1158
|
+
* const h = 300;
|
|
1472
1159
|
*
|
|
1473
|
-
*
|
|
1474
|
-
*
|
|
1475
|
-
*
|
|
1476
|
-
*
|
|
1477
|
-
*
|
|
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
|
-
*
|
|
1506
|
-
*
|
|
1507
|
-
*
|
|
1508
|
-
*
|
|
1509
|
-
*
|
|
1510
|
-
*
|
|
1511
|
-
*
|
|
1512
|
-
*
|
|
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
|
|
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
|
|
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
|
*
|
|
@@ -1664,116 +1391,6 @@ declare global {
|
|
|
1664
1391
|
* ```
|
|
1665
1392
|
*/
|
|
1666
1393
|
function screen_to_local(node: Opaque<"node">, screen_position: Vector3 | Vector4): Vector3;
|
|
1667
|
-
/**
|
|
1668
|
-
* Instead of using specific setteres such as gui.set_position or gui.set_scale,
|
|
1669
|
-
* you can use gui.set instead and supply the property as a string or a hash.
|
|
1670
|
-
* While this function is similar to go.get and go.set, there are a few more restrictions
|
|
1671
|
-
* when operating in the gui namespace. Most notably, only these named properties identifiers are supported:
|
|
1672
|
-
*
|
|
1673
|
-
* - `"position"`
|
|
1674
|
-
* - `"rotation"`
|
|
1675
|
-
* - `"euler"`
|
|
1676
|
-
* - `"scale"`
|
|
1677
|
-
* - `"color"`
|
|
1678
|
-
* - `"outline"`
|
|
1679
|
-
* - `"shadow"`
|
|
1680
|
-
* - `"size"`
|
|
1681
|
-
* - `"fill_angle"` (pie)
|
|
1682
|
-
* - `"inner_radius"` (pie)
|
|
1683
|
-
* - `"leading"` (text)
|
|
1684
|
-
* - `"tracking"` (text)
|
|
1685
|
-
* - `"slice9"` (slice9)
|
|
1686
|
-
*
|
|
1687
|
-
* 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.
|
|
1688
|
-
* I.e when setting the "position" property, you need to use a vmath.vector4 and when setting a single component of the property,
|
|
1689
|
-
* such as "position.x", you need to use a single value.
|
|
1690
|
-
* 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,
|
|
1691
|
-
* 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,
|
|
1692
|
-
* use the "euler" property instead. The rotation and euler properties are linked, changing one of them will change the backing data of the other.
|
|
1693
|
-
* 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
|
|
1694
|
-
* 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())`
|
|
1695
|
-
* 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.
|
|
1696
|
-
* 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.
|
|
1697
|
-
*
|
|
1698
|
-
* @param node - node to set the property for, or msg.url() to the gui itself
|
|
1699
|
-
* @param property - the property to set
|
|
1700
|
-
* @param value - the property to set. `nil` is only supported for removing runtime texture mappings with `gui.set(msg.url(), "textures", nil, {key = ...})`.
|
|
1701
|
-
* @param options - optional options table (only applicable for material constants)
|
|
1702
|
-
* - `index` number index into array property (1 based)
|
|
1703
|
-
* - `key` hash name of internal property
|
|
1704
|
-
*
|
|
1705
|
-
* **⚠️ `index` is 1-based; passed to Defold unchanged.**
|
|
1706
|
-
* @example
|
|
1707
|
-
* Updates the position property on an existing node:
|
|
1708
|
-
* ```ts
|
|
1709
|
-
* const node = gui.get_node("my_box_node");
|
|
1710
|
-
* const node_position = gui.get(node, "position") as Vector3;
|
|
1711
|
-
* gui.set(node, "position.x", node_position.x + 128);
|
|
1712
|
-
* ```
|
|
1713
|
-
* @example
|
|
1714
|
-
* Updates the rotation property on an existing node:
|
|
1715
|
-
* ```ts
|
|
1716
|
-
* const node = gui.get_node("my_box_node");
|
|
1717
|
-
* gui.set(node, "rotation", vmath.quat_rotation_z(math.rad(45)));
|
|
1718
|
-
* // this is equivalent to:
|
|
1719
|
-
* gui.set(node, "euler.z", 45);
|
|
1720
|
-
* // or using the entire vector:
|
|
1721
|
-
* gui.set(node, "euler", vmath.vector3(0, 0, 45));
|
|
1722
|
-
* // or using the set_rotation
|
|
1723
|
-
* gui.set_rotation(node, vmath.vector3(0, 0, 45));
|
|
1724
|
-
* ```
|
|
1725
|
-
* @example
|
|
1726
|
-
* Sets various material constants for a node:
|
|
1727
|
-
* ```ts
|
|
1728
|
-
* const node = gui.get_node("my_box_node");
|
|
1729
|
-
* gui.set(node, "tint", vmath.vector4(1, 0, 0, 1));
|
|
1730
|
-
* // matrix4 is also supported
|
|
1731
|
-
* gui.set(node, "light_matrix", vmath.matrix4());
|
|
1732
|
-
* // update a constant in an array at position 4. the array is specified in the shader as:
|
|
1733
|
-
* // uniform vec4 tint_array[4]; // lua is 1 based, shader is 0 based
|
|
1734
|
-
* gui.set(node, "tint_array", vmath.vector4(1, 0, 0, 1), { index: 4 });
|
|
1735
|
-
* // update a matrix constant in an array at position 4. the array is specified in the shader as:
|
|
1736
|
-
* // uniform mat4 light_matrix_array[4];
|
|
1737
|
-
* gui.set(node, "light_matrix_array", vmath.matrix4(), { index: 4 });
|
|
1738
|
-
* // update a sub-element in a constant
|
|
1739
|
-
* gui.set(node, "tint.x", 1);
|
|
1740
|
-
* // update a sub-element in an array constant at position 4
|
|
1741
|
-
* gui.set(node, "tint_array.x", 1, { index: 4 });
|
|
1742
|
-
* ```
|
|
1743
|
-
* @example
|
|
1744
|
-
* Set a named property
|
|
1745
|
-
* ```ts
|
|
1746
|
-
* export default defineGuiScript({
|
|
1747
|
-
* on_message(self, message_id, message) {
|
|
1748
|
-
* if (message_id === hash("set_font") && types.is_hash(message.font)) {
|
|
1749
|
-
* gui.set(msg.url(), "fonts", message.font, { key: "my_font_name" });
|
|
1750
|
-
* gui.set_font(gui.get_node("text"), "my_font_name");
|
|
1751
|
-
* } else if (message_id === hash("set_texture") && types.is_hash(message.texture)) {
|
|
1752
|
-
* gui.set(msg.url(), "textures", message.texture, { key: "my_texture" });
|
|
1753
|
-
* gui.set_texture(gui.get_node("box"), "my_texture");
|
|
1754
|
-
* gui.play_flipbook(gui.get_node("box"), "logo_256");
|
|
1755
|
-
* }
|
|
1756
|
-
* },
|
|
1757
|
-
* });
|
|
1758
|
-
* ```
|
|
1759
|
-
* @example
|
|
1760
|
-
* Remove a named runtime texture resource mapping:
|
|
1761
|
-
* ```ts
|
|
1762
|
-
* const atlas_params = {
|
|
1763
|
-
* texture: "/runtime.texturec",
|
|
1764
|
-
* animations: [{ id: "runtime", width: 1, height: 1, frames: [1] }],
|
|
1765
|
-
* 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] }],
|
|
1766
|
-
* } satisfies Parameters<typeof resource.create_atlas>[1];
|
|
1767
|
-
* const atlas_id = resource.create_atlas("/runtime.texturesetc", atlas_params);
|
|
1768
|
-
* gui.set(msg.url(), "textures", atlas_id, { key: "runtime_texture" });
|
|
1769
|
-
* gui.set_texture(gui.get_node("box"), "runtime_texture");
|
|
1770
|
-
*
|
|
1771
|
-
* // Later, remove the GUI mapping before releasing the atlas resource.
|
|
1772
|
-
* gui.set(msg.url(), "textures", undefined, { key: "runtime_texture" });
|
|
1773
|
-
* resource.release(atlas_id);
|
|
1774
|
-
* ```
|
|
1775
|
-
*/
|
|
1776
|
-
function set(node: Opaque<"node"> | Url, property: string | Hash | gui.Property, value: number | Vector4 | Vector3 | Quaternion | Matrix4 | Hash | undefined, options?: { index?: number; key?: string | Hash; keys?: (Hash | string)[] }): void;
|
|
1777
1394
|
/**
|
|
1778
1395
|
* Sets the adjust mode on a node.
|
|
1779
1396
|
* The adjust mode defines how the node will adjust itself to screen
|
|
@@ -2213,7 +1830,52 @@ declare global {
|
|
|
2213
1830
|
* });
|
|
2214
1831
|
* ```
|
|
2215
1832
|
*/
|
|
2216
|
-
function set_texture_data(texture: string | Hash, width: number, height: number, type: string | Opaque<"constant">, buffer: string
|
|
1833
|
+
function set_texture_data(texture: string | Hash, width: number, height: number, type: string | Opaque<"constant">, buffer: string): boolean;
|
|
1834
|
+
/**
|
|
1835
|
+
* Set the texture buffer data for a dynamically created texture.
|
|
1836
|
+
*
|
|
1837
|
+
* @param texture - texture id
|
|
1838
|
+
* @param width - texture width
|
|
1839
|
+
* @param height - texture height
|
|
1840
|
+
* @param type - texture type
|
|
1841
|
+
*
|
|
1842
|
+
* - `"rgb"` - RGB
|
|
1843
|
+
* - `"rgba"` - RGBA
|
|
1844
|
+
* - `"l"` - LUMINANCE
|
|
1845
|
+
* - `"astc"` - ASTC compressed format
|
|
1846
|
+
* @param buffer - texture data
|
|
1847
|
+
* @param flip - flip texture vertically
|
|
1848
|
+
* @returns setting the data was successful
|
|
1849
|
+
* @example
|
|
1850
|
+
* ```ts
|
|
1851
|
+
* export default defineGuiScript({
|
|
1852
|
+
* init(self) {
|
|
1853
|
+
* const w = 200;
|
|
1854
|
+
* const h = 300;
|
|
1855
|
+
*
|
|
1856
|
+
* // Create a dynamic texture, all white.
|
|
1857
|
+
* if (gui.new_texture("dynamic_tx", w, h, "rgb", String.fromCharCode(0xff).repeat(w * h * 3))) {
|
|
1858
|
+
* // Create a box node and apply the texture to it.
|
|
1859
|
+
* const n = gui.new_box_node(vmath.vector3(200, 200, 0), vmath.vector3(w, h, 0));
|
|
1860
|
+
* gui.set_texture(n, "dynamic_tx");
|
|
1861
|
+
*
|
|
1862
|
+
* // ...
|
|
1863
|
+
*
|
|
1864
|
+
* // Change the data in the texture to a nice orange.
|
|
1865
|
+
* const orange = String.fromCharCode(0xff, 0x80, 0x10);
|
|
1866
|
+
* if (gui.set_texture_data("dynamic_tx", w, h, "rgb", orange.repeat(w * h))) {
|
|
1867
|
+
* // Go on and to more stuff
|
|
1868
|
+
* // ...
|
|
1869
|
+
* }
|
|
1870
|
+
* } else {
|
|
1871
|
+
* // Something went wrong
|
|
1872
|
+
* // ...
|
|
1873
|
+
* }
|
|
1874
|
+
* },
|
|
1875
|
+
* });
|
|
1876
|
+
* ```
|
|
1877
|
+
*/
|
|
1878
|
+
function set_texture_data(texture: string | Hash, width: number, height: number, type: string | Opaque<"constant">, buffer: string, flip: boolean): boolean;
|
|
2217
1879
|
/**
|
|
2218
1880
|
* Sets the tracking value of a text node. This value is used to
|
|
2219
1881
|
* adjust the vertical spacing of characters in the text.
|
|
@@ -2274,56 +1936,16 @@ declare global {
|
|
|
2274
1936
|
*
|
|
2275
1937
|
* - boolean `clear`: instantly clear spawned particles
|
|
2276
1938
|
*/
|
|
2277
|
-
function stop_particlefx(node: Opaque<"node"
|
|
1939
|
+
function stop_particlefx(node: Opaque<"node">): void;
|
|
2278
1940
|
/**
|
|
2279
|
-
*
|
|
2280
|
-
* It can be used to perform any kind of gui related tasks, e.g. animating nodes.
|
|
2281
|
-
*
|
|
2282
|
-
* @param self - reference to the script state to be used for storing data
|
|
2283
|
-
* @param dt - the time-step of the frame update
|
|
2284
|
-
* @example
|
|
2285
|
-
* ```ts
|
|
2286
|
-
* // This example demonstrates how to update a text node that displays game score
|
|
2287
|
-
* // in a counting fashion. It is assumed that the gui component receives messages
|
|
2288
|
-
* // from the game when a new score is to be shown.
|
|
2289
|
-
* export default defineGuiScript({
|
|
2290
|
-
* init() {
|
|
2291
|
-
* return {
|
|
2292
|
-
* // fetch the score text node for later use (assumes it is called "score")
|
|
2293
|
-
* score_node: gui.get_node("score"),
|
|
2294
|
-
* // keep track of the current score counted up so far
|
|
2295
|
-
* current_score: 0,
|
|
2296
|
-
* // keep track of the target score we should count up to
|
|
2297
|
-
* target_score: 0,
|
|
2298
|
-
* // how fast we will update the score, in score/second
|
|
2299
|
-
* score_update_speed: 1,
|
|
2300
|
-
* };
|
|
2301
|
-
* },
|
|
1941
|
+
* Stops the particle fx for a gui node
|
|
2302
1942
|
*
|
|
2303
|
-
*
|
|
2304
|
-
*
|
|
2305
|
-
* if (self.current_score < self.target_score) {
|
|
2306
|
-
* // increment current score according to the speed
|
|
2307
|
-
* self.current_score = self.current_score + dt * self.score_update_speed;
|
|
2308
|
-
* // check if we went past the target score, clamp current score in that case
|
|
2309
|
-
* if (self.current_score > self.target_score) {
|
|
2310
|
-
* self.current_score = self.target_score;
|
|
2311
|
-
* }
|
|
2312
|
-
* // update the score text node
|
|
2313
|
-
* gui.set_text(self.score_node, "" + math.floor(self.current_score));
|
|
2314
|
-
* }
|
|
2315
|
-
* },
|
|
1943
|
+
* @param node - node to stop particle fx for
|
|
1944
|
+
* @param options - options when stopping the particle fx. Supported options:
|
|
2316
1945
|
*
|
|
2317
|
-
*
|
|
2318
|
-
* // check the message
|
|
2319
|
-
* if (message_id === hash("set_score") && typeof message.score === "number") {
|
|
2320
|
-
* self.target_score = message.score;
|
|
2321
|
-
* }
|
|
2322
|
-
* },
|
|
2323
|
-
* });
|
|
2324
|
-
* ```
|
|
1946
|
+
* - boolean `clear`: instantly clear spawned particles
|
|
2325
1947
|
*/
|
|
2326
|
-
function
|
|
1948
|
+
function stop_particlefx(node: Opaque<"node">, options: { clear?: boolean }): void;
|
|
2327
1949
|
interface properties {
|
|
2328
1950
|
/**
|
|
2329
1951
|
* The fonts used in the gui. The type of the property is hash.
|