----------------------------------------------------------------------------
-- Vdo_button_pip
-- A button that contains pips for use in the megalists usually for upgrades
----------------------------------------------------------------------------
-- Standard Init Function
function vdo_button_pip_init()
end
-- Standard Cleanup Function
function vdo_button_pip_cleanup()
end
-- Inherited from Vdo_base_object
Vdo_button_pip = Vdo_base_object:new_base()
---------------------------------------------------------------------------
-- Initializes VDO Object
---------------------------------------------------------------------------
function Vdo_button_pip:init()
self.base_pip_img_h = vint_object_find("pip_img", self.handle, self.doc_handle)
end
---------------------------------------------------------------------------
-- Set pips
---------------------------------------------------------------------------
function Vdo_button_pip:set_pips(total, num_active, list_width, color)
--Table of pips
self.pips_h = {}
self.color = color
--Hide the base pip
vint_set_property(self.base_pip_img_h, "visible", false)
--Get anchor of base pip
local base_x, base_y = vint_get_property(self.base_pip_img_h, "anchor")
--Take the width of the list - (width of all the pips + 1.5 for padding)
local PIP_SPACE = 25
local new_x = list_width - ((total + 1.5) * PIP_SPACE)
--Clone the pips we need
for i=1, total do
self.pips_h[i] = vint_object_clone(self.base_pip_img_h)
local current_pip = self.pips_h[i]
--Set pip on or off
if i <= num_active then
--On
vint_set_property(current_pip, "image", "ui_pip_full")
else
--Off
vint_set_property(current_pip, "image", "ui_pip_empty")
end
--Space out pips
vint_set_property(current_pip, "anchor", new_x, base_y)
new_x = new_x + PIP_SPACE
--Color pips
vint_set_property(current_pip, "tint", color.r, color.g, color.b)
--Set visible
vint_set_property(current_pip, "visible", true)
end
end
---------------------------------------------------------------------------
-- Tint pips for highlight state
---------------------------------------------------------------------------
function Vdo_button_pip:set_highlight(is_highlighted)
if self.pips_h ~= nil then
for i=1, #self.pips_h do
if is_highlighted then
vint_set_property(self.pips_h[i], "tint", 0, 0, 0)
else
vint_set_property(self.pips_h[i], "tint", self.color.R, self.color.G, self.color.B)
end
end
end
end