--ENUMS
--Screen types... Wave, win or fail...
local HORDE_SCREEN_TYPE_WAVE = 0
local HORDE_SCREEN_TYPE_WIN = 1
local HORDE_SCREEN_TYPE_FAIL = 2
local HMEA_RETRY = 0
local HMEA_NEW = 1
local HMEA_QUIT = 2
--Player ids...
local PLAYER_1_ID = 0
local PLAYER_2_ID = 1
--Menu ids...
local MENU_ID_CONTINUE = 1
local MENU_ID_NEW_GAME = 2
local MENU_ID_QUIT = 3
--Constants
local WAVE_SCREEN_TIME = 8 -- Displays for Eight seconds on the screen...
--Internal name is on left, bitmap on right.
local HORDE_PLAYER_IMAGES = {
["Bobert"] = "ui_whored_bobert",
["Cowgirl"] = "ui_whored_cowgirl",
["Cyril"] = "ui_whored_cyril",
["Gimpy"] = "ui_whored_gimpy",
["Super"] = "ui_whored_super",
}
local Screen_animated_in = false
local Horde_results_doc_h = -1
--Global Vdo's
local Input_tracker
local Mouse_input_tracker = 0
local Mega_list
Horde_results_disconnect_dialog_handle = 0
-- for host when players win...
Horde_host_list = {
[1] = {
type = TYPE_BUTTON,
label = "HORDE_MODE_MENU_NEW_GAME",
id = MENU_ID_NEW_GAME,
},
[2] = {
type = TYPE_BUTTON,
label = "HORDE_MODE_MENU_EXIT",
id = MENU_ID_QUIT,
}
}
-- for host when players fail...
Horde_host_fail_list = {
[1] = {
type = TYPE_BUTTON,
label = "HORDE_MODE_MENU_RETRY",
id = MENU_ID_CONTINUE,
},
[2] = {
type = TYPE_BUTTON,
label = "HORDE_MODE_MENU_NEW_GAME",
id = MENU_ID_NEW_GAME,
},
[3] = {
type = TYPE_BUTTON,
label = "HORDE_MODE_MENU_EXIT",
id = MENU_ID_QUIT,
}
}
Horde_wave_end_audio = -1
function horde_results_init()
Horde_results_doc_h = vint_document_find("horde_results")
bg_saints_show(true)
--init megalist...
Mega_list = Vdo_mega_list:new("megalist")
Input_tracker = Vdo_input_tracker:new()
-- Add mouse inputs for the PC
if game_get_platform() == "PC" then
Mouse_input_tracker = Vdo_input_tracker:new()
Mouse_input_tracker:subscribe(false)
end
--hide screen group... will fade in via animation...
local screen_grp_h = vint_object_find("screen_grp")
vint_set_property(screen_grp_h, "alpha", 0)
Horde_wave_end_audio = audio_object_post_event("ui_whr_wave_end")
if vint_is_std_res() then
bg_saints_set_type(BG_TYPE_DEFAULT, false, 1280, 0)
else
bg_saints_set_type(BG_TYPE_DEFAULT, false)
end
bg_saints_set_background(false)
--set and resize headers if necessary
local scores_header_grp_h = vint_object_find("scores_header_grp")
local kills_header_h = vint_object_find("kills_txt", scores_header_grp_h)
local time_header_h = vint_object_find("time_txt", scores_header_grp_h)
vint_set_property(kills_header_h,"text_tag", "HORDE_MODE_TITLE_KILLS")
vint_set_property(time_header_h,"text_tag", "HORDE_MODE_TITLE_SURVIVAL_TIME")
local KILLS_MAX_WIDTH = 120
local TIME_MAX_WIDTH = 215
local kills_width, kills_height = element_get_actual_size(kills_header_h)
local time_width, time_height = element_get_actual_size(time_header_h)
if kills_width > KILLS_MAX_WIDTH then
local text_scale = KILLS_MAX_WIDTH/kills_width
vint_set_property(kills_header_h, "scale", text_scale,1)
end
if time_width > TIME_MAX_WIDTH then
local text_scale = TIME_MAX_WIDTH/time_width
vint_set_property(time_header_h, "scale", text_scale,1)
end
--do data responder...
vint_dataresponder_request("horde_results_populate", "horde_results_populate", 0)
--fake populate... for testing :)
--horde_results_populate(HORDE_SCREEN_TYPE_FAIL, 10, "EXCELLENT WAVE", "You might want to try something special next time. It is the only way.", 20000, 40000, "Zimos", "James Designer", 200, 500000, .5, "Zimos", "Joe Mazooola", 400, 520000, .6)
--horde_results_populate(HORDE_SCREEN_TYPE_FAIL, 12, "EXCELLENT WAVE", "You might want to try something special next time. It is the only way.", 300000, 120000, "Zimos", "James Designer", 200, 500000, .5, "Zimos", "Joe Mazooola", 400, 520000, .6)
--horde_results_populate(HORDE_SCREEN_TYPE_WAVE, 12, "DUMBASS WAVE", "You might want to try something special next time. It is the only way.", 300000, 120000, "Bobert", "James Designer", 200, 500000, .5, "Super", "Joe Mazooola", 400, 520000, 1)
end
function horde_results_cleanup()
audio_stop(Horde_wave_end_audio)
end
function horde_results_populate(type, wave_num, wave_title, wave_failure_text, score, previous_high_score, local_player_character, local_player_name, local_player_kills, local_player_survival_time_ms, local_player_wave_progress, remote_player_character, remote_player_name, remote_player_kills, remote_player_survival_time_ms, remote_player_wave_progress)
--Do titles...
local title_grp_h = vint_object_find("title_grp")
local title_wave_txt_h = vint_object_find("title_wave_txt", title_grp_h)
local title_result_txt_h = vint_object_find("title_result_txt", title_grp_h)
local title_game_txt_h = vint_object_find("title_game_txt", title_grp_h)
--figure out how to display each title... depending on type and final wave...
local title_wave_combined_txt = ""
local values = {[0] = wave_num + 1}
title_wave_combined_txt = vint_insert_values_in_string("COOP_LOBBY_WAVE", values)
local result_txt = ""
local result_color = {148/255,0,197/255}
if type == HORDE_SCREEN_TYPE_WAVE then
result_txt = "COMPLETION_COMPLETE"
elseif type == HORDE_SCREEN_TYPE_WIN then
result_txt = "COMPLETION_COMPLETE"
title_wave_combined_txt = ""
elseif type == HORDE_SCREEN_TYPE_FAIL then
result_txt = "COMPLETION_FAILED"
result_color = {225/255, 42/255, 1/255}
end
vint_set_property(title_wave_txt_h, "text_tag", title_wave_combined_txt) --"WAVE 10"
vint_set_property(title_result_txt_h, "text_tag", result_txt) --"COMPLETE"
vint_set_property(title_game_txt_h, "text_tag", wave_title) --"ZOMBIE FISTING"
vint_set_property(title_result_txt_h, "tint", result_color[1], result_color[2], result_color[3])
--Reposition result text
local x, y = vint_get_property(title_wave_txt_h, "anchor")
local width, height = element_get_actual_size(title_wave_txt_h)
if type ~= HORDE_SCREEN_TYPE_WIN then
x = x + width + 10
else
end
vint_set_property(title_result_txt_h, "anchor", x, y)
--setup data...
local player_local = {}
player_local.name = local_player_name
player_local.kills = local_player_kills
player_local.time = local_player_survival_time_ms
player_local.character = local_player_character
player_local.progress = local_player_wave_progress
local player_remote = {}
player_remote.name = remote_player_name
player_remote.kills = remote_player_kills
player_remote.time = remote_player_survival_time_ms
player_remote.character = remote_player_character
player_remote.progress = remote_player_wave_progress
local data = {}
data[1] = player_local
if remote_player_name ~= "" then
data[2] = player_remote
end
local player_grp_h = vint_object_find("player_grp")
-- store sizes about progress bar...
local progress_bg_h = vint_object_find("progress_bg", player_grp_h)
local progress_base_width, progress_base_height = element_get_actual_size(progress_bg_h)
for idx, player_data in pairs(data) do
local base_h
if idx == 1 then
base_h = player_grp_h
else
base_h = vint_object_clone(player_grp_h)
--position
local x, y = vint_get_property(base_h, "anchor")
vint_set_property(base_h, "anchor", x, y + 100)
vint_set_property(base_h, "depth", idx)
end
local name_txt_h = vint_object_find("name_txt", base_h)
local kills_txt_h = vint_object_find("kills_txt", base_h)
local time_txt_h = vint_object_find("time_txt", base_h)
local player_img_h = vint_object_find("player_img", base_h)
--set text files...
vint_set_property(name_txt_h, "text_tag", player_data.name )
vint_set_property(kills_txt_h, "text_tag", format_cash(player_data.kills) )
local time_in_seconds = abs(player_data.time / 1000)
if time_in_seconds < 60 then
vint_set_property(time_txt_h, "text_tag", ":".. format_time(player_data.time / 1000, false, false) )
else
vint_set_property(time_txt_h, "text_tag", format_time(player_data.time / 1000, false, false) )
end
-- set image based on character info......
local image = HORDE_PLAYER_IMAGES[player_data.character]
image = image or "ui_homie_zimos"
vint_set_property(player_img_h, "image", image)
--Set player progress data...
local progress_bg_h = vint_object_find("progress_bg", base_h)
local progress_img_h = vint_object_find("progress_img", base_h)
local progress_anim_h = vint_object_find("progress_anim", 0, Horde_results_doc_h)
if player_data.progress == 1 then
--full progress
--reset bar to full size...
element_set_actual_size(progress_bg_h, progress_base_width, progress_base_height)
--no icon...
vint_set_property( progress_img_h, "visible", false)
--animate
lua_play_anim(progress_anim_h)
else
--set bar bar to full size...
local width = progress_base_width * player_data.progress
element_set_actual_size(progress_bg_h, progress_base_width, progress_base_height)
--element_set_actual_size(progress_bg_h, width, progress_base_height)
--position end icon...
local progress_img_twn_h = vint_object_find("progress_img_twn", 0, Horde_results_doc_h)
local progress_bg_twn_h = vint_object_find("progress_bg_twn", 0, Horde_results_doc_h)
local x, y = vint_get_property(progress_img_h, "anchor")
x = width
vint_set_property(progress_img_twn_h,"end_value", x, y)
vint_set_property(progress_bg_twn_h,"end_value", x, y)
--vint_set_property(progress_img_h, "anchor", x, y)
vint_set_property( progress_img_h, "visible", true)
--animate
lua_play_anim(progress_anim_h)
end
local shadow = Vdo_shadow:new("shadow", base_h)
shadow:set_props(815,82, false, 20)
end
--score, previous_high_score
--Do scores now...
local total_score_grp_h = vint_object_find("total_score_grp")
--local wave_fail_grp_h = vint_object_find("wave_fail_grp")
--local wave_failure_txt_h = vint_object_find("wave_failure_txt_h")
--vint_set_property(wave_failure_txt_h, "text_tag", "This is hello")
--TODO: SET POSITION OF SCORES...
--vint_set_property(total_score_grp_h, "anchor",)
--set crown image
local winner_bmp_h = vint_object_find("winner_bmp")
if remote_player_name ~= "" then
vint_set_property(winner_bmp_h, "visible", true)
else
vint_set_property(winner_bmp_h, "visible", false)
end
--Set score...
local score_value_txt_h = vint_object_find("score_value_txt", total_score_grp_h)
local score_high_value_txt_h = vint_object_find("score_high_value_txt", total_score_grp_h)
local score_high_title_txt_h = vint_object_find("score_high_title_txt", total_score_grp_h)
vint_set_property(score_value_txt_h, "text_tag", format_cash(score))
--Check to see if we broke a previous high score...
if score > previous_high_score then
--NEW HIGHSCORE...
vint_set_property(score_high_value_txt_h, "text_tag", format_cash(score))
vint_set_property(score_high_title_txt_h, "text_tag", "HORDE_MODE_TITLE_HIGHSCORE_NEW")
vint_set_property(score_high_title_txt_h, "tint", 148/255, 0/255, 197/255)
else
vint_set_property(score_high_value_txt_h, "text_tag", format_cash(previous_high_score))
vint_set_property(score_high_title_txt_h, "text_tag", "HORDE_MODE_TITLE_HIGHSCORE")
vint_set_property(score_high_title_txt_h, "tint", 153/255, 153/255, 153/255)
end
-- Only show options if we are in a win or fail screen...
local waiting_for_coop_grp_h = vint_object_find("waiting_for_coop_grp")
if ( type == HORDE_SCREEN_TYPE_WIN or type == HORDE_SCREEN_TYPE_FAIL ) then
if not game_get_is_host() then
--Coop players screen...
vint_set_property(waiting_for_coop_grp_h, "visible", true)
Mega_list:set_visible(false)
-- do coop player inputs...
Input_tracker:add_input("map", "horde_results_input_coop_back")
Input_tracker:add_input("pause", "horde_results_input_nothing", 50)
else
--Host players screen... this is the same even if we aren't in coop...
vint_set_property(waiting_for_coop_grp_h, "visible", false)
--Use the appropriate list options...
local mega_list_data = Horde_host_fail_list
if type == HORDE_SCREEN_TYPE_WIN then
mega_list_data = Horde_host_list
end
Mega_list:draw_items(mega_list_data, 1, 815)
Mega_list:set_highlight_color(COLOR_STORE_REWARDS_PRIMARY, COLOR_STORE_REWARDS_SECONDARY)
--subscribe to inputs...
Input_tracker:add_input("select", "horde_results_input_a", 50)
Input_tracker:add_input("back", "horde_results_input_nothing", 50)
Input_tracker:add_input("nav_up", "horde_results_nav_up", 50)
Input_tracker:add_input("nav_down", "horde_results_nav_down", 50)
Input_tracker:add_input("nav_left", "horde_results_input_nothing", 50)
Input_tracker:add_input("nav_right", "horde_results_input_nothing", 50)
Input_tracker:add_input("map", "horde_results_input_nothing")
Input_tracker:add_input("pause", "horde_results_input_a", 50)
if Mouse_input_tracker ~= 0 then
Mouse_input_tracker:remove_all()
Mega_list:add_mouse_inputs("horde_results", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
end
end
else
Input_tracker:add_input("map", "horde_results_input_nothing")
Input_tracker:add_input("pause", "horde_results_input_nothing", 50)
--wave mode...
vint_set_property(waiting_for_coop_grp_h, "visible", false)
Mega_list:set_visible(false)
--delay the animation of the screen out...
horde_results_animate_out(WAVE_SCREEN_TIME)
end
--Animate screen in...
horde_results_animate_in()
Input_tracker:subscribe(true)
end
--------------------------------------------------------------------------------
-- Host input...
--------------------------------------------------------------------------------
function horde_results_input_a()
if Screen_animated_in == false then
return
end
--make selection on current megalist...
local id = Mega_list:get_id()
if id == MENU_ID_CONTINUE then
--Continue/restart from last wave...
horde_results_set_end_action(HMEA_RETRY)
horde_results_exit()
elseif id == MENU_ID_NEW_GAME then
--State new game...
horde_results_set_end_action(HMEA_NEW)
horde_results_exit()
elseif id == MENU_ID_QUIT then
--Quit game
audio_object_post_event("ui_whr_quit_gameplay")
horde_results_set_end_action(HMEA_QUIT)
horde_results_exit()
end
end
function horde_results_nav_up()
if Screen_animated_in == false then
return
end
Mega_list:move_cursor(-1)
end
function horde_results_nav_down()
if Screen_animated_in == false then
return
end
Mega_list:move_cursor(1)
end
function horde_results_input_nothing()
--do nothing...
end
--------------------------------------------------------------------------------
-- Coop player input...
--------------------------------------------------------------------------------
function horde_results_input_coop_back()
local options = { [0] = "CONTROL_YES", [1] = "CONTROL_NO" }
Horde_results_disconnect_dialog_handle = dialog_box_open("MENU_TITLE_WARNING", "DIALOG_PAUSE_DISCONNECT_PROMPT", options, "horde_results_coop_disconnect", 1, DIALOG_PRIORITY_SYSTEM_CRITICAL, true, nil, false, false)
end
-------------------------------------------------------------------------------
-- When the coop disconnect dialog closes... this is called.
--
function horde_results_coop_disconnect(result, action)
--They selected yes...
if result == 0 then
dialog_box_disconnect()
end
Horde_results_disconnect_dialog_handle = 0
end
-------------------------------------------------------------------------------
-- animates the screen in...
-------------------------------------------------------------------------------
function horde_results_animate_in()
--animate in...
bg_saints_slide_in()
local screen_grp_h = vint_object_find("screen_grp")
vint_set_property(screen_grp_h, "alpha", 1)
local screen_slide_in_anim_h = vint_object_find("screen_slide_in_anim", 0, Horde_results_doc_h)
local screen_slide_in_twn_h = vint_object_find("screen_slide_in_twn", screen_slide_in_anim_h)
vint_set_property(screen_slide_in_twn_h, "end_event", "horde_results_anim_in_cb")
lua_play_anim(screen_slide_in_anim_h)
end
function horde_results_anim_in_cb()
--subscribe to registered inputs...
Screen_animated_in = true
end
-------------------------------------------------------------------------------
-- animates the screen out...
-- @param time time in seconds you want to fade out...
-------------------------------------------------------------------------------
function horde_results_animate_out(time)
--animate out...
local screen_slide_out_anim_h = vint_object_find("screen_slide_out_anim", 0, Horde_results_doc_h)
local screen_slide_out_twn_h = vint_object_find("screen_slide_out_twn", screen_slide_out_anim_h)
vint_set_property(screen_slide_out_twn_h, "start_event", "horde_results_bg_slide_out")
vint_set_property(screen_slide_out_twn_h, "end_event", "horde_results_anim_out_cb")
lua_play_anim(screen_slide_out_anim_h, time)
end
--slides out the bg_saints once the screen animation actually kicks off
function horde_results_bg_slide_out()
bg_saints_slide_out(1300)
end
function horde_results_anim_out_cb()
horde_results_exit()
end
-------------------------------------------------------------------------------
-- Exits whored mode...
-------------------------------------------------------------------------------
function horde_results_exit()
--unload screen...
-- local horde_results_h = vint_document_find("horde_results")
-- vint_document_unload(horde_results_h)
pop_screen()
end
-------------------------------------------------------------------------------
-- Mouse inputs
function horde_results_mouse_click(event, target_handle, mouse_x, mouse_y)
local new_index = Mega_list:get_button_index(target_handle)
if new_index ~= 0 then
Mega_list:set_selection(new_index)
horde_results_input_a()
end
end
function horde_results_mouse_move(event, target_handle)
local new_index = Mega_list:get_button_index(target_handle)
if new_index ~= 0 then
Mega_list:set_selection(new_index)
Mega_list:move_cursor(0, true)
end
end
function horde_results_mouse_drag(event, target_handle, mouse_x, mouse_y)
end
function horde_results_mouse_drag_release(event, target_handle, mouse_x, mouse_y)
end