@defold-typescript/library-types 0.20.8 → 0.21.1

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.
@@ -0,0 +1,2067 @@
1
+ /** @noResolution */
2
+ declare module 'druid.druid' {
3
+ type druid_text_adjust_type = "downscale" | "trim" | "no_adjust" | "downscale_limited" | "scroll" | "scale_then_scroll" | "trim_left" | "scale_then_trim" | "scale_then_trim_left";
4
+ type color = Vector4 | Vector3 | string;
5
+ type druid_container_mode = "stretch" | "fit" | "stretch_x" | "stretch_y";
6
+ type druid_layout_type = "horizontal" | "vertical" | "horizontal_wrap";
7
+ /**
8
+ * Component to handle back button. It handles Android back button and Backspace key.
9
+ *
10
+ * ### Setup
11
+ * Create back handler component with druid: `druid:new_back_handler(callback)`
12
+ *
13
+ * ### Notes
14
+ * - Key triggers in `input.binding` should be setup for correct working
15
+ * - It uses a key_back and key_backspace action ids
16
+ */
17
+ interface druid_back_handler extends druid_component {
18
+ on_back: unknown;
19
+ params: unknown | undefined;
20
+ /**
21
+ * The Back Handler constructor
22
+ */
23
+ init(callback: unknown | undefined, params: unknown | undefined): void;
24
+ on_input(action_id: Hash, action: LuaTable): boolean;
25
+ }
26
+ /**
27
+ * Druid component for block input. Use it to block input in special zone.
28
+ *
29
+ * ### Setup
30
+ * Create blocker component with druid: `druid:new_blocker(node_name)`
31
+ *
32
+ * ### Notes
33
+ * - Blocker can be used to create safe zones, where you have big buttons
34
+ * - Blocker will capture all input events that hit the node, preventing them from reaching other components
35
+ * - Blocker works placed as usual component in stack, so any other component can be placed on top of it and will work as usual
36
+ */
37
+ interface druid_blocker extends druid_component {
38
+ node: Opaque<"node">;
39
+ _is_enabled: boolean;
40
+ /**
41
+ * The Blocker constructor
42
+ */
43
+ init(node: Opaque<"node"> | string): void;
44
+ on_input(action_id: string, action: LuaTable): boolean;
45
+ /**
46
+ * Set blocker enabled state
47
+ */
48
+ set_enabled(state: boolean): druid_blocker;
49
+ /**
50
+ * Get blocker enabled state
51
+ */
52
+ is_enabled(): boolean;
53
+ }
54
+ /**
55
+ * Button style params.
56
+ * You can override this component styles params in Druid styles table or create your own style
57
+ */
58
+ interface druid_button_style {
59
+ LONGTAP_TIME: number | undefined;
60
+ AUTOHOLD_TRIGGER: number | undefined;
61
+ DOUBLETAP_TIME: number | undefined;
62
+ on_init: ((self: unknown) => void) | undefined;
63
+ on_click: ((self: unknown, node: unknown) => void) | undefined;
64
+ on_click_disabled: ((self: unknown, node: unknown) => void) | undefined;
65
+ on_hover: ((self: unknown, node: unknown, hover_state: unknown) => void) | undefined;
66
+ on_mouse_hover: ((self: unknown, node: unknown, hover_state: unknown) => void) | undefined;
67
+ on_set_enabled: ((self: unknown, node: unknown, enabled_state: unknown) => void) | undefined;
68
+ }
69
+ /**
70
+ * Basic Druid input component. Handle input on node and provide different callbacks on touch events.
71
+ *
72
+ * ### Setup
73
+ * Create button with druid: `button = druid:new_button(node_name, callback, [params], [animation_node])`
74
+ * Where node_name is name of node from GUI scene. You can use `node_name` as input trigger zone and point another node for animation via `animation_node`
75
+ *
76
+ * ### Notes
77
+ * - Button callback have next params: (self, params, button_instance)
78
+ * - - **self** - Druid self context
79
+ * - - **params** - Additional params, specified on button creating
80
+ * - - **button_instance** - button itself
81
+ * - You can set _params_ on button callback on button creating: `druid:new_button("node_name", callback, params)`.
82
+ * - Button have several events like on_click, on_repeated_click, on_long_click, on_hold_click, on_double_click
83
+ * - Click event will not trigger if between pressed and released state cursor was outside of node zone
84
+ * - Button can have key trigger to use them by key: `button:set_key_trigger`
85
+ * -
86
+ */
87
+ interface druid_button extends druid_component {
88
+ on_click: unknown;
89
+ on_pressed: unknown;
90
+ on_repeated_click: unknown;
91
+ on_long_click: unknown;
92
+ on_double_click: unknown;
93
+ on_hold_callback: unknown;
94
+ on_click_outside: unknown;
95
+ node: Opaque<"node">;
96
+ node_id: Hash;
97
+ anim_node: Opaque<"node">;
98
+ params: unknown;
99
+ hover: druid_hover;
100
+ click_zone: Opaque<"node"> | undefined;
101
+ start_scale: Vector3;
102
+ start_pos: Vector3;
103
+ disabled: boolean;
104
+ key_trigger: Hash;
105
+ style: LuaTable;
106
+ /**
107
+ * The constructor for the button component
108
+ */
109
+ init(node_or_node_id: Opaque<"node"> | string, callback: (() => void) | undefined, custom_args: unknown | undefined, anim_node: Opaque<"node"> | string | undefined): void;
110
+ on_style_change(style: druid_button_style): void;
111
+ /**
112
+ * Remove default button style animations
113
+ */
114
+ set_animations_disabled(): druid_button;
115
+ on_late_init(): void;
116
+ on_input(action_id: Hash, action: LuaTable): boolean;
117
+ on_input_interrupt(): void;
118
+ /**
119
+ * Set button enabled state.
120
+ * The style.on_set_enabled will be triggered.
121
+ * Disabled button is not clickable.
122
+ */
123
+ set_enabled(state: boolean | undefined): druid_button;
124
+ /**
125
+ * Get button enabled state.
126
+ * By default all Buttons are enabled on creating.
127
+ */
128
+ is_enabled(): boolean;
129
+ /**
130
+ * Set additional button click area.
131
+ * Useful to restrict click outside of stencil node or scrollable content.
132
+ * If button node placed inside stencil node, it will be automatically set to this stencil node.
133
+ */
134
+ set_click_zone(zone: Opaque<"node"> | string | undefined): druid_button;
135
+ /**
136
+ * Set key name to trigger this button by keyboard.
137
+ */
138
+ set_key_trigger(key: Hash | string): druid_button;
139
+ /**
140
+ * Get current key name to trigger this button.
141
+ */
142
+ get_key_trigger(): Hash;
143
+ /**
144
+ * Set function for additional check for button click availability.
145
+ */
146
+ set_check_function(check_function: unknown | undefined, failure_callback: unknown | undefined): druid_button;
147
+ /**
148
+ * Set Button mode to work inside user HTML5 interaction event.
149
+ *
150
+ * It's required to make protected things like copy & paste text, show mobile keyboard, etc
151
+ * The HTML5 button doesn't call any events except on_click event.
152
+ *
153
+ * If the game is not HTML, html mode will be not enabled
154
+ */
155
+ set_web_user_interaction(is_web_mode: boolean | undefined): druid_button;
156
+ _is_input_match(action_id: Hash): boolean;
157
+ /**
158
+ * Call button style on_hover callback
159
+ */
160
+ button_hover(hover_state: boolean): void;
161
+ /**
162
+ * Call button style on_hover callback
163
+ */
164
+ button_mouse_hover(hover_state: boolean): void;
165
+ /**
166
+ * Call button click callback
167
+ */
168
+ button_click(): void;
169
+ /**
170
+ * Call button repeated click callback
171
+ */
172
+ button_repeated_click(): void;
173
+ /**
174
+ * Call button long click callback
175
+ */
176
+ button_long_click(): void;
177
+ /**
178
+ * Call button double click callback
179
+ */
180
+ button_double_click(): void;
181
+ /**
182
+ * Call button hold callback
183
+ */
184
+ button_hold(press_time: number): void;
185
+ _on_button_release(): void;
186
+ }
187
+ interface druid_drag_style {
188
+ DRAG_DEADZONE: number;
189
+ NO_USE_SCREEN_KOEF: boolean;
190
+ }
191
+ /**
192
+ * A component that allows you to subscribe to drag events over a node
193
+ */
194
+ interface druid_drag extends druid_component {
195
+ node: Opaque<"node">;
196
+ on_touch_start: unknown;
197
+ on_touch_end: unknown;
198
+ on_drag_start: unknown;
199
+ on_drag: unknown;
200
+ on_drag_end: unknown;
201
+ style: druid_drag_style;
202
+ click_zone: Opaque<"node"> | undefined;
203
+ is_touch: boolean;
204
+ is_drag: boolean;
205
+ can_x: boolean;
206
+ can_y: boolean;
207
+ dx: number;
208
+ dy: number;
209
+ touch_id: number;
210
+ x: number;
211
+ y: number;
212
+ screen_x: number;
213
+ screen_y: number;
214
+ touch_start_pos: Vector3;
215
+ _is_enabled: boolean;
216
+ _x_koef: number;
217
+ _y_koef: number;
218
+ /**
219
+ * The constructor for Drag component
220
+ */
221
+ init(node_or_node_id: Opaque<"node"> | string, on_drag_callback: (self: unknown, touch: unknown) => void): void;
222
+ on_style_change(style: druid_drag_style): void;
223
+ /**
224
+ * Set Drag component enabled state.
225
+ */
226
+ set_drag_cursors(is_enabled: boolean): void;
227
+ on_late_init(): void;
228
+ on_window_resized(): void;
229
+ on_input_interrupt(): void;
230
+ on_input(action_id: Hash, action: LuaTable): boolean;
231
+ /**
232
+ * Set Drag click zone
233
+ */
234
+ set_click_zone(node: Opaque<"node"> | string | undefined): druid_drag;
235
+ /**
236
+ * Set Drag component enabled state.
237
+ */
238
+ set_enabled(is_enabled: boolean): druid_drag;
239
+ /**
240
+ * Check if Drag component is capture input
241
+ */
242
+ is_enabled(): boolean;
243
+ _start_touch(): void;
244
+ _end_touch(touch: touch | undefined): void;
245
+ _process_touch(touch: touch): void;
246
+ /**
247
+ * Return current touch action from action input data
248
+ * If touch_id stored - return exact this touch action
249
+ */
250
+ _find_touch(action_id: Hash, action: LuaTable, touch_id: number): LuaTable | undefined;
251
+ /**
252
+ * Process on touch release. We should to find, if any other
253
+ * touches exists to switch to another touch.
254
+ */
255
+ _on_touch_release(action_id: Hash, action: LuaTable, touch: LuaTable): void;
256
+ }
257
+ interface druid_hover_style {
258
+ ON_HOVER_CURSOR: string | number | undefined;
259
+ ON_MOUSE_HOVER_CURSOR: string | number | undefined;
260
+ }
261
+ /**
262
+ * The component for handling hover events on a node
263
+ */
264
+ interface druid_hover extends druid_component {
265
+ node: Opaque<"node">;
266
+ on_hover: unknown;
267
+ on_mouse_hover: unknown;
268
+ style: druid_hover_style;
269
+ click_zone: Opaque<"node">;
270
+ _is_hovered: boolean | undefined;
271
+ _is_mouse_hovered: boolean | undefined;
272
+ _is_enabled: boolean | undefined;
273
+ _is_mobile: boolean;
274
+ /**
275
+ * The constructor for the hover component
276
+ */
277
+ init(node: Opaque<"node">, on_hover_callback: unknown, on_mouse_hover: unknown): void;
278
+ on_late_init(): void;
279
+ on_style_change(style: druid_hover_style): void;
280
+ on_input(action_id: Hash, action: LuaTable): boolean;
281
+ on_input_interrupt(): void;
282
+ /**
283
+ * Set hover state
284
+ */
285
+ set_hover(state: boolean | undefined): void;
286
+ /**
287
+ * Return current hover state. True if touch action was on the node at current time
288
+ */
289
+ is_hovered(): boolean;
290
+ /**
291
+ * Set mouse hover state
292
+ */
293
+ set_mouse_hover(state: boolean | undefined): void;
294
+ /**
295
+ * Return current hover state. True if nil action_id (usually desktop mouse) was on the node at current time
296
+ */
297
+ is_mouse_hovered(): boolean;
298
+ /**
299
+ * Strict hover click area. Useful for no click events outside stencil node
300
+ */
301
+ set_click_zone(zone: Opaque<"node"> | string | undefined): void;
302
+ /**
303
+ * Set enable state of hover component.
304
+ * If hover is not enabled, it will not generate
305
+ * any hover events
306
+ */
307
+ set_enabled(state: boolean | undefined): void;
308
+ /**
309
+ * Return current hover enabled state
310
+ */
311
+ is_enabled(): boolean;
312
+ on_remove(): void;
313
+ _set_cursor(): void;
314
+ }
315
+ /**
316
+ * Scroll style parameters
317
+ */
318
+ interface druid_scroll_style {
319
+ FRICT: number | undefined;
320
+ FRICT_HOLD: number | undefined;
321
+ INERT_THRESHOLD: number | undefined;
322
+ INERT_SPEED: number | undefined;
323
+ POINTS_DEADZONE: number | undefined;
324
+ BACK_SPEED: number | undefined;
325
+ ANIM_SPEED: number | undefined;
326
+ EXTRA_STRETCH_SIZE: number | undefined;
327
+ SMALL_CONTENT_SCROLL: boolean | undefined;
328
+ WHEEL_SCROLL_SPEED: number | undefined;
329
+ WHEEL_SCROLL_INVERTED: boolean | undefined;
330
+ WHEEL_SCROLL_BY_INERTION: boolean | undefined;
331
+ }
332
+ /**
333
+ * Basic Druid scroll component. Handles all scrolling behavior in Druid GUI.
334
+ *
335
+ * ### Setup
336
+ * Create scroll component with druid: `druid:new_scroll(view_node, content_node)`
337
+ *
338
+ * ### Notes
339
+ * - View_node is the static part that captures user input and recognizes scrolling touches
340
+ * - Content_node is the dynamic part that will change position according to the scroll system
341
+ * - Initial scroll size will be equal to content_node size
342
+ * - The initial view box will be equal to view_node size
343
+ * - Scroll by default style has inertia and extra size for stretching effect
344
+ * - You can setup "points of interest" to make scroll always center on closest point
345
+ * - Scroll events:
346
+ * - - on_scroll(self, position): On scroll move callback
347
+ * - - on_scroll_to(self, position, is_instant): On scroll_to function callback
348
+ * - - on_point_scroll(self, item_index, position): On scroll_to_index function callback
349
+ * - Multitouch is required for scroll. Scroll correctly handles touch_id swap while dragging
350
+ */
351
+ interface druid_scroll extends druid_component {
352
+ node: Opaque<"node">;
353
+ click_zone: Opaque<"node"> | undefined;
354
+ on_scroll: unknown;
355
+ on_scroll_to: unknown;
356
+ on_point_scroll: unknown;
357
+ view_node: Opaque<"node">;
358
+ view_border: Vector4;
359
+ content_node: Opaque<"node">;
360
+ view_size: Vector3;
361
+ position: Vector3;
362
+ target_position: Vector3;
363
+ available_pos: Vector4;
364
+ available_size: Vector3;
365
+ drag: druid_drag;
366
+ selected: number | undefined;
367
+ is_animate: boolean;
368
+ style: druid_scroll_style;
369
+ _is_inert: boolean;
370
+ inertion: Vector3;
371
+ _is_horizontal_scroll: boolean;
372
+ _is_vertical_scroll: boolean;
373
+ _grid_on_change: unknown;
374
+ _grid_on_change_callback: unknown;
375
+ _offset: Vector3;
376
+ _layout_on_change_callback: unknown;
377
+ /**
378
+ * The Scroll constructor
379
+ */
380
+ init(view_node: string | Opaque<"node">, content_node: string | Opaque<"node">): void;
381
+ on_style_change(style: druid_scroll_style): void;
382
+ on_late_init(): void;
383
+ on_layout_change(): void;
384
+ update(): void;
385
+ on_input(): void;
386
+ on_remove(): void;
387
+ /**
388
+ * Start scroll to target point.
389
+ */
390
+ scroll_to(point: Vector3, is_instant: boolean | undefined): void;
391
+ /**
392
+ * Scroll to the node, if node is not visible in scroll view
393
+ */
394
+ scroll_to_make_node_visible(node: Opaque<"node">, is_instant: boolean | undefined): void;
395
+ /**
396
+ * Scroll to item in scroll by point index.
397
+ */
398
+ scroll_to_index(index: number, is_silent: boolean | undefined, is_instant: boolean | undefined): void;
399
+ /**
400
+ * Start scroll to target scroll percent
401
+ */
402
+ scroll_to_percent(percent: Vector3, is_instant: boolean | undefined): void;
403
+ /**
404
+ * Return current scroll progress status.
405
+ */
406
+ get_percent(): Vector3;
407
+ /**
408
+ * Set scroll content size.
409
+ */
410
+ set_size(size: Vector3, offset: Vector3 | undefined): druid_scroll;
411
+ /**
412
+ * Set new scroll view size in case the node size was changed.
413
+ */
414
+ set_view_size(size: Vector3): druid_scroll;
415
+ /**
416
+ * Refresh scroll view size, used when view node size is changed
417
+ */
418
+ update_view_size(): druid_scroll;
419
+ /**
420
+ * Enable or disable scroll inert
421
+ */
422
+ set_inert(state: boolean): druid_scroll;
423
+ /**
424
+ * Return if scroll have inertion
425
+ */
426
+ is_inert(): boolean;
427
+ /**
428
+ * Set extra size for scroll stretching
429
+ */
430
+ set_extra_stretch_size(stretch_size: number | undefined): druid_scroll;
431
+ /**
432
+ * Return vector of scroll size with width and height.
433
+ */
434
+ get_scroll_size(): Vector3;
435
+ /**
436
+ * Set points of interest.
437
+ */
438
+ set_points(points: LuaTable): druid_scroll;
439
+ /**
440
+ * Lock or unlock horizontal scroll
441
+ */
442
+ set_horizontal_scroll(state: boolean): druid_scroll;
443
+ /**
444
+ * Lock or unlock vertical scroll
445
+ */
446
+ set_vertical_scroll(state: boolean): druid_scroll;
447
+ /**
448
+ * Check node if it visible now on scroll.
449
+ */
450
+ is_node_in_view(node: Opaque<"node">): boolean;
451
+ /**
452
+ * Bind the grid component (Static or Dynamic) to recalculate
453
+ */
454
+ bind_grid(grid: druid_grid | undefined): druid_scroll;
455
+ /**
456
+ * Bind the layout component to recalculate
457
+ */
458
+ bind_layout(layout: druid_layout | undefined): druid_scroll;
459
+ /**
460
+ * Strict drag scroll area. Useful for
461
+ */
462
+ set_click_zone(node: Opaque<"node"> | string): void;
463
+ _on_scroll_drag(): void;
464
+ _check_soft_zone(): void;
465
+ _cancel_animate(): void;
466
+ _set_scroll_position(): void;
467
+ /**
468
+ * Find closer point of interest
469
+ */
470
+ _check_points(): void;
471
+ _check_threshold(): void;
472
+ _update_free_scroll(): void;
473
+ _update_hand_scroll(): void;
474
+ _on_touch_start(): void;
475
+ _on_touch_end(): void;
476
+ _update_size(): void;
477
+ _process_scroll_wheel(): void;
478
+ _on_mouse_hover(): void;
479
+ _inverse_lerp(): void;
480
+ /**
481
+ * Update vector with next conditions:
482
+ * Field x have to <= field z
483
+ * Field y have to <= field w
484
+ */
485
+ _get_border_vector(vector: Vector4, offset: Vector3): Vector4;
486
+ /**
487
+ * Return size from scroll border vector4
488
+ */
489
+ _get_size_vector(vector: Vector4): Vector3;
490
+ }
491
+ interface druid_grid_style {
492
+ IS_DYNAMIC_NODE_POSES: boolean | undefined;
493
+ IS_ALIGN_LAST_ROW: boolean | undefined;
494
+ }
495
+ /**
496
+ * The component for manage the nodes position in the grid with various options
497
+ */
498
+ interface druid_grid extends druid_component {
499
+ on_add_item: unknown;
500
+ on_remove_item: unknown;
501
+ on_change_items: unknown;
502
+ on_clear: unknown;
503
+ on_update_positions: unknown;
504
+ parent: Opaque<"node">;
505
+ nodes: Opaque<"node">[];
506
+ first_index: number;
507
+ last_index: number;
508
+ anchor: Vector3;
509
+ pivot: Vector3;
510
+ node_size: Vector3;
511
+ border: Vector4;
512
+ in_row: number;
513
+ style: druid_grid_style;
514
+ /**
515
+ * The constructor for the grid component
516
+ */
517
+ init(parent: string | Opaque<"node">, element: Opaque<"node">, in_row: number | undefined): void;
518
+ on_style_change(style: druid_grid_style): void;
519
+ /**
520
+ * Return pos for grid node index
521
+ */
522
+ get_pos(index: number): Vector3;
523
+ /**
524
+ * Return grid index by content-local x, y. Inverse of get_pos + _get_dynamic_offset.
525
+ */
526
+ get_index_xy(x: number, y: number): number;
527
+ /**
528
+ * Return grid index by position. Inverse of get_pos + _get_dynamic_offset.
529
+ */
530
+ get_index(pos: Vector3): number;
531
+ /**
532
+ * Return grid index by node
533
+ */
534
+ get_index_by_node(node: Opaque<"node">): number | undefined;
535
+ on_layout_change(): void;
536
+ /**
537
+ * Set grid anchor. Default anchor is equal to anchor of grid parent node
538
+ */
539
+ set_anchor(anchor: Vector3): void;
540
+ /**
541
+ * Instantly update the grid content
542
+ */
543
+ refresh(): druid_grid;
544
+ /**
545
+ * Set grid pivot
546
+ */
547
+ set_pivot(pivot: Opaque<"constant">): druid_grid;
548
+ /**
549
+ * Add new item to the grid
550
+ */
551
+ add(item: Opaque<"node">, index: number | undefined, shift_policy: number | undefined, is_instant: boolean | undefined): druid_grid;
552
+ /**
553
+ * Set new items to the grid. All previous items will be removed
554
+ */
555
+ set_items(nodes: Opaque<"node">[], is_instant: boolean | undefined): druid_grid;
556
+ /**
557
+ * Remove the item from the grid. Note that gui node will be not deleted
558
+ */
559
+ remove(index: number, shift_policy: number | undefined, is_instant: boolean | undefined): Opaque<"node">;
560
+ /**
561
+ * Return items count in grid
562
+ */
563
+ get_items_count(): number;
564
+ /**
565
+ * Return grid content size
566
+ */
567
+ get_size(): Vector3;
568
+ /**
569
+ * Return grid content size for given count of nodes
570
+ */
571
+ get_size_for(count: number): Vector3;
572
+ /**
573
+ * Return grid content borders
574
+ */
575
+ get_borders(): Vector4;
576
+ /**
577
+ * Return array of all node positions
578
+ */
579
+ get_all_pos(): Vector3[];
580
+ /**
581
+ * Change set position function for grid nodes. It will call on
582
+ */
583
+ set_position_function(callback: unknown): druid_grid;
584
+ /**
585
+ * Clear grid nodes array. GUI nodes will be not deleted!
586
+ */
587
+ clear(): druid_grid;
588
+ /**
589
+ * Return StaticGrid offset, where StaticGrid content starts.
590
+ */
591
+ get_offset(): Vector3;
592
+ /**
593
+ * Set new in_row elements for grid
594
+ */
595
+ set_in_row(in_row: number): druid_grid;
596
+ /**
597
+ * Set new node size for grid
598
+ */
599
+ set_item_size(width: number | undefined, height: number | undefined): druid_grid;
600
+ /**
601
+ * Sort grid nodes by custom comparator function
602
+ */
603
+ sort_nodes(comparator: unknown): druid_grid;
604
+ /**
605
+ * Update grid inner state
606
+ */
607
+ _update(is_instant: boolean | undefined): void;
608
+ /**
609
+ * Update first and last indexes of grid nodes
610
+ */
611
+ _update_indexes(): void;
612
+ /**
613
+ * Update grid content borders, recalculate min and max values
614
+ */
615
+ _update_borders(): void;
616
+ /**
617
+ * Update grid nodes position
618
+ */
619
+ _update_pos(is_instant: boolean | undefined): void;
620
+ /**
621
+ * Return dynamic centering offset. Only non-zero when IS_DYNAMIC_NODE_POSES is enabled,
622
+ * centers grid content according to pivot within its current borders.
623
+ */
624
+ _get_dynamic_offset(): LuaMultiReturn<[number, number]>;
625
+ /**
626
+ * Return x offset for a given row. For most rows returns _base_offset.x,
627
+ * but when IS_ALIGN_LAST_ROW is enabled, the last row gets a different offset.
628
+ */
629
+ _get_row_offset_x(): number;
630
+ _extend_border(border: Vector4, pos: Vector3, size: Vector3, pivot: Vector3): void;
631
+ }
632
+ interface druid_text_style {
633
+ TRIM_POSTFIX: string | undefined;
634
+ DEFAULT_ADJUST: string | undefined;
635
+ ADJUST_STEPS: number | undefined;
636
+ ADJUST_SCALE_DELTA: number | undefined;
637
+ }
638
+ /**
639
+ * Basic Druid text component. Text components by default have the text size adjusting.
640
+ *
641
+ * ### Setup
642
+ * Create text node with druid: `text = druid:new_text(node_name, [initial_value], [text_adjust_type])`
643
+ *
644
+ * ### Notes
645
+ * - Text component by default have auto adjust text sizing. Text never will be bigger, than text node size, which you can setup in GUI scene.
646
+ * - Text pivot can be changed with `text:set_pivot`, and text will save their position inside their text size box
647
+ * - There are several text adjust types:
648
+ * - - **"downscale"** - Change text's scale to fit in the text node size (default)
649
+ * - - **"trim"** - Trim the text with postfix (default - "...") to fit in the text node size
650
+ * - - **"no_adjust"** - No any adjust, like default Defold text node
651
+ * - - **"downscale_limited"** - Change text's scale like downscale, but there is limit for text's scale
652
+ * - - **"scroll"** - Change text's pivot to imitate scrolling in the text box. Use with stencil node for better effect.
653
+ * - - **"scale_then_scroll"** - Combine two modes: first limited downscale, then scroll
654
+ * - - **"trim_left"** - Trim the text with postfix (default - "...") to fit in the text node size
655
+ * - - **"scale_then_trim"** - Combine two modes: first limited downscale, then trim
656
+ * - - **"scale_then_trim_left"** - Combine two modes: first limited downscale, then trim left
657
+ */
658
+ interface druid_text extends druid_component {
659
+ node: Opaque<"node">;
660
+ on_set_text: unknown;
661
+ on_update_text_scale: unknown;
662
+ on_set_pivot: unknown;
663
+ style: druid_text_style;
664
+ start_pivot: number;
665
+ start_scale: Vector3;
666
+ scale: Vector3;
667
+ /**
668
+ * The Text constructor
669
+ */
670
+ init(node: string | Opaque<"node">, value: string | undefined, adjust_type: druid_text_adjust_type | undefined): void;
671
+ on_style_change(style: druid_text_style): void;
672
+ on_layout_change(): void;
673
+ /**
674
+ * Calculate text width with font with respect to trailing space
675
+ */
676
+ get_text_size(text: string | undefined): LuaMultiReturn<[number, number]>;
677
+ /**
678
+ * Get chars count by width
679
+ */
680
+ get_text_index_by_width(width: number): number;
681
+ /**
682
+ * Set text to text field
683
+ */
684
+ set_to(set_to: string): druid_text;
685
+ set_text(): void;
686
+ get_text(): void;
687
+ /**
688
+ * Set text area size
689
+ */
690
+ set_size(size: Vector3): druid_text;
691
+ /**
692
+ * Set color
693
+ */
694
+ set_color(color: Vector4): druid_text;
695
+ /**
696
+ * Set alpha
697
+ */
698
+ set_alpha(alpha: number): druid_text;
699
+ /**
700
+ * Set scale
701
+ */
702
+ set_scale(scale: Vector3): druid_text;
703
+ /**
704
+ * Set text pivot. Text will re-anchor inside text area
705
+ */
706
+ set_pivot(pivot: number): druid_text;
707
+ /**
708
+ * Return true, if text with line break
709
+ */
710
+ is_multiline(): boolean;
711
+ /**
712
+ * Set text adjust, refresh the current text visuals, if needed
713
+ */
714
+ set_text_adjust(adjust_type: druid_text_adjust_type | undefined, minimal_scale: number | undefined): druid_text;
715
+ /**
716
+ * Set minimal scale for "downscale_limited" or "scale_then_scroll" adjust types
717
+ */
718
+ set_minimal_scale(minimal_scale: number): druid_text;
719
+ /**
720
+ * Return current text adjust type
721
+ */
722
+ get_text_adjust(): string;
723
+ _update_text_size(): void;
724
+ /**
725
+ * Reset initial scale for text
726
+ */
727
+ _reset_default_scale(): void;
728
+ _is_fit_info_area(metrics: LuaTable): boolean;
729
+ /**
730
+ * Setup scale x, but can only be smaller, than start text scale
731
+ */
732
+ _update_text_area_size(): void;
733
+ _update_text_with_trim(trim_postfix: string): void;
734
+ _update_text_with_trim_left(trim_postfix: string): void;
735
+ _update_text_with_anchor_shift(): void;
736
+ _update_adjust(): void;
737
+ }
738
+ /**
739
+ * Color palette and utility functions for working with colors.
740
+ * Supports palette management, hex conversion, RGB/HSB conversion, and color interpolation.
741
+ */
742
+ interface druid_color {
743
+ }
744
+ interface druid_component_meta {
745
+ template: string;
746
+ context: LuaTable;
747
+ nodes: LuaTable<Hash, Opaque<"node">> | undefined;
748
+ style: LuaTable | undefined;
749
+ druid: druid_instance;
750
+ input_enabled: boolean;
751
+ children: LuaTable;
752
+ parent: druid_component | undefined;
753
+ instance_class: LuaTable;
754
+ }
755
+ interface druid_component_component {
756
+ name: string;
757
+ input_priority: number;
758
+ default_input_priority: number;
759
+ _is_input_priority_changed: boolean;
760
+ _uid: number;
761
+ }
762
+ interface druid_component {
763
+ druid: druid_instance;
764
+ /**
765
+ * Called when component is created
766
+ */
767
+ init?(...args: any[]): void;
768
+ /**
769
+ * Called every frame
770
+ */
771
+ update?(...args: any[]): void;
772
+ /**
773
+ * Called when component is removed
774
+ */
775
+ on_remove?(...args: any[]): void;
776
+ /**
777
+ * Called when input event is triggered
778
+ */
779
+ on_input?(...args: any[]): void;
780
+ /**
781
+ * Called when input event is consumed before
782
+ */
783
+ on_input_interrupt?(...args: any[]): void;
784
+ /**
785
+ * Called when message is received
786
+ */
787
+ on_message?(...args: any[]): void;
788
+ /**
789
+ * Called before update once time after GUI init
790
+ */
791
+ on_late_init?(...args: any[]): void;
792
+ /**
793
+ * Called when app lost focus
794
+ */
795
+ on_focus_lost?(...args: any[]): void;
796
+ /**
797
+ * Called when app gained focus
798
+ */
799
+ on_focus_gained?(...args: any[]): void;
800
+ /**
801
+ * Called when style is changed
802
+ */
803
+ on_style_change?(...args: any[]): void;
804
+ /**
805
+ * Called when GUI layout is changed
806
+ */
807
+ on_layout_change?(...args: any[]): void;
808
+ /**
809
+ * Called when window is resized
810
+ */
811
+ on_window_resized?(...args: any[]): void;
812
+ /**
813
+ * Called when language is changed
814
+ */
815
+ on_language_change?(...args: any[]): void;
816
+ _component: druid_component_component;
817
+ _meta: druid_component_meta;
818
+ /**
819
+ * Set component style. Pass nil to clear style
820
+ */
821
+ set_style<T>(self: T, druid_style: LuaTable | undefined): T;
822
+ /**
823
+ * Set component template name. Pass nil to clear template.
824
+ * This template id used to access nodes inside the template on GUI scene.
825
+ * Parent template will be added automatically if exist.
826
+ */
827
+ set_template<T>(self: T, template: string | undefined): T;
828
+ /**
829
+ * Get full template name.
830
+ */
831
+ get_template(): string;
832
+ /**
833
+ * Set current component nodes, returned from `gui.clone_tree` function.
834
+ */
835
+ set_nodes(nodes: LuaTable<Hash, Opaque<"node">> | Opaque<"node"> | string | undefined): druid_component;
836
+ /**
837
+ * Return current component context
838
+ */
839
+ get_context(): unknown;
840
+ /**
841
+ * Get component node by node_id. Respect to current template and nodes.
842
+ */
843
+ get_node(node_id: string | Opaque<"node">): Opaque<"node">;
844
+ /**
845
+ * Get Druid instance for inner component creation.
846
+ */
847
+ get_druid(template: string | undefined, nodes: LuaTable<Hash, Opaque<"node">> | Opaque<"node"> | string | undefined): druid_instance;
848
+ /**
849
+ * Get component name
850
+ */
851
+ get_name(): string;
852
+ /**
853
+ * Get parent component name
854
+ */
855
+ get_parent_name(): string | undefined;
856
+ /**
857
+ * Get component input priority, the bigger number processed first. Default value: 10
858
+ */
859
+ get_input_priority(): number;
860
+ /**
861
+ * Set component input priority, the bigger number processed first. Default value: 10
862
+ */
863
+ set_input_priority(value: number, is_temporary: boolean | undefined): druid_component;
864
+ /**
865
+ * Reset component input priority to it's default value, that was set in `create` function or `set_input_priority`
866
+ */
867
+ reset_input_priority(): druid_component;
868
+ /**
869
+ * Get component UID, unique identifier created in component creation order.
870
+ */
871
+ get_uid(): number;
872
+ /**
873
+ * Set component input state. By default it's enabled.
874
+ * If input is disabled, the component will not receive input events.
875
+ * Recursive for all children components.
876
+ */
877
+ set_input_enabled(state: boolean): druid_component;
878
+ /**
879
+ * Get component input state. By default it's enabled. Can be disabled by `set_input_enabled` function.
880
+ */
881
+ get_input_enabled(): boolean;
882
+ /**
883
+ * Get parent component
884
+ */
885
+ get_parent_component(): druid_component | undefined;
886
+ /**
887
+ * Setup component context and his style table
888
+ */
889
+ setup_component(druid_instance: druid_instance, context: LuaTable, style: LuaTable, instance_class: LuaTable): druid_component;
890
+ /**
891
+ * Return true, if input priority was changed
892
+ */
893
+ _is_input_priority_changed(): void;
894
+ /**
895
+ * Reset is_input_priority_changed field
896
+ */
897
+ _reset_input_priority_changed(): void;
898
+ /**
899
+ * Get current component nodes
900
+ */
901
+ get_nodes(): LuaTable<Hash, Opaque<"node">> | undefined;
902
+ /**
903
+ * Add child to component children list
904
+ */
905
+ __add_child<T extends druid_component>(child: T): T;
906
+ /**
907
+ * Remove child from component children list
908
+ */
909
+ __remove_child<T extends druid_component>(child: T): boolean;
910
+ /**
911
+ * Return all children components, recursive
912
+ */
913
+ get_childrens(): LuaTable;
914
+ }
915
+ interface druid_system_const {
916
+ }
917
+ /**
918
+ * The component that handles a rich text input field, it's a wrapper around the druid.input component
919
+ */
920
+ interface druid_rich_input extends druid_component {
921
+ root: Opaque<"node">;
922
+ input: druid_input;
923
+ cursor: Opaque<"node">;
924
+ cursor_text: Opaque<"node">;
925
+ cursor_position: Vector3;
926
+ init(template: string, nodes: LuaTable): void;
927
+ on_input(action_id: Hash, action: LuaTable): boolean;
928
+ /**
929
+ * Set placeholder text
930
+ */
931
+ set_placeholder(placeholder_text: string): druid_rich_input;
932
+ /**
933
+ * Select input field
934
+ */
935
+ select(): druid_rich_input;
936
+ /**
937
+ * Set input field text
938
+ */
939
+ set_text(text: string): druid_rich_input;
940
+ /**
941
+ * Set input field font
942
+ */
943
+ set_font(font: Hash): druid_rich_input;
944
+ /**
945
+ * Set input field text
946
+ */
947
+ get_text(): void;
948
+ /**
949
+ * Set allowed charaters for input field.
950
+ */
951
+ set_allowed_characters(characters: string): druid_rich_input;
952
+ }
953
+ interface druid_rich_text_settings {
954
+ parent: Opaque<"node">;
955
+ size: number;
956
+ fonts: LuaTable<string, string>;
957
+ scale: Vector3;
958
+ color: Vector4;
959
+ shadow: Vector4;
960
+ outline: Vector4;
961
+ position: Vector3;
962
+ image_pixel_grid_snap: boolean;
963
+ combine_words: boolean;
964
+ default_animation: string;
965
+ split_by_character: boolean;
966
+ text_prefab: Opaque<"node">;
967
+ adjust_scale: number;
968
+ default_texture: string;
969
+ is_multiline: boolean;
970
+ text_leading: number;
971
+ font: Hash;
972
+ width: number;
973
+ height: number;
974
+ }
975
+ interface druid_rich_text_word {
976
+ node: Opaque<"node">;
977
+ relative_scale: number;
978
+ source_text: string;
979
+ color: Vector4;
980
+ text_color: Vector4;
981
+ position: Vector3;
982
+ offset: Vector3;
983
+ scale: Vector3;
984
+ size: Vector3;
985
+ metrics: druid_rich_text_metrics;
986
+ pivot: Opaque<"constant">;
987
+ text: string;
988
+ shadow: Vector4;
989
+ outline: Vector4;
990
+ font: string;
991
+ image: druid_rich_text_word_image;
992
+ br: boolean;
993
+ nobr: boolean;
994
+ tags: LuaTable<string, boolean>;
995
+ }
996
+ interface druid_rich_text_word_image {
997
+ texture: string;
998
+ anim: string;
999
+ width: number;
1000
+ height: number;
1001
+ }
1002
+ interface druid_rich_text_style {
1003
+ ADJUST_STEPS: number;
1004
+ ADJUST_SCALE_DELTA: number;
1005
+ }
1006
+ interface druid_rich_text_lines_metrics {
1007
+ text_width: number;
1008
+ text_height: number;
1009
+ lines: LuaTable<number, druid_rich_text_metrics>;
1010
+ }
1011
+ interface druid_rich_text_metrics {
1012
+ width: number;
1013
+ height: number;
1014
+ offset_x: number | undefined;
1015
+ offset_y: number | undefined;
1016
+ node_size: Vector3 | undefined;
1017
+ }
1018
+ /**
1019
+ * The component that handles a rich text display, allows to custom color, size, font, etc. of the parts of the text
1020
+ */
1021
+ interface druid_rich_text extends druid_component {
1022
+ root: Opaque<"node">;
1023
+ text_prefab: Opaque<"node">;
1024
+ _last_value: string;
1025
+ _settings: LuaTable;
1026
+ _split_to_characters: boolean;
1027
+ _anchor: Vector3 | undefined;
1028
+ init(text_node: Opaque<"node"> | string, value: string | undefined): void;
1029
+ on_layout_change(): void;
1030
+ on_style_change(style: druid_rich_text_style): void;
1031
+ /**
1032
+ * Set text for Rich Text
1033
+ * -- Color
1034
+ * rich_text:set_text("<color=red>Foobar</color>")
1035
+ * rich_text:set_text("<color=1.0,0,0,1.0>Foobar</color>")
1036
+ * rich_text:set_text("<color=#ff0000>Foobar</color>")
1037
+ * rich_text:set_text("<color=#ff0000ff>Foobar</color>")
1038
+ * -- Shadow
1039
+ * rich_text:set_text("<shadow=red>Foobar</shadow>")
1040
+ * rich_text:set_text("<shadow=1.0,0,0,1.0>Foobar</shadow>")
1041
+ * rich_text:set_text("<shadow=#ff0000>Foobar</shadow>")
1042
+ * rich_text:set_text("<shadow=#ff0000ff>Foobar</shadow>")
1043
+ * -- Outline
1044
+ * rich_text:set_text("<outline=red>Foobar</outline>")
1045
+ * rich_text:set_text("<outline=1.0,0,0,1.0>Foobar</outline>")
1046
+ * rich_text:set_text("<outline=#ff0000>Foobar</outline>")
1047
+ * rich_text:set_text("<outline=#ff0000ff>Foobar</outline>")
1048
+ * -- Font
1049
+ * rich_text:set_text("<font=MyCoolFont>Foobar</font>")
1050
+ * -- Size
1051
+ * rich_text:set_text("<size=2>Twice as large</size>")
1052
+ * -- Line break
1053
+ * rich_text:set_text("<br/>Insert a line break")
1054
+ * -- No break
1055
+ * rich_text:set_text("<nobr>Prevent the text from breaking")
1056
+ * -- Image
1057
+ * rich_text:set_text("<img=texture:image>Display image")
1058
+ * rich_text:set_text("<img=texture:image,size>Display image with size")
1059
+ * rich_text:set_text("<img=texture:image,width,height>Display image with width and height")
1060
+ */
1061
+ set_text(text: string | undefined): LuaMultiReturn<[druid_rich_text_word[], druid_rich_text_lines_metrics]>;
1062
+ /**
1063
+ * Get the current text of the rich text
1064
+ */
1065
+ get_text(): string;
1066
+ /**
1067
+ * Set pivot and keep the content in place (anchor). After this, resizing the root will keep the anchor fixed.
1068
+ */
1069
+ set_pivot(pivot: number): druid_rich_text;
1070
+ on_remove(): void;
1071
+ /**
1072
+ * Clear all created words.
1073
+ */
1074
+ clear(): void;
1075
+ /**
1076
+ * Get all words, which has a passed tag.
1077
+ */
1078
+ tagged(tag: string): druid_rich_text_word[];
1079
+ /**
1080
+ * Set if the rich text should split to characters, not words
1081
+ */
1082
+ set_split_to_characters(value: boolean): druid_rich_text;
1083
+ /**
1084
+ * Get all current created words, each word is a table that contains the information about the word
1085
+ */
1086
+ get_words(): druid_rich_text_word[];
1087
+ /**
1088
+ * Get the current line metrics
1089
+ */
1090
+ get_line_metric(): druid_rich_text_lines_metrics;
1091
+ _create_settings(): LuaTable;
1092
+ /**
1093
+ * Set the width of the rich text, not affects the size of current spawned words
1094
+ */
1095
+ set_width(width: number): druid_rich_text;
1096
+ /**
1097
+ * Set the height of the rich text, not affects the size of current spawned words
1098
+ */
1099
+ set_height(height: number): druid_rich_text;
1100
+ }
1101
+ /**
1102
+ * Entry point for Druid UI Framework.
1103
+ * Create a new Druid instance and adjust the Druid settings here.
1104
+ */
1105
+ interface druid {
1106
+ }
1107
+ interface druid_container_style {
1108
+ DRAGGABLE_CORNER_SIZE: Vector3;
1109
+ DRAGGABLE_CORNER_COLOR: Vector4;
1110
+ }
1111
+ /**
1112
+ * Druid component to manage the size and positions with other containers relations to create a adaptable layouts.
1113
+ *
1114
+ * ### Setup
1115
+ * Create container component with druid: `container = druid:new_container(node, mode, callback)`
1116
+ *
1117
+ * ### Notes
1118
+ * - Container can be used to create adaptable layouts that respond to window size changes
1119
+ * - Container supports different layout modes: FIT, STRETCH, STRETCH_X, STRETCH_Y
1120
+ * - Container can be nested inside other containers
1121
+ * - Container supports fixed margins and percentage-based sizing
1122
+ * - Container can be positioned using pivot points
1123
+ * - Container supports minimum size constraints
1124
+ * - Container can be fitted into window or custom size
1125
+ */
1126
+ interface druid_container extends druid_component {
1127
+ node: Opaque<"node">;
1128
+ druid: druid_instance;
1129
+ node_offset: Vector4;
1130
+ origin_size: Vector3;
1131
+ size: Vector3;
1132
+ origin_position: Vector3;
1133
+ position: Vector3;
1134
+ pivot_offset: Vector3;
1135
+ center_offset: Vector3;
1136
+ mode: druid_container_mode;
1137
+ fit_size: Vector3;
1138
+ min_size_x: number | undefined;
1139
+ min_size_y: number | undefined;
1140
+ max_size_x: number | undefined;
1141
+ max_size_y: number | undefined;
1142
+ on_size_changed: unknown;
1143
+ _parent_container: druid_container;
1144
+ _containers: LuaTable;
1145
+ _draggable_corners: LuaTable;
1146
+ /**
1147
+ * The Container constructor
1148
+ */
1149
+ init(node: Opaque<"node">, mode: string, callback: ((self: druid_container, size: Vector3) => void) | undefined): void;
1150
+ on_late_init(): void;
1151
+ on_remove(): void;
1152
+ /**
1153
+ * Refresh the origins of the container, origins is the size and position of the container when it was created
1154
+ */
1155
+ refresh_origins(): void;
1156
+ /**
1157
+ * Set the pivot of the container
1158
+ */
1159
+ set_pivot(pivot: Opaque<"constant">): void;
1160
+ on_style_change(style: druid_container_style): void;
1161
+ /**
1162
+ * Set new size of layout node
1163
+ */
1164
+ set_size(width: number | undefined, height: number | undefined, anchor_pivot: Opaque<"constant"> | undefined): druid_container;
1165
+ /**
1166
+ * Get the position of the container
1167
+ */
1168
+ get_position(): Vector3;
1169
+ /**
1170
+ * Set the position of the container
1171
+ */
1172
+ set_position(pos_x: number, pos_y: number): void;
1173
+ /**
1174
+ * Get the current size of the layout node
1175
+ */
1176
+ get_size(): Vector3;
1177
+ /**
1178
+ * Get the current scale of the layout node
1179
+ */
1180
+ get_scale(): Vector3;
1181
+ /**
1182
+ * Set size for layout node to fit inside it
1183
+ */
1184
+ fit_into_size(target_size: Vector3): druid_container;
1185
+ /**
1186
+ * Set current size for layout node to fit inside it
1187
+ */
1188
+ fit_into_window(): druid_container;
1189
+ on_window_resized(): void;
1190
+ add_container(node_or_container: Opaque<"node"> | string | druid_container | LuaTable, mode: druid_container_mode | undefined, on_resize_callback: ((self: Opaque<"userdata">, size: Vector3) => void) | undefined): druid_container;
1191
+ remove_container_by_node(): druid_container | undefined;
1192
+ set_parent_container(parent_container: druid_container | undefined): void;
1193
+ refresh(): void;
1194
+ refresh_scale(): void;
1195
+ update_child_containers(): void;
1196
+ create_draggable_corners(): druid_container;
1197
+ clear_draggable_corners(): druid_container;
1198
+ _on_corner_drag(): void;
1199
+ /**
1200
+ * Set node for layout node to fit inside it. Pass nil to reset
1201
+ */
1202
+ fit_into_node(node: string | Opaque<"node">): druid_container;
1203
+ /**
1204
+ * Set the minimum size of the container
1205
+ */
1206
+ set_min_size(min_size_x: number | undefined, min_size_y: number | undefined): druid_container;
1207
+ /**
1208
+ * Set the maximum size of the container
1209
+ */
1210
+ set_max_size(max_size_x: number | undefined, max_size_y: number | undefined): druid_container;
1211
+ }
1212
+ /**
1213
+ * Druid component to manage a list of data with a scrollable view, used to manage huge list data and render only visible elements.
1214
+ *
1215
+ * ### Setup
1216
+ * Create data list component with druid: `data_list = druid:new_data_list(scroll, grid, create_function)`
1217
+ *
1218
+ * ### Notes
1219
+ * - Data List uses a scroll component for scrolling and a grid component for layout
1220
+ * - Data List only renders visible elements for better performance
1221
+ * - Data List supports caching of elements for better performance
1222
+ * - Data List supports adding, removing and updating elements
1223
+ * - Data List supports scrolling to specific elements
1224
+ * - Data List supports custom element creation and cleanup
1225
+ */
1226
+ interface druid_data_list extends druid_component {
1227
+ scroll: druid_scroll;
1228
+ grid: druid_grid;
1229
+ on_scroll_progress_change: unknown;
1230
+ on_element_add: unknown;
1231
+ on_element_remove: unknown;
1232
+ top_index: number;
1233
+ last_index: number;
1234
+ scroll_progress: number;
1235
+ _create_function: unknown;
1236
+ _is_use_cache: boolean;
1237
+ _cache: LuaTable;
1238
+ _data: LuaTable;
1239
+ _data_visual: LuaTable;
1240
+ /**
1241
+ * The DataList constructor
1242
+ */
1243
+ init(scroll: druid_scroll, grid: druid_grid, create_function: unknown): void;
1244
+ on_remove(): void;
1245
+ /**
1246
+ * Set use cache version of DataList. Requires make setup of components in on_element_add callback and clean in on_element_remove
1247
+ */
1248
+ set_use_cache(is_use_cache: boolean): druid_data_list;
1249
+ /**
1250
+ * Set new data set for DataList component
1251
+ */
1252
+ set_data(data: LuaTable): druid_data_list;
1253
+ /**
1254
+ * Return current data from DataList component
1255
+ */
1256
+ get_data(): LuaTable;
1257
+ /**
1258
+ * Add element to DataList
1259
+ */
1260
+ add(data: LuaTable, index: number | undefined, shift_policy: number | undefined): druid_data_list;
1261
+ /**
1262
+ * Remove element from DataList
1263
+ */
1264
+ remove(index: number | undefined, shift_policy: number | undefined): druid_data_list;
1265
+ /**
1266
+ * Remove element from DataList by data value
1267
+ */
1268
+ remove_by_data(data: LuaTable, shift_policy: number | undefined): druid_data_list;
1269
+ /**
1270
+ * Clear the DataList and refresh visuals
1271
+ */
1272
+ clear(): druid_data_list;
1273
+ /**
1274
+ * Return index for data value
1275
+ */
1276
+ get_index(data: LuaTable): void;
1277
+ /**
1278
+ * Return all currently created nodes in DataList
1279
+ */
1280
+ get_created_nodes(): Opaque<"node">[];
1281
+ /**
1282
+ * Return all currently created components in DataList
1283
+ */
1284
+ get_created_components(): druid_component[];
1285
+ /**
1286
+ * Instant scroll to element with passed index
1287
+ */
1288
+ scroll_to_index(index: number): void;
1289
+ /**
1290
+ * Add element at passed index using cache or create new
1291
+ */
1292
+ _add_at(index: number): void;
1293
+ /**
1294
+ * Remove element from passed index and add it to cache if applicable
1295
+ */
1296
+ _remove_at(index: number): void;
1297
+ /**
1298
+ * Get the visible area bounds in content-local coordinates (top-left and bottom-right),
1299
+ * clamped to the grid coordinate range so get_index_xy produces valid results.
1300
+ */
1301
+ _get_visible_bounds(): LuaMultiReturn<[number, number, number, number]>;
1302
+ /**
1303
+ * Refresh all elements in DataList
1304
+ */
1305
+ _refresh(): void;
1306
+ }
1307
+ interface druid_hotkey_style {
1308
+ MODIFICATORS: string[] | Hash[];
1309
+ MODIFICATOR_RELEASE_TIME: number;
1310
+ }
1311
+ /**
1312
+ * Druid component to manage hotkeys and trigger callbacks when hotkeys are pressed.
1313
+ *
1314
+ * ### Setup
1315
+ * Create hotkey component with druid: `hotkey = druid:new_hotkey(keys, callback, callback_argument)`
1316
+ *
1317
+ * ### Notes
1318
+ * - Hotkey can be triggered by pressing a single key or a combination of keys
1319
+ * - Hotkey supports modificator keys (e.g. Ctrl, Shift, Alt)
1320
+ * - Hotkey can be triggered on key press, release or repeat
1321
+ * - Hotkey can be added or removed at runtime
1322
+ * - Hotkey can be enabled or disabled
1323
+ * - Hotkey can be set to repeat on key hold
1324
+ */
1325
+ interface druid_hotkey extends druid_component {
1326
+ on_hotkey_pressed: unknown;
1327
+ on_hotkey_released: unknown;
1328
+ style: druid_hotkey_style;
1329
+ _hotkeys: LuaTable;
1330
+ _modificators: LuaTable<Hash, boolean>;
1331
+ _modificator_released_at: LuaTable<Hash, number>;
1332
+ _node: Opaque<"node"> | undefined;
1333
+ /**
1334
+ * The Hotkey constructor
1335
+ */
1336
+ init(keys: string[] | string, callback: unknown, callback_argument: unknown | undefined): void;
1337
+ on_style_change(style: druid_hotkey_style): void;
1338
+ /**
1339
+ * Add hotkey for component callback
1340
+ */
1341
+ add_hotkey(keys: string[] | Hash[] | string | Hash, callback_argument: unknown | undefined): druid_hotkey;
1342
+ is_processing(): void;
1343
+ on_focus_gained(): void;
1344
+ _is_modificator_active(modificator: Hash, time: number): boolean;
1345
+ on_input(action_id: Hash | undefined, action: action): boolean;
1346
+ /**
1347
+ * If true, the callback will be triggered on action.repeated
1348
+ */
1349
+ set_repeat(is_enabled_repeated: boolean): druid_hotkey;
1350
+ /**
1351
+ * If node is provided, the hotkey can be disabled, if the node is disabled
1352
+ */
1353
+ bind_node(node: Opaque<"node"> | undefined): druid_hotkey;
1354
+ }
1355
+ interface druid_input_style {
1356
+ MASK_DEFAULT_CHAR: string;
1357
+ IS_LONGTAP_ERASE: boolean;
1358
+ IS_UNSELECT_ON_RESELECT: boolean;
1359
+ on_init: ((self: druid_input) => void) | undefined;
1360
+ on_select: (self: druid_input, button_node: Opaque<"node">) => void;
1361
+ on_unselect: (self: druid_input, button_node: Opaque<"node">) => void;
1362
+ on_input_wrong: (self: druid_input, button_node: Opaque<"node">) => void;
1363
+ }
1364
+ /**
1365
+ * Basic Druid text input component. Handles user text input via component with button and text.
1366
+ *
1367
+ * ### Setup
1368
+ * Create input component with druid: `input = druid:new_input(button_node_name, text_node_name, keyboard_type)`
1369
+ *
1370
+ * ### Notes
1371
+ * - Input component handles user text input. Input contains button and text components
1372
+ * - Button needed for selecting/unselecting input field
1373
+ * - Click outside of button to unselect input field
1374
+ * - On focus lost (game minimized) input field will be unselected
1375
+ * - You can setup max length of the text
1376
+ * - You can setup allowed characters. On add not allowed characters `on_input_wrong` will be called
1377
+ */
1378
+ interface druid_input extends druid_component {
1379
+ on_input_select: unknown;
1380
+ on_input_unselect: unknown;
1381
+ on_input_text: unknown;
1382
+ on_input_empty: unknown;
1383
+ on_input_full: unknown;
1384
+ on_input_wrong: unknown;
1385
+ on_select_cursor_change: unknown;
1386
+ style: druid_input_style;
1387
+ init(click_node: Opaque<"node">, text_node: Opaque<"node"> | druid_text, keyboard_type: Opaque<"constant"> | undefined): void;
1388
+ on_style_change(style: druid_input_style): void;
1389
+ on_input(action_id: Hash | undefined, action: action): boolean;
1390
+ on_focus_lost(): void;
1391
+ get_text_selected(): void;
1392
+ /**
1393
+ * Replace selected text with new text
1394
+ */
1395
+ get_text_selected_replaced(text: string): string;
1396
+ /**
1397
+ * Set text for input field
1398
+ */
1399
+ set_text(input_text: string | undefined): void;
1400
+ /**
1401
+ * Select input field. It will show the keyboard and trigger on_select events
1402
+ */
1403
+ select(): void;
1404
+ /**
1405
+ * Remove selection from input. It will hide the keyboard and trigger on_unselect events
1406
+ */
1407
+ unselect(): void;
1408
+ /**
1409
+ * Return current input field text
1410
+ */
1411
+ get_text(): string;
1412
+ /**
1413
+ * Set maximum length for input field.
1414
+ * Pass nil to make input field unliminted (by default)
1415
+ */
1416
+ set_max_length(max_length: number): druid_input;
1417
+ /**
1418
+ * Set allowed charaters for input field.
1419
+ * See: https://defold.com/ref/stable/string/
1420
+ * ex: [%a%d] for alpha and numeric
1421
+ * ex: [abcdef] to allow only these characters
1422
+ * ex: [^%s] to allow only non-space characters
1423
+ */
1424
+ set_allowed_characters(characters: string): druid_input;
1425
+ /**
1426
+ * Reset current input selection and return previous value
1427
+ */
1428
+ reset_changes(): druid_input;
1429
+ /**
1430
+ * Set cursor position in input field
1431
+ */
1432
+ select_cursor(cursor_index: number | undefined, start_index: number | undefined, end_index: number | undefined): druid_input;
1433
+ /**
1434
+ * Change cursor position by delta
1435
+ */
1436
+ move_selection(delta: number, is_add_to_selection: boolean, is_move_to_end: boolean): druid_input;
1437
+ }
1438
+ /**
1439
+ * The component used for displaying localized text, can automatically update text when locale is changed.
1440
+ * It wraps the Text component to handle localization using druid's get_text_function to set text by its id.
1441
+ *
1442
+ * ### Setup
1443
+ * Create lang text component with druid: `text = druid:new_lang_text(node_name, locale_id)`
1444
+ *
1445
+ * ### Notes
1446
+ * - Component automatically updates text when locale is changed
1447
+ * - Uses druid's get_text_function to get localized text by id
1448
+ * - Supports string formatting with additional parameters
1449
+ */
1450
+ interface druid_lang_text extends druid_component {
1451
+ text: druid_text;
1452
+ node: Opaque<"node">;
1453
+ on_change: unknown;
1454
+ last_locale_args: LuaTable;
1455
+ last_locale: string;
1456
+ init(node: string | Opaque<"node">, locale_id: string | undefined, adjust_type: string | undefined): void;
1457
+ on_language_change(): void;
1458
+ /**
1459
+ * Setup raw text to lang_text component. This will clear any locale settings.
1460
+ */
1461
+ set_to(text: string): druid_lang_text;
1462
+ /**
1463
+ * Setup raw text to lang_text component. This will clear any locale settings.
1464
+ */
1465
+ set_text(text: string): druid_lang_text;
1466
+ /**
1467
+ * Translate the text by locale_id. The text will be automatically updated when locale changes.
1468
+ */
1469
+ translate(locale_id: string, ...args: string[]): druid_lang_text;
1470
+ /**
1471
+ * Format string with new text params on localized text. Keeps the current locale but updates the format parameters.
1472
+ */
1473
+ format(...args: string[]): druid_lang_text;
1474
+ }
1475
+ interface event_on_size_changed {
1476
+ subscribe: (_: unknown, callback: (new_size: Vector3) => void, context: unknown | undefined) => void;
1477
+ }
1478
+ interface druid_layout_row_data {
1479
+ width: number;
1480
+ height: number;
1481
+ count: number;
1482
+ }
1483
+ interface druid_layout_rows_data {
1484
+ total_width: number;
1485
+ total_height: number;
1486
+ nodes_width: LuaTable<Opaque<"node">, number>;
1487
+ nodes_height: LuaTable<Opaque<"node">, number>;
1488
+ rows: unknown;
1489
+ }
1490
+ /**
1491
+ * Druid component to manage the layout of nodes, placing them inside the node size with respect to the size and pivot of each node.
1492
+ *
1493
+ * ### Setup
1494
+ * Create layout component with druid: `layout = druid:new_layout(node, layout_type)`
1495
+ *
1496
+ * ### Notes
1497
+ * - Layout can be horizontal, vertical or horizontal with wrapping
1498
+ * - Layout can resize parent node to fit content
1499
+ * - Layout can justify content
1500
+ * - Layout supports margins and padding
1501
+ * - Layout automatically updates when nodes are added or removed
1502
+ * - Layout can be manually updated by calling set_dirty()
1503
+ */
1504
+ interface druid_layout extends druid_component {
1505
+ node: Opaque<"node">;
1506
+ rows_data: druid_layout_rows_data;
1507
+ is_dirty: boolean;
1508
+ entities: Opaque<"node">[];
1509
+ margin: { x: number; y: number };
1510
+ padding: Vector4;
1511
+ type: string;
1512
+ is_resize_width: boolean;
1513
+ is_resize_height: boolean;
1514
+ is_justify: boolean;
1515
+ on_size_changed: event_on_size_changed;
1516
+ init(node_or_node_id: Opaque<"node"> | string, layout_type: druid_layout_type): void;
1517
+ update(): void;
1518
+ on_layout_change(): void;
1519
+ get_entities(): Opaque<"node">[];
1520
+ get_entities_count(): number;
1521
+ set_node_index(node: Opaque<"node">, index: number): druid_layout;
1522
+ /**
1523
+ * Set the margin of the layout
1524
+ */
1525
+ set_margin(margin_x: number | undefined, margin_y: number | undefined): druid_layout;
1526
+ set_padding(padding_x: number | undefined, padding_y: number | undefined, padding_z: number | undefined, padding_w: number | undefined): druid_layout;
1527
+ set_dirty(): druid_layout;
1528
+ set_justify(is_justify: boolean): druid_layout;
1529
+ set_type(layout_type: druid_layout_type): druid_layout;
1530
+ set_hug_content(is_hug_width: boolean, is_hug_height: boolean): druid_layout;
1531
+ /**
1532
+ * Add node to layout
1533
+ */
1534
+ add(node_or_node_id: Opaque<"node"> | string): druid_layout;
1535
+ /**
1536
+ * Remove node from layout
1537
+ */
1538
+ remove(node_or_node_id: Opaque<"node"> | string): druid_layout;
1539
+ get_size(): Vector3;
1540
+ get_content_size(): unknown;
1541
+ refresh_layout(is_instant: boolean | undefined): druid_layout;
1542
+ clear_layout(): druid_layout;
1543
+ get_node_size(node: Opaque<"node">): LuaMultiReturn<[number, number]>;
1544
+ /**
1545
+ * Calculate rows data for layout. Contains total width, height and rows info (width, height, count of elements in row)
1546
+ */
1547
+ calculate_rows_data(): druid_layout_rows_data;
1548
+ set_node_position(node: Opaque<"node">, x: number, y: number): Opaque<"node">;
1549
+ /**
1550
+ * Set custom position function for layout nodes. It will call on update poses on layout elements. Default: gui.set_position
1551
+ */
1552
+ set_position_function(callback: unknown): druid_layout;
1553
+ }
1554
+ interface druid_progress_style {
1555
+ SPEED: number | undefined;
1556
+ MIN_DELTA: number | undefined;
1557
+ }
1558
+ /**
1559
+ * Basic Druid progress bar component. Changes the size or scale of a node to represent progress.
1560
+ *
1561
+ * ### Setup
1562
+ * Create progress bar component with druid: `progress = druid:new_progress(node_name, key, init_value)`
1563
+ *
1564
+ * ### Notes
1565
+ * - Node should have maximum node size in GUI scene, it represents the progress bar's maximum size
1566
+ * - Key is value from druid const: "x" or "y"
1567
+ * - Progress works correctly with 9slice nodes, it tries to set size by _set_size_ first until minimum size is reached, then it continues sizing via _set_scale_
1568
+ * - Progress bar can fill only by vertical or horizontal size. For diagonal progress bar, just rotate the node in GUI scene
1569
+ * - If you have glitchy or dark texture bugs with progress bar, try to disable mipmaps in your texture profiles
1570
+ */
1571
+ interface druid_progress extends druid_component {
1572
+ node: Opaque<"node">;
1573
+ on_change: unknown;
1574
+ style: druid_progress_style;
1575
+ key: string;
1576
+ prop: Hash;
1577
+ init(node: string | Opaque<"node">, key: string, init_value: number | undefined): void;
1578
+ on_style_change(style: druid_progress_style): void;
1579
+ on_layout_change(): void;
1580
+ on_remove(): void;
1581
+ update(dt: number): void;
1582
+ /**
1583
+ * Fill the progress bar
1584
+ */
1585
+ fill(): druid_progress;
1586
+ /**
1587
+ * Empty the progress bar
1588
+ */
1589
+ empty(): druid_progress;
1590
+ /**
1591
+ * Instant fill progress bar to value
1592
+ */
1593
+ set_to(to: number): druid_progress;
1594
+ /**
1595
+ * Return the current value of the progress bar
1596
+ */
1597
+ get(): number;
1598
+ /**
1599
+ * Set points on progress bar to fire the callback
1600
+ */
1601
+ set_steps(steps: number[], callback: unknown): druid_progress;
1602
+ /**
1603
+ * Start animation of a progress bar
1604
+ */
1605
+ to(to: number, callback: unknown | undefined): druid_progress;
1606
+ /**
1607
+ * Set progress bar max node size
1608
+ */
1609
+ set_max_size(max_size: Vector3): druid_progress;
1610
+ _check_steps(from: number, to: number, exactly: number | undefined): void;
1611
+ _set_bar_to(set_to: number): void;
1612
+ }
1613
+ /**
1614
+ * Basic Druid slider component. Creates a draggable node over a line with progress reporting.
1615
+ *
1616
+ * ### Setup
1617
+ * Create slider component with druid: `slider = druid:new_slider(node_name, end_pos, callback)`
1618
+ *
1619
+ * ### Notes
1620
+ * - Pin node should be placed in initial position at zero progress
1621
+ * - It will be available to move Pin node between start pos and end pos
1622
+ * - You can setup points of interests on slider via `slider:set_steps`. If steps exist, slider values will be only from these steps (notched slider)
1623
+ * - Start pos and end pos should be on vertical or horizontal line (their x or y value should be equal)
1624
+ * - To catch input across all slider, you can setup input node via `slider:set_input_node`
1625
+ */
1626
+ interface druid_slider extends druid_component {
1627
+ node: Opaque<"node">;
1628
+ on_change_value: unknown;
1629
+ style: LuaTable;
1630
+ start_pos: Vector3;
1631
+ pos: Vector3;
1632
+ target_pos: Vector3;
1633
+ end_pos: Vector3;
1634
+ dist: Vector3;
1635
+ is_drag: boolean;
1636
+ value: number;
1637
+ steps: number[] | undefined;
1638
+ /**
1639
+ * The Slider constructor
1640
+ */
1641
+ init(node: Opaque<"node">, end_pos: Vector3, callback: unknown | undefined): void;
1642
+ on_layout_change(): void;
1643
+ on_remove(): void;
1644
+ on_style_change(style: LuaTable): void;
1645
+ on_window_resized(): void;
1646
+ on_input(action_id: Hash, action: LuaTable): boolean;
1647
+ /**
1648
+ * Set value for slider
1649
+ */
1650
+ set(value: number, is_silent: boolean | undefined): druid_slider;
1651
+ /**
1652
+ * Set slider steps. Pin node will
1653
+ * apply closest step position
1654
+ */
1655
+ set_steps(steps: number[]): druid_slider;
1656
+ /**
1657
+ * Adjust the end position of the slider
1658
+ */
1659
+ set_end_pos(end_pos: Vector3): druid_slider;
1660
+ /**
1661
+ * Set input zone for slider.
1662
+ * User can touch any place of node, pin instantly will
1663
+ * move at this position and node drag will start.
1664
+ * This function require the Defold version 1.3.0+
1665
+ */
1666
+ set_input_node(input_node: Opaque<"node"> | string | undefined): druid_slider;
1667
+ /**
1668
+ * Set Slider input enabled or disabled
1669
+ */
1670
+ set_enabled(is_enabled: boolean): druid_slider;
1671
+ /**
1672
+ * Check if Slider component is enabled
1673
+ */
1674
+ is_enabled(): boolean;
1675
+ _on_change_value(): void;
1676
+ _set_position(): void;
1677
+ }
1678
+ interface druid_swipe_style {
1679
+ SWIPE_TIME: number | undefined;
1680
+ SWIPE_THRESHOLD: number | undefined;
1681
+ SWIPE_TRIGGER_ON_MOVE: boolean | undefined;
1682
+ }
1683
+ /**
1684
+ * The component to manage swipe events over a node
1685
+ */
1686
+ interface druid_swipe extends druid_component {
1687
+ node: Opaque<"node">;
1688
+ on_swipe: unknown;
1689
+ style: druid_swipe_style;
1690
+ click_zone: Opaque<"node">;
1691
+ _trigger_on_move: boolean;
1692
+ _swipe_start_time: number;
1693
+ _start_pos: Vector3;
1694
+ _is_enabled: boolean;
1695
+ _is_mobile: boolean;
1696
+ init(node_or_node_id: Opaque<"node"> | string, on_swipe_callback: unknown): void;
1697
+ on_late_init(): void;
1698
+ on_style_change(style: druid_swipe_style): void;
1699
+ on_input(action_id: Hash, action: action): boolean;
1700
+ on_input_interrupt(): void;
1701
+ /**
1702
+ * Set the click zone for the swipe, useful for restricting events outside stencil node
1703
+ */
1704
+ set_click_zone(zone: Opaque<"node"> | string | undefined): void;
1705
+ /**
1706
+ * Start swipe event
1707
+ */
1708
+ _start_swipe(action: action): void;
1709
+ /**
1710
+ * Reset swipe event
1711
+ */
1712
+ _reset_swipe(): void;
1713
+ /**
1714
+ * Check swipe event
1715
+ */
1716
+ _check_swipe(self: druid_swipe, action: action): void;
1717
+ }
1718
+ /**
1719
+ * Druid component to handle timer work on gui text node. Displays time in a formatted way.
1720
+ *
1721
+ * ### Setup
1722
+ * Create timer component with druid: `timer = druid:new_timer(text_node, from_seconds, to_seconds, callback)`
1723
+ *
1724
+ * ### Notes
1725
+ * - Timer fires callback when timer value equals to _to_seconds_
1726
+ * - Timer will set text node with current timer value
1727
+ * - Timer uses update function to handle time
1728
+ */
1729
+ interface druid_timer extends druid_component {
1730
+ on_tick: unknown;
1731
+ on_set_enabled: unknown;
1732
+ on_timer_end: unknown;
1733
+ node: Opaque<"node">;
1734
+ from: number;
1735
+ target: number;
1736
+ value: number;
1737
+ is_on: boolean | undefined;
1738
+ init(node: Opaque<"node">, seconds_from: number | undefined, seconds_to: number | undefined, callback: unknown | undefined): void;
1739
+ update(): void;
1740
+ on_layout_change(): void;
1741
+ /**
1742
+ * Set the timer to a specific value
1743
+ */
1744
+ set_to(set_to: number): druid_timer;
1745
+ /**
1746
+ * Set the timer to a specific value
1747
+ */
1748
+ set_state(is_on: boolean | undefined): druid_timer;
1749
+ /**
1750
+ * Set the timer interval
1751
+ */
1752
+ set_interval(from: number, to: number): druid_timer;
1753
+ _second_string_min(sec: number): string;
1754
+ }
1755
+ /**
1756
+ * The helper module contains various functions that are used in the Druid library.
1757
+ * You can use these functions in your projects as well.
1758
+ */
1759
+ interface druid_helper {
1760
+ }
1761
+ interface druid_system_animation_data {
1762
+ frames: LuaTable<number, LuaTable<string, number>>;
1763
+ width: number;
1764
+ height: number;
1765
+ fps: number;
1766
+ current_frame: number;
1767
+ node: Opaque<"node">;
1768
+ v: Vector4;
1769
+ }
1770
+ interface druid_widget extends druid_component {
1771
+ druid: druid_instance;
1772
+ }
1773
+ interface druid_logger {
1774
+ trace: (message: string, context: unknown) => void;
1775
+ debug: (message: string, context: unknown) => void;
1776
+ info: (message: string, context: unknown) => void;
1777
+ warn: (message: string, context: unknown) => void;
1778
+ error: (message: string, context: unknown) => void;
1779
+ }
1780
+ interface GUITextMetrics {
1781
+ width: number;
1782
+ height: number;
1783
+ max_ascent: number;
1784
+ max_descent: number;
1785
+ offset_x: number;
1786
+ offset_y: number;
1787
+ }
1788
+ interface utf8 {
1789
+ len: (s: string) => number;
1790
+ sub: (s: string, start_index: number, length: number) => void;
1791
+ reverse: () => void;
1792
+ char: () => void;
1793
+ unicode: () => void;
1794
+ gensub: () => void;
1795
+ byte: () => void;
1796
+ find: () => void;
1797
+ match: (s: string, m: string) => void;
1798
+ gmatch: (s: string, m: string) => void;
1799
+ gsub: () => void;
1800
+ dump: () => void;
1801
+ format: () => void;
1802
+ lower: () => void;
1803
+ upper: () => void;
1804
+ rep: () => void;
1805
+ }
1806
+ interface action {
1807
+ value: number;
1808
+ pressed: boolean;
1809
+ released: boolean;
1810
+ repeated: boolean;
1811
+ x: number;
1812
+ y: number;
1813
+ screen_x: number;
1814
+ screen_y: number;
1815
+ dx: number;
1816
+ dy: number;
1817
+ screen_dx: number;
1818
+ screen_dy: number;
1819
+ gamepad: number;
1820
+ touch: touch[];
1821
+ text: string;
1822
+ }
1823
+ interface touch {
1824
+ id: number;
1825
+ pressed: boolean;
1826
+ released: boolean;
1827
+ tap_count: number;
1828
+ x: number;
1829
+ y: number;
1830
+ dx: number;
1831
+ dy: number;
1832
+ acc_x: number | undefined;
1833
+ acc_y: number | undefined;
1834
+ acc_z: number | undefined;
1835
+ }
1836
+ /**
1837
+ * The Druid Factory used to create components
1838
+ */
1839
+ interface druid_instance {
1840
+ input_inited: boolean;
1841
+ components_all: druid_component[];
1842
+ components_interest: LuaTable<string, druid_component[]>;
1843
+ _context: LuaTable;
1844
+ _style: LuaTable;
1845
+ _late_init_timer_id: number;
1846
+ _late_remove: druid_component[];
1847
+ _is_late_remove_enabled: boolean;
1848
+ _input_blacklist: druid_component[] | undefined;
1849
+ _input_whitelist: druid_component[] | undefined;
1850
+ /**
1851
+ * Check whitelists and blacklists for input components
1852
+ */
1853
+ _can_use_input_component(component: druid_component): boolean;
1854
+ /**
1855
+ * Create new Druid component instance
1856
+ */
1857
+ "new"<T extends druid_component>(component: T, ...args: unknown[]): T;
1858
+ /**
1859
+ * Call this in gui_script final function.
1860
+ */
1861
+ final(): void;
1862
+ /**
1863
+ * Remove created component from Druid instance.
1864
+ *
1865
+ * Component `on_remove` function will be invoked, if exist.
1866
+ */
1867
+ remove<T extends druid_component>(component: T): boolean;
1868
+ /**
1869
+ * Get a context of Druid instance (usually a self of gui script)
1870
+ */
1871
+ get_context(): unknown;
1872
+ /**
1873
+ * Get a style of Druid instance
1874
+ */
1875
+ get_style(): LuaTable;
1876
+ /**
1877
+ * Druid late update function called after initialization and before the regular update step.
1878
+ * This function is used to check the GUI state and perform actions after all components and nodes have been created.
1879
+ * An example use case is performing an auto stencil check in the GUI hierarchy for input components.
1880
+ */
1881
+ late_init(): void;
1882
+ /**
1883
+ * Call this in gui_script update function.
1884
+ */
1885
+ update(dt: number): void;
1886
+ /**
1887
+ * Call this in gui_script on_input function.
1888
+ */
1889
+ on_input(action_id: Hash, action: LuaTable): boolean;
1890
+ /**
1891
+ * Call this in gui_script on_message function.
1892
+ */
1893
+ on_message(message_id: Hash, message: LuaTable, sender: Url): void;
1894
+ /**
1895
+ * Called when the window event occurs
1896
+ */
1897
+ on_window_event(window_event: number): void;
1898
+ /**
1899
+ * Calls the on_language_change function in all related components
1900
+ * This one called by global druid.on_language_change, but can be called manually to update all translations
1901
+ */
1902
+ on_language_change(): void;
1903
+ /**
1904
+ * Set whitelist components for input processing.
1905
+ * If whitelist is not empty and component not contains in this list,
1906
+ * component will be not processed on the input step
1907
+ */
1908
+ set_whitelist(whitelist_components: LuaTable | druid_component[]): druid_instance;
1909
+ /**
1910
+ * Set blacklist components for input processing.
1911
+ * If blacklist is not empty and component is contained in this list,
1912
+ * component will be not processed on the input step DruidInstance
1913
+ */
1914
+ set_blacklist(blacklist_components: LuaTable | druid_component[]): druid_instance;
1915
+ /**
1916
+ * Remove all components on late remove step DruidInstance
1917
+ */
1918
+ _clear_late_remove(): void;
1919
+ /**
1920
+ * Create new Druid widget instance
1921
+ */
1922
+ new_widget<T extends druid_component>(widget: T, template: string | undefined, nodes: LuaTable<Hash, Opaque<"node">> | Opaque<"node"> | string | undefined, ...args: unknown[]): T;
1923
+ /**
1924
+ * Create Button component
1925
+ */
1926
+ new_button(node: string | Opaque<"node">, callback: unknown | unknown | undefined, params: unknown | undefined, anim_node: Opaque<"node"> | string | undefined): druid_button;
1927
+ /**
1928
+ * Create Blocker component
1929
+ */
1930
+ new_blocker(node: string | Opaque<"node">): druid_blocker;
1931
+ /**
1932
+ * Create BackHandler component
1933
+ */
1934
+ new_back_handler(callback: unknown | unknown | undefined, params: unknown | undefined): druid_back_handler;
1935
+ /**
1936
+ * Create Hover component
1937
+ */
1938
+ new_hover(node: string | Opaque<"node">, on_hover_callback: unknown | undefined, on_mouse_hover_callback: unknown | undefined): druid_hover;
1939
+ /**
1940
+ * Create Text component
1941
+ */
1942
+ new_text(node: string | Opaque<"node"> | druid_text, value: string | undefined, adjust_type: string | undefined): druid_text;
1943
+ /**
1944
+ * Create Grid component
1945
+ */
1946
+ new_grid(parent_node: string | Opaque<"node">, item: string | Opaque<"node">, in_row: number | undefined): druid_grid;
1947
+ /**
1948
+ * Create Scroll component
1949
+ */
1950
+ new_scroll(view_node: string | Opaque<"node">, content_node: string | Opaque<"node">): druid_scroll;
1951
+ /**
1952
+ * Create Drag component
1953
+ */
1954
+ new_drag(node: string | Opaque<"node">, on_drag_callback: unknown | undefined): druid_drag;
1955
+ /**
1956
+ * Create Swipe component
1957
+ */
1958
+ new_swipe(node: string | Opaque<"node">, on_swipe_callback: unknown | undefined): druid_swipe;
1959
+ /**
1960
+ * Create LangText component
1961
+ */
1962
+ new_lang_text(node: string | Opaque<"node">, locale_id: string | undefined, adjust_type: string | undefined): druid_lang_text;
1963
+ /**
1964
+ * Create Slider component
1965
+ */
1966
+ new_slider(pin_node: string | Opaque<"node">, end_pos: Vector3, callback: unknown | undefined): druid_slider;
1967
+ /**
1968
+ * Create Input component
1969
+ */
1970
+ new_input(click_node: string | Opaque<"node">, text_node: string | Opaque<"node"> | druid_text, keyboard_type: number | undefined): druid_input;
1971
+ /**
1972
+ * Create DataList component
1973
+ */
1974
+ new_data_list(druid_scroll: druid_scroll, druid_grid: druid_grid, create_function: unknown): druid_data_list;
1975
+ /**
1976
+ * Create Timer component
1977
+ */
1978
+ new_timer(node: string | Opaque<"node">, seconds_from: number | undefined, seconds_to: number | undefined, callback: unknown | undefined): druid_timer;
1979
+ /**
1980
+ * Create Progress component
1981
+ */
1982
+ new_progress(node: string | Opaque<"node">, key: string, init_value: number | undefined): druid_progress;
1983
+ /**
1984
+ * Create Layout component
1985
+ */
1986
+ new_layout(node: string | Opaque<"node">, mode: string | undefined): druid_layout;
1987
+ /**
1988
+ * Create Container component
1989
+ */
1990
+ new_container(node: string | Opaque<"node">, mode: druid_container_mode | undefined, callback: ((self: druid_container, size: Vector3) => void) | undefined): druid_container;
1991
+ /**
1992
+ * Create Hotkey component
1993
+ */
1994
+ new_hotkey(keys_array: string | string[], callback: unknown | unknown | undefined, callback_argument: unknown | undefined): druid_hotkey;
1995
+ /**
1996
+ * Create RichText component.
1997
+ */
1998
+ new_rich_text(text_node: string | Opaque<"node">, value: string | undefined): druid_rich_text;
1999
+ /**
2000
+ * Create RichInput component.
2001
+ * As a template please check rich_input.gui layout.
2002
+ */
2003
+ new_rich_input(template: string, nodes: LuaTable | undefined): druid_rich_input;
2004
+ }
2005
+ interface druid_system_settings {
2006
+ }
2007
+ /**
2008
+ * Create a new Druid instance for creating GUI components.
2009
+ */
2010
+ export function new_(this: void, context: LuaTable, style: LuaTable | undefined): druid_instance;
2011
+ export { new_ as new };
2012
+ /**
2013
+ * Register a new external Druid component.
2014
+ * Register component just makes the druid:new_{name} function.
2015
+ * For example, if you register a component called "my_component", you can create it using druid:new_my_component(...).
2016
+ * This can be useful if you have your own "basic" components that you don't want to require in every file.
2017
+ * The default way to create component is `druid_instance:new(component_class, ...)`.
2018
+ */
2019
+ export function register(this: void, name: string, module: LuaTable): void;
2020
+ /**
2021
+ * Set the default style for all Druid instances.
2022
+ */
2023
+ export function set_default_style(this: void, style: LuaTable): void;
2024
+ /**
2025
+ * Set the text function for the LangText component.
2026
+ */
2027
+ export function set_text_function(this: void, callback: (text_id: string) => string): void;
2028
+ /**
2029
+ * Set the sound function to able components to play sounds.
2030
+ */
2031
+ export function set_sound_function(this: void, callback: (sound_id: string) => void): void;
2032
+ /**
2033
+ * Subscribe Druid to the window listener. It will override your previous
2034
+ * window listener, so if you have one, you should call M.on_window_callback manually.
2035
+ */
2036
+ export function init_window_listener(this: void): void;
2037
+ /**
2038
+ * Set the window callback to enable Druid window events.
2039
+ */
2040
+ export function on_window_callback(this: void, window_event: Opaque<"constant">): void;
2041
+ /**
2042
+ * Call this function when the game language changes.
2043
+ * It will notify all Druid instances to update the lang text components.
2044
+ */
2045
+ export function on_language_change(this: void): void;
2046
+ /**
2047
+ * Create a widget from the bound Druid GUI instance.
2048
+ * The widget will be created and all widget functions can be called from Game Object contexts.
2049
+ * This allows using only `druid_widget.gui_script` for GUI files and call this widget functions from Game Object script file.
2050
+ * Widget class here is your lua file for the GUI scene (widgets in Druid)
2051
+ * msg.url(nil, nil, "gui_widget") -- current game object
2052
+ * msg.url(nil, object_url, "gui_widget") -- other game object
2053
+ */
2054
+ export function get_widget<T extends druid_widget>(this: void, widget_class: T, gui_url: Url | string, params: unknown | undefined): T;
2055
+ /**
2056
+ * Bind a Druid GUI instance to the current game object.
2057
+ * This instance now can produce widgets from `druid.get_widget()` function.
2058
+ * Only one widget can be set per game object.
2059
+ */
2060
+ export function register_druid_as_widget(this: void, druid: druid_instance): void;
2061
+ /**
2062
+ * Should be called on final, where druid instance is destroyed.
2063
+ */
2064
+ export function unregister_druid_as_widget(this: void): void;
2065
+ export function set_logger(this: void, logger_instance: druid_logger | LuaTable | undefined): void;
2066
+ export function get_logger(this: void, name: string | undefined, level: string | undefined): druid_logger;
2067
+ }