local Errors = {}
local Msn_redbox_doc_h = vint_document_find("msn_redbox")
local Sr_grp_h
local Error_grp_h
local Redbox_grp_h
local Highlight_h
local Input_tracker = {}
local Mouse_input_tracker
local continue_hint_data = {
{CTRL_MENU_BUTTON_A, ""},
}
function msn_redbox_init()
Sr_grp_h = vint_object_find("sr_grp", 0, Msn_redbox_doc_h)
Error_grp_h = vint_object_find("error_grp", 0, Msn_redbox_doc_h)
Redbox_grp_h = vint_object_find("redbox_grp", 0, Msn_redbox_doc_h)
Highlight_h = vint_object_find("highlight", 0, Msn_redbox_doc_h)
vint_set_property(Sr_grp_h, "visible", false)
vint_set_property(Error_grp_h, "visible", true)
vint_set_property(Redbox_grp_h, "visible", true)
for i=1,8 do
Errors[i] = vint_object_find("error_txt_"..i, 0, Msn_redbox_doc_h)
vint_set_property(Errors[i], "visible", false)
end
vint_set_glitch_preset("hub")
vint_spike_glitch( 10, 0 )
--input
Input_tracker = Vdo_input_tracker:new()
Input_tracker:add_input("select", "msn_redbox_input", 200)
Input_tracker:add_input("alt_select", "msn_redbox_input", 200)
Input_tracker:add_input("map", "msn_redbox_input", 200)
Input_tracker:add_input("pause", "msn_redbox_input", 200)
Input_tracker:add_input("back", "msn_redbox_input", 200)
if game_get_platform() == "PC" then
local mouse_region_h = vint_object_find("mouse_region", 0, Msn_redbox_doc_h)
Mouse_input_tracker = Vdo_input_tracker:new()
Mouse_input_tracker:add_mouse_input("mouse_move", "msn_redbox_mouse_move", 0, mouse_region_h)
Mouse_input_tracker:add_mouse_input("mouse_click", "msn_redbox_mouse_click", 0, mouse_region_h)
end
--hintbar
local redbox_hint_bar = Vdo_hint_bar:new("hint_bar")
redbox_hint_bar:set_hints(continue_hint_data)
thread_new( "msn_redbox_load_assets" )
thread_new( "msn_redbox_fill_with_errors" )
end
function msn_redbox_load_assets()
pause_map_dump( true )
game_peg_load_with_cb("msn_redbox_peg_loaded", 1, "ui_msn_redbox_sr")
end
function msn_redbox_peg_loaded()
local sr_bg_h = vint_object_find("sr_bg", 0, Msn_redbox_doc_h)
vint_set_property(sr_bg_h, "image", "ui_msn_redbox_sr")
end
function msn_redbox_fill_with_errors()
delay(1)
vint_set_property(Errors[1], "visible", true)
delay(.8)
vint_spike_glitch( .2, 0 )
vint_set_property(Errors[2], "visible", true)
delay(1.6)
vint_set_property(Errors[3], "visible", true)
delay(.7)
vint_spike_glitch( 20, 0 )
vint_set_property(Errors[4], "visible", true)
vint_set_property(Errors[5], "visible", true)
delay(.5)
vint_spike_glitch( 5, 0 )
delay(2.4)
vint_set_property(Errors[6], "visible", true)
delay(1)
vint_set_property(Errors[7], "visible", true)
delay(.6)
vint_set_property(Errors[8], "visible", true)
delay(1.1)
vint_spike_glitch( 800, .2 )
delay(1.2)
msn_redbox_start_sr()
end
function msn_redbox_start_sr()
vint_set_property(Error_grp_h, "visible", false)
vint_set_property(Redbox_grp_h, "visible", false)
--insert audio song here
local highlight_anim_h = vint_object_find("highlight_anim", 0, Msn_redbox_doc_h)
lua_play_anim(highlight_anim_h)
vint_set_property(Sr_grp_h, "visible", true)
Input_tracker:subscribe(true)
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(true)
end
end
function msn_redbox_input()
msn_redbox_unload()
end
function msn_redbox_unload()
vint_spike_glitch( 200, 0 )
game_peg_unload_wait("ui_msn_redbox_sr")
pause_map_restore()
pop_screen()
end
function msn_redbox_cleanup()
Input_tracker:subscribe(false)
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(false)
end
vint_spike_glitch( 200, 0 )
end
--Mouse functions
function msn_redbox_mouse_click(event, target_handle)
msn_redbox_unload()
end
function msn_redbox_mouse_move(event, target_handle)
end