translatable should be in data

This commit is contained in:
Insality 2019-03-27 00:50:46 +03:00
parent da1e75fa89
commit 9af3046ca4
2 changed files with 13 additions and 12 deletions

View File

@ -6,11 +6,13 @@ M.A_BACKSPACE = hash("backspace")
M.A_ENTER = hash("enter") M.A_ENTER = hash("enter")
M.A_ANDR_BACK = hash("back") M.A_ANDR_BACK = hash("back")
-- interest
M.LAYOUT_CHANGED = hash("layout_changed") M.LAYOUT_CHANGED = hash("layout_changed")
M.ON_MESSAGE = hash("on_message") M.ON_MESSAGE = hash("on_message")
M.ON_INPUT = hash("on_input") M.ON_INPUT = hash("on_input")
M.ON_SWIPE = hash("on_swipe") M.ON_SWIPE = hash("on_swipe")
M.ON_UPDATE = hash("on_update") M.ON_UPDATE = hash("on_update")
M.TRANSLATABLE = hash("TRANSLATABLE")
M.RELEASED = "released" M.RELEASED = "released"
M.PRESSED = "pressed" M.PRESSED = "pressed"

View File

@ -1,19 +1,11 @@
local M = {}
local druid_input = require("druid.help_modules.druid_input")
local data = require("druid.data") local data = require("druid.data")
local druid_input = require("druid.help_modules.druid_input")
M.input = druid_input local M = {}
M.TRANSLATABLE = hash("TRANSLATABLE")
local STRING = "string" local STRING = "string"
--- New druid era, registering components --- New druid era, registering components
-- temporary make components outside
local components = { local components = {
-- base -- base
button = require("druid.base.button"), button = require("druid.base.button"),
@ -22,6 +14,7 @@ local components = {
-- timer = require("druid.base.timer"), -- timer = require("druid.base.timer"),
} }
local function register_components() local function register_components()
for k, v in pairs(components) do for k, v in pairs(components) do
-- TODO: Find better solution to creating elements? -- TODO: Find better solution to creating elements?
@ -43,7 +36,7 @@ function M.on_message(factory, message_id, message, sender)
v:on_layout_updated(message) v:on_layout_updated(message)
end end
end end
elseif message_id == M.TRANSLATABLE then elseif message_id == data.TRANSLATABLE then
M.translate(factory) M.translate(factory)
else else
if factory[data.ON_MESSAGE] then if factory[data.ON_MESSAGE] then
@ -54,6 +47,7 @@ function M.on_message(factory, message_id, message, sender)
end end
end end
--- Called ON_INPUT --- Called ON_INPUT
function M.on_input(factory, action_id, action) function M.on_input(factory, action_id, action)
if factory[data.ON_SWIPE] then if factory[data.ON_SWIPE] then
@ -81,6 +75,7 @@ function M.on_input(factory, action_id, action)
return false return false
end end
--- Called on_update --- Called on_update
function M.update(factory, dt) function M.update(factory, dt)
if factory[data.ON_UPDATE] then if factory[data.ON_UPDATE] then
@ -90,6 +85,7 @@ function M.update(factory, dt)
end end
end end
--- Create UI instance for ui elements --- Create UI instance for ui elements
-- @return instance with all ui components -- @return instance with all ui components
function M.new(self) function M.new(self)
@ -98,6 +94,7 @@ function M.new(self)
return factory return factory
end end
local function input_init(factory) local function input_init(factory)
if not factory.input_inited then if not factory.input_inited then
factory.input_inited = true factory.input_inited = true
@ -136,6 +133,7 @@ local function create(meta, factory, name, ...)
return instance return instance
end end
function M.create(factory, meta, name, ...) function M.create(factory, meta, name, ...)
local instance = create(meta, factory, name) local instance = create(meta, factory, name)
instance.factory = factory instance.factory = factory
@ -145,4 +143,5 @@ function M.create(factory, meta, name, ...)
end end
end end
return M
return M