./msn_redbox.lua

  1.  
  2. local Errors = {} 
  3. local Msn_redbox_doc_h = vint_document_find("msn_redbox") 
  4.  
  5. local Sr_grp_h 
  6. local Error_grp_h 
  7. local Redbox_grp_h 
  8. local Highlight_h 
  9.  
  10. local Input_tracker = {} 
  11. local Mouse_input_tracker 
  12.  
  13. local continue_hint_data = { 
  14. 	{CTRL_MENU_BUTTON_A, ""}, 
  15. } 
  16.   
  17. function msn_redbox_init() 
  18. 	Sr_grp_h = vint_object_find("sr_grp", 0, Msn_redbox_doc_h) 
  19. 	Error_grp_h = vint_object_find("error_grp", 0, Msn_redbox_doc_h) 
  20. 	Redbox_grp_h = vint_object_find("redbox_grp", 0, Msn_redbox_doc_h) 
  21. 	Highlight_h = vint_object_find("highlight", 0, Msn_redbox_doc_h) 
  22. 	vint_set_property(Sr_grp_h, "visible", false) 
  23. 	vint_set_property(Error_grp_h, "visible", true) 
  24. 	vint_set_property(Redbox_grp_h, "visible", true) 
  25. 	 
  26. 	 
  27. 	for i=1,8 do 
  28. 		Errors[i] = vint_object_find("error_txt_"..i, 0, Msn_redbox_doc_h)  
  29. 		vint_set_property(Errors[i], "visible", false) 
  30. 	end 
  31. 	 
  32. 	vint_set_glitch_preset("hub") 
  33. 	vint_spike_glitch( 10, 0 ) 
  34. 	 
  35. 	--input 
  36. 	Input_tracker = Vdo_input_tracker:new() 
  37. 	Input_tracker:add_input("select", "msn_redbox_input", 200) 
  38. 	Input_tracker:add_input("alt_select", 	"msn_redbox_input", 200) 
  39. 	Input_tracker:add_input("map", 			"msn_redbox_input", 200) 
  40. 	Input_tracker:add_input("pause", 		"msn_redbox_input", 200) 
  41. 	Input_tracker:add_input("back", 			"msn_redbox_input", 200) 
  42. 	 
  43. 	if game_get_platform() == "PC" then 
  44. 		local mouse_region_h = vint_object_find("mouse_region", 0, Msn_redbox_doc_h) 
  45. 		Mouse_input_tracker = Vdo_input_tracker:new() 
  46. 		Mouse_input_tracker:add_mouse_input("mouse_move", "msn_redbox_mouse_move", 0, mouse_region_h) 
  47. 		Mouse_input_tracker:add_mouse_input("mouse_click", "msn_redbox_mouse_click", 0, mouse_region_h) 
  48. 	end 
  49. 	 
  50. 	--hintbar 
  51. 	local redbox_hint_bar = Vdo_hint_bar:new("hint_bar") 
  52. 	redbox_hint_bar:set_hints(continue_hint_data) 
  53. 	 
  54. 	thread_new( "msn_redbox_load_assets" ) 
  55. 	thread_new( "msn_redbox_fill_with_errors" ) 
  56. end 
  57.  
  58.  
  59. function msn_redbox_load_assets() 
  60. 	pause_map_dump( true ) 
  61. 	game_peg_load_with_cb("msn_redbox_peg_loaded", 1, "ui_msn_redbox_sr") 
  62. end 
  63.  
  64. function msn_redbox_peg_loaded() 
  65. 	local sr_bg_h = vint_object_find("sr_bg", 0, Msn_redbox_doc_h) 
  66. 	vint_set_property(sr_bg_h, "image", "ui_msn_redbox_sr") 
  67. end 
  68.  
  69. function msn_redbox_fill_with_errors() 
  70. 	delay(1) 
  71. 	vint_set_property(Errors[1], "visible", true) 
  72. 	delay(.8) 
  73. 	vint_spike_glitch( .2, 0 ) 
  74. 	vint_set_property(Errors[2], "visible", true) 
  75. 	delay(1.6) 
  76. 	vint_set_property(Errors[3], "visible", true) 
  77. 	delay(.7) 
  78. 	vint_spike_glitch( 20, 0 ) 
  79. 	vint_set_property(Errors[4], "visible", true) 
  80. 	vint_set_property(Errors[5], "visible", true) 
  81. 	delay(.5) 
  82. 	vint_spike_glitch( 5, 0 ) 
  83. 	delay(2.4) 
  84. 	 
  85. 	vint_set_property(Errors[6], "visible", true) 
  86. 	delay(1) 
  87. 	 
  88. 	vint_set_property(Errors[7], "visible", true) 
  89. 	delay(.6) 
  90. 	vint_set_property(Errors[8], "visible", true) 
  91. 	delay(1.1) 
  92. 	vint_spike_glitch( 800, .2 ) 
  93. 	delay(1.2) 
  94. 	msn_redbox_start_sr() 
  95. end 
  96.  
  97. function msn_redbox_start_sr() 
  98. 	vint_set_property(Error_grp_h, "visible", false) 
  99. 	vint_set_property(Redbox_grp_h, "visible", false) 
  100. 	 
  101. 	--insert audio song here 
  102. 	 
  103. 	local highlight_anim_h = vint_object_find("highlight_anim", 0, Msn_redbox_doc_h) 
  104. 	lua_play_anim(highlight_anim_h) 
  105. 	vint_set_property(Sr_grp_h, "visible", true) 
  106. 	Input_tracker:subscribe(true) 
  107. 	if Mouse_input_tracker ~= nil then 
  108. 		Mouse_input_tracker:subscribe(true) 
  109. 	end 
  110. end 
  111.  
  112. function msn_redbox_input() 
  113. 	msn_redbox_unload() 
  114. end 
  115.  
  116. function msn_redbox_unload() 
  117. 	vint_spike_glitch( 200, 0 ) 
  118. 	game_peg_unload_wait("ui_msn_redbox_sr") 
  119. 	pause_map_restore() 
  120. 	pop_screen() 
  121. end 
  122.  
  123. function msn_redbox_cleanup() 
  124. 	Input_tracker:subscribe(false) 
  125. 	if Mouse_input_tracker ~= nil then 
  126. 		Mouse_input_tracker:subscribe(false) 
  127. 	end 
  128. 	vint_spike_glitch( 200, 0 ) 
  129. end 
  130.  
  131. --Mouse functions 
  132.  
  133. function msn_redbox_mouse_click(event, target_handle) 
  134. 	msn_redbox_unload() 
  135. end 
  136.  
  137. function msn_redbox_mouse_move(event, target_handle) 
  138. 	 
  139. end 
  140.  
  141.