function vdo_cell_menu_button_init()
end
-- Inherited from Vdo_base_object
Vdo_cell_menu_button = Vdo_base_object:new_base()
PAD_BTN_LABEL = 0
SCALE_BTN_HIGHLIGHT = 1
SCALE_BTN_UNHIGHLIGHT = 0.75
BTN_LABEL_BUFFER = 8
local NUM_BG_SCALE = 0.8
local NUM_BG_SCALE_LARGE = 1.15
function Vdo_cell_menu_button:init()
self.btn_h = vint_object_find("btn_scale_grp", self.handle, self.doc_handle)
self.btn_grp_h = vint_object_find("btn_grp", self.handle, self.doc_handle)
self.btn_hint = Vdo_hint_button:new("btn_hint", self.handle, self.doc_handle)
self.btn_label_h = vint_object_find("btn_label", self.handle, self.doc_handle)
self.btn_img_h = vint_object_find("btn_img", self.handle, self.doc_handle)
self.btn_num_h = vint_object_find("btn_num", self.handle, self.doc_handle)
self.btn_num_bg_h = vint_object_find("btn_num_bg", self.handle, self.doc_handle)
--self.btn_meter_h = vint_object_find("btn_meter", self.handle, self.doc_handle)
self.btn_bg_h = vint_object_find("btn_bg_grp", self.handle, self.doc_handle)
self.btn_bg_img_h = vint_object_find("btn_bg_img", self.handle, self.doc_handle)
--self.btn_highlight_anim_h = vint_object_find("btn_highlight_anim", self.handle, self.doc_handle)
--self.btn_unhighlight_anim_h = vint_object_find("btn_unhighlight_anim", self.handle, self.doc_handle)
self.btn_intro_anim_h = vint_object_find("btn_intro_anim", self.handle, self.doc_handle)
--Retarget the anim for this vdo
vint_set_property(self.btn_highlight_anim_h, "target_handle", self.btn_h)
vint_set_property(self.btn_unhighlight_anim_h, "target_handle", self.btn_h)
vint_set_property(self.btn_intro_anim_h, "target_handle", self.btn_h)
--vint_apply_start_values(self.btn_highlight_anim_h)
--Hide the A button for now
self.btn_hint:set_visible(false)
self.btn_hint:set_button(CTRL_MENU_BUTTON_A)
--Init to unhighlighted
self:set_highlight(false)
end
function Vdo_cell_menu_button:set_highlight(is_highlighted)
if is_highlighted == true then
--Are we using controller or mouse/keyboard?
if game_is_active_input_gamepad() then
self.btn_hint:set_button(CTRL_MENU_BUTTON_A)
self.btn_hint:set_visible(true)
else
self.btn_hint:set_visible(false)
end
--Set text color
vint_set_property(self.btn_label_h, "tint", 0,0,0) --COLOR_CELL_MENU_HIGHLIGHT_TEXT.R, COLOR_CELL_MENU_HIGHLIGHT_TEXT.G, COLOR_CELL_MENU_HIGHLIGHT_TEXT.B)
--Show background image
vint_set_property(self.btn_bg_h, "alpha", 1)
vint_set_property(self.btn_bg_img_h, "alpha", 1)
vint_set_property(self.btn_bg_img_h, "tint", 1, .58, .16)
vint_set_property(self.btn_img_h, "tint", 0, 0, 0)
vint_set_property(self.btn_num_bg_h, "tint", 0, 0, 0)
vint_set_property(self.btn_num_h, "tint", 1, .58, .16)
--Draw in front...
self:set_depth(-20)
--lua_play_anim(self.btn_highlight_anim_h, 0)
else
--Hide the A button
self.btn_hint:set_visible(false)
--Set text color
vint_set_property(self.btn_label_h, "tint", .86, .86, .86)--COLOR_CELL_MENU_UNHIGHLIGHT_TEXT.R,COLOR_CELL_MENU_UNHIGHLIGHT_TEXT.G,COLOR_CELL_MENU_UNHIGHLIGHT_TEXT.B)
--Hide background image
vint_set_property(self.btn_bg_h, "alpha", 1)
vint_set_property(self.btn_bg_img_h, "alpha", 0)
vint_set_property(self.btn_bg_img_h, "tint", .2, .2, .2)
vint_set_property(self.btn_img_h, "tint", .8, .8, .8)
vint_set_property(self.btn_num_bg_h, "tint", 1, .58, .16)
vint_set_property(self.btn_num_h, "tint", 0, 0, 0)
--Move to back
self:set_depth(10)
--Play unhighlight anim, scale button back down
--lua_play_anim(self.btn_unhighlight_anim_h, 0)
end
end
function Vdo_cell_menu_button:populate_button(label, icon, is_enabled, new_items, is_visible, can_wrap, meter_value)
vint_set_property(self.btn_label_h, "text_tag", label)
vint_set_property(self.btn_img_h, "image", icon)
if is_visible ~= nil then
vint_set_property(self.btn_grp_h, "visible", is_visible)
end
if new_items ~= nil and new_items > 0 and is_enabled ~= false then
vint_set_property(self.btn_num_h, "text_tag", new_items)
vint_set_property(self.btn_num_h, "visible", true)
vint_set_property(self.btn_num_bg_h, "visible", true)
local num_bg_scale_x = NUM_BG_SCALE
local num_bg_scale_y = NUM_BG_SCALE
--if larger than 100 then expand num bg to fit
if new_items > 99 then
num_bg_scale_x = NUM_BG_SCALE_LARGE
end
vint_set_property(self.btn_num_bg_h, "scale", num_bg_scale_x, num_bg_scale_y)
else
vint_set_property(self.btn_num_h, "visible", false)
vint_set_property(self.btn_num_bg_h, "visible", false)
end
if is_enabled ~= nil then
self.is_enabled = is_enabled
--If disabled, darken the button
if is_enabled == false then
self:set_color(0.33, 0.33, 0.33)
self:set_alpha(0.8)
end
end
end
function Vdo_cell_menu_button:animate_in(time_offset)
vint_apply_start_values(self.btn_intro_anim_h)
lua_play_anim(self.btn_intro_anim_h, time_offset, self.doc_handle)
end