Update FAQ

This commit is contained in:
Insality 2020-09-28 21:40:09 +03:00
parent a36ba5ab1c
commit 453c8327c8
4 changed files with 51 additions and 10 deletions

View File

@ -1,18 +1,59 @@
# Druid FAQ # Druid FAQ
### Q: How to remove the Druid component instance ### Q: Why I want use Druid?
A: --- **A:** ---
### Q: How to remove the Druid component instance?
**A:** Any created **Druid** component can be removed with _druid:remove_. [API reference link](https://insality.github.io/druid/modules/druid_instance.html#druid:remove).
### Q: How to make scroll work? ### Q: How to make scroll work?
A: --- **A:** ---
### Q: How the input is processing? ### Q: How the input is processing?
A: --- **A:**
*SImply*: the **Druid** has a LIFO queue to check input. Last added buttons have more priority than first. Placing your buttons from behind to the front is correct in most cases.
### Q: For what purpose Blocker component is exist? ### Q: For what purpose Blocker component is exist?
A: --- **A:** Component explanation [here](https://github.com/Insality/druid/blob/master/docs_md/01-components.md#notes-2).
With Blocker you can block input in some zone. It is useful for make unclickable zone in buttons or kind of buttons panel on other big button (ex. close windows on window background click)
### Q: Which stuff can I do with custom components? ### Q: Which stuff can I do with custom components?
A: --- **A:** Any of you can imagine! There is a lot of examples, but in general: custom components allow you place component and some game logic separately from other stuff. It will be reusable, easier for testing and developing.
For example it can be element in scroll with buttons, your custom GUI widget or even component with your game logic. Usually custom components going with templates. You can do several templates for single component module (for different visuals!)
Some examples of custom components you can find [here](https://github.com/Insality/druid-assets).
### Q: How *self:get_node()* is working?
**A:** The node can be placed in gui directly or can be cloned via *gui.clone_tree()*. Also nodes can be placed as templates, so full node id will be composed from template name and node name (in cloned nodes too).
**Druid** component *self:get_node()* trying to search in all of this places. Use *self:set_template()* and *self:set_component_nodes()* for correct setup component nodes before any call of *self:get_node()*.
Remember, usually you should pass *__string name__ of the node*, not gui node itself. It's better and more druid-way.
### Q: My button in scroll is clickable outside the stencil node
**A:** Since **Druid** checking click node with _gui.pick_node_, stencil is not prevent this. You can setup additional click zone on your buttons with _button:set_click_zone_.
The usual Druid way after add button to the scroll do:
```lua
-- Scroll view node usually is stencil node
button:set_click_zone(scroll.view_node)
```
### Q: How to use EmmyLua annotations?
**A:** Since the dependencies can't be processed by external editors, for use generated EmmyLua annotations you should copy the _annotations.lua_ to your project. For EmmyLua it will be enough. Remember you can _restart emmylua server_ for refresh the changes, if something goes wrong.
After the annotations is processed, you should point the type of druid in requires:
```lua
---@type druid
local druid = require("druid.druid")
-- Now the autocomplete is working
```

View File

@ -43,7 +43,7 @@ local AVAILABLE_PIVOTS = {
--- Component init function --- Component init function
-- @function dynamic_grid:init -- @function dynamic_grid:init
-- @tparam node parent The gui node parent, where items will be placed -- @tparam node parent The gui node parent, where items will be placed
function DynamicGrid:init(parent, side) function DynamicGrid:init(parent)
self.parent = self:get_node(parent) self.parent = self:get_node(parent)
local parent_pivot = gui.get_pivot(self.parent) local parent_pivot = gui.get_pivot(self.parent)

View File

@ -10461,7 +10461,7 @@ nodes {
} }
nodes { nodes {
position { position {
x: 250.0 x: -250.0
y: -1464.0 y: -1464.0
z: 0.0 z: 0.0
w: 1.0 w: 1.0
@ -10479,7 +10479,7 @@ nodes {
w: 1.0 w: 1.0
} }
size { size {
x: -500.0 x: 500.0
y: 100.0 y: 100.0
z: 0.0 z: 0.0
w: 1.0 w: 1.0

View File

@ -41,7 +41,7 @@ end
local function clear_nodes(self) local function clear_nodes(self)
local nodes = self.grid_nodes.nodes local nodes = self.grid_static_grid.nodes
for i, node in pairs(nodes) do for i, node in pairs(nodes) do
gui.delete_node(node) gui.delete_node(node)
end end