./vdo_powers_button.lua

  1. local ROW_TOP_Y = 25 
  2. local ROW_BOT_Y = 75 
  3. local TEXT_MAX_WIDTH = 220 
  4.  
  5. local COLOR = { 
  6. 	DARK_PURPLE = {R=44/255, G=0/255, B=59/255}, 
  7. 	LIGHT_PURPLE = {R=255/255, G=147/255, B=42/255}, 
  8. 	DARK_GREY = {R=25/255, G=25/255, B=25/255}, 
  9. 	LIGHT_GREY = {R=120/255, G=120/255, B=120/255}, 
  10. } 
  11.  
  12. function vdo_powers_button_init() 
  13.  
  14. end 
  15.  
  16. function vdo_powers_button_cleanup() 
  17.  
  18. end 
  19.  
  20.  
  21. Vdo_powers_button = Vdo_base_object:new_base() 
  22.  
  23. function Vdo_powers_button:init() 
  24. 	--find elements 
  25. 	self.top_txt_h = vint_object_find("top_txt", self.handle, self.doc_handle) 
  26. 	self.bot_txt_h = vint_object_find("bot_txt", self.handle, self.doc_handle) 
  27. 	self.popup_top_txt_h = vint_object_find("popup_top_txt", self.handle, self.doc_handle) 
  28. 	self.popup_bot_txt_h = vint_object_find("popup_bot_txt", self.handle, self.doc_handle) 
  29. 	self.arrow_h = vint_object_find("arrow", self.handle, self.doc_handle) 
  30. 	self.hint_button_h = Vdo_hint_button:new("hint_button", self.handle, self.doc_handle) 
  31. 	self.power_icon_h = vint_object_find("power_icon", self.handle, self.doc_handle) 
  32. 	self.element_icon_h = vint_object_find("element_icon", self.handle, self.doc_handle) 
  33. 	self.bg_on_grp_h = vint_object_find("bg_on_grp", self.handle, self.doc_handle) 
  34. 	self.bg_on_lines_h = vint_object_find("bg_on_lines", self.handle, self.doc_handle) 
  35. 	self.bg_on_bar_h = vint_object_find("bg_on_bar", self.handle, self.doc_handle) 
  36. 	self.bg_off_grp_h = vint_object_find("bg_off_grp", self.handle, self.doc_handle) 
  37. 	self.bg_off_h = vint_object_find("bg_off", self.handle, self.doc_handle) 
  38. 	self.pulse_grp_h = vint_object_find("pulse_grp", self.handle, self.doc_handle)	 
  39. 	self.mouse_top_h = vint_object_find("mouse_top", self.handle, self.doc_handle) 
  40. 	self.mouse_bot_h = vint_object_find("mouse_bot", self.handle, self.doc_handle) 
  41. 	 
  42. 	resize_text_element(self.popup_top_txt_h, TEXT_MAX_WIDTH) 
  43. 	resize_text_element(self.popup_bot_txt_h , TEXT_MAX_WIDTH) 
  44. 	 
  45. 	--get starting anchor points for things we'll move 
  46. 	self.bg_on_bar_x, self.bg_on_bar_y = vint_get_property(self.bg_on_bar_h, "anchor") 
  47. 	self.hint_button_x, self.hint_button_y = self.hint_button_h:get_anchor() 
  48. 	 
  49. 	--if pc then hide ctrl button 
  50. 	if game_is_active_input_gamepad() == false then		 
  51. 		self.hint_button_h:set_visible(false) 
  52. 	else	 
  53. 		self.hint_button_h:set_button(CTRL_MENU_BUTTON_A) 
  54. 	end 
  55. 	 
  56. 	 
  57. 	--self.pulse_anim = vint_object_find("pulse_anim", self.handle, self.doc_handle) 
  58. 	--self.pulse_anim:set_target_handle(self.text_grp_h) 
  59. 	--lua_play_anim(self.pulse_anim)	 
  60. end 
  61.  
  62. function Vdo_powers_button:play_pulse_anim() 
  63. 	self.pulse_anim_h = vint_object_find("pulse_anim", self.handle, self.doc_handle) 
  64. 	self.pulse_twn_h = vint_object_find("pulse_twn", self.pulse_anim_h)	 
  65. 	self.lines_twn_h = vint_object_find("lines_twn", self.pulse_anim_h)	 
  66. 	 
  67. 	--Retarget twn to make sure we find the right instance 
  68. 	vint_set_property(self.pulse_twn_h, "target_handle", self.pulse_grp_h) 
  69. 	vint_set_property(self.lines_twn_h, "target_handle", self.bg_on_lines_h) 
  70. 	 
  71. 	lua_play_anim(self.pulse_anim_h) 
  72. end 
  73.  
  74. --------------- 
  75. --Get functions 
  76. --------------- 
  77. function Vdo_powers_button:get_mouse_region() 
  78. 	return self.bg_off_h 
  79. end 
  80.  
  81. function Vdo_powers_button:get_power_name() 
  82. 	return vint_get_property(self.top_txt_h, "text_tag") 
  83. end 
  84.  
  85. function Vdo_powers_button:get_power_icon() 
  86. 	return self.power_icon_ref 
  87. end 
  88.  
  89. function Vdo_powers_button:get_power_tint() 
  90. 	return self.power_tint 
  91. end 
  92.  
  93. function Vdo_powers_button:get_element_icon() 
  94. 	return self.element_icon_ref 
  95. end 
  96.  
  97. --------------- 
  98. --Set functions 
  99. --------------- 
  100.  
  101. function Vdo_powers_button:set_power_num_upgrades(num) 
  102. 	self.num_upgrades = num 
  103. end 
  104.  
  105. function Vdo_powers_button:set_power_id(id) 
  106. 	self.power_id = id 
  107. end 
  108.  
  109. function Vdo_powers_button:set_power_name(text) 
  110. 	vint_set_property(self.top_txt_h, "text_tag", text) 
  111. 	resize_text_element(self.top_txt_h, TEXT_MAX_WIDTH) 
  112. end 
  113.  
  114. function Vdo_powers_button:set_power_icon(icon) 
  115. 	vint_set_property(self.power_icon_h, "image", icon) 
  116. 	self.power_icon_ref = icon 
  117. end 
  118.  
  119. function Vdo_powers_button:set_power_tint(tint) 
  120. 	self.power_tint = tint 
  121. end 
  122.  
  123. function Vdo_powers_button:set_element_icon(visible, icon) 
  124. 	vint_set_property(self.element_icon_h, "image", icon) 
  125. 	vint_set_property(self.element_icon_h, "visible", visible) 
  126. 	self.element_icon_ref = icon 
  127. end 
  128.  
  129. function Vdo_powers_button:set_new_indicator(visible, text_string) 
  130. 	vint_set_property(self.arrow_h, "visible", visible) 
  131. 	vint_set_property(self.bot_txt_h, "visible", visible) 
  132. 	if visible then 
  133. 		vint_set_property(self.bot_txt_h, "tint", COLOR.LIGHT_PURPLE.R, COLOR.LIGHT_PURPLE.G, COLOR.LIGHT_PURPLE.B) 
  134. 		--local insert_values = {[0] = number} 
  135. 		--local new_string = vint_insert_values_in_string("POWERS_NEW", insert_values) 
  136. 		vint_set_property(self.bot_txt_h, "text_tag", text_string) 
  137. 		--resize_text_element(self.bot_txt_h, TEXT_MAX_WIDTH) 
  138. 	end 
  139. end 
  140.  
  141. function Vdo_powers_button:set_state_on() 
  142. 	vint_set_property(self.bg_on_grp_h, "visible", true) 
  143. 	vint_set_property(self.bg_off_grp_h, "visible", false) 
  144. 	vint_set_property(self.arrow_h, "alpha", 1) 
  145. 	self.hint_button_h:set_visible(true) 
  146. 	vint_set_property(self.bg_on_bar_h, "anchor", self.bg_on_bar_x, ROW_TOP_Y) 
  147. 	self.hint_button_h:set_anchor(self.hint_button_x, ROW_TOP_Y) 
  148. 	vint_set_property(self.top_txt_h, "tint", COLOR.DARK_PURPLE.R, COLOR.DARK_PURPLE.G, COLOR.DARK_PURPLE.B) 
  149. 	vint_set_property(self.bot_txt_h, "tint", COLOR.LIGHT_PURPLE.R, COLOR.LIGHT_PURPLE.G, COLOR.LIGHT_PURPLE.B) 
  150. 	vint_set_property(self.top_txt_h, "alpha", 1) 
  151. 	vint_set_property(self.bot_txt_h, "alpha", 1) 
  152. 	vint_set_property(self.popup_top_txt_h, "alpha", 0) 
  153. 	vint_set_property(self.popup_bot_txt_h, "alpha", 0) 
  154. 	 
  155. end 
  156.  
  157. function Vdo_powers_button:set_state_off() 
  158. 	vint_set_property(self.bg_on_grp_h, "visible", false) 
  159. 	vint_set_property(self.bg_off_grp_h, "visible", true) 
  160. 	vint_set_property(self.arrow_h, "alpha", 1) 
  161. 	self.hint_button_h:set_visible(false) 
  162. 	self.hint_button_h:set_anchor(self.hint_button_x, ROW_TOP_Y) 
  163. 	vint_set_property(self.top_txt_h, "tint", COLOR.DARK_GREY.R, COLOR.DARK_GREY.G, COLOR.DARK_GREY.B) 
  164. 	vint_set_property(self.bot_txt_h, "tint", COLOR.LIGHT_PURPLE.R, COLOR.LIGHT_PURPLE.G, COLOR.LIGHT_PURPLE.B) 
  165. 	vint_set_property(self.top_txt_h, "alpha", 1) 
  166. 	vint_set_property(self.bot_txt_h, "alpha", 1) 
  167. 	vint_set_property(self.popup_top_txt_h, "alpha", 0) 
  168. 	vint_set_property(self.popup_bot_txt_h, "alpha", 0) 
  169. end 
  170.  
  171. function Vdo_powers_button:set_state_popup(position, is_flight) 
  172. 	self.popup_position = position 
  173.  
  174. 	if is_flight ~= nil and is_flight == true then 
  175. 		vint_set_property(self.popup_bot_txt_h, "text_tag", "POWERS_WING_STYLE_HEADER") 
  176. 	else 
  177. 		vint_set_property(self.popup_bot_txt_h, "text_tag", "POWERS_ELEMENTS_HEADER") 
  178. 	end 
  179. 	 
  180. 	vint_set_property(self.bg_on_grp_h, "visible", true) 
  181. 	vint_set_property(self.bg_off_grp_h, "visible", false) 
  182. 	vint_set_property(self.arrow_h, "alpha", 0) 
  183. 	self.hint_button_h:set_visible(true) 
  184. 	vint_set_property(self.top_txt_h, "alpha", 0) 
  185. 	vint_set_property(self.bot_txt_h, "alpha", 0) 
  186. 	vint_set_property(self.popup_top_txt_h, "alpha", 1) 
  187. 	vint_set_property(self.popup_bot_txt_h, "alpha", 1) 
  188. 	 
  189. 	if position == 2 then 
  190. 		vint_set_property(self.bg_on_bar_h, "anchor", self.bg_on_bar_x, ROW_BOT_Y) 
  191. 		self.hint_button_h:set_anchor(self.hint_button_x, ROW_BOT_Y) 
  192. 		vint_set_property(self.popup_top_txt_h, "tint", COLOR.LIGHT_PURPLE.R, COLOR.LIGHT_PURPLE.G, COLOR.LIGHT_PURPLE.B) 
  193. 		vint_set_property(self.popup_bot_txt_h, "tint", COLOR.DARK_PURPLE.R, COLOR.DARK_PURPLE.G, COLOR.DARK_PURPLE.B) 
  194. 	else 
  195. 		vint_set_property(self.bg_on_bar_h, "anchor", self.bg_on_bar_x, ROW_TOP_Y) 
  196. 		self.hint_button_h:set_anchor(self.hint_button_x, ROW_TOP_Y) 
  197. 		vint_set_property(self.popup_top_txt_h, "tint", COLOR.DARK_PURPLE.R, COLOR.DARK_PURPLE.G, COLOR.DARK_PURPLE.B) 
  198. 		vint_set_property(self.popup_bot_txt_h, "tint", COLOR.LIGHT_PURPLE.R, COLOR.LIGHT_PURPLE.G, COLOR.LIGHT_PURPLE.B) 
  199. 	end 
  200. end 
  201.  
  202.  
  203.  
  204.  
  205.  
  206.