mirror of
https://github.com/Insality/druid.git
synced 2025-06-26 18:07:45 +02:00
4.1 KiB
4.1 KiB
druid.progress API
at /druid/extended/progress.lua
Basic Druid progress bar component. Changes the size or scale of a node to represent progress.
Setup
Create progress bar component with druid: progress = druid:new_progress(node_name, key, init_value)
Notes
- Node should have maximum node size in GUI scene, it represents the progress bar's maximum size
- Key is value from druid const: "x" or "y"
- 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
- Progress bar can fill only by vertical or horizontal size. For diagonal progress bar, just rotate the node in GUI scene
- If you have glitchy or dark texture bugs with progress bar, try to disable mipmaps in your texture profiles
Functions
Fields
- node
- on_change
- style
- key
- prop
- scale
- size
- max_size
- slice
- last_value
- slice_size
- target
- steps
- step_callback
- target_callback
init
progress:init(node, key, [init_value])
- Parameters:
node
(string|node): Node name or GUI Node itself.key
(string): Progress bar direction: "x" or "y"[init_value]
(number|nil): Initial value of progress bar (0 to 1). Default: 1
update
progress:update(dt)
- Parameters:
dt
(number): Delta time
fill
progress:fill()
Fill the progress bar
- Returns:
self
(druid.progress): Current progress instance
empty
progress:empty()
Empty the progress bar
- Returns:
self
(druid.progress): Current progress instance
set_to
progress:set_to(to)
Instant fill progress bar to value
-
Parameters:
to
(number): Progress bar value, from 0 to 1
-
Returns:
self
(druid.progress): Current progress instance
get
progress:get()
Return the current value of the progress bar
- Returns:
value
(number): The current value of the progress bar
set_steps
progress:set_steps(steps, callback)
Set points on progress bar to fire the callback
-
Parameters:
steps
(number[]): Array of progress bar valuescallback
(function): Callback on intersect step value
-
Returns:
self
(druid.progress): Current progress instance
to
progress:to(to, [callback])
Start animation of a progress bar
-
Parameters:
to
(number): value between 0..1[callback]
(function|nil): Callback on animation ends
-
Returns:
self
(druid.progress): Current progress instance
set_max_size
progress:set_max_size(max_size)
Set progress bar max node size
-
Parameters:
max_size
(vector3): The new node maximum (full) size
-
Returns:
self
(druid.progress): Current progress instance
Fields
- node (node): The progress bar node
- on_change (event): fun(self: druid.progress, value: number) Event triggered when progress value changes
- style (druid.progress.style): Component style parameters
- key (string): Progress bar direction: "x" or "y"
- prop (hash): Property for scaling the progress bar
- scale (unknown)
- size (unknown)
- max_size (unknown)
- slice (unknown)
- last_value (number)
- slice_size (unknown)
- target (nil)
- steps (number[])
- step_callback (function)
- target_callback (function|nil)