mirror of
https://github.com/Insality/druid
synced 2025-06-27 02:17:52 +02:00
first iteration of trash cleaning
This commit is contained in:
parent
00e984efdc
commit
e80ba7106b
@ -1,6 +1,6 @@
|
||||
local M = {}
|
||||
|
||||
local ui_animate = require "modules.ui.ui_animate"
|
||||
local ui_animate = require "druid.help_modules.druid_animate"
|
||||
|
||||
M.DEFAULT_SCALE_CHANGE = vmath.vector3(-0.05, - 0.1, 1)
|
||||
M.DEFAULT_POS_CHANGE = vmath.vector3(0, - 10, 0)
|
||||
|
@ -1,6 +1,6 @@
|
||||
local M = {}
|
||||
|
||||
local text_field = require "modules.ui.components.text_field"
|
||||
local text_field = require "druid.components.text_field"
|
||||
|
||||
local FRAMES = 60
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
local M = {}
|
||||
|
||||
local ui_animate = require "modules.ui.ui_animate"
|
||||
local ui_animate = require "druid.help_modules.druid_animate"
|
||||
|
||||
local function fly_to(instance, pos_from, speed, callback)
|
||||
local pos_to = instance.get_pos_func()
|
||||
|
@ -1,6 +1,6 @@
|
||||
local M = {}
|
||||
|
||||
local ui_animate = require "modules.ui.ui_animate"
|
||||
local ui_animate = require "druid.help_modules.druid_animate"
|
||||
|
||||
--- Bounce image
|
||||
function M.bounce(instance)
|
||||
|
@ -1,8 +1,7 @@
|
||||
local M = {}
|
||||
|
||||
local input = require "modules.input.input"
|
||||
local ui_animate = require "modules.ui.ui_animate"
|
||||
local extra_math = require "modules.utils.extra_math"
|
||||
local druid_input = require "druid.help_modules.druid_input"
|
||||
local ui_animate = require "druid.help_modules.druid_animate"
|
||||
|
||||
M.START = hash("START")
|
||||
M.FINISH = hash("FINISH")
|
||||
@ -62,13 +61,18 @@ local function checkSwipeDirection(swipe, action)
|
||||
end
|
||||
end
|
||||
|
||||
function lenght(x1, y1, x2, y2)
|
||||
local a, b = x1 - x2, y1 - y2
|
||||
return math.sqrt(a * a + b * b)
|
||||
end
|
||||
|
||||
local function back_move(instance)
|
||||
if not instance.swipe.end_position_x and not instance.swipe.end_position_y then
|
||||
if instance.points_of_interest then
|
||||
local min_index, min_lenght = 0, math.huge
|
||||
local len
|
||||
for k, v in pairs(instance.points_of_interest) do
|
||||
len = extra_math.lenght(instance.pos.x, instance.pos.y, v.x, v.y)
|
||||
len = lenght(instance.pos.x, instance.pos.y, v.x, v.y)
|
||||
if len < min_lenght then
|
||||
min_lenght = len
|
||||
min_index = k
|
||||
@ -130,14 +134,14 @@ end
|
||||
-- @param action_id - input action id
|
||||
-- @param action - input action
|
||||
function M.on_input(instance, action_id, action)
|
||||
if action_id == input.A_CLICK then
|
||||
if action_id == druid_input.A_CLICK then
|
||||
if gui.pick_node(instance.scrolling_zone, action.x, action.y) then
|
||||
local swipe = instance.swipe
|
||||
if action.pressed then
|
||||
swipe.pressed = true
|
||||
swipe.beginX = action.x
|
||||
swipe.beginY = action.y
|
||||
input.is_swipe = false
|
||||
druid_input.is_swipe = false
|
||||
swipe.end_move_coef_x = 1
|
||||
elseif not action.released and not action.pressed and not swipe.special_move then
|
||||
swipe.endX = action.x
|
||||
|
@ -1,19 +1,19 @@
|
||||
local M = {}
|
||||
|
||||
local helper = require "modules.render.helper"
|
||||
local tab_page = require "modules.ui.components.tab_page"
|
||||
--local helper = require "modules.render.helper"
|
||||
local tab_page = require "druid.components.tab_page"
|
||||
|
||||
local DISABLE = hash("disable")
|
||||
|
||||
function M.update_sizes(instance, width)
|
||||
width = width or helper.config_x
|
||||
-- width = width or helper.config_x
|
||||
instance.left = vmath.vector3(width * - 1, 0, 0)
|
||||
instance.right = vmath.vector3(width * 1, 0, 0)
|
||||
end
|
||||
|
||||
--- Called when layout updated (rotate for example)
|
||||
function M.on_layout_updated(instance, message)
|
||||
local width = helper.settings_x
|
||||
-- local width = helper.settings_x
|
||||
M.update_sizes(instance, width)
|
||||
end
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
local M = {}
|
||||
|
||||
local ui_animate = require "modules.ui.ui_animate"
|
||||
local ui_animate = require "druid.help_modules.druid_animate"
|
||||
|
||||
--- Bounce text field
|
||||
function M.bounce(instance, callback)
|
||||
|
@ -1,6 +1,6 @@
|
||||
local M = {}
|
||||
|
||||
local formats = require "modules.utils.formats"
|
||||
local formats = require "druid.help_modules.formats"
|
||||
|
||||
--- Set text to text field
|
||||
-- @param set_to - set value in seconds
|
||||
|
@ -1,23 +1,22 @@
|
||||
local M = {}
|
||||
|
||||
local lang = require "modules.localize.lang"
|
||||
local input = require "modules.input.input"
|
||||
M.input = input
|
||||
local druid_input = require "druid.help_modules.druid_input"
|
||||
M.input = druid_input
|
||||
|
||||
local pie_progress_bar = require "modules.ui.components.pie_progress_bar"
|
||||
local progress_bar = require "modules.ui.components.progress_bar"
|
||||
local flying_particles = require "modules.ui.components.flying_particles"
|
||||
local text_field = require "modules.ui.components.text_field"
|
||||
local counter = require "modules.ui.components.counter"
|
||||
local image = require "modules.ui.components.image"
|
||||
local button = require "modules.ui.components.button"
|
||||
local timer = require "modules.ui.components.timer"
|
||||
local tab_page = require "modules.ui.components.tab_page"
|
||||
local tabs_container = require "modules.ui.components.tabs_container"
|
||||
local spine_anim = require "modules.ui.components.spine_anim"
|
||||
local scrolling_box = require "modules.ui.components.scrolling_box"
|
||||
local pie_progress_bar = require "druid.components.pie_progress_bar"
|
||||
local progress_bar = require "druid.components.progress_bar"
|
||||
local flying_particles = require "druid.components.flying_particles"
|
||||
local text_field = require "druid.components.text_field"
|
||||
local counter = require "druid.components.counter"
|
||||
local image = require "druid.components.image"
|
||||
local button = require "druid.components.button"
|
||||
local timer = require "druid.components.timer"
|
||||
local tab_page = require "druid.components.tab_page"
|
||||
local tabs_container = require "druid.components.tabs_container"
|
||||
local spine_anim = require "druid.components.spine_anim"
|
||||
local scrolling_box = require "druid.components.scrolling_box"
|
||||
|
||||
local andr_back_btn = require "modules.ui.components.andr_back_btn"
|
||||
local andr_back_btn = require "druid.components.andr_back_btn"
|
||||
|
||||
local LAYOUT_CHANGED = hash("layout_changed")
|
||||
local ON_MESSAGE = hash("on_message")
|
||||
@ -117,7 +116,7 @@ end
|
||||
local function input_init(factory)
|
||||
if not factory.input_inited then
|
||||
factory.input_inited = true
|
||||
input.focus()
|
||||
druid_input.focus()
|
||||
end
|
||||
end
|
||||
|
||||
@ -269,8 +268,8 @@ M.BTN_SOUND_DISABLE_FUNC = function()end
|
||||
function M.new_button(factory, name, callback, params, animate_node_name, event, action, sound, sound_disable)
|
||||
input_init(factory)
|
||||
local instance = create(button, factory, name, ON_INPUT)
|
||||
instance.event = event or input.A_CLICK
|
||||
instance.action = action or input.RELEASED
|
||||
instance.event = event or druid_input.A_CLICK
|
||||
instance.action = action or druid_input.RELEASED
|
||||
instance.anim_node = animate_node_name and gui.get_node(animate_node_name) or instance.node
|
||||
instance.scale_from = gui.get_scale(instance.anim_node)
|
||||
instance.scale_to = instance.scale_from + button.DEFAULT_SCALE_CHANGE
|
||||
@ -290,8 +289,8 @@ end
|
||||
function M.new_back_handler(factory, callback)
|
||||
input_init(factory)
|
||||
local instance = create(andr_back_btn, factory, nil, ON_INPUT)
|
||||
instance.event = input.A_ANDR_BACK
|
||||
instance.action = input.RELEASED
|
||||
instance.event = druid_input.A_ANDR_BACK
|
||||
instance.action = druid_input.RELEASED
|
||||
instance.callback = callback
|
||||
return instance
|
||||
end
|
||||
@ -304,7 +303,7 @@ end
|
||||
-- @param callback - call when change page
|
||||
-- @return instance that represents the tab page
|
||||
function M.new_tab_page(factory, name, easing, duration, callback)
|
||||
local instance = create(tab_page, factory, name, ON_MESSAGE)
|
||||
local instance = create(tab_page, factory, name, M.EVENTS.ON_MESSAGE)
|
||||
instance.in_pos = gui.get_position(instance.node)
|
||||
instance.out_pos = gui.get_position(instance.node)
|
||||
instance.easing = easing or tab_page.DEFAULT_EASING
|
@ -2,7 +2,6 @@ local M = {}
|
||||
|
||||
local ADD_FOCUS = hash("acquire_input_focus")
|
||||
local REMOVE_FOCUS = hash("release_input_focus")
|
||||
|
||||
local PATH_OBJ = "."
|
||||
|
||||
M.A_CLICK = hash("click")
|
34
druid/help_modules/formats.lua
Normal file
34
druid/help_modules/formats.lua
Normal file
@ -0,0 +1,34 @@
|
||||
local M = {}
|
||||
|
||||
local ZERO = "0"
|
||||
|
||||
-- Return number with zero number prefix
|
||||
-- @param num - number for conversion
|
||||
-- @param count - count of numerals
|
||||
-- @return string with need count of zero (1,3) -> 001
|
||||
function M.add_prefix_zeros(num, count)
|
||||
local result = tostring(num)
|
||||
for i = string.len(result), count - 1 do
|
||||
result = ZERO..result
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
-- Convert seconds to string minutes:seconds
|
||||
-- @param num - number of seconds
|
||||
-- @return string minutes:seconds
|
||||
function M.second_string_min(sec)
|
||||
local mins = math.floor(sec / 60)
|
||||
local seconds = math.floor(sec - mins * 60)
|
||||
return string.format("%.2d:%.2d", mins, seconds)
|
||||
end
|
||||
|
||||
-- Interpolate string with named Parameters in Table
|
||||
-- @param s - string for interpolate
|
||||
-- @param tab - table with parameters
|
||||
-- @return string with replaced parameters
|
||||
function M.interpolate_strinng(s, tab)
|
||||
return (s:gsub('($%b{})', function(w) return tab[w:sub(3, -2)] or w end))
|
||||
end
|
||||
|
||||
return M
|
37
example/example.collection
Normal file
37
example/example.collection
Normal file
@ -0,0 +1,37 @@
|
||||
name: "main"
|
||||
scale_along_z: 0
|
||||
embedded_instances {
|
||||
id: "go"
|
||||
data: "components {\n"
|
||||
" id: \"example\"\n"
|
||||
" component: \"/example/example.gui\"\n"
|
||||
" position {\n"
|
||||
" x: 0.0\n"
|
||||
" y: 0.0\n"
|
||||
" z: 0.0\n"
|
||||
" }\n"
|
||||
" rotation {\n"
|
||||
" x: 0.0\n"
|
||||
" y: 0.0\n"
|
||||
" z: 0.0\n"
|
||||
" w: 1.0\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
""
|
||||
position {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
}
|
||||
rotation {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
scale3 {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
}
|
||||
}
|
10
example/example.gui
Normal file
10
example/example.gui
Normal file
@ -0,0 +1,10 @@
|
||||
script: "/example/example.gui.gui_script"
|
||||
background_color {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 0.0
|
||||
}
|
||||
material: "/builtins/materials/gui.material"
|
||||
adjust_reference: ADJUST_REFERENCE_PARENT
|
||||
max_nodes: 512
|
29
example/example.gui.gui_script
Normal file
29
example/example.gui.gui_script
Normal file
@ -0,0 +1,29 @@
|
||||
local druid = require "druid.druid"
|
||||
|
||||
function init(self)
|
||||
end
|
||||
|
||||
function final(self)
|
||||
-- Add finalization code here
|
||||
-- Remove this function if not needed
|
||||
end
|
||||
|
||||
function update(self, dt)
|
||||
-- Add update code here
|
||||
-- Remove this function if not needed
|
||||
end
|
||||
|
||||
function on_message(self, message_id, message, sender)
|
||||
-- Add message-handling code here
|
||||
-- Remove this function if not needed
|
||||
end
|
||||
|
||||
function on_input(self, action_id, action)
|
||||
-- Add input-handling code here
|
||||
-- Remove this function if not needed
|
||||
end
|
||||
|
||||
function on_reload(self)
|
||||
-- Add input-handling code here
|
||||
-- Remove this function if not needed
|
||||
end
|
@ -1,5 +1,5 @@
|
||||
[bootstrap]
|
||||
main_collection = /main/main.collectionc
|
||||
main_collection = /example/example.collectionc
|
||||
|
||||
[script]
|
||||
shared_state = 1
|
||||
|
@ -1,2 +0,0 @@
|
||||
name: "main"
|
||||
scale_along_z: 0
|
Loading…
x
Reference in New Issue
Block a user