mirror of
https://github.com/Insality/druid
synced 2025-06-27 10:27:48 +02:00
Solve #198 move input init and late init to Druid instance init function
This commit is contained in:
parent
e683eed90f
commit
25a17773e7
@ -57,7 +57,7 @@ local lang_text = require("druid.extended.lang_text")
|
|||||||
local progress = require("druid.extended.progress")
|
local progress = require("druid.extended.progress")
|
||||||
local radio_group = require("druid.extended.radio_group")
|
local radio_group = require("druid.extended.radio_group")
|
||||||
local slider = require("druid.extended.slider")
|
local slider = require("druid.extended.slider")
|
||||||
local timer = require("druid.extended.timer")
|
local timer_component = require("druid.extended.timer")
|
||||||
local data_list = require("druid.extended.data_list")
|
local data_list = require("druid.extended.data_list")
|
||||||
|
|
||||||
|
|
||||||
@ -215,6 +215,10 @@ function DruidInstance.initialize(self, context, style)
|
|||||||
for i = 1, #base_component.ALL_INTERESTS do
|
for i = 1, #base_component.ALL_INTERESTS do
|
||||||
self.components_interest[base_component.ALL_INTERESTS[i]] = {}
|
self.components_interest[base_component.ALL_INTERESTS[i]] = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
timer.delay(0, false, function()
|
||||||
|
self:late_init()
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -311,10 +315,9 @@ function DruidInstance.remove(self, component)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Druid update function
|
--- Druid late update function call after init and before udpate step
|
||||||
-- @tparam DruidInstance self
|
-- @tparam DruidInstance self
|
||||||
-- @tparam number dt Delta time
|
function DruidInstance.late_init(self)
|
||||||
function DruidInstance.update(self, dt)
|
|
||||||
local late_init_components = self.components_interest[base_component.ON_LATE_INIT]
|
local late_init_components = self.components_interest[base_component.ON_LATE_INIT]
|
||||||
while late_init_components[1] do
|
while late_init_components[1] do
|
||||||
late_init_components[1]:on_late_init()
|
late_init_components[1]:on_late_init()
|
||||||
@ -325,7 +328,13 @@ function DruidInstance.update(self, dt)
|
|||||||
-- Input init on late init step, to be sure it goes after user go acquire input
|
-- Input init on late init step, to be sure it goes after user go acquire input
|
||||||
input_init(self)
|
input_init(self)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Druid update function
|
||||||
|
-- @tparam DruidInstance self
|
||||||
|
-- @tparam number dt Delta time
|
||||||
|
function DruidInstance.update(self, dt)
|
||||||
self._is_late_remove_enabled = true
|
self._is_late_remove_enabled = true
|
||||||
local components = self.components_interest[base_component.ON_UPDATE]
|
local components = self.components_interest[base_component.ON_UPDATE]
|
||||||
for i = 1, #components do
|
for i = 1, #components do
|
||||||
@ -724,7 +733,7 @@ end
|
|||||||
-- @treturn Timer timer component
|
-- @treturn Timer timer component
|
||||||
function DruidInstance.new_timer(self, node, seconds_from, seconds_to, callback)
|
function DruidInstance.new_timer(self, node, seconds_from, seconds_to, callback)
|
||||||
-- return helper.extended_component("timer")
|
-- return helper.extended_component("timer")
|
||||||
return DruidInstance.new(self, timer, node, seconds_from, seconds_to, callback)
|
return DruidInstance.new(self, timer_component, node, seconds_from, seconds_to, callback)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ use_accelerometer = 0
|
|||||||
|
|
||||||
[druid]
|
[druid]
|
||||||
no_auto_input = 0
|
no_auto_input = 0
|
||||||
stencil_check = 0
|
no_stencil_check = 0
|
||||||
no_auto_template = 0
|
no_auto_template = 0
|
||||||
input_text = text
|
input_text = text
|
||||||
input_touch = touch
|
input_touch = touch
|
||||||
|
Loading…
x
Reference in New Issue
Block a user