rename data to const

This commit is contained in:
Insality 2019-09-25 20:54:50 +03:00
parent 711b28ede1
commit aaac514a3d
8 changed files with 27 additions and 27 deletions

View File

@ -1,11 +1,11 @@
--- Component to handle back key --- Component to handle back key
-- @module base.back_handler -- @module base.back_handler
local data = require("druid.data") local const = require("druid.const")
local M = {} local M = {}
M.interest = { M.interest = {
data.ON_INPUT const.ON_INPUT
} }
--- Component init function --- Component init function
@ -13,7 +13,7 @@ M.interest = {
-- @tparam callback callback on back button -- @tparam callback callback on back button
-- @tparam[opt] params callback argument -- @tparam[opt] params callback argument
function M.init(self, callback, params) function M.init(self, callback, params)
self.event = data.ACTION_BACK self.event = const.ACTION_BACK
self.callback = callback self.callback = callback
self.params = params self.params = params
end end
@ -23,7 +23,7 @@ end
-- @tparam string action_id on_input action id -- @tparam string action_id on_input action id
-- @tparam table action on_input action -- @tparam table action on_input action
function M.on_input(self, action_id, action) function M.on_input(self, action_id, action)
if action[data.RELEASED] then if action[const.RELEASED] then
self.callback(self.parent.parent, self.params) self.callback(self.parent.parent, self.params)
end end

View File

@ -5,7 +5,7 @@
-- Long tap -- Long tap
-- Repeated tap -- Repeated tap
local data = require("druid.data") local const = require("druid.const")
local ui_animate = require("druid.helper.druid_animate") local ui_animate = require("druid.helper.druid_animate")
local settings = require("druid.settings") local settings = require("druid.settings")
local helper = require("druid.helper") local helper = require("druid.helper")
@ -13,7 +13,7 @@ local b_settings = settings.button
local M = {} local M = {}
M.interest = { M.interest = {
data.ON_INPUT const.ON_INPUT
} }
M.DEFAULT_DEACTIVATE_COLOR = vmath.vector4(0, 0, 0, 0) M.DEFAULT_DEACTIVATE_COLOR = vmath.vector4(0, 0, 0, 0)
@ -24,7 +24,7 @@ M.DEFAULT_ACTIVATION_TIME = 0.2
function M.init(self, node, callback, params, anim_node, event) function M.init(self, node, callback, params, anim_node, event)
self.node = helper.get_node(node) self.node = helper.get_node(node)
self.event = data.ACTION_TOUCH self.event = const.ACTION_TOUCH
self.anim_node = anim_node and helper.get_node(anim_node) or self.node self.anim_node = anim_node and helper.get_node(anim_node) or self.node
self.scale_from = gui.get_scale(self.anim_node) self.scale_from = gui.get_scale(self.anim_node)
self.scale_to = self.scale_from + b_settings.SCALE_CHANGE self.scale_to = self.scale_from + b_settings.SCALE_CHANGE

View File

@ -1,7 +1,7 @@
--- Component to handle progress bars --- Component to handle progress bars
-- @module base.progress -- @module base.progress
local data = require("druid.data") local const = require("druid.const")
local helper = require("druid.helper") local helper = require("druid.helper")
local settings = require("druid.settings") local settings = require("druid.settings")
local p_settings = settings.progress local p_settings = settings.progress
@ -9,7 +9,7 @@ local p_settings = settings.progress
local M = {} local M = {}
M.interest = { M.interest = {
data.ON_UPDATE, const.ON_UPDATE,
} }
local PROP_Y = "y" local PROP_Y = "y"

View File

@ -2,7 +2,7 @@
-- @module base.scroll -- @module base.scroll
local helper = require("druid.helper") local helper = require("druid.helper")
local data = require("druid.data") local const = require("druid.const")
local settings = require("druid.settings").scroll local settings = require("druid.settings").scroll
local M = {} local M = {}
@ -11,8 +11,8 @@ local SIDE_X = "x"
local SIDE_Y = "y" local SIDE_Y = "y"
M.interest = { M.interest = {
data.ON_UPDATE, const.ON_UPDATE,
data.ON_SWIPE, const.ON_SWIPE,
} }
-- Global on all scrolls -- Global on all scrolls
@ -257,7 +257,7 @@ end
function M.on_input(self, action_id, action) function M.on_input(self, action_id, action)
if action_id ~= data.ACTION_TOUCH then if action_id ~= const.ACTION_TOUCH then
return false return false
end end
local inp = self.input local inp = self.input

View File

@ -2,13 +2,13 @@
-- Good working with localization system -- Good working with localization system
-- @module base.text -- @module base.text
local data = require("druid.data") local const = require("druid.const")
local settings = require("druid.settings") local settings = require("druid.settings")
local helper = require("druid.helper") local helper = require("druid.helper")
local M = {} local M = {}
M.interest = { M.interest = {
data.ON_CHANGE_LANGUAGE, const.ON_CHANGE_LANGUAGE,
} }

View File

@ -1,13 +1,13 @@
--- Component to handle GUI timers --- Component to handle GUI timers
-- @module base.timer -- @module base.timer
local data = require("druid.data") local const = require("druid.const")
local formats = require("druid.helper.formats") local formats = require("druid.helper.formats")
local helper = require("druid.helper") local helper = require("druid.helper")
local M = {} local M = {}
M.interest = { M.interest = {
data.ON_UPDATE const.ON_UPDATE
} }
local empty = function() end local empty = function() end

View File

@ -4,7 +4,7 @@
-- to create your own rich components. -- to create your own rich components.
-- @module druid -- @module druid
local data = require("druid.data") local const = require("druid.const")
local druid_input = require("druid.helper.druid_input") local druid_input = require("druid.helper.druid_input")
local settings = require("druid.settings") local settings = require("druid.settings")
@ -86,7 +86,7 @@ local function create(self, module)
end end
self[v][#self[v] + 1] = instance self[v][#self[v] + 1] = instance
if data.ui_input[v] then if const.ui_input[v] then
input_init(self) input_init(self)
end end
end end
@ -130,7 +130,7 @@ end
--- Called on_message --- Called on_message
function _fct_metatable.on_message(self, message_id, message, sender) function _fct_metatable.on_message(self, message_id, message, sender)
local specific_ui_message = data.specific_ui_messages[message_id] local specific_ui_message = const.specific_ui_messages[message_id]
if specific_ui_message then if specific_ui_message then
local array = self[message_id] local array = self[message_id]
if array then if array then
@ -141,7 +141,7 @@ function _fct_metatable.on_message(self, message_id, message, sender)
end end
end end
else else
local array = self[data.ON_MESSAGE] local array = self[const.ON_MESSAGE]
if array then if array then
for i = 1, #array do for i = 1, #array do
array[i]:on_message(message_id, message, sender) array[i]:on_message(message_id, message, sender)
@ -152,10 +152,10 @@ end
local function notify_input_on_swipe(self) local function notify_input_on_swipe(self)
if self[data.ON_INPUT] then if self[const.ON_INPUT] then
local len = #self[data.ON_INPUT] local len = #self[const.ON_INPUT]
for i = len, 1, -1 do for i = len, 1, -1 do
local comp = self[data.ON_INPUT][i] local comp = self[const.ON_INPUT][i]
if comp.on_swipe then if comp.on_swipe then
comp:on_swipe() comp:on_swipe()
end end
@ -179,7 +179,7 @@ end
--- Called ON_INPUT --- Called ON_INPUT
function _fct_metatable.on_input(self, action_id, action) function _fct_metatable.on_input(self, action_id, action)
local array = self[data.ON_SWIPE] local array = self[const.ON_SWIPE]
if array then if array then
local v, result local v, result
local len = #array local len = #array
@ -192,7 +192,7 @@ function _fct_metatable.on_input(self, action_id, action)
return true return true
end end
end end
array = self[data.ON_INPUT] array = self[const.ON_INPUT]
if array then if array then
local v local v
local len = #array local len = #array
@ -210,7 +210,7 @@ end
--- Called on_update --- Called on_update
function _fct_metatable.update(self, dt) function _fct_metatable.update(self, dt)
local array = self[data.ON_UPDATE] local array = self[const.ON_UPDATE]
if array then if array then
for i = 1, #array do for i = 1, #array do
array[i]:update(dt) array[i]:update(dt)