function vdo_cell_menu_button_init()
end
COLOR_STORE_REWARDS_PRIMARY = {R=148/255, G=0/255, B=197/255}
-- 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.95
BTN_LABEL_BUFFER = 8
local NUM_BG_SCALE = 0.8
local NUM_BG_SCALE_LARGE = 1.04
function Vdo_cell_menu_button:init()
self.btn = Vdo_base_object:new("btn_scale_grp", self.handle, self.doc_handle)
self.btn_blur = Vdo_base_object:new("btn_blur", self.handle, self.doc_handle)
self.btn_grp = Vdo_base_object:new("btn_grp", self.handle, self.doc_handle)
self.btn_hint = Vdo_hint_button:new("btn_hint", self.handle, self.doc_handle)
self.btn_label = Vdo_base_object:new("btn_label", self.handle, self.doc_handle)
self.btn_img = Vdo_base_object:new("btn_img", self.handle, self.doc_handle)
self.btn_num = Vdo_base_object:new("btn_num", self.handle, self.doc_handle)
self.btn_num_bg = Vdo_base_object:new("btn_num_bg", self.handle, self.doc_handle)
self.btn_label_x,self.btn_label_y = self.btn_label:get_anchor()
self.btn_hint_x,self.btn_hint_y = self.btn_hint:get_anchor()
self.btn_hint:set_visible(false)
self.btn_hint:set_button(CTRL_MENU_BUTTON_A)
self:set_highlight(false)
end
function Vdo_cell_menu_button:set_highlight(is_highlighted)
local btn_width, btn_height
if is_highlighted then
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
self.btn:set_scale(SCALE_BTN_HIGHLIGHT,SCALE_BTN_HIGHLIGHT)
btn_width, btn_height = self.btn_img:get_actual_size()
self.btn_label:set_anchor(0 , btn_height * 0.55 + BTN_LABEL_BUFFER)
self.btn_label:set_property("horz_align","center")
self.btn_label:set_property("auto_offset", "n")
self.btn_blur:set_visible(true)
local btn_pulse = Vdo_anim_object:new("btn_pulse", self.handle, self.doc_handle)
btn_pulse:set_target_handle(self.btn_blur.handle)
btn_pulse:play(0)
self.btn_label:set_color(COLOR_CELL_MENU_HIGHLIGHT_TEXT.R,COLOR_CELL_MENU_HIGHLIGHT_TEXT.G,COLOR_CELL_MENU_HIGHLIGHT_TEXT.B)
--Draw in front...
self:set_depth(-20)
else
self.btn_hint:set_visible(false)
self.btn:set_scale(SCALE_BTN_UNHIGHLIGHT,SCALE_BTN_UNHIGHLIGHT)
btn_width, btn_height = self.btn_img:get_actual_size()
self.btn_label:set_anchor(0, btn_height * 0.5 + BTN_LABEL_BUFFER)
self.btn_label:set_property("horz_align","center")
self.btn_label:set_property("auto_offset", "n")
self.btn_blur:set_visible(false)
self.btn_label:set_color(COLOR_CELL_MENU_UNHIGHLIGHT_TEXT.R,COLOR_CELL_MENU_UNHIGHLIGHT_TEXT.G,COLOR_CELL_MENU_UNHIGHLIGHT_TEXT.B)
--Move to back
self:set_depth(10)
end
end
function Vdo_cell_menu_button:populate_button(label, icon, is_enabled, new_items, is_visible, can_wrap)
self.btn_label:set_text(label)
self.btn_img:set_image(icon)
if is_visible ~= nil then
self.btn_grp:set_visible(is_visible)
end
if new_items ~= nil and new_items > 0 then
self.btn_num:set_text(new_items)
self.btn_num:set_visible(true)
self.btn_num_bg:set_visible(true)
--if larger than 100 then expand num bg to fit
self.btn_num_bg:set_scale(NUM_BG_SCALE, NUM_BG_SCALE)
if new_items > 99 then
self.btn_num_bg:set_scale(NUM_BG_SCALE_LARGE, NUM_BG_SCALE)
end
self.btn_num:set_visible(true)
self.btn_num_bg:set_visible(true)
else
self.btn_num:set_visible(false)
self.btn_num_bg:set_visible(false)
end
if is_enabled ~= nil then
self.is_enabled = is_enabled
self:set_color(.5,.5,.5)
end
if can_wrap == false then
self.btn_label:set_property("word_wrap", false)
else
self.btn_label:set_property("word_wrap", true)
end
end