local ROW_TOP_Y = 25
local ROW_BOT_Y = 75
local TEXT_MAX_WIDTH = 220
local COLOR = {
DARK_PURPLE = {R=44/255, G=0/255, B=59/255},
LIGHT_PURPLE = {R=255/255, G=147/255, B=42/255},
DARK_GREY = {R=25/255, G=25/255, B=25/255},
LIGHT_GREY = {R=120/255, G=120/255, B=120/255},
}
function vdo_powers_button_init()
end
function vdo_powers_button_cleanup()
end
Vdo_powers_button = Vdo_base_object:new_base()
function Vdo_powers_button:init()
--find elements
self.top_txt_h = vint_object_find("top_txt", self.handle, self.doc_handle)
self.bot_txt_h = vint_object_find("bot_txt", self.handle, self.doc_handle)
self.popup_top_txt_h = vint_object_find("popup_top_txt", self.handle, self.doc_handle)
self.popup_bot_txt_h = vint_object_find("popup_bot_txt", self.handle, self.doc_handle)
self.arrow_h = vint_object_find("arrow", self.handle, self.doc_handle)
self.hint_button_h = Vdo_hint_button:new("hint_button", self.handle, self.doc_handle)
self.power_icon_h = vint_object_find("power_icon", self.handle, self.doc_handle)
self.element_icon_h = vint_object_find("element_icon", self.handle, self.doc_handle)
self.bg_on_grp_h = vint_object_find("bg_on_grp", self.handle, self.doc_handle)
self.bg_on_lines_h = vint_object_find("bg_on_lines", self.handle, self.doc_handle)
self.bg_on_bar_h = vint_object_find("bg_on_bar", self.handle, self.doc_handle)
self.bg_off_grp_h = vint_object_find("bg_off_grp", self.handle, self.doc_handle)
self.bg_off_h = vint_object_find("bg_off", self.handle, self.doc_handle)
self.pulse_grp_h = vint_object_find("pulse_grp", self.handle, self.doc_handle)
self.mouse_top_h = vint_object_find("mouse_top", self.handle, self.doc_handle)
self.mouse_bot_h = vint_object_find("mouse_bot", self.handle, self.doc_handle)
resize_text_element(self.popup_top_txt_h, TEXT_MAX_WIDTH)
resize_text_element(self.popup_bot_txt_h , TEXT_MAX_WIDTH)
--get starting anchor points for things we'll move
self.bg_on_bar_x, self.bg_on_bar_y = vint_get_property(self.bg_on_bar_h, "anchor")
self.hint_button_x, self.hint_button_y = self.hint_button_h:get_anchor()
--if pc then hide ctrl button
if game_is_active_input_gamepad() == false then
self.hint_button_h:set_visible(false)
else
self.hint_button_h:set_button(CTRL_MENU_BUTTON_A)
end
--self.pulse_anim = vint_object_find("pulse_anim", self.handle, self.doc_handle)
--self.pulse_anim:set_target_handle(self.text_grp_h)
--lua_play_anim(self.pulse_anim)
end
function Vdo_powers_button:play_pulse_anim()
self.pulse_anim_h = vint_object_find("pulse_anim", self.handle, self.doc_handle)
self.pulse_twn_h = vint_object_find("pulse_twn", self.pulse_anim_h)
self.lines_twn_h = vint_object_find("lines_twn", self.pulse_anim_h)
--Retarget twn to make sure we find the right instance
vint_set_property(self.pulse_twn_h, "target_handle", self.pulse_grp_h)
vint_set_property(self.lines_twn_h, "target_handle", self.bg_on_lines_h)
lua_play_anim(self.pulse_anim_h)
end
---------------
--Get functions
---------------
function Vdo_powers_button:get_mouse_region()
return self.bg_off_h
end
function Vdo_powers_button:get_power_name()
return vint_get_property(self.top_txt_h, "text_tag")
end
function Vdo_powers_button:get_power_icon()
return self.power_icon_ref
end
function Vdo_powers_button:get_power_tint()
return self.power_tint
end
function Vdo_powers_button:get_element_icon()
return self.element_icon_ref
end
---------------
--Set functions
---------------
function Vdo_powers_button:set_power_num_upgrades(num)
self.num_upgrades = num
end
function Vdo_powers_button:set_power_id(id)
self.power_id = id
end
function Vdo_powers_button:set_power_name(text)
vint_set_property(self.top_txt_h, "text_tag", text)
resize_text_element(self.top_txt_h, TEXT_MAX_WIDTH)
end
function Vdo_powers_button:set_power_icon(icon)
vint_set_property(self.power_icon_h, "image", icon)
self.power_icon_ref = icon
end
function Vdo_powers_button:set_power_tint(tint)
self.power_tint = tint
end
function Vdo_powers_button:set_element_icon(visible, icon)
vint_set_property(self.element_icon_h, "image", icon)
vint_set_property(self.element_icon_h, "visible", visible)
self.element_icon_ref = icon
end
function Vdo_powers_button:set_new_indicator(visible, text_string)
vint_set_property(self.arrow_h, "visible", visible)
vint_set_property(self.bot_txt_h, "visible", visible)
if visible then
vint_set_property(self.bot_txt_h, "tint", COLOR.LIGHT_PURPLE.R, COLOR.LIGHT_PURPLE.G, COLOR.LIGHT_PURPLE.B)
--local insert_values = {[0] = number}
--local new_string = vint_insert_values_in_string("POWERS_NEW", insert_values)
vint_set_property(self.bot_txt_h, "text_tag", text_string)
--resize_text_element(self.bot_txt_h, TEXT_MAX_WIDTH)
end
end
function Vdo_powers_button:set_state_on()
vint_set_property(self.bg_on_grp_h, "visible", true)
vint_set_property(self.bg_off_grp_h, "visible", false)
vint_set_property(self.arrow_h, "alpha", 1)
self.hint_button_h:set_visible(true)
vint_set_property(self.bg_on_bar_h, "anchor", self.bg_on_bar_x, ROW_TOP_Y)
self.hint_button_h:set_anchor(self.hint_button_x, ROW_TOP_Y)
vint_set_property(self.top_txt_h, "tint", COLOR.DARK_PURPLE.R, COLOR.DARK_PURPLE.G, COLOR.DARK_PURPLE.B)
vint_set_property(self.bot_txt_h, "tint", COLOR.LIGHT_PURPLE.R, COLOR.LIGHT_PURPLE.G, COLOR.LIGHT_PURPLE.B)
vint_set_property(self.top_txt_h, "alpha", 1)
vint_set_property(self.bot_txt_h, "alpha", 1)
vint_set_property(self.popup_top_txt_h, "alpha", 0)
vint_set_property(self.popup_bot_txt_h, "alpha", 0)
end
function Vdo_powers_button:set_state_off()
vint_set_property(self.bg_on_grp_h, "visible", false)
vint_set_property(self.bg_off_grp_h, "visible", true)
vint_set_property(self.arrow_h, "alpha", 1)
self.hint_button_h:set_visible(false)
self.hint_button_h:set_anchor(self.hint_button_x, ROW_TOP_Y)
vint_set_property(self.top_txt_h, "tint", COLOR.DARK_GREY.R, COLOR.DARK_GREY.G, COLOR.DARK_GREY.B)
vint_set_property(self.bot_txt_h, "tint", COLOR.LIGHT_PURPLE.R, COLOR.LIGHT_PURPLE.G, COLOR.LIGHT_PURPLE.B)
vint_set_property(self.top_txt_h, "alpha", 1)
vint_set_property(self.bot_txt_h, "alpha", 1)
vint_set_property(self.popup_top_txt_h, "alpha", 0)
vint_set_property(self.popup_bot_txt_h, "alpha", 0)
end
function Vdo_powers_button:set_state_popup(position, is_flight)
self.popup_position = position
if is_flight ~= nil and is_flight == true then
vint_set_property(self.popup_bot_txt_h, "text_tag", "POWERS_WING_STYLE_HEADER")
else
vint_set_property(self.popup_bot_txt_h, "text_tag", "POWERS_ELEMENTS_HEADER")
end
vint_set_property(self.bg_on_grp_h, "visible", true)
vint_set_property(self.bg_off_grp_h, "visible", false)
vint_set_property(self.arrow_h, "alpha", 0)
self.hint_button_h:set_visible(true)
vint_set_property(self.top_txt_h, "alpha", 0)
vint_set_property(self.bot_txt_h, "alpha", 0)
vint_set_property(self.popup_top_txt_h, "alpha", 1)
vint_set_property(self.popup_bot_txt_h, "alpha", 1)
if position == 2 then
vint_set_property(self.bg_on_bar_h, "anchor", self.bg_on_bar_x, ROW_BOT_Y)
self.hint_button_h:set_anchor(self.hint_button_x, ROW_BOT_Y)
vint_set_property(self.popup_top_txt_h, "tint", COLOR.LIGHT_PURPLE.R, COLOR.LIGHT_PURPLE.G, COLOR.LIGHT_PURPLE.B)
vint_set_property(self.popup_bot_txt_h, "tint", COLOR.DARK_PURPLE.R, COLOR.DARK_PURPLE.G, COLOR.DARK_PURPLE.B)
else
vint_set_property(self.bg_on_bar_h, "anchor", self.bg_on_bar_x, ROW_TOP_Y)
self.hint_button_h:set_anchor(self.hint_button_x, ROW_TOP_Y)
vint_set_property(self.popup_top_txt_h, "tint", COLOR.DARK_PURPLE.R, COLOR.DARK_PURPLE.G, COLOR.DARK_PURPLE.B)
vint_set_property(self.popup_bot_txt_h, "tint", COLOR.LIGHT_PURPLE.R, COLOR.LIGHT_PURPLE.G, COLOR.LIGHT_PURPLE.B)
end
end