./team_assign.lua

  1. Team_assign_doc_handle = -1 
  2.  
  3. local BEN = 1 
  4. local SHAUNDI_2 = 2 
  5. local SHAUNDI_3 = 3 
  6. local PIERCE = 4 
  7. local LIN = 5 
  8.  
  9. local DISTRACTION = 1 
  10. local INFILTRATION = 2 
  11. local COMMANDER = 3 
  12. local COMBAT = 4 
  13.  
  14. local Input_tracker 
  15. local Hint_bar = -1 
  16.  
  17. local Character_grp_h = -1 
  18. local Character_bio_h = -1 
  19. local Character_name_h = -1 
  20. local Head_h = -1 
  21. local Character_bg_h = -1 
  22.  
  23. local Mission_grp_h = -1 
  24. local Mission_bio_h = -1 
  25. local Mission_name_h = -1 
  26. local Mission_bg_h = -1 
  27.  
  28. local Character_bounce_anim_h = -1 
  29.  
  30. local CHARACTER_DATA = { 
  31. 		[BEN] = 			{head = "ui_homie_35_ben", name = "M22_2_TEAM_BEN_NAME", bio = "M22_2_TEAM_BEN_BIO"}, --SR1 Ben King 
  32. 		[SHAUNDI_2] = 	{head = "ui_homie_35_shaundi", name = "M22_2_TEAM_SHAUNDI_2_NAME", bio = "M22_2_TEAM_SHAUNDI_2_BIO"}, --SR2 Shaundi 
  33. 		[SHAUNDI_3] = 	{head = "ui_homie_shaundi", name = "M22_2_TEAM_SHAUNDI_3_NAME", bio = "M22_2_TEAM_SHAUNDI_3_BIO"}, --SR3 Shaundi 
  34. 		[PIERCE] = 		{head = "ui_homie_pierce", name = "M22_2_TEAM_PIERCE_NAME", bio = "M22_2_TEAM_PIERCE_BIO"}, --SR3 Pierce 
  35. 		[LIN] = 			{head = "ui_homie_35_lin", name = "M22_2_TEAM_LIN_NAME", bio = "M22_2_TEAM_LIN_BIO"}, --SR1 Lin 
  36. 	} 
  37. 	 
  38. local MISSION_DATA = { 
  39. 		[DISTRACTION] = 	{name = "M22_2_TEAM_DISTRACTION_NAME", bio = "M22_2_TEAM_DISTRACTION_BIO"},  
  40. 		[INFILTRATION] = 	{name = "M22_2_TEAM_INFILTRATION_NAME", bio = "M22_2_TEAM_INFILTRATION_BIO"},  
  41. 		[COMMANDER] = 		{name = "M22_2_TEAM_COMMANDER_NAME", bio = "M22_2_TEAM_COMMANDER_BIO"},  
  42. 		[COMBAT] =			{name = "M22_2_TEAM_COMBAT_NAME", bio = "M22_2_TEAM_COMBAT_BIO"}, 
  43. 	} 
  44.  
  45. function team_assign_init() 
  46. 	 
  47. 	Team_assign_doc_handle = vint_document_find("team_assign") 
  48. 	vint_dataitem_add_subscription("team_assign_update", "update", "team_assign_update") 
  49.  
  50. 	Character_grp_h = vint_object_find("character_grp", 0, Team_assign_doc_handle) 
  51. 	Character_bio_h = vint_object_find("character_bio", 0, Team_assign_doc_handle) 
  52. 	Character_name_h = vint_object_find("character_name", 0, Team_assign_doc_handle) 
  53. 	Head_h = vint_object_find("head", 0, Team_assign_doc_handle) 
  54. 	Character_bg_h = vint_object_find("character_bg", 0, Team_assign_doc_handle) 
  55. 	 
  56. 	Mission_grp_h = vint_object_find("mission_grp", 0, Team_assign_doc_handle) 
  57. 	Mission_bio_h = vint_object_find("mission_bio", 0, Team_assign_doc_handle) 
  58. 	Mission_name_h = vint_object_find("mission_name", 0, Team_assign_doc_handle) 
  59. 	Mission_bg_h = vint_object_find("mission_bg", 0, Team_assign_doc_handle) 
  60. 	 
  61. 	Character_bounce_anim_h = vint_object_find("character_bounce_anim") 
  62. 	lua_play_anim(Character_bounce_anim_h) 
  63. 	 
  64. 	--hide character box 
  65. 	vint_set_property(Character_grp_h, "visible", false) 
  66. 	 
  67. 	--hide mission box 
  68. 	vint_set_property(Mission_grp_h, "visible", false) 
  69. 	 
  70. end 
  71.  
  72. function team_assign_resize_text_element(element_h, max_width) 
  73. 	vint_set_property(element_h, "scale", 1, 1) 
  74. 	local text_width, text_height = element_get_actual_size(element_h)	 
  75. 	 
  76. 			debug_print("vint", "text_width: " .. text_width .. "\n") 
  77. 	if text_width > max_width then 
  78. 		local text_scale = max_width/text_width 
  79. 		debug_print("vint", "max width: " .. max_width .. "\n") 
  80. 		vint_set_property(element_h, "scale", text_scale, text_scale) 
  81. 	end 
  82. end 
  83.  
  84.  
  85. function team_assign_update(di_h) 
  86. 	local character, is_visible, mission = vint_dataitem_get(di_h) 
  87. 	--[[is_visible = true 
  88. 	character = 1 
  89. 	mission = 1]] 
  90. 	 
  91. 	--Populate with data 
  92. 	if (mission > 0) then 
  93. 		vint_set_property(Mission_name_h, "text_tag", MISSION_DATA[mission].name) 
  94. 		 
  95. 		--acount for long text 
  96. 		team_assign_resize_text_element(Mission_name_h, 297) 
  97. 		 
  98. 		vint_set_property(Mission_bio_h, "text_tag", MISSION_DATA[mission].bio) 
  99. 		 
  100. 		--show mission box 
  101. 		vint_set_property(Mission_grp_h, "visible", true) 
  102. 	else  
  103. 		--hide the mission box 
  104. 		vint_set_property(Mission_grp_h, "visible", false)		 
  105. 	end 
  106. 	 
  107. 	--arrange mission box 
  108. 	local mission_bg_width, mission_bg_height = element_get_actual_size(Mission_bg_h) 
  109. 	local mission_bio_width, mission_bio_height = element_get_actual_size(Mission_bio_h) 
  110. 	local mission_bg_new_height = mission_bio_height + 69 
  111. 	 
  112. 	element_set_actual_size(Mission_bg_h, mission_bg_width, mission_bg_new_height) 
  113. 	 
  114. 	if is_visible == true then 
  115.  
  116. 		--Arrange character box to be below mission box 
  117. 		local character_grp_x, character_grp_y = vint_get_property(Character_grp_h, "anchor") 
  118. 		local mission_grp_x, mission_grp_y = vint_get_property(Mission_grp_h, "anchor") 
  119. 		local character_grp_new_y = mission_bg_new_height + mission_grp_y + 25 --25 is padding 
  120. 		vint_set_property(Character_grp_h, "anchor", character_grp_x, character_grp_new_y) 
  121. 		 
  122. 		--Populate with data 
  123. 		vint_set_property(Head_h, "image", CHARACTER_DATA[character].head) 
  124. 		vint_set_property(Character_name_h, "text_tag", CHARACTER_DATA[character].name) 
  125. 		vint_set_property(Character_bio_h, "text_tag", CHARACTER_DATA[character].bio) 
  126. 		 
  127. 		local insert_values = {[0] = CHARACTER_DATA[character].name} 
  128. 		local confirm_string = vint_insert_values_in_string("M22_2_TEAM_CONFIRM", insert_values) 
  129. 		 
  130. 		local hint_data = { 
  131. 		{CTRL_BUTTON_Y, confirm_string}, 
  132. 		} 
  133. 		 
  134. 		Hint_bar = Vdo_hint_bar:new("hint_bar") 
  135. 		Hint_bar:set_hints(hint_data) 
  136. 		 
  137. 		--Arrange character elements 
  138. 		local character_bg_width, character_bg_height = element_get_actual_size(Character_bg_h) 
  139. 		local character_bio_width, character_bio_height = element_get_actual_size(Character_bio_h) 
  140. 		local hint_bar_x, hint_bar_y = Hint_bar:get_property("anchor") 
  141. 		local hint_bar_new_y = 110 + character_bio_height --110 is the space from the top of the bio to the top of the box 
  142. 		Hint_bar:set_property("anchor",hint_bar_x,hint_bar_new_y) 
  143. 		local character_bg_new_height = hint_bar_new_y + 26 
  144. 		element_set_actual_size(Character_bg_h, character_bg_width, character_bg_new_height) 
  145. 		 
  146. 		--show character box 
  147. 		vint_set_property(Character_grp_h, "visible", true) 
  148. 		 
  149. 	else 
  150. 		--hide character box 
  151. 		vint_set_property(Character_grp_h, "visible", false) 
  152. 	end 
  153. 	 
  154. end 
  155.  
  156. function team_assign_cleanup() 
  157.  
  158. end 
  159.  
  160.  
  161.  
  162.  
  163.