-- enums
local CAMSUR_RETRY = 0
local CAMSUR_QUIT = 1
--Global Vdo's
local Input_tracker
local Mouse_input_tracker = 0
local Mega_list
local MENU_ID_PLAY_AGAIN = 1
local MENU_ID_STOP = 2
local MENU_ID_CONTINUE = 3
-- Scoring types
local SCORE_TYPE_POINTS = 0
local SCORE_TYPE_KILLS = 1
local DIV_TYPE_DEATHTAG = 0
local DIV_TYPE_CAT_MOUSE = 1
local DIV_TYPE_SURVIVAL = 2
local STATUS_TYPE_WIN = 0
local STATUS_TYPE_LOSE = 1
local STATUS_TYPE_TIE = 2
-- Host list data...
Cat_mouse_host_list = {
[1] = {
type = TYPE_BUTTON,
label = "CAT_MOUSE_PLAY_AGAIN",
id = MENU_ID_PLAY_AGAIN,
},
[2] = {
type = TYPE_BUTTON,
label = "CAT_MOUSE_QUIT_DIVERSION",
id = MENU_ID_STOP,
}
}
-- Host list data...
Cat_mouse_client_list = {
[1] = {
type = TYPE_BUTTON,
label = "COMPLETION_CONTINUE",
id = MENU_ID_CONTINUE,
},
}
function cat_mouse_results_init()
--init megalist...
Mega_list = Vdo_mega_list:new("megalist")
Input_tracker = Vdo_input_tracker:new()
--Set background type of bg_saints...
bg_saints_set_type(BG_TYPE_COMPLETION)
vint_dataresponder_request("cat_mouse_results_populate", "cat_mouse_results_populate", 0, 0)
--cat_mouse_results_populate(DIV_TYPE_CAT_MOUSE, STATUS_TYPE_WIN, true, SCORE_TYPE_POINTS, "HARRIS", 4000, "MASTER", 3000, 4000)
end
function cat_mouse_results_cleanup()
if Mouse_input_tracker ~= 0 then
Mouse_input_tracker:subscribe(false)
end
Input_tracker:subscribe(false)
end
-- @param diversion_type Diversion type (0 = Death Tag, 1 = Cat & Mouse, 2 = Co-op Survival)
-- @param win_status Win status (0 = Win, 1 = Lose, 2 = Tie)
-- @param is_host Am I the host? (used for determining whether or not to let the player "retry")
-- @param points_type Points type (0 = Points, 1 = Kills)
-- @param my_name My name
-- @param my_points My points
-- @param enemy_name Partner's name
-- @param enemy_points Partner's points
-- @param reward Reward
function cat_mouse_results_populate(diversion_type, win_status, is_host, points_type, my_name, my_points, enemy_name, enemy_points, reward)
--Set Screen Title
local diversion_titles = {
[DIV_TYPE_DEATHTAG] = "DIVERSION_COOP_DEATH_TAG_TITLE", --Death Tag
[DIV_TYPE_CAT_MOUSE] = "DIVERSION_COOP_CAT_AND_MOUSE_TITLE", --Cat And Mouse
[DIV_TYPE_SURVIVAL] = "DIVERSION_COOP_SURVIVAL_TITLE", --Survival
}
local title_string = diversion_titles[diversion_type]
local title_game_h = vint_object_find("title_game_txt")
vint_set_property(title_game_h, "text_tag", title_string)
--Win Status
local status_titles = {
[STATUS_TYPE_WIN] = "MP_WINNERS_YOU_WIN", --You Win
[STATUS_TYPE_LOSE] = "MP_WINNERS_YOU_LOSE", --You Lose
[STATUS_TYPE_TIE] = "MP_WINNERS_TIE" --Tie
}
local status_string = status_titles[win_status]
local title_status_h = vint_object_find("title_status_txt")
vint_set_property(title_status_h, "text_tag", status_string)
if win_status == STATUS_TYPE_LOSE then
vint_set_property(title_status_h, "tint", 0.666, 0, 0.004)
elseif win_status == STATUS_TYPE_TIE then
vint_set_property(title_status_h, "tint", 0.623, 0.635, 0.644)
end
--Show Scores
--Determine winner position
local winner_name = my_name
local winner_points = my_points
local loser_name = my_name
local loser_points = my_points
if my_points >= enemy_points then
-- Host is winner
loser_name = enemy_name
loser_points = enemy_points
else
winner_name = enemy_name
winner_points = enemy_points
end
--Winner
local score_winner_label_txt_h = vint_object_find("score_winner_label_txt")
local score_winner_value_txt_h = vint_object_find("score_winner_value_txt")
vint_set_property(score_winner_label_txt_h, "text_tag", winner_name)
vint_set_property(score_winner_value_txt_h, "text_tag", format_cash(winner_points))
--Loser
local score_loser_label_txt_h = vint_object_find("score_loser_label_txt")
local score_loser_value_txt_h = vint_object_find("score_loser_value_txt")
vint_set_property(score_loser_label_txt_h, "text_tag", loser_name)
vint_set_property(score_loser_value_txt_h, "text_tag", format_cash(loser_points))
--Set points Description string for scores
local points_string = ""
if points_type == SCORE_TYPE_POINTS then
points_string = "HUD_DIVERSION_POINTS"
elseif points_type == SCORE_TYPE_KILLS then
points_string = "MULTI_MENU_STATS_KILLS"
end
local score_loser_type_txt_h = vint_object_find("score_loser_type_txt")
local score_winner_type_txt_h = vint_object_find("score_winner_type_txt")
vint_set_property(score_loser_type_txt_h, "text_tag", points_string)
vint_set_property(score_winner_type_txt_h, "text_tag", points_string)
--Move points to align with scores...
local winner_val_x, winner_val_y = vint_get_property(score_winner_value_txt_h, "anchor")
local loser_val_x, loser_val_y = vint_get_property(score_loser_value_txt_h, "anchor")
local winner_val_width, winner_val_height = element_get_actual_size(score_winner_value_txt_h)
local loser_val_width, loser_val_height = element_get_actual_size(score_loser_value_txt_h)
local x, y = vint_get_property(score_winner_type_txt_h, "anchor")
vint_set_property(score_winner_type_txt_h, "anchor", winner_val_x + winner_val_width + 10, y)
x, y = vint_get_property(score_loser_type_txt_h, "anchor")
vint_set_property(score_loser_type_txt_h, "anchor", loser_val_x + loser_val_width + 10, y)
--My Reward
local award_grp_h = vint_object_find("award_grp")
local cash_award_value_txt_h = vint_object_find("cash_award_value_txt")
if reward > 0 then
vint_set_property(cash_award_value_txt_h, "text_tag", "$" .. format_cash(reward))
else
vint_set_property(award_grp_h, "visible", false)
end
-- List data is different if we are the host or client...
local list_data = Cat_mouse_host_list
if is_host == false then
list_data = Cat_mouse_client_list
end
Mega_list:set_highlight_color(COLOR_STORE_REWARDS_PRIMARY, COLOR_STORE_REWARDS_SECONDARY, COLOR_STORE_REWARDS_TERTIARY)
Mega_list:draw_items(list_data, 1, 430)
--TODO: Play any Animations here...
Input_tracker:add_input("nav_up", "cat_mouse_results_input", 50)
Input_tracker:add_input("nav_down", "cat_mouse_results_input", 50)
Input_tracker:add_input("select", "cat_mouse_results_input", 50)
Input_tracker:add_input("back", "cat_mouse_results_input", 50)
Input_tracker:subscribe(true)
if game_get_platform() == "PC" then
Mouse_input_tracker = Vdo_input_tracker:new()
Mega_list:add_mouse_inputs("cat_mouse_results", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
end
end
function cat_mouse_results_input(event)
if event == "select" then
--Select item from list and do it
local id = Mega_list:get_id()
if id == MENU_ID_PLAY_AGAIN or id == MENU_ID_CONTINUE then
--select continue
cat_mouse_results_select(CAMSUR_RETRY)
elseif id == MENU_ID_STOP then
cat_mouse_results_select(CAMSUR_QUIT)
end
pop_screen()
elseif event == "back" then
cat_mouse_results_select(CAMSUR_QUIT)
pop_screen()
elseif event == "nav_up" then
Mega_list:move_cursor(-1)
elseif event == "nav_down" then
Mega_list:move_cursor(1)
end
end
-------------------------------------------------------------------------------
-- Mouse Inputs
--
function cat_mouse_results_mouse_click(event, target_handle)
-- If the target_handle matches a button, activate it
local new_index = Mega_list:get_button_index(target_handle)
if new_index ~= 0 then
-- Enter an option if the target_handle is in the List
Mega_list:set_selection(new_index)
cat_mouse_results_input("select")
end
end
function cat_mouse_results_mouse_move(event, target_handle)
local new_index = Mega_list:get_button_index(target_handle)
if new_index ~= 0 then
-- Set the button as the new selected highlight
Mega_list:set_selection(new_index)
Mega_list:move_cursor(0, true)
end
end
function cat_mouse_results_mouse_scroll(event, target_handle, mouse_x, mouse_y, scroll_lines)
end
function cat_mouse_results_mouse_drag(event, target_handle, mouse_x, mouse_y)
end
function cat_mouse_results_drag_release(event, target_handle, mouse_x, mouse_y)
end