mirror of
https://github.com/Insality/druid.git
synced 2025-06-27 10:27:47 +02:00
Move const to const.lua
This commit is contained in:
parent
e45dce150d
commit
f8a3b6f632
@ -12,6 +12,7 @@ M.ACTION_BACK = hash("back")
|
||||
|
||||
M.RELEASED = "released"
|
||||
M.PRESSED = "pressed"
|
||||
M.STRING = "string"
|
||||
|
||||
--- Interests
|
||||
M.ON_MESSAGE = hash("on_message")
|
||||
@ -21,6 +22,18 @@ M.ON_UPDATE = hash("on_update")
|
||||
M.ON_SWIPE = hash("on_swipe")
|
||||
M.ON_INPUT = hash("on_input")
|
||||
|
||||
M.PIVOTS = {
|
||||
[gui.PIVOT_CENTER] = vmath.vector3(0),
|
||||
[gui.PIVOT_N] = vmath.vector3(0, 0.5, 0),
|
||||
[gui.PIVOT_NE] = vmath.vector3(0.5, 0.5, 0),
|
||||
[gui.PIVOT_E] = vmath.vector3(0.5, 0, 0),
|
||||
[gui.PIVOT_SE] = vmath.vector3(0.5, -0.5, 0),
|
||||
[gui.PIVOT_S] = vmath.vector3(0, -0.5, 0),
|
||||
[gui.PIVOT_SW] = vmath.vector3(-0.5, -0.5, 0),
|
||||
[gui.PIVOT_W] = vmath.vector3(-0.5, 0, 0),
|
||||
[gui.PIVOT_NW] = vmath.vector3(-0.5, -0.5, 0),
|
||||
}
|
||||
|
||||
M.ui_input = {
|
||||
[M.ON_SWIPE] = true,
|
||||
[M.ON_INPUT] = true
|
||||
@ -30,7 +43,7 @@ M.ui_input = {
|
||||
M.ON_CHANGE_LANGUAGE = hash("on_change_language")
|
||||
M.ON_LAYOUT_CHANGED = hash("on_layout_changed")
|
||||
|
||||
M.specific_ui_messages = {
|
||||
M.SPECIFIC_UI_MESSAGES = {
|
||||
[M.ON_CHANGE_LANGUAGE] = "on_change_language",
|
||||
[M.ON_LAYOUT_CHANGED] = "on_layout_changed"
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ local function create(self, module)
|
||||
end
|
||||
self[v][#self[v] + 1] = instance
|
||||
|
||||
if const.ui_input[v] then
|
||||
if const.UI_INPUT[v] then
|
||||
input_init(self)
|
||||
end
|
||||
end
|
||||
@ -135,7 +135,7 @@ end
|
||||
|
||||
--- Called on_message
|
||||
function _fct_metatable.on_message(self, message_id, message, sender)
|
||||
local specific_ui_message = const.specific_ui_messages[message_id]
|
||||
local specific_ui_message = const.SPECIFIC_UI_MESSAGES[message_id]
|
||||
if specific_ui_message then
|
||||
local array = self[message_id]
|
||||
if array then
|
||||
|
@ -81,7 +81,6 @@ function M.after(count, callback)
|
||||
end
|
||||
|
||||
|
||||
local STRING = "string"
|
||||
function M.node(node_or_name)
|
||||
if type(node_or_name) == const.STRING then
|
||||
return gui.get_node(node_or_name)
|
||||
@ -144,19 +143,8 @@ function M.is_enabled(node)
|
||||
end
|
||||
|
||||
|
||||
local pivots = {
|
||||
[gui.PIVOT_CENTER] = vmath.vector3(0),
|
||||
[gui.PIVOT_N] = vmath.vector3(0, 0.5, 0),
|
||||
[gui.PIVOT_NE] = vmath.vector3(0.5, 0.5, 0),
|
||||
[gui.PIVOT_E] = vmath.vector3(0.5, 0, 0),
|
||||
[gui.PIVOT_SE] = vmath.vector3(0.5, -0.5, 0),
|
||||
[gui.PIVOT_S] = vmath.vector3(0, -0.5, 0),
|
||||
[gui.PIVOT_SW] = vmath.vector3(-0.5, -0.5, 0),
|
||||
[gui.PIVOT_W] = vmath.vector3(-0.5, 0, 0),
|
||||
[gui.PIVOT_NW] = vmath.vector3(-0.5, -0.5, 0),
|
||||
}
|
||||
function M.get_pivot_offset(pivot)
|
||||
return pivots[pivot]
|
||||
return const.PIVOTS[pivot]
|
||||
end
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user