Skip to content

Commit

Permalink
Merge pull request #145 from Insality/release/0.7.0
Browse files Browse the repository at this point in the history
Release/0.7.0 to master
  • Loading branch information
Insality authored Oct 23, 2021
2 parents 5d74531 + c16c3e4 commit 9459ecc
Show file tree
Hide file tree
Showing 103 changed files with 8,202 additions and 187 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 Maxim Tuprikov
Copyright (c) 2021 Maxim Tuprikov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Or point to the ZIP file of a [specific release](https://github.com/Insality/dru
**Druid** requires the following input bindings:

- Mouse trigger - `Button 1` -> `touch` _For basic input components_
- Mouse trigger - `Wheel up` -> `scroll_up` _For scroll component_
- Mouse trigger - `Wheel down` -> `scroll_down` _For scroll component_
- Key trigger - `Backspace` -> `key_backspace` _For back_handler component, input component_
- Key trigger - `Back` -> `key_back` _For back_handler component, Android back button, input component_
- Key trigger - `Enter` -> `key_enter` _For input component, optional_
Expand All @@ -32,6 +34,25 @@ Or point to the ZIP file of a [specific release](https://github.com/Insality/dru
![](media/input_binding_1.png)


### Change key bindings [optional]
If you have to use your own key bindings (and key name), you can change it in your *game.project* file.

Here is current default values for key bindings:
```
[druid]
input_text = text
input_touch = touch
input_marked_text = marked_text
input_key_esc = key_esc
input_key_back = key_back
input_key_enter = key_enter
input_key_backspace = key_backspace
input_multitouch = multitouch
input_scroll_up = scroll_up
input_scroll_down = scroll_down
```


### Input capturing [optional]

By default, **Druid** will auto-capture input focus, if any input component will be created. So you don't need to call `msg.post(".", "acquire_input_focus")`
Expand All @@ -42,6 +63,16 @@ If you don't need this behaviour, you can disable it by settings `druid.no_auto_
no_auto_input = 1
```


### Stencil check [optional]

When creating input components inside stencil nodes, you probably will use `component:set_click_zone()` to restrict clicks outside this stencil zone.
Druid can do it automatically on _late_init_ component step. To enable this feature add next field in your _game.project_ file
```
[druid]
stencil_check = 1
```

### Code [optional]

Adjust **Druid** settings, if needed:
Expand Down
88 changes: 80 additions & 8 deletions annotations.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ local druid = {}
function druid.new(context, style) end

--- Druid on language change.
function druid.on_language_change() end
---@param self druid_instance
function druid.on_language_change(self) end

--- Callback on global language change event.
function druid.on_language_change() end
Expand All @@ -28,6 +29,11 @@ function druid.on_window_callback(event) end
---@param module table lua table with component
function druid.register(name, module) end

--- Set blacklist components for input processing.
---@param self druid_instance
---@param blacklist_components table|Component The array of component to blacklist
function druid.set_blacklist(self, blacklist_components) end

--- Set new default style.
---@param style table Druid style module
function druid.set_default_style(style) end
Expand All @@ -40,6 +46,11 @@ function druid.set_sound_function(callback) end
---@param callback function Get localized text function
function druid.set_text_function(callback) end

--- Set whitelist components for input processing.
---@param self druid_instance
---@param whitelist_components table|Component The array of component to whitelist
function druid.set_whitelist(self, whitelist_components) end


---@class druid.back_handler : druid.base_component
---@field on_back druid_event On back handler callback(self, params)
Expand All @@ -63,6 +74,11 @@ function druid__back_handler.on_input(self, action_id, action) end
---@field ALL field Component Interests
local druid__base_component = {}

--- Return all children components, recursive
---@param self druid.base_component
---@return table Array of childrens if the Druid component instance
function druid__base_component.get_childrens(self) end

--- Get current component context
---@param self druid.base_component
---@return table BaseComponent context
Expand Down Expand Up @@ -163,6 +179,7 @@ function druid__blocker.set_enabled(self, state) end
---@class druid.button : druid.base_component
---@field anim_node node Animation node
---@field click_zone node Restriction zone
---@field hash node_id The hash of trigger node
---@field hover druid.hover Druid hover logic component
---@field node node Trigger node
---@field on_click druid_event On release button callback(self, params, button_instance)
Expand Down Expand Up @@ -196,6 +213,12 @@ function druid__button.init(self, node, callback, params, anim_node) end
---@return bool True, if button is enabled
function druid__button.is_enabled(self) end

--- Set function for additional check for button click availability
---@param check_function function Should return true or false. If true - button can be pressed.
---@param failure_callback function Function what will be called on button click, if check function return false
---@return druid.button Current button instance
function druid__button.set_check_function(check_function, failure_callback) end

--- Strict button click area.
---@param self druid.button
---@param zone node Gui node
Expand Down Expand Up @@ -393,7 +416,8 @@ function druid__dynamic_grid._get_side_vector(self, side, is_forward) end
---@param node node Gui node
---@param index number The node position. By default add as last node
---@param shift_policy number How shift nodes, if required. See const.SHIFT
function druid__dynamic_grid.add(self, node, index, shift_policy) end
---@param is_instance boolean If true, update node positions instantly
function druid__dynamic_grid.add(self, node, index, shift_policy, is_instance) end

--- Clear grid nodes array.
---@param self druid.dynamic_grid
Expand Down Expand Up @@ -444,8 +468,9 @@ function druid__dynamic_grid.init(self, parent) end
---@param self druid.dynamic_grid
---@param index number The grid node index to remove
---@param shift_policy number How shift nodes, if required. See const.SHIFT
---@param is_instance boolean If true, update node positions instantly
---@return Node The deleted gui node from grid
function druid__dynamic_grid.remove(self, index, shift_policy) end
function druid__dynamic_grid.remove(self, index, shift_policy, is_instance) end

--- Change set position function for grid nodes.
---@param self druid.dynamic_grid
Expand Down Expand Up @@ -780,6 +805,7 @@ function druid__scroll.set_vertical_scroll(self, state) end
---@field INERT_THRESHOLD field Scroll speed to stop inertion
---@field POINTS_DEADZONE field Speed to check points of interests in no_inertion mode
---@field SMALL_CONTENT_SCROLL field If true, content node with size less than view node size can be scrolled
---@field WHEEL_SCROLL_BY_INERTION field If true, wheel will add inertion to scroll. Direct set position otherwise.
---@field WHEEL_SCROLL_INVERTED field If true, invert direction for touchpad and mouse wheel scroll
---@field WHEEL_SCROLL_SPEED field The scroll speed via mouse wheel scroll or touchpad. Set to 0 to disable wheel scrolling
local druid__scroll__style = {}
Expand Down Expand Up @@ -829,14 +855,16 @@ function druid__slider.set_steps(self, steps) end
---@field on_remove_item druid_event On item remove callback(self, index)
---@field on_update_positions druid_event On update item positions callback(self)
---@field parent node Parent gui node
---@field style druid.static_grid.style Component style params.
local druid__static_grid = {}

--- Add new item to the grid
---@param self druid.static_grid
---@param item node Gui node
---@param index number The item position. By default add as last item
---@param shift_policy number How shift nodes, if required. See const.SHIFT
function druid__static_grid.add(self, item, index, shift_policy) end
---@param is_instance boolean If true, update node positions instantly
function druid__static_grid.add(self, item, index, shift_policy, is_instance) end

--- Clear grid nodes array.
---@param self druid.static_grid
Expand Down Expand Up @@ -892,8 +920,9 @@ function druid__static_grid.init(self, parent, element, in_row) end
---@param self druid.static_grid
---@param index number The grid node index to remove
---@param shift_policy number How shift nodes, if required. See const.SHIFT
---@param is_instance boolean If true, update node positions instantly
---@return Node The deleted gui node from grid
function druid__static_grid.remove(self, index, shift_policy) end
function druid__static_grid.remove(self, index, shift_policy, is_instance) end

--- Set grid anchor.
---@param self druid.static_grid
Expand All @@ -907,6 +936,11 @@ function druid__static_grid.set_anchor(self, anchor) end
function druid__static_grid.set_position_function(self, callback) end


---@class druid.static_grid.style
---@field IS_DYNAMIC_NODE_POSES field If true, always center grid content as grid pivot sets
local druid__static_grid__style = {}


---@class druid.swipe : druid.base_component
---@field click_zone node Restriction zone
---@field node node Swipe node
Expand Down Expand Up @@ -934,19 +968,27 @@ local druid__swipe__style = {}


---@class druid.text : druid.base_component
---@field adjust_type number Current text size adjust settings
---@field color vector3 Current text color
---@field is_no_adjust bool Current text size adjust settings
---@field node node Text node
---@field node_id hash The node id of text node
---@field on_set_pivot druid_event On change pivot callback(self, pivot)
---@field on_set_text druid_event On set text callback(self, text)
---@field on_update_text_scale druid_event On adjust text size callback(self, new_scale)
---@field pos vector3 Current text position
---@field scale vector3 Current text node scale
---@field start_scale vector3 Initial text node scale
---@field start_size vector3 Initial text node size
---@field style druid.text.style Component style params.
---@field text_area vector3 Current text node available are
local druid__text = {}

--- Return current text adjust type
---@param self unknown
---@param adjust_type unknown
---@return number The current text adjust type
function druid__text.get_text_adjust(self, adjust_type) end

--- Calculate text width with font with respect to trailing space
---@param self druid.text
---@param text string
Expand All @@ -956,8 +998,8 @@ function druid__text.get_text_width(self, text) end
---@param self druid.text
---@param node node Gui text node
---@param value string Initial text. Default value is node text from GUI scene.
---@param no_adjust bool If true, text will be not auto-adjust size
function druid__text.init(self, node, value, no_adjust) end
---@param adjust_type int Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference
function druid__text.init(self, node, value, adjust_type) end

--- Return true, if text with line break
---@param self druid.text
Expand All @@ -967,29 +1009,53 @@ function druid__text.is_multiline(self) end
--- Set alpha
---@param self druid.text
---@param alpha number Alpha for node
---@return druid.text Current text instance
function druid__text.set_alpha(self, alpha) end

--- Set color
---@param self druid.text
---@param color vector4 Color for node
---@return druid.text Current text instance
function druid__text.set_color(self, color) end

--- Set minimal scale for DOWNSCALE_LIMITED or SCALE_THEN_SCROLL adjust types
---@param self druid.text
---@param minimal_scale number If pass nil - not use minimal scale
---@return druid.text Current text instance
function druid__text.set_minimal_scale(self, minimal_scale) end

--- Set text pivot.
---@param self druid.text
---@param pivot gui.pivot Gui pivot constant
---@return druid.text Current text instance
function druid__text.set_pivot(self, pivot) end

--- Set scale
---@param self druid.text
---@param scale vector3 Scale for node
---@return druid.text Current text instance
function druid__text.set_scale(self, scale) end

--- Set text adjust, refresh the current text visuals, if needed
---@param self druid.text
---@param adjust_type number See const.TEXT_ADJUST. If pass nil - use current adjust type
---@param minimal_scale number If pass nil - not use minimal scale
---@return druid.text Current text instance
function druid__text.set_text_adjust(self, adjust_type, minimal_scale) end

--- Set text to text field
---@param self druid.text
---@param set_to string Text for node
---@return druid.text Current text instance
function druid__text.set_to(self, set_to) end


---@class druid.text.style
---@field DEFAULT_ADJUST field The default adjust type for any text component
---@field TRIM_POSTFIX field The postfix for TRIM adjust type
local druid__text__style = {}


---@class druid.timer : druid.base_component
---@field from number Initial timer value
---@field node node Trigger node
Expand Down Expand Up @@ -1248,6 +1314,7 @@ function druid_instance.on_focus_lost(self) end
---@param self druid_instance
---@param action_id hash Action_id from on_input
---@param action table Action from on_input
---@return bool The boolean value is input was consumed
function druid_instance.on_input(self, action_id, action) end

--- Druid on layout change function.
Expand Down Expand Up @@ -1323,6 +1390,11 @@ function helper.deprecated(message) end
---@return vector4 Vector with distance to node border: (left, top, right, down)
function helper.get_border(node, offset) end

--- Return closest non inverted clipping parent node for node
---@param node node Gui node
---@return node|nil The clipping node
function helper.get_closest_stencil_node(node) end

--- Get node offset for given gui pivot
---@param pivot gui.pivot The node pivot
---@return vector3 Vector offset with [-1..1] values
Expand Down
2 changes: 1 addition & 1 deletion docs/druid/archive/archive_files.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"content":[{"name":"game.projectc","size":3432,"pieces":[{"name":"game.projectc0","offset":0}]},{"name":"game.arci","size":11568,"pieces":[{"name":"game.arci0","offset":0}]},{"name":"game.arcd","size":388522,"pieces":[{"name":"game.arcd0","offset":0}]},{"name":"game.dmanifest","size":25565,"pieces":[{"name":"game.dmanifest0","offset":0}]},{"name":"game.public.der","size":162,"pieces":[{"name":"game.public.der0","offset":0}]}]}
{"content":[{"name":"game.projectc","size":3748,"pieces":[{"name":"game.projectc0","offset":0}]},{"name":"game.arci","size":13488,"pieces":[{"name":"game.arci0","offset":0}]},{"name":"game.arcd","size":948341,"pieces":[{"name":"game.arcd0","offset":0}]},{"name":"game.dmanifest","size":13875,"pieces":[{"name":"game.dmanifest0","offset":0}]},{"name":"game.public.der","size":162,"pieces":[{"name":"game.public.der0","offset":0}]}]}
Binary file modified docs/druid/archive/game.arcd0
Binary file not shown.
Binary file modified docs/druid/archive/game.arci0
Binary file not shown.
Binary file modified docs/druid/archive/game.dmanifest0
Binary file not shown.
24 changes: 18 additions & 6 deletions docs/druid/archive/game.projectc0
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[project]
title = druid
version = 0.6.466
version = 0.7.499
write_log = 0
compress_archive = 1
publisher = Insality
developer = Insality
commit_sha = ffa3bafa002c561f6f4a31e8bbca228c3606b1cc
build_time = 2021-05-30T08:51:36Z
commit_sha = 1ae77e727fd29b01a514e73820b3e02213aeb7db
build_time = 2021-10-23T14:38:03Z

[display]
width = 600
Expand Down Expand Up @@ -35,7 +35,7 @@ world_count = 4
gravity_x = 0
gravity_z = 0
scale = 1
allow_dynamic_transforms = 0
allow_dynamic_transforms = 1
debug_scale = 30
max_collisions = 64
max_contacts = 128
Expand Down Expand Up @@ -121,9 +121,9 @@ default_language = en
localizations = en

[android]
version_code = 466
version_code = 499
minimum_sdk_version = 16
target_sdk_version = 29
target_sdk_version = 30
package = com.insality.druid
manifest = /builtins/manifests/android/AndroidManifest.xml
iap_provider = GooglePlay
Expand All @@ -149,6 +149,7 @@ cssfile = /builtins/manifests/web/light_theme.css
archive_location_prefix = archive
show_fullscreen_button = 0
show_made_with_defold = 0
show_console_banner = 1
scale_mode = fit
engine_arguments = --verify-graphics-calls=false
splash_image = /media/druid_logo.png
Expand Down Expand Up @@ -191,6 +192,17 @@ run_while_iconified = 0

[druid]
no_auto_input = 0
stencil_check = 0
input_text = text
input_touch = touch
input_marked_text = marked_text
input_key_esc = key_esc
input_key_back = key_back
input_key_enter = key_enter
input_key_backspace = key_backspace
input_multitouch = multitouch
input_scroll_up = scroll_up
input_scroll_down = scroll_down

[native_extension]
app_manifest = /example/game.appmanifest
Expand Down
Binary file modified docs/druid/archive/game.public.der0
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/druid/dmloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var FileLoader = {
return;
}
currentAttempt = currentAttempt + 1;
setTimeout(obj.send, FileLoader.options.retryInterval);
setTimeout(obj.send.bind(obj), FileLoader.options.retryInterval);
};
xhr.onload = function(e) {
if (onload) onload(xhr, e);
Expand Down
Binary file modified docs/druid/druid.wasm
Binary file not shown.
Loading

0 comments on commit 9459ecc

Please sign in to comment.