function vdo_item_stats_init() 
 
end 
 
 
 
function vdo_item_stats_cleanup() 
 
end 
 
 
 
-- Inherited from Vdo_base_object 
 
Vdo_item_stats = Vdo_base_object:new_base() 
 
 
 
local ITEM_VERTICAL_SPACING = 0			-- Spacing between the elements vertically... 
 
local ITEM_STATS_LABEL_SPACING = 10		--  
 
local NUM_ITEM_LEVELS = 5 					-- needs to match the number in the vint_doc 
 
 
 
function Vdo_item_stats:init() 
 
	--Store base objects... 
 
	self.base_item_stat_h 	= vint_object_find("base_stat_grp", self.handle, self.doc_handle)  
	self.base_pulse_anim_h 	= vint_object_find("pulse_lvl_anim", self.handle, self.doc_handle)  
	self.base_pulse_twn_h 	= vint_object_find("pulse_lvl_twn", self.base_pulse_anim_h)   
 
 
	-- Hide the initial stat 
 
	vint_set_property(self.base_item_stat_h, "visible", false)		 
 
end 
 
 
 
-- Deletes the internal data and destroys the button clones 
 
function Vdo_item_stats:cleanup() 
 
	if self.items ~= nil then 
 
		for index, item in pairs(self.items) do 
 
			vint_object_destroy(item.item_h) 
 
		end 
 
		self.items = nil 
 
	end 
 
end 
 
 
 
------------------------------------------------------------------------------- 
 
-- Populates the data... 
 
-- 
 
--	Data example 
 
-- 
 
--	local Vehicle_stats_data = {  
--			[1] = {  
--				label = "TEST_TORQUE", 
 
--				max_level = 5, 
 
--				level = 2, 
 
--			}, 
 
--			[2] = {  
--				label = "TEST_OFFENSE", 
 
--				max_level = 5, 
 
--				level = 5, 
 
--			},	 
 
--		} 
 
------------------------------------------------------------------------------- 
 
function Vdo_item_stats:draw_items(data, show_next_level) 
 
	--Reset label width... 
 
	self.max_label_width = 0 
 
	 
 
	-- Destroy all clones 
 
	self:cleanup() 
 
	 
 
	-- Get position of first item 
 
	--local item_stat_x, item_stat_y = item_stat:get_property("anchor")  
	 
 
	-- Set up table for data and clones 
 
	self.items = {}  
	self.num_items = #data 
 
	 
 
	for index = 1, self.num_items do 
 
	 
 
		local item = {}  
		local item_h = vint_object_clone(self.base_item_stat_h) 
 
		local item_label_h = vint_object_find("item_label", item_h)  
		local lvl_grp_h = vint_object_find("lvl_grp", item_h)  
 
 
		--Set text of our current row... 
 
		local label_str = data[index].label 
 
		vint_set_property(item_label_h, "text_tag", label_str) 
 
		 
 
		-- find max label width to line up stats 
 
		local label_width, label_height = element_get_actual_size(item_label_h) 
 
		self.max_label_width = max(label_width, self.max_label_width) 
 
		 
 
		-- Turn on the levels that we need... 
 
		for i = 1, NUM_ITEM_LEVELS do 
 
			--find each element... 
 
			local lvl_on_h = vint_object_find("lvl_on" .. i, item_h)  
			local lvl_off_h = vint_object_find("lvl_off" .. i, item_h)		  
 
 
			vint_set_property(lvl_off_h, "visible", false) 
 
			vint_set_property(lvl_on_h, "visible", false)			 
 
			 
 
			if i <= data[index].max_level then 
 
				-- Only turn on what we need... 
 
				vint_set_property(lvl_off_h, "visible", true) 
 
				if i <= data[index].level  then 
 
					vint_set_property(lvl_on_h, "alpha", 1) 
 
					vint_set_property(lvl_on_h, "visible", true) 
 
				end 
 
			else 
 
				-- turn off the rest... 
 
				vint_set_property(lvl_off_h, "visible", false) 
 
				vint_set_property(lvl_on_h, "visible", false) 
 
			end 
 
		end		 
 
		 
 
		-- animate next level 
 
		if show_next_level then 
 
			local next_level = data[index].level + 1 
 
			local max_level = data[index].max_level 
 
			 
 
			--make sure we havn't already maxed out... 
 
			if max_level >= next_level then 
 
				local lvl_on_h = vint_object_find("lvl_on" .. next_level, item_h)  
				 
 
				--verify that we have a legitimate target... 
 
				if lvl_on_h ~= 0 and lvl_on_h ~= nil then 
 
					--show next level and animate it... 
 
					vint_set_property(lvl_on_h, "visible", true) 
 
					--vint_set_property(lvl_on_h, "tint", need color passed down) 
 
					vint_set_property(self.base_pulse_twn_h, "target_handle", lvl_on_h) 
 
					lua_play_anim(self.base_pulse_anim_h) 
 
				end 
 
			else 
 
				-- Pause animation 
 
				vint_set_property(self.base_pulse_anim_h, "is_paused", true) 
 
			end			 
 
		end 
 
		 
 
		--store object handles to a table for alignment and cleanup... 
 
		item.item_h = item_h 
 
		item.item_label_h = item_label_h 
 
		 
 
		--store item into the self... 
 
		self.items[index] = item 
 
		 
 
		-- position each element...	 
 
		local prev_x, prev_y 
 
		local new_y 
 
		 
 
		if index <= 1 then 
 
			new_y = 0 
 
		else 
 
			--get the previous button's y 
 
			local prev_item_h = self.items[index - 1].item_h  
 
			prev_x, prev_y = vint_get_property(prev_item_h, "anchor") 
 
			 
 
			--set the current button's y to the previous buttons y plus its height 
 
			new_y = prev_y + label_height + ITEM_VERTICAL_SPACING 
 
		end 
 
		 
 
		-- Move the button copy into the correct position\ 
 
		vint_set_property(item_h, "anchor", 0, new_y) 
 
		 
 
		 
 
		-- Make the button visible 
 
		vint_set_property(item_h, "visible", true) 
 
	end 
 
	 
 
	--Align all level meters in VDO to right of max level width... 
 
	for index = 1, self.num_items do 
 
		local lvl_grp_h = vint_object_find("lvl_grp", self.items[index].item_h)   
		local lvl_grp_x, lvl_grp_y = vint_set_property(lvl_grp_h, "anchor") 
 
		lvl_grp_x = self.max_label_width + ITEM_STATS_LABEL_SPACING 
 
		vint_set_property(lvl_grp_h, "anchor", lvl_grp_x, lvl_grp_y) 
 
	end 
 
end