./vdo_gsi_xy.lua

  1. ------------------------------------------------------------------------------- 
  2. --GSI XY Component 
  3. ------------------------------------------------------------------------------- 
  4. -- Inherited from Vdo_base_object 
  5. Vdo_gsi_xy = Vdo_base_object:new_base() 
  6.  
  7. -- Standard Init Function 
  8. function vdo_gsi_xy_init() 
  9. end 
  10.  
  11. -- Standard Cleanup Function 
  12. function vdo_gsi_meter_cleanup() 
  13. end 
  14.  
  15. --Constants 
  16. local	GSI_XY_LABEL_PADDING = 9  
  17. local	GSI_XY_SLASH_PADDING = 2 
  18.  
  19. function Vdo_gsi_xy:init() 
  20.  
  21. 	--Store references to objects 
  22. 	self.label_txt_h 	= vint_object_find("label_txt", self.handle) 
  23. 	self.slash_txt_h 	= vint_object_find("slash_txt", self.handle) 
  24. 	self.x_txt_h 		= vint_object_find("x_txt", self.handle) 
  25. 	self.y_txt_h  		= vint_object_find("y_txt", self.handle) 
  26. 	self.gsi_x_anim_h = vint_object_find("gsi_x_anim", self.handle) 
  27. 	 
  28. 	--Retarget_animation... 
  29. 	vint_set_property(self.gsi_x_anim_h, "target_handle", self.x_txt_h) 
  30. end 
  31.  
  32. function Vdo_gsi_xy:create(skin) 
  33. 	--Initialize Standard Indicator Values 
  34. 	self.visible = -1						--Is the indicator displaying?  
  35. 	self.is_dirty = true					--Is the indicator dirty? we set this to true if we want the GSI to re-align everything. 
  36. 	self.skin = skin 
  37. 	self.width = -1 
  38. 	self.height = -1 
  39. 	 
  40. 	--Initialize Custom Values  
  41. 	self.x_value = 200 
  42. 	self.y_value = 200 
  43. 	self.label = 0 
  44. end 
  45.  
  46. function Vdo_gsi_xy:update(visible, skin, label_crc, x_value, y_value, is_cash, is_fraud) 
  47. 	--Set visible 
  48. 	self:set_visible(visible) 
  49. 	 
  50. 	local label_txt_h = self.label_txt_h 
  51. 	local slash_txt_h = self.slash_txt_h 
  52. 	local x_txt_h = self.x_txt_h 
  53. 	local y_txt_h = self.y_txt_h 
  54.  
  55. 	if label_crc ~= Cur_xy_label_crc then 
  56. 		self.parent:blink_queue(true) 
  57. 	else 
  58. 		--self.parent:blink_queue(true) 
  59. 	end 
  60. 	 
  61. 	 
  62. 	--Set label with crc 
  63. 	if label_crc == 0 or label_crc == nil then 
  64. 		--No crc or Invalid crc 
  65. 		vint_set_property(label_txt_h, "text_tag", "") 
  66. 	else 
  67. 		vint_set_property(label_txt_h, "text_tag_crc", label_crc) 
  68. 	end 
  69. 	 
  70. 	--Animate it... 
  71. 	if x_value ~= self.x_value then 
  72. 		lua_play_anim(self.gsi_x_anim_h) 
  73. 	end 
  74. 	 
  75. 	--If skin is left blank then  
  76. 	if skin == "" then 
  77. 		if is_cash == true then 
  78. 			skin = "cash" 
  79. 		else  
  80. 			skin = "default" 
  81. 		end 
  82. 	end 
  83. 		 
  84. 	--Apply any special formatting to the text 
  85. 	local x_value_text, y_value_text 
  86. 	 
  87. 	if is_fraud == true then 
  88. 		x_value_text = format_cash(x_value) .. " {ACT_FRAUD_SCORE_UNIT}" 
  89. 		y_value_text = format_cash(y_value) .. " {ACT_FRAUD_SCORE_UNIT}" 
  90. 	elseif skin == "Cash" or skin == "Cash_Flash_Disabled" then 
  91. 		x_value_text = "{GAME_CASH}" .. format_cash(x_value) 
  92. 		y_value_text = "{GAME_CASH}" .. format_cash(y_value) 
  93. 	else 
  94. 		x_value_text = format_cash(x_value) 
  95. 		y_value_text = format_cash(y_value) 
  96. 	end 
  97. 	 
  98. 	--Set Text Fields 
  99. 	vint_set_property(x_txt_h, "text_tag", x_value_text) 
  100. 	 
  101. 	--test size in the y slot because the x slot could be scaling because of animation... 
  102. 	vint_set_property(y_txt_h, "text_tag", x_value_text) 
  103. 	local x_width, x_height = element_get_actual_size(y_txt_h) 
  104. 	 
  105. 	vint_set_property(y_txt_h, "text_tag", y_value_text) 
  106. 	 
  107. 	 
  108. 	--Get Sizes first 
  109. 	local label_x, label_y = vint_get_property(label_txt_h, "anchor") 
  110. 	local label_width, label_height = element_get_actual_size(label_txt_h) 
  111.  
  112. 	local slash_width, slash_height = element_get_actual_size(slash_txt_h) 
  113. 	local y_width, y_height = element_get_actual_size(y_txt_h) 
  114.  
  115. 	local x_anchor_x = x_width/2 
  116. 	if label_width ~= 0 then 
  117. 		x_anchor_x = label_x + label_width + GSI_XY_LABEL_PADDING + x_anchor_x 
  118. 	end 
  119. 	 
  120. 	--Set Positions 
  121. 	local slash_anchor_x = x_anchor_x + x_width/2 + GSI_XY_SLASH_PADDING 
  122. 	local y_anchor_x = slash_anchor_x + slash_width + GSI_XY_SLASH_PADDING 
  123. 	 
  124. 	vint_set_property(x_txt_h, "anchor", x_anchor_x, label_y) 
  125. 	vint_set_property(y_txt_h, "anchor", y_anchor_x, label_y) 
  126. 	vint_set_property(slash_txt_h, "anchor", slash_anchor_x, label_y) 
  127. 	 
  128. 	--Calculate Width 
  129. 	local width = y_anchor_x + y_width + (GSI_TEXT_SPACING * 1.5) 
  130. 	local width_dif = abs(self.width - width) 
  131. 	 
  132. 	if width_dif > 3 then 
  133. 		self.is_dirty = true 
  134. 	end 
  135. 	 
  136. 	--Store size values 
  137. 	self.width = width 
  138. 	self.height = x_height 
  139. 	 
  140. 	--Store Object values 
  141. 	self.label_crc = label_crc 
  142. 	Cur_xy_label_crc = label_crc 
  143. 	self.x_value = x_value 
  144. 	self.y_value = y_value 
  145. end 
  146.  
  147. function Vdo_gsi_xy:get_size() 
  148. 	return self.width, self.height 
  149. end 
  150.  
  151. --Standard Indicator Functions 
  152. function Vdo_gsi_xy:set_visible(visible) 
  153. 	--Hide the indicator if it is not visible 
  154. 	if visible ~= self.visible then 
  155. 		if visible == true then 
  156. 			self:set_property("visible", true) 
  157. 			self.visible = visible 
  158. 		else 
  159. 			self:set_property("visible", false) 
  160. 			self.visible = visible 
  161. 		end 
  162. 		 
  163. 		--Format of the indicators changed, so lets make sure we set the flag to dirty. 
  164. 		--The vdo_gsi will take care of everything when we set this dirty flag to true... 
  165. 		self.is_dirty = true 
  166. 	end 
  167. end