mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
start/stop animations with show/hide and pass show/hide down children
This commit is contained in:
parent
dcf275784c
commit
98c826e762
@ -141,6 +141,14 @@ function element.new(args)
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- start animations
|
||||||
|
function protected.start_anim()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- stop animations
|
||||||
|
function protected.stop_anim()
|
||||||
|
end
|
||||||
|
|
||||||
-- get public interface
|
-- get public interface
|
||||||
---@return graphics_element element, element_id id
|
---@return graphics_element element, element_id id
|
||||||
function protected.get() return public, self.id end
|
function protected.get() return public, self.id end
|
||||||
@ -272,10 +280,20 @@ function element.new(args)
|
|||||||
-- show the element
|
-- show the element
|
||||||
function public.show()
|
function public.show()
|
||||||
protected.window.setVisible(true)
|
protected.window.setVisible(true)
|
||||||
|
protected.start_anim()
|
||||||
|
|
||||||
|
for i = 1, #self.children do
|
||||||
|
self.children[i].show()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- hide the element
|
-- hide the element
|
||||||
function public.hide()
|
function public.hide()
|
||||||
|
protected.stop_anim()
|
||||||
|
for i = 1, #self.children do
|
||||||
|
self.children[i].hide()
|
||||||
|
end
|
||||||
|
|
||||||
protected.window.setVisible(false)
|
protected.window.setVisible(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ local element = require("graphics.element")
|
|||||||
---@return graphics_element element, element_id id
|
---@return graphics_element element, element_id id
|
||||||
local function waiting(args)
|
local function waiting(args)
|
||||||
local state = 0
|
local state = 0
|
||||||
|
local run_animation = false
|
||||||
|
|
||||||
args.width = 4
|
args.width = 4
|
||||||
args.height = 3
|
args.height = 3
|
||||||
@ -28,7 +29,8 @@ local function waiting(args)
|
|||||||
local blit_fg_2x = e.fg_bg.blit_fgd .. e.fg_bg.blit_fgd
|
local blit_fg_2x = e.fg_bg.blit_fgd .. e.fg_bg.blit_fgd
|
||||||
local blit_bg_2x = e.fg_bg.blit_bkg .. e.fg_bg.blit_bkg
|
local blit_bg_2x = e.fg_bg.blit_bkg .. e.fg_bg.blit_bkg
|
||||||
|
|
||||||
local function update()
|
-- tick the animation
|
||||||
|
local function animate()
|
||||||
e.window.clear()
|
e.window.clear()
|
||||||
|
|
||||||
if state >= 0 and state < 7 then
|
if state >= 0 and state < 7 then
|
||||||
@ -82,10 +84,23 @@ local function waiting(args)
|
|||||||
state = state + 1
|
state = state + 1
|
||||||
if state >= 12 then state = 0 end
|
if state >= 12 then state = 0 end
|
||||||
|
|
||||||
tcd.dispatch(0.5, update)
|
if run_animation then
|
||||||
|
tcd.dispatch(0.5, animate)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
update()
|
-- start the animation
|
||||||
|
function e.start_anim()
|
||||||
|
run_animation = true
|
||||||
|
animate()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- stop the animation
|
||||||
|
function e.stop_anim()
|
||||||
|
run_animation = false
|
||||||
|
end
|
||||||
|
|
||||||
|
e.start_anim()
|
||||||
|
|
||||||
return e.get()
|
return e.get()
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user