./vdo_gsi_lite.lua

  1. ----------------------------------------------------------------------------------------------- 
  2. -- Vdo_gsi_lite 
  3. -- 
  4. -- description:  A light weight version of the gsi to be used in interface tutorials. 
  5. ----------------------------------------------------------------------------------------------- 
  6.  
  7. function vdo_gsi_lite_init() 
  8. end 
  9.  
  10.  
  11. Vdo_gsi_lite = Vdo_base_object:new_base() 
  12.  
  13.  
  14. function Vdo_gsi_lite:init() 
  15. 	self.black_bar_img_h = vint_object_find("black_bar_img", self.handle, self.doc_handle) 
  16. 	self.icon_img_h = vint_object_find("icon_img", self.handle, self.doc_handle) 
  17. 	self.obj_txt_h = vint_object_find("obj_txt", self.handle, self.doc_handle) 
  18. 	self.new_obj_anim_h = vint_object_find("new_obj_anim", self.handle, self.doc_handle) 
  19. 	 
  20. 	self.updated_called = false 
  21. 	 
  22. 	self:set_visible(false) 
  23. end 
  24.  
  25.  
  26. function Vdo_gsi_lite:update(new_obj_txt, new_icon_img) 
  27. 	 
  28. 	--Update text and icon 
  29. 	vint_set_property(self.obj_txt_h, "text_tag", new_obj_txt) 
  30. 	vint_set_property(self.icon_img_h, "image", new_icon_img) 
  31. 	 
  32. 	--Resize bar 
  33. 	local new_txt_width, new_txt_height = element_get_actual_size(self.obj_txt_h) 
  34. 	local obj_txt_x, obj_txt_y = vint_get_property(self.obj_txt_h, "anchor") 
  35. 	local bar_width, bar_height = element_get_actual_size(self.black_bar_img_h) 
  36. 	bar_width = obj_txt_x + new_txt_width + 10 
  37. 	element_set_actual_size(self.black_bar_img_h, bar_width, bar_height) 
  38. 	 
  39. 	--Color icons  
  40. 	if new_icon_img == "ui_target_icon_use"	then 
  41. 		vint_set_property(self.icon_img_h, "tint", COLOR_TARGET_USE.R, COLOR_TARGET_USE.G, COLOR_TARGET_USE.B) 
  42. 	elseif new_icon_img == "ui_target_icon_location" then 
  43. 		vint_set_property(self.icon_img_h, "tint", COLOR_TARGET_LOCATION.R, COLOR_TARGET_LOCATION.G, COLOR_TARGET_LOCATION.B) 
  44. 	end 
  45. 	 
  46. 	--POLISH: Color and position small bars for fancy intro anim  
  47. 	--[[local bars = {} 
  48. 	 
  49. 	for i=1,3 do 
  50. 		bars[i] = { 
  51. 			img_h = vint_object_find("bar_img_"..i, self.handle, self.doc_handle), 
  52. 			twn_h = vint_object_find("bar_twn_"..i, self.new_obj_anim_h), 
  53. 		} 
  54. 		 
  55. 		local small_bar_width, small_bar_height = element_get_actual_size(bars[i].img_h) 
  56. 		element_set_actual_size(bars[i].img_h, bar_width, small_bar_height) 
  57. 		vint_set_property(bars[i].img_h, "anchor", bar_width * 0.5, (i-1) * small_bar_height) 
  58. 	end]] 
  59. 	 
  60. 	 
  61. 	--Center grp in middle of screen and play new objective anim 
  62. 	local anchor_twn_h = vint_object_find("new_obj_anchor_twn", self.new_obj_anim_h) 
  63. 	 
  64. 	local gsi_x = 0 
  65. 	 
  66. 	if vint_is_std_res() == true then 
  67. 		gsi_x = (320 * 1.5) - (bar_width * .75) 
  68. 	else 
  69. 		gsi_x = 640 - (bar_width * .75) 
  70. 	end 
  71. 	 
  72. 	vint_set_property(anchor_twn_h, "start_value", gsi_x, 200) 
  73. 	 
  74. 	vint_apply_start_values(self.new_obj_anim_h)	 
  75. 	 
  76. 	local delay = 0 
  77. 	 
  78. 	if self.updated_called == true then 
  79. 		delay = -1 
  80. 	end 
  81. 	 
  82. 	lua_play_anim(self.new_obj_anim_h, delay, self.doc_handle) 
  83. 	 
  84. 	self:set_visible(true) 
  85. 	 
  86. 	self.updated_called = true 
  87. end