function vdo_level_meter()
end
local Level_meter_frame_left_width = -1
local Level_meter_frame_left_height = -1
local Level_meter_fill_spacing_x = 3
local Level_meter_fill_spacing_y = 3
-- Inherited from Vdo_base_object
Vdo_level_meter = Vdo_base_object:new_base()
function Vdo_level_meter:init()
--Find base stuff, make base objects, store to self and hide...
self.level_text_obj = Vdo_base_object:new("level_text", self.handle)
self.left_frame_obj = Vdo_base_object:new("left_frame", self.handle)
self.right_frame_obj = Vdo_base_object:new("right_cap", self.handle)
self.fill_obj = Vdo_base_object:new("fill", self.handle)
self.left_frame_obj:set_visible(false)
self.fill_obj:set_visible(false)
self.frame_objects = {}
Level_meter_frame_left_width, Level_meter_frame_left_height = self.left_frame_obj:get_actual_size()
--Subtract one because of extra padding...
Level_meter_frame_left_width = Level_meter_frame_left_width - 1
end
-- Sets the level of the meter
-- This must be called for teh object to be initialized properly.
--
-- @param level The current level of the meter
-- @param max_level How many empty spaces there will be in the meter.
-- @param is_blinking Is the last level in the meter blinking?
function Vdo_level_meter:set_level(level, max_level, is_blinking)
--Clear out any existing frame objects...
for key, val in pairs(self.frame_objects) do
val:object_destroy()
end
self.frame_objects = {}
local x = 48
local y = 0
local object_count = 0
if max_level == 0 then
--Hide meter if no levels...
self.level_text_obj:set_visible(false)
self.right_frame_obj:set_visible(false)
return
else
--Make sure meter is visible...
self.level_text_obj:set_visible(true)
self.right_frame_obj:set_visible(true)
end
for i = 0, max_level - 1 do
--Clone
local left_frame = Vdo_base_object:clone(self.left_frame_obj.handle)
local fill = Vdo_base_object:clone(self.fill_obj.handle)
--Position left frames
x = x + Level_meter_frame_left_width
left_frame:set_anchor(x, y)
left_frame:set_visible(true)
--Fills
if i < level then
fill:set_anchor(x + Level_meter_fill_spacing_x, y + Level_meter_fill_spacing_y)
fill:set_visible(true)
--If we are blinking and this is the last animations then play the pulsing on the final object...
if i == level - 1 and is_blinking then
--retarget tween...
local pulse_twn = Vdo_tween_object:new("pulse_twn", self.handle)
pulse_twn:set_target_handle(fill.handle)
--playback
local pulse_level_anim = Vdo_anim_object:new("pulse_level_anim", self.handle)
pulse_level_anim:play()
end
end
--Store and reference objects...
self.frame_objects[ "obj_" .. object_count .. "_a"] = left_frame
self.frame_objects[ "obj_" .. object_count .. "_b"] = fill
object_count = object_count + 1
end
--Move Right Cap
self.right_frame_obj:set_anchor(x + Level_meter_frame_left_width + 1)
end