Skip to content

Defold Druid v0.9.0

Compare
Choose a tag to compare
@Insality Insality released this 12 Mar 10:13
· 239 commits to master since this release
b5a7739

Druid 0.9.0

Custom components update

Hello!

Here is the long awaited update! Finally I implemented some ideas how to make easier creating custom components. There is a bunch of improvements you can be interested in.

I wanna make a point that Druid is not only set of defined components to place buttons, scroll, etc. But mostly it's a way how to handle all your GUI elements in general. Custom components is most powerful way to separate logic and make higher abstraction in your code.

Usually - custom components is set of GUI template and lua code for this template. I've added editor script, that can make a lua component file from your GUI scene (all boilerplate and usage code, also some component that can be defined right in GUI scene).

Auto layout from GUI script should be a powerful tool too! Also it's brings some code structure and style across all your files. Auto layout works from node names. If its starts or equal to some string, it will add code to generated lua file. For example, if you have in your scene node with name "button_start", it will create the Druid button, stub function and annotations to this. Sounds good!

For more information see Create custom components documentations.

Also this update have some breaking changes: you should no more pass full tempalte name in inner components and the second one is renaming text:get_text_width to text:get_text_size.

The Defold 1.3.0 solves the old my issue with slider component. Now you can define input zone (not only the slider pin node) to interact with slider. It's because of inroduction gui.screen_to_local and gui.set_screen_position in default GUI api. If you using previuos Defold releases, this piece of logic will be ignored.

The Druid Assets repository will be closed and I move some components right in Druid repository. You can now use custom components in your game if your need. Right now it's Rich Input (input field with cursor and placegolder) and Pin Knob (Rotating node for set value). And slowly working on adding new examples and improvements of existing ones.

You can say thanks to me via stars on GitHub! 😉
Also you can help with testing new functions and leave feedback.
Wanna something more? Add an issues!
Take care of yourself

Changelog 0.9.0


  • #119 Add Create Druid Component editor script (python3 with deftree required)
    • The headliner of current update. This editor scripts allows you to create Custom component lua script from you .gui scene file. It will create component file with the same name as GUI scene and place it nearby. Inside this generated file you will find the instructions how to start usage this (require and create code).
    • This code contains GUI scheme, basic component boilerplace and generated code for components, used in this GUI scene (see #159)
    • See Create custom components for more info
  • #159 Add auto layout custom components by node naming
    • The Create Druid Component script will check the node names to create Druid components stubs inside generated code
    • The generator will check the node name, if it's starts from special prefix, it will create component code for you
    • Currently support the next components: button, text, lang_text, grid, static_grid, dynamic_grid, scroll_view, blocker, slider, progress and timer
  • #158 [BREAKING] Auto get_node inside inner components with template/nodes
    • Before this update, if your component with template using another component with template, you had to pass full template name (current_template .. "/" .. inner_component_template). From this update you should pass only the inner_component_template name. It's will auto check the parent component template name to build full template path
    • If you don't want migrate code for this, this option can be disabled via druid.no_auto_template in your game.project file. By default it's enabled now
  • #171 Add component:get_template() function to Druid Base Component
    • Now it's able to get full component template name. This function has "protected" scope, so you should use it only inside your component code.
  • #173 Fix GUI nodes usage inside inner templates
    • Now you can pass the node name instead of node itself to Druid components inside your Custom Components. Before this update Druid didn't check the nodes in parent component (usually for basic components such as button, text inside your components)
    • So you can use now self.druid:new_button(SCHEME.BUTTON) instead of self.druid:new_button(self:get_node(SCHEME.BUTTON)) inside your custom components
  • #174 Add assert to nil node on self:get_node()
    • It's required for easier debuging components, when GUI node path is wrong and your got the nil. The error with node path will appear in console.
  • #169 [System] Fix on_layout_change event
    • It was broken, now the on_layout_change event is working as expected
  • #165 [StaticGrid] Add static_grid:set_in_row(amount) function
  • #44 [Slider] Click zone on all slider node, not only pin node
    • Finally! Added the slider:set_input_node(node) function. Now slider can be interacted not only with slider pin node, but with any zone you will define.
    • It will work only from Defold 1.3.0. If you use earlier version, nothing is happened. It using new gui.screen_to_local and gui.set_screen_position functions.
  • #178 [BREAKING][Text] Rename text:get_text_width to text:get_text_size. Now it return two numbers: width and height
  • #114 Add default component templates
    • Added templates for fast prototyping. Use GUI templates to place buttons, checkbox, input and sliders on your GUI scene. You still have to create component with druid:new functions inside gui_script.
  • #168 Add button to open code of current example
    • Inside every example added button to open code of this example on GitHub
  • #140 Better documentation for custom components
  • #172 Update documentation with links to components
  • #175 Remove Druid Assets repository, move to Druid library
    • Added folder druid/custom. It will have the complex custom components. Usually you should to use default GUI template or create your own with similar GUI scheme. Currently add RichInput and PinKnob components from druid-assets repository.
    • Usually to use custom component you have to require lua file first and create it's via druid:new(Component, template_name, [nodes]). See component docs to see constructor params.
    • This components will be included in build only if used
  • #176 Keep last scene and scroll position in Druid example
    • Probably, it's useful for faster debug, but anyway. The example now keep the last scene and scroll position.
  • Add new examples: Checkboxes, Swipe, Grid, Rich input, Pin knob
  • Now editor scripts are available in Druid as dependency
  • Move emmylua annotations inside Druid dependency folder. You can copy it from Defold Editor outline
  • Optimize different stuff(Scroll, Druid Event, Druid instance and Base component)
  • Force Data List component to IS_DYNAMIC_NODE_POSES = false style