---------------------------------------------------------------------------
-- Vdo_button_highlight
--
-- The highlight behind a botton toggle for use in a megalist.
---------------------------------------------------------------------------
local BOTTOM_FILL_PAD = 8
local Levels_off = {}
local Levels_on = {}
-- Standard Init Function
function vdo_button_highlight_init()
end
-- Standard Cleanup Function
function vdo_button_highlight_cleanup()
end
-- Inherited from Vdo_base_object
Vdo_button_highlight = Vdo_base_object:new_base()
---------------------------------------------------------------------------
-- Initializes VDO Object
---------------------------------------------------------------------------
function Vdo_button_highlight:init()
self.bottom_grp = Vdo_base_object:new("bottom_grp", self.handle, self.doc_handle)
self.bottom_bar = Vdo_base_object:new("bottom_bar", self.handle, self.doc_handle)
self.extended_text = Vdo_base_object:new("extended_text", self.handle, self.doc_handle)
self.item_stats = Vdo_item_stats:new("item_stats", self.handle, self.doc_handle)
--Hide bottom group..
self.bottom_grp:set_visible(false)
end
function Vdo_button_highlight:cleanup()
if self.item_stats ~= nil then
self.item_stats:cleanup()
end
end
---------------------------------------------------------------------------
-- Sets the button image on the VDO Object.
-- @param button_icon Button Icon, please use the globals set in
-- vdo_hint_button.lua. If no button is provided the
-- button is hidden.
---------------------------------------------------------------------------
function Vdo_button_highlight:show_button(button_icon, override_show)
local button = Vdo_hint_button:new("icon", self.handle, self.doc_handle)
local always_show = override_show or false
if game_is_active_input_gamepad() or always_show == true then
if button.handle ~= 0 then
if button_icon == "" then
button:set_property("visible", false)
else
if always_show == true then
button:set_button( button_icon, "", true )
else
button:set_button( button_icon )
end
button:set_property("visible", true)
end
end
else
button:set_property("visible", false)
end
end
---------------------------------------------------------------------------
-- Sets width of the button highlight
-- @param width Width of the highlight in pixels
---------------------------------------------------------------------------
function Vdo_button_highlight:set_width(width)
-- Set width of bottom fill
local bg = Vdo_base_object:new("bg", self.handle, self.doc_handle)
local button_cap = Vdo_base_object:new("button_cap", self.handle, self.doc_handle)
local bottom_bar = Vdo_base_object:new("bottom_bar", self.handle, self.doc_handle)
local bottom_fill = Vdo_base_object:new("bottom_bar_fill", self.handle, self.doc_handle)
--Get sizes of width and height for manipulation...
local bg_width, bg_height = bg:get_actual_size()
local button_cap_width, button_cap_height = button_cap:get_actual_size()
local bottom_bar_width, bottom_bar_height = bottom_bar:get_actual_size()
local bottom_fill_width, bottom_fill_height = bottom_fill:get_actual_size()
--Set sizes of bar...
bg:set_actual_size(width-button_cap_width, bg_height)
button_cap:set_actual_size(button_cap_width, bg_height)
bottom_bar:set_actual_size(width-button_cap_width, bottom_bar_height)
bottom_fill:set_actual_size(width - BOTTOM_FILL_PAD, bottom_fill_height)
end
function Vdo_button_highlight:set_highlight()
end
---------------------------------------------------------------------------
-- Colors highlight bar
-- @param new_color Sets color of highlight
---------------------------------------------------------------------------
function Vdo_button_highlight:set_highlight_color(new_color)
local bg = Vdo_base_object:new("bg", self.handle, self.doc_handle)
local button_buffer = Vdo_base_object:new("button_buffer", self.handle, self.doc_handle)
local button_cap = Vdo_base_object:new("button_cap", self.handle, self.doc_handle)
self.highlight_color = new_color
bg:set_color(new_color.R, new_color.G, new_color.B)
button_buffer:set_color(new_color.R, new_color.G, new_color.B)
button_cap:set_color(new_color.R, new_color.G, new_color.B)
self.bottom_bar:set_color(new_color.R, new_color.G, new_color.B)
self.extended_text:set_color(new_color.R, new_color.G, new_color.B)
end
---------------------------------------------------------------------------
-- Reveals extra info on highlight for items that have levels
-- @param is_extended Determines visibilty of extra highlight
-- line.
---------------------------------------------------------------------------
function Vdo_button_highlight:show_extended(is_extended)
self.bottom_grp:set_visible(is_extended)
end
---------------------------------------------------------------------------
-- Sets levels for items that are upgradable such as rewards,
-- performance mods, etc.
-- @param max_level Max level of item. Determines how
-- many slots to show.
--
-- @param current_level Current level of item. Fills in the
-- the slots.
---------------------------------------------------------------------------
function Vdo_button_highlight:set_level(max_level, current_level, is_purchased, show_next_level)
local stats_data
if is_purchased == false or is_purchased == nil then
--Set current level...
stats_data = {
[1] = {
label = "STORE_LEVEL",
level = current_level,
max_level = max_level,
}
}
else
-- If user has max levels then they own that item
stats_data = {
[1] = {
label = "STORE_LEVEL",
level = current_level,
max_level = max_level,
}
}
end
--Set item stats level...
self.item_stats:draw_items(stats_data, show_next_level)
end