./vdo_gsi_info.lua

  1. ------------------------------------------------------------------------------- 
  2. -- GSI Info Component 
  3. -- This combonent is used to display in the format of the following. 
  4. -- STATUS: XXXX 
  5. --  
  6. -- It is used for things like mayhem to keep track of combos. i.e. COMBO: 1  
  7. ------------------------------------------------------------------------------- 
  8. -- Inherited from Vdo_base_object 
  9. Vdo_gsi_info = Vdo_base_object:new_base() 
  10.  
  11. -- Standard Init Function 
  12. function vdo_gsi_info_init() 
  13. end 
  14.  
  15. -- Standard Cleanup Function 
  16. function vdo_gsi_info_cleanup() 
  17. end 
  18.  
  19. --Constants 
  20. local GSI_INFO_LABEL_PADDING = 9 
  21.  
  22. function Vdo_gsi_info:init() 
  23. end 
  24.  
  25. function Vdo_gsi_info:set_parent(parent) 
  26. 	self.parent = parent 
  27. end 
  28.  
  29. function Vdo_gsi_info:create(skin) 
  30. 	--Initialize Standard Indicator Values 
  31. 	self.visible = -1						--Is the indicator displaying?  
  32. 	self.is_dirty = true					--Is the indicator dirty? we set this to true if we want the GSI to re-align everything. 
  33. 	self.skin = skin 
  34. 	self.width = 100 
  35. 	self.height = 10 
  36. 	 
  37. 	--Initialize Custom Values  
  38. 	self.info_value = "XXXX: IS AWESOME" 
  39. 	self.label = 0 
  40. end 
  41.  
  42. function Vdo_gsi_info:update(visible, skin, label_crc, info_crc, info_value) 
  43. 	--Set visible 
  44. 	self:set_visible(visible) 
  45. 	 
  46. 	--Check if everything is formatted during change? 
  47. 	 
  48. 	local info_txt_obj = Vdo_base_object:new("info_txt", self.handle) 
  49. 	local label_txt_obj = Vdo_base_object:new("label_txt", self.handle) 
  50. 	 
  51. 	--Set label with crc 
  52. 	if label_crc == 0 or label_crc == nil then 
  53. 		--No crc or Invalid crc 
  54. 		label_txt_obj:set_text("") 
  55. 	else 
  56. 		label_txt_obj:set_text_crc(label_crc) 
  57. 	end 
  58. 	 
  59. 	--Set Info Part 
  60. 	if info_crc == 0 and info_value == nil then 
  61. 		--no string 
  62. 		info_txt_obj:set_text("") 
  63. 		self.parent:blink_queue(true) 
  64. 		 
  65. 	elseif info_crc == 0 then 
  66. 		--Use string 
  67. 		 
  68. 		--Skin processing 
  69. 		if skin == "Cash" then 
  70. 			--format the cash 
  71. 			info_value = "{GAME_CASH}" .. format_cash(tonumber(info_value)) 
  72. 		elseif skin == "TrailBlazing" then 
  73. 			--Trailblazing specific 
  74. 			local insertion_text 	= { [0] = info_value } 
  75. 			info_value = vint_insert_values_in_string("HUD_AMT_SECS_B", insertion_text) 
  76. 			 
  77. 			--Tint the bonus yellow 
  78. 			info_txt_obj:set_color(GSI_SKIN["Default"].tint[1], GSI_SKIN["Default"].tint[2], GSI_SKIN["Default"].tint[3]) 
  79. 		else 
  80. 			self.parent:blink_queue(true) 
  81. 		end 
  82. 		 
  83. 		info_txt_obj:set_text(info_value) 
  84. 		 
  85. 	else 
  86. 		--use crc 
  87. 		info_txt_obj:set_text_crc(info_crc) 
  88. 		self.parent:blink_queue(true) 
  89. 	end 
  90. 	 
  91. 	--Mayhem Activity Specific Coloring 
  92. 	if skin == "Mayhem" then 
  93. 		if info_value ~= "0" then 
  94. 			info_txt_obj:set_color(Hud_mayhem_world_cash_status.color_r, Hud_mayhem_world_cash_status.color_g, Hud_mayhem_world_cash_status.color_b) 
  95. 		else 
  96. 			--reset color 
  97. 			info_txt_obj:set_color(GSI_SKIN["Mayhem"].tint[1], GSI_SKIN["Mayhem"].tint[2], GSI_SKIN["Mayhem"].tint[3]) 
  98. 		end 
  99. 	end 
  100.  
  101. 	label_txt_obj:set_scale(1,1) 
  102. 	info_txt_obj:set_scale(1,1) 
  103. 	 
  104. 	--Repostion Elements and Calculate width/height 
  105. 	local label_width, label_height = label_txt_obj:get_actual_size() 
  106. 	local info_width, info_height = info_txt_obj:get_actual_size() 
  107. 	 
  108. 	--Resize if its too wide to fit within reason... 
  109. 	local width_total = label_width + info_width 
  110. 	local width_max = 536 
  111. 	if width_total > width_max then 
  112. 		local scale = width_max/width_total 
  113. 		label_txt_obj:set_scale(scale, 1) 
  114. 		info_txt_obj:set_scale(scale, 1) 
  115. 		label_width = label_width * scale 
  116. 		info_width = info_width * scale 
  117. 	end 
  118. 	 
  119. 	local label_padding = GSI_INFO_LABEL_PADDING 
  120. 	if label_width == 0 then 
  121. 		--If the label doesn't exist then we don't need any padding 
  122. 		label_padding = 0  
  123. 	end 
  124. 	 
  125. 	--Left Aligned Only? 
  126. 	local info_x = label_padding + label_width 
  127. 	local info_y = 0 
  128. 	 
  129. 	info_txt_obj:set_anchor(info_x, info_y) 
  130. 	 
  131. 	--Override width for mayhem only. 
  132. 	if skin == "Mayhem" then 
  133. 		info_width = 30 
  134. 	end 
  135. 	 
  136. 	--Clean up GSI if the label changed... 
  137. 	if label_crc ~= self.label_crc  then 
  138. 		self.is_dirty = true	 
  139. 	end 
  140. 	 
  141. 	--Add spacing to width 
  142. 	local width = info_x + info_width + GSI_TEXT_SPACING 
  143. 	local width_dif = abs(self.width - width) 
  144. 	 
  145. 	--Determine if we need to do more cleanup? 
  146. 	if width_dif > 3 then 
  147. 		self.is_dirty = true	 
  148. 	end 
  149.  
  150. 	--Get Height of object... 
  151. 	local height = info_height 
  152. 	if label_height > info_height then 
  153. 		height = label_height 
  154. 	end 
  155. 	 
  156. 	--Store new width and height of indicator 
  157. 	self.width = width 
  158. 	self.height = height 
  159. 	 
  160. 	---Store Values 
  161. 	self.label_crc = label_crc 
  162. 	self.info_value = info_value 
  163. end 
  164.  
  165. function Vdo_gsi_info:get_size() 
  166. 	return self.width, self.height 
  167. end 
  168.  
  169. --Standard Indicator Functions 
  170. function Vdo_gsi_info:set_visible(visible) 
  171. 	--Hide the indicator if it is not visible 
  172. 	if visible ~= self.visible then 
  173. 		if visible == true then 
  174. 			self:set_property("visible", true) 
  175. 			self.visible = visible 
  176. 		else 
  177. 			self:set_property("visible", false) 
  178. 			self.visible = visible 
  179. 		end 
  180. 		 
  181. 		--Format of the indicators changed, so lets make sure we set the flag to dirty. 
  182. 		--The vdo_gsi will take care of everything when we set this dirty flag to true... 
  183. 		self.is_dirty = true 
  184. 	end 
  185. end