Powers_main_doc_handle = -1
Powers_screen_state = -1
Powers_cur_type = -1
Powers_cur_id = -1
Powers_cur_power_name = -1
Powers_cur_power_bitmap = -1
Powers_cur_power_tint = -1
Powers_cur_element_bitmap = -1
POWERS_SCREEN_STATE_UPGRADE = 1
POWERS_SCREEN_STATE_ELEMENT = 2
POWERS_TYPE_RAD = 1
POWERS_TYPE_ALT = 2
local Safe_frame_h = -1
local Rad_powers_list = {}
local Alt_powers_list = {}
local List_bg_grp_h
local Rad_bg = {}
local Alt_bg = {}
local Cur_popup_position
local Input_tracker = {}
local Mouse_input_tracker
local Hint_bar_mouse_input_tracker
local Hint_bar
local Cur_list -- 1-2 (columns)
local Cur_index -- 1-4 (rows)
local Out_anim
local In_anim
local First_cur_list = POWERS_TYPE_ALT
local Popup_is_active = false
local Popup_is_rad_power = false
local Rad_powers_data = {
[1] = {id = 0, label = "SUPER_TELEKINESIS_LABEL", power_bitmap = "ui_hud_inv_power_tele", tint = COLOR_POWER_TELE},
[2] = {id = 1, label = "SUPER_GROUNDPOUND_LABEL", power_bitmap = "ui_hud_inv_power_pound", tint = COLOR_POWER_POUND},
[3] = {id = 2, label = "SUPER_BUFF_LABEL", power_bitmap = "ui_hud_inv_power_buff", tint = COLOR_POWER_BUFF},
[4] = {id = 3, label = "SUPER_BLAST_LABEL", power_bitmap = "ui_hud_inv_power_blast", tint = COLOR_POWER_BLAST},
}
local Alt_powers_data = {
[1] = {id = 4, label = "SUPER_FORCE_SHIELD_LABEL", power_bitmap = "ui_hud_inv_power_shield", tint = COLOR_POWER_MOVE},
[2] = {id = 5, label = "SUPER_SPRINT_LABEL", power_bitmap = "ui_hud_inv_power_move", tint = COLOR_POWER_MOVE},
[3] = {id = 6, label = "SUPER_JUMP_LABEL", power_bitmap = "ui_hud_inv_power_jump", tint = COLOR_POWER_MOVE},
[4] = {id = 7, label = "SUPER_DFA_LABEL", power_bitmap = "ui_hud_inv_power_dfa", tint = COLOR_POWER_MOVE},
}
function powers_main_init()
pause_map_dump()
Powers_main_doc_handle = vint_document_find("powers_main")
Safe_frame_h = vint_object_find("safe_frame", 0, Powers_main_doc_handle)
--Set up button hints
Hint_bar = Vdo_hint_bar:new("hint_bar", 0, Powers_main_doc_handle)
local hint_data = {
{CTRL_MENU_BUTTON_B, "MENU_BACK"},
}
Hint_bar:set_hints(hint_data)
Hint_bar:set_visible(true)
--Set up title
local cell_title_h = Vdo_cell_title:new("cell_title", 0, Powers_main_doc_handle)
cell_title_h:set_text("POWERS_HEADER")
cell_title_h:set_icon("ui_cell_icon_saintsbook")
cell_title_h:play_dots_anim()
-- Setup input tracker
Input_tracker = Vdo_input_tracker:new()
Input_tracker:add_input("map", "powers_main_button_map", 50)
Input_tracker:add_input("select", "powers_main_button_a", 50)
Input_tracker:add_input("back", "powers_main_button_b", 50)
Input_tracker:add_input("nav_up", "powers_main_nav_up", 50)
Input_tracker:add_input("nav_down", "powers_main_nav_down", 50)
Input_tracker:add_input("nav_left", "powers_main_nav_left", 50)
Input_tracker:add_input("nav_right", "powers_main_nav_right", 50)
Out_anim = vint_object_find("powers_main_out_anim", 0, Powers_main_doc_handle)
In_anim = vint_object_find("powers_main_in_anim", 0, Powers_main_doc_handle)
--send true to signify this is the first time entering the screen
powers_main_populate_screen(true)
--power button placeholder bgs
List_bg_grp_h = vint_object_find("list_bg_grp", 0, Powers_main_doc_handle)
local bg
--set up rad list
for i = 1, 4 do
bg = "rad_bg_" .. i
Rad_bg[i] = vint_object_find(bg, 0, Powers_main_doc_handle)
bg = "alt_bg_" .. i
Alt_bg[i] = vint_object_find(bg, 0, Powers_main_doc_handle)
end
--turn them on or off
for i = 1, 4 do
if Rad_powers_list[i]:get_visible() == false then
vint_set_property(Rad_bg[i], "visible", true)
else
vint_set_property(Rad_bg[i], "visible", false)
end
if Alt_powers_list[i]:get_visible() == false then
vint_set_property(Alt_bg[i], "visible", true)
else
vint_set_property(Alt_bg[i], "visible", false)
end
end
--setup PC inputs after grid is drawn
if game_get_platform() == "PC" then
Hint_bar:set_highlight(0)
Mouse_input_tracker = Vdo_input_tracker:new()
Hint_bar_mouse_input_tracker = Vdo_input_tracker:new()
powers_main_add_mouse_inputs()
Mouse_input_tracker:subscribe(false)
Hint_bar_mouse_input_tracker:subscribe(false)
end
--show tutorial
cell_foreground_update_tutorial("main")
--get rid of this line to test
vint_apply_start_values(In_anim)
lua_play_anim(In_anim)
cell_transition_screen(CELL_STATE_LANDSCAPE, CELL_SCREEN_POWERS, CELL_SCREEN_MAIN, powers_main_unlock_controls)
--glitch
--glitch_cell()
end
function powers_main_cleanup()
pause_map_restore()
Input_tracker:subscribe(false)
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(false)
end
if Hint_bar_mouse_input_tracker ~= nil then
Hint_bar_mouse_input_tracker:subscribe(false)
end
end
function powers_main_populate_screen(is_first)
--datarespponder
local power
--set up main list
for i = 1, 4 do
power = "rad_power_" .. i
Rad_powers_list[i] = Vdo_powers_button:new(power, 0, Powers_main_doc_handle)
Rad_powers_list[i]:set_visible(false)
Rad_powers_list[i]:set_state_off()
Rad_powers_list[i]:play_pulse_anim()
end
--set up alt list
for i = 1, 4 do
power = "alt_power_" .. i
Alt_powers_list[i] = Vdo_powers_button:new(power, 0, Powers_main_doc_handle)
Alt_powers_list[i]:set_visible(false)
Alt_powers_list[i]:set_state_off()
Alt_powers_list[i]:play_pulse_anim()
end
vint_dataresponder_request("powers_upgrades_dr", "powers_main_populate", 0, "get_avail_powers")
--[[
--testing
powers_main_populate(0, 3, 2)
powers_main_populate(1, 2, 0)
powers_main_populate(2, 2, 12)
powers_main_populate(3, -1, 0)
powers_main_populate(4, -1, 1)
powers_main_populate(5, -1, 3)
powers_main_populate(6, -1, 0)
powers_main_populate(7, -1, 51)
]]
--Start the highlight at the top of the populated list
if is_first then
powers_main_set_highlight(First_cur_list, 1)
else
if Cur_list == POWERS_TYPE_RAD then
--When returning to this screen, set popup state if in left list
powers_main_set_highlight(Cur_list, Cur_index, true)
else
local is_popup = false
-- the flight menu has a popup now
if Cur_index == 2 and game_unlockable_is_unlocked( "DLC_Preorder_Saints_Wings" ) then
is_popup = true
end
powers_main_set_highlight(Cur_list, Cur_index, is_popup)
end
end
end
--Power Enums
--SUPERPOWER_TELEKINESIS, == 0
--SUPERPOWER_GROUNDPOUND,
--SUPERPOWER_BUFF,
--SUPERPOWER_BLAST,
--SUPERPOWER_FORCE_SHIELD,
--SUPERPOWER_SPRINT,
--SUPERPOWER_JUMP,
--SUPERPOWER_DEATH_FROM_ABOVE,
function powers_main_populate(power, element, num_new_upgrades, num_upgrades, num_new_elements)
power = power + 1
local data
local list
--Convert data to Rad and Alt lists
if power < 5 then
data = Rad_powers_data[power]
list = Rad_powers_list
First_cur_list = POWERS_TYPE_RAD
else
power = power - 4
data = Alt_powers_data[power]
list = Alt_powers_list
end
--Determine the current slot
local list_slot = 1
--start at the top of list, if first slot is not visible, populate first slot
--if first slot is visible, then its already been populated, and go to the next, and so on...
for i = 1, 4 do
if list[i]:get_visible() then
list_slot = i + 1
end
end
data.num_new_upgrades = num_new_upgrades
data.num_upgrades = num_upgrades
data.num_new_elements = num_new_elements
--Set Power name and icon
list[list_slot]:set_power_id(data.id)
list[list_slot]:set_power_name(data.label)
list[list_slot]:set_power_icon(data.power_bitmap)
list[list_slot]:set_power_tint(data.tint)
list[list_slot]:set_power_num_upgrades(data.num_upgrades)
--Set Element Icon
if element ~= nil and element ~= -1 then
data.element_bitmap = POWERS_ELEMENTS_ENUMS[element].bitmap
list[list_slot]:set_element_icon(true, data.element_bitmap)
else
if list == Rad_powers_list then
-- set empty slot bitmap
list[list_slot]:set_element_icon(true, POWERS_ELEMENTS_ENUMS[element].bitmap)
else
-- show nothing
list[list_slot]:set_element_icon(false, POWERS_ELEMENTS_ENUMS[element].bitmap)
end
end
--Set New Indicator
if num_new_upgrades > 0 and num_new_elements > 0 then
list[list_slot]:set_new_indicator(true, "POWERS_NEW_BOTH")
else
if num_new_upgrades > 0 then
list[list_slot]:set_new_indicator(true, "POWERS_NEW_UPGRADES")
elseif num_new_elements > 0 then
list[list_slot]:set_new_indicator(true, "POWERS_NEW_ELEMENTS")
else
list[list_slot]:set_new_indicator(false, "")
end
end
--Show button
list[list_slot]:set_visible(true)
end
function powers_main_set_highlight(list, index, is_popup)
--Turn off old selection
if Cur_list == POWERS_TYPE_RAD then
Rad_powers_list[Cur_index]:set_state_off()
elseif Cur_list == POWERS_TYPE_ALT then
Alt_powers_list[Cur_index]:set_state_off()
end
--Turn on new selection
if list == POWERS_TYPE_RAD then
--if coming back to this screen on a power with a popup
if is_popup then
Rad_powers_list[index]:set_state_popup(Cur_popup_position)
else
Rad_powers_list[index]:set_state_on()
end
--Store off values for subpage header
Powers_cur_id = Rad_powers_list[index].power_id
Powers_cur_power_name = Rad_powers_list[index]:get_power_name()
Powers_cur_power_bitmap = Rad_powers_list[index]:get_power_icon()
Powers_cur_element_bitmap = Rad_powers_list[index]:get_element_icon()
Powers_cur_power_tint = Rad_powers_list[index]:get_power_tint()
Powers_cur_type = POWERS_TYPE_RAD
elseif list == POWERS_TYPE_ALT then
--if coming back to this screen on a power with a popup
if is_popup then
Alt_powers_list[index]:set_state_popup(Cur_popup_position, true)
else
Alt_powers_list[index]:set_state_on()
end
--Alt_powers_list[index]:set_state_on()
--Store off values for subpage header
Powers_cur_id = Alt_powers_list[index].power_id
Powers_cur_power_name = Alt_powers_list[index]:get_power_name()
Powers_cur_power_bitmap = Alt_powers_list[index]:get_power_icon()
Powers_cur_element_bitmap = Alt_powers_list[index]:get_element_icon()
Powers_cur_power_tint = Alt_powers_list[index]:get_power_tint()
Powers_cur_type = POWERS_TYPE_ALT
end
Cur_list = list
Cur_index = index
end
function powers_main_unload()
cell_transition_screen(CELL_STATE_PORTRAIT, CELL_SCREEN_MAIN, CELL_SCREEN_POWERS, nil)
end
function powers_main_exit(event)
--Transition to cell main
lua_play_anim(Out_anim)
cell_transition_screen(CELL_STATE_PORTRAIT, CELL_SCREEN_MAIN, CELL_SCREEN_POWERS, powers_main_exit_to_cell)
ui_audio_post_event("UI_Hub_Menu_Back")
cell_foreground_update_tutorial("hub")
end
function powers_main_exit_to_cell()
pop_screen()
end
function powers_main_exit_to_game(event)
pop_screen()
pop_screen()
pop_screen()
end
function powers_main_return_from_sub()
--returning anim here
--unlock controls at end of this anim
powers_main_populate_screen()
lua_play_anim(In_anim)
cell_transition_screen(CELL_STATE_LANDSCAPE, CELL_SCREEN_POWERS, CELL_SCREEN_NONE, powers_main_unlock_controls)
--glitch
--cell_foreground_update_tutorial("main")
glitch_cell()
end
---------------
--Input tracker
---------------
function powers_main_unlock_controls()
Input_tracker:subscribe(true)
if Mouse_input_tracker ~= nil and Hint_bar_mouse_input_tracker ~= nil then
if Popup_is_active and Cur_list == 1 then
powers_main_add_mouse_inputs_popup(Cur_index, false)
elseif Popup_is_active and Cur_list == 2 then
powers_main_add_mouse_inputs_popup(Cur_index, true)
else
powers_main_add_mouse_inputs()
end
Mouse_input_tracker:subscribe(true)
Hint_bar_mouse_input_tracker:subscribe(true)
end
end
function powers_main_lock_controls()
Input_tracker:subscribe(false)
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(false)
end
if Hint_bar_mouse_input_tracker ~= nil then
Hint_bar_mouse_input_tracker:subscribe(false)
end
end
function powers_main_button_b(event, acceleration)
if Popup_is_active then
for i = 1, 4 do
Rad_powers_list[i]:set_color(1, 1, 1)
Alt_powers_list[i]:set_color(1, 1, 1)
end
vint_set_property(List_bg_grp_h, "tint", 1, 1, 1)
if Popup_is_rad_power then
Rad_powers_list[Cur_index]:set_state_on()
else
Alt_powers_list[Cur_index]:set_state_on()
end
if Mouse_input_tracker ~= nil and Hint_bar_mouse_input_tracker ~= nil then
powers_main_add_mouse_inputs()
end
Popup_is_active = false
game_UI_audio_play("UI_Reward_Store_Menu_Navigation")
else
powers_main_exit()
powers_main_lock_controls()
end
end
function powers_main_button_map(event, acceleration)
cell_foreground_update_tutorial("off")
lua_play_anim(Out_anim)
cell_transition_screen(CELL_STATE_OUT, CELL_SCREEN_NONE, CELL_SCREEN_POWERS, powers_main_exit_to_game)
end
function powers_main_button_a(event, acceleration)
if Cur_list == POWERS_TYPE_RAD then
if Popup_is_active == false then
for i = 1, 4 do
Rad_powers_list[i]:set_color(.3, .3, .3)
Alt_powers_list[i]:set_color(.3, .3, .3)
end
vint_set_property(List_bg_grp_h, "tint", .3, .3, .3)
Rad_powers_list[Cur_index]:set_color(1, 1, 1)
Rad_powers_list[Cur_index]:set_state_popup(POWERS_SCREEN_STATE_UPGRADE)
if game_get_platform() == "PC" then
powers_main_add_mouse_inputs_popup(Cur_index, false)
end
game_UI_audio_play("UI_HUD_Help")
Popup_is_active = true
Popup_is_rad_power = true
else
if Rad_powers_list[Cur_index].popup_position == POWERS_SCREEN_STATE_UPGRADE then
if Rad_powers_list[Cur_index].num_upgrades == 0 then
dialog_box_message("MENU_TITLE_NOTICE", "STORE_NO_ITEMS_IN_CATEGORY", true, true)
return
else
--push upgrades screen
Powers_screen_state = POWERS_SCREEN_STATE_UPGRADE
end
else
--push elements screen
Powers_screen_state = POWERS_SCREEN_STATE_ELEMENT
end
-- Store position for when we return
Cur_popup_position = Rad_powers_list[Cur_index].popup_position
ui_audio_post_event("UI_Hub_Menu_Forward")
push_screen("powers_sub")
powers_main_lock_controls()
lua_play_anim(Out_anim)
--vint_set_property(Safe_frame_h, "visible", false)
end
else
--The flight menu now has a wing style screen
if Cur_index == 2 and game_unlockable_is_unlocked( "DLC_Preorder_Saints_Wings" ) then
if Popup_is_active == false then
for i = 1, 4 do
Rad_powers_list[i]:set_color(.3, .3, .3)
Alt_powers_list[i]:set_color(.3, .3, .3)
end
vint_set_property(List_bg_grp_h, "tint", .3, .3, .3)
Alt_powers_list[Cur_index]:set_color(1, 1, 1)
Alt_powers_list[Cur_index]:set_state_popup(POWERS_SCREEN_STATE_UPGRADE, true)
if game_get_platform() == "PC" then
powers_main_add_mouse_inputs_popup(Cur_index, true)
end
game_UI_audio_play("UI_HUD_Help")
Popup_is_active = true
Popup_is_rad_power = false
else
if Alt_powers_list[Cur_index].popup_position == POWERS_SCREEN_STATE_UPGRADE then
if Alt_powers_list[Cur_index].num_upgrades == 0 then
dialog_box_message("MENU_TITLE_NOTICE", "STORE_NO_ITEMS_IN_CATEGORY", true, true)
return
else
--push upgrades screen
Powers_screen_state = POWERS_SCREEN_STATE_UPGRADE
end
else
--push elements screen
Powers_screen_state = POWERS_SCREEN_STATE_ELEMENT
end
-- Store position for when we return
Cur_popup_position = Alt_powers_list[Cur_index].popup_position
ui_audio_post_event("UI_Hub_Menu_Forward")
push_screen("powers_sub")
powers_main_lock_controls()
lua_play_anim(Out_anim)
--vint_set_property(Safe_frame_h, "visible", false)
end
else
--push upgrades screen
if Alt_powers_list[Cur_index].num_upgrades == 0 then
dialog_box_message("MENU_TITLE_NOTICE", "STORE_NO_ITEMS_IN_CATEGORY", true, true)
return
else
Powers_screen_state = POWERS_SCREEN_STATE_UPGRADE
ui_audio_post_event("UI_Hub_Menu_Forward")
push_screen("powers_sub")
powers_main_lock_controls()
lua_play_anim(Out_anim)
--vint_set_property(Safe_frame_h, "visible", false)
end
end
end
end
function powers_main_nav_up(event, acceleration)
if Popup_is_active == false then
local new_list = Cur_list
local new_index = Cur_index
local max_index
if Cur_list == POWERS_TYPE_RAD then
for i = 4, 1, -1 do
if Rad_powers_list[i]:get_visible() == true then
max_index = i
break
end
end
else
for i = 4, 1, -1 do
if Alt_powers_list[i]:get_visible() == true then
max_index = i
break
end
end
end
if new_index > 1 then
new_index = Cur_index - 1
else
new_index = max_index
end
if new_index ~= Cur_index then
powers_main_set_highlight(new_list, new_index)
end
ui_audio_post_event("ui_powers_menu_nav")
else
if Popup_is_rad_power then
if Rad_powers_list[Cur_index].popup_position == POWERS_SCREEN_STATE_UPGRADE then
Rad_powers_list[Cur_index]:set_state_popup(POWERS_SCREEN_STATE_ELEMENT)
else
Rad_powers_list[Cur_index]:set_state_popup(POWERS_SCREEN_STATE_UPGRADE)
end
else
if Alt_powers_list[Cur_index].popup_position == POWERS_SCREEN_STATE_UPGRADE then
Alt_powers_list[Cur_index]:set_state_popup(POWERS_SCREEN_STATE_ELEMENT, true)
else
Alt_powers_list[Cur_index]:set_state_popup(POWERS_SCREEN_STATE_UPGRADE, true)
end
end
game_UI_audio_play("UI_Reward_Store_Menu_Navigation")
end
end
function powers_main_nav_down(event, acceleration)
if Popup_is_active == false then
local new_list = Cur_list
local new_index = Cur_index
local max_index
if Cur_list == POWERS_TYPE_RAD then
for i = 4, 1, -1 do
if Rad_powers_list[i]:get_visible() == true then
max_index = i
break
end
end
else
for i = 4, 1, -1 do
if Alt_powers_list[i]:get_visible() == true then
max_index = i
break
end
end
end
if new_index < max_index then
new_index = Cur_index + 1
else
new_index = 1
end
if new_index ~= Cur_index then
powers_main_set_highlight(new_list, new_index)
end
ui_audio_post_event("ui_powers_menu_nav")
else
if Popup_is_rad_power then
if Rad_powers_list[Cur_index].popup_position == POWERS_SCREEN_STATE_UPGRADE then
Rad_powers_list[Cur_index]:set_state_popup(POWERS_SCREEN_STATE_ELEMENT)
else
Rad_powers_list[Cur_index]:set_state_popup(POWERS_SCREEN_STATE_UPGRADE)
end
else
if Alt_powers_list[Cur_index].popup_position == POWERS_SCREEN_STATE_UPGRADE then
Alt_powers_list[Cur_index]:set_state_popup(POWERS_SCREEN_STATE_ELEMENT, true)
else
Alt_powers_list[Cur_index]:set_state_popup(POWERS_SCREEN_STATE_UPGRADE, true)
end
end
game_UI_audio_play("UI_Reward_Store_Menu_Navigation")
end
end
function powers_main_nav_left(event, acceleration)
if Popup_is_active == false then
local new_list = Cur_list
local new_index = Cur_index
if Cur_list == POWERS_TYPE_ALT and Rad_powers_list[1]:get_visible() == true then
new_list = Cur_list - 1
for i = Cur_index, 1, -1 do
if Rad_powers_list[i]:get_visible() == true then
new_index = i
break
end
end
end
if Cur_list == POWERS_TYPE_RAD and Alt_powers_list[1]:get_visible() == true then
new_list = Cur_list + 1
for i = Cur_index, 1, -1 do
if Alt_powers_list[i]:get_visible() == true then
new_index = i
break
end
end
end
if new_list ~= Cur_list or new_index ~= Cur_index then
powers_main_set_highlight(new_list, new_index)
end
end
ui_audio_post_event("ui_powers_menu_nav")
end
function powers_main_nav_right(event, acceleration)
if Popup_is_active == false then
local new_list = Cur_list
local new_index = Cur_index
if Cur_list == POWERS_TYPE_RAD and Alt_powers_list[1]:get_visible() == true then
new_list = Cur_list + 1
for i = Cur_index, 1, -1 do
if Alt_powers_list[i]:get_visible() == true then
new_index = i
break
end
end
end
if Cur_list == POWERS_TYPE_ALT and Rad_powers_list[1]:get_visible() == true then
new_list = Cur_list - 1
for i = Cur_index, 1, -1 do
if Rad_powers_list[i]:get_visible() == true then
new_index = i
break
end
end
end
if new_list ~= Cur_list or new_index ~= Cur_index then
powers_main_set_highlight(new_list, new_index)
end
end
ui_audio_post_event("ui_powers_menu_nav")
end
-----------------
--Mouse Functions
-----------------
function powers_main_add_mouse_inputs()
local priority = 500000
--clear all mouse inputs
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:remove_all()
end
if Hint_bar_mouse_input_tracker ~= nil then
Hint_bar_mouse_input_tracker:remove_all()
end
--rebuild all mouse inputs
Hint_bar:add_mouse_inputs( "powers_main_hint", Hint_bar_mouse_input_tracker, 700000 )
for i = 1, 4 do
if Rad_powers_list[i]:get_visible() then
Mouse_input_tracker:add_mouse_input( "mouse_click", "powers_main_mouse_click", priority, Rad_powers_list[i]:get_mouse_region() )
Mouse_input_tracker:add_mouse_input( "mouse_move", "powers_main_mouse_move", priority, Rad_powers_list[i]:get_mouse_region() )
end
end
for i = 1, 4 do
if Alt_powers_list[i]:get_visible() then
Mouse_input_tracker:add_mouse_input( "mouse_click", "powers_main_mouse_click", priority, Alt_powers_list[i]:get_mouse_region() )
Mouse_input_tracker:add_mouse_input( "mouse_move", "powers_main_mouse_move", priority, Alt_powers_list[i]:get_mouse_region() )
end
end
Mouse_input_tracker:subscribe(true)
Hint_bar_mouse_input_tracker:subscribe(true)
end
function powers_main_add_mouse_inputs_popup(index, alt_power)
--[[
if alt_power and game_unlockable_is_unlocked( "DLC_Preorder_Saints_Wings" ) then
alt_power = false
end
--]]
local priority = 500000
--clear all mouse inputs
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(false)
Mouse_input_tracker:remove_all()
-- Add mouse inputs to all the power categories that aren't currently selected
for i = 1, 4 do
if alt_power then
if Rad_powers_list[i]:get_visible() then
Mouse_input_tracker:add_mouse_input( "mouse_click", "powers_main_mouse_click", priority, Rad_powers_list[i]:get_mouse_region() )
Mouse_input_tracker:add_mouse_input( "mouse_move", "powers_main_mouse_move", priority, Rad_powers_list[i]:get_mouse_region() )
end
if Alt_powers_list[i]:get_visible() and i ~= Cur_index then
Mouse_input_tracker:add_mouse_input( "mouse_click", "powers_main_mouse_click", priority, Alt_powers_list[i]:get_mouse_region() )
Mouse_input_tracker:add_mouse_input( "mouse_move", "powers_main_mouse_move", priority, Alt_powers_list[i]:get_mouse_region() )
end
else
if Rad_powers_list[i]:get_visible() and i ~= Cur_index then
Mouse_input_tracker:add_mouse_input( "mouse_click", "powers_main_mouse_click", priority, Rad_powers_list[i]:get_mouse_region() )
Mouse_input_tracker:add_mouse_input( "mouse_move", "powers_main_mouse_move", priority, Rad_powers_list[i]:get_mouse_region() )
end
if Alt_powers_list[i]:get_visible() then
Mouse_input_tracker:add_mouse_input( "mouse_click", "powers_main_mouse_click", priority, Alt_powers_list[i]:get_mouse_region() )
Mouse_input_tracker:add_mouse_input( "mouse_move", "powers_main_mouse_move", priority, Alt_powers_list[i]:get_mouse_region() )
end
end
end
end
if Hint_bar_mouse_input_tracker ~= nil then
Hint_bar_mouse_input_tracker:remove_all()
end
--rebuild all mouse inputs
Hint_bar:add_mouse_inputs( "powers_main_hint", Hint_bar_mouse_input_tracker, 700000 )
if alt_power then
Mouse_input_tracker:add_mouse_input( "mouse_click", "powers_main_mouse_click", 600000, Alt_powers_list[index].mouse_top_h )
Mouse_input_tracker:add_mouse_input( "mouse_click", "powers_main_mouse_click", 600000, Alt_powers_list[index].mouse_bot_h )
Mouse_input_tracker:add_mouse_input( "mouse_move", "powers_main_mouse_move", 600000, Alt_powers_list[index].mouse_top_h )
Mouse_input_tracker:add_mouse_input( "mouse_move", "powers_main_mouse_move", 600000, Alt_powers_list[index].mouse_bot_h )
else
Mouse_input_tracker:add_mouse_input( "mouse_click", "powers_main_mouse_click", 600000, Rad_powers_list[index].mouse_top_h )
Mouse_input_tracker:add_mouse_input( "mouse_click", "powers_main_mouse_click", 600000, Rad_powers_list[index].mouse_bot_h )
Mouse_input_tracker:add_mouse_input( "mouse_move", "powers_main_mouse_move", 600000, Rad_powers_list[index].mouse_top_h )
Mouse_input_tracker:add_mouse_input( "mouse_move", "powers_main_mouse_move", 600000, Rad_powers_list[index].mouse_bot_h )
end
Mouse_input_tracker:subscribe(true)
Hint_bar_mouse_input_tracker:subscribe(true)
end
function powers_main_mouse_click(event, target_handle)
if Popup_is_active == false then
for i = 1, 4 do
if target_handle == Rad_powers_list[i].bg_off_h then
powers_main_set_highlight(POWERS_TYPE_RAD, i, Popup_is_active)
end
if target_handle == Alt_powers_list[i].bg_off_h then
powers_main_set_highlight(POWERS_TYPE_ALT, i, Popup_is_active)
end
end
else
for i = 1, 4 do
-- If the player has selected an item that is not in the pop up, take them back to the main power screen
if target_handle == Rad_powers_list[i].bg_off_h or target_handle == Alt_powers_list[i].bg_off_h then
-- Back out from the pop up
powers_main_button_b()
--Move the highlight over where the mouse selected
if target_handle == Rad_powers_list[i].bg_off_h then
powers_main_set_highlight(POWERS_TYPE_RAD, i, Popup_is_active)
elseif target_handle == Alt_powers_list[i].bg_off_h then
powers_main_set_highlight(POWERS_TYPE_ALT, i, Popup_is_active)
end
-- We don't want to select the highlighted item so leave this function
return
end
end
end
powers_main_button_a()
end
--used so clicking on hint bar doesnt interfere with power buttons
function powers_main_hint_mouse_click(event, target_handle)
local hint_index = Hint_bar:get_hint_index( target_handle )
if hint_index == 1 then
powers_main_button_b()
end
end
function powers_main_hint_mouse_move(event, target_handle)
Hint_bar:set_highlight(0)
local hint_index = Hint_bar:get_hint_index( target_handle )
if hint_index == 1 then
Hint_bar:set_highlight(hint_index)
end
end
function powers_main_mouse_move(event, target_handle)
if Popup_is_active then
if Popup_is_rad_power then
for i = 1, 4 do
if target_handle == Rad_powers_list[i].mouse_top_h then
Rad_powers_list[i].popup_position = POWERS_SCREEN_STATE_UPGRADE
Rad_powers_list[i]:set_state_popup(POWERS_SCREEN_STATE_UPGRADE)
game_UI_audio_play("UI_Reward_Store_Menu_Navigation")
end
if target_handle == Rad_powers_list[i].mouse_bot_h then
Rad_powers_list[i].popup_position = POWERS_SCREEN_STATE_ELEMENT
Rad_powers_list[i]:set_state_popup(POWERS_SCREEN_STATE_ELEMENT)
game_UI_audio_play("UI_Reward_Store_Menu_Navigation")
--powers_main_set_highlight(POWERS_TYPE_RAD, i, Popup_is_active)
end
end
else
for i = 1, 4 do
if target_handle == Alt_powers_list[i].mouse_top_h then
Alt_powers_list[i].popup_position = POWERS_SCREEN_STATE_UPGRADE
Alt_powers_list[i]:set_state_popup(POWERS_SCREEN_STATE_UPGRADE, true)
game_UI_audio_play("UI_Reward_Store_Menu_Navigation")
end
if target_handle == Alt_powers_list[i].mouse_bot_h then
Alt_powers_list[i].popup_position = POWERS_SCREEN_STATE_ELEMENT
Alt_powers_list[i]:set_state_popup(POWERS_SCREEN_STATE_ELEMENT, true)
game_UI_audio_play("UI_Reward_Store_Menu_Navigation")
--powers_main_set_highlight(POWERS_TYPE_RAD, i, Popup_is_active)
end
end
end
else
for i = 1, 4 do
if target_handle == Rad_powers_list[i].bg_off_h then
powers_main_set_highlight(POWERS_TYPE_RAD, i, Popup_is_active)
ui_audio_post_event("ui_powers_menu_nav")
end
if target_handle == Alt_powers_list[i].bg_off_h then
powers_main_set_highlight(POWERS_TYPE_ALT, i, Popup_is_active)
ui_audio_post_event("ui_powers_menu_nav")
end
end
end
end