./vdo_cell_missions_button.lua

  1. function vdo_cell_missions_button_init() 
  2. end 
  3.  
  4. -- Inherited from Vdo_base_object 
  5. Vdo_cell_missions_button = Vdo_base_object:new_base() 
  6.  
  7. CELL_MISSIONS_BUTTON_SELECTED_HEIGHT	= 120 
  8. CELL_MISSIONS_BUTTON_UNSELECTED_HEIGHT	= 120 
  9.  
  10. function Vdo_cell_missions_button:init() 
  11.  
  12. 	self.mission_title = Vdo_base_object:new("mission_title",self.handle, self.doc_handle) 
  13. 	self.contact_name = Vdo_base_object:new("contact_name",self.handle, self.doc_handle) 
  14. 	self.contact_img = Vdo_base_object:new("contact_img",self.handle, self.doc_handle) 
  15. 	self.btn_bg = Vdo_base_object:new("btn_bg",self.handle, self.doc_handle) 
  16. 	self.btn_bar = Vdo_base_object:new("btn_hint_bar", self.handle, self.doc_handle) 
  17. 	self.highlight_grp = Vdo_base_object:new("highlight_grp", self.handle, self.doc_handle) 
  18. 	self.btn_new = Vdo_base_object:new("new_mission", self.handle, self.doc_handle) 
  19. 	 
  20. 	self.highlight_grp:set_visible(false) 
  21. 	self.btn_new:set_visible(false) 
  22. 	 
  23. 	self.mission_title:set_color(COLOR_CELL_MENU_UNHIGHLIGHT_TEXT.R,COLOR_CELL_MENU_UNHIGHLIGHT_TEXT.G,COLOR_CELL_MENU_UNHIGHLIGHT_TEXT.B) 
  24. 	self.contact_name:set_color(COLOR_CELL_MENU_HIGHLIGHT_TEXT.R,COLOR_CELL_MENU_HIGHLIGHT_TEXT.G,COLOR_CELL_MENU_HIGHLIGHT_TEXT.B)		 
  25. end 
  26.  
  27. function Vdo_cell_missions_button:populate_button(title, contact_image, contact_name, is_new) 
  28. 	 
  29. 	self.mission_title:set_text(title) 
  30. 	self.contact_name:set_text(contact_name) 
  31. 	self.contact_img:set_image(contact_image)	 
  32. 	self.btn_new:set_visible(is_new) 
  33. 	 
  34. 	--resize mission title to fit 
  35. 	self.mission_title:set_scale(1,1) 
  36. 	local MAX_WIDTH_TITLE = 275 
  37. 	local text_width_label, text_height_label = element_get_actual_size(self.mission_title.handle) 
  38.  
  39. 	if text_width_label > MAX_WIDTH_TITLE then 
  40. 		local text_scale_label = MAX_WIDTH_TITLE/text_width_label 
  41. 		self.mission_title:set_scale(text_scale_label,1) 
  42. 	end	 
  43. 	 
  44. end 
  45.  
  46.  
  47. function Vdo_cell_missions_button:set_highlight(is_highlighted) 
  48.  
  49. 	if(is_highlighted) then 
  50. 		self.mission_title:set_color(.75,.75,.75) 
  51. 		self.contact_name:set_color(0,0,0) 
  52. 		self.highlight_grp:set_visible(true)	 
  53. 	else 
  54. 		self.mission_title:set_color(COLOR_CELL_MENU_UNHIGHLIGHT_TEXT.R,COLOR_CELL_MENU_UNHIGHLIGHT_TEXT.G,COLOR_CELL_MENU_UNHIGHLIGHT_TEXT.B) 
  55. 		self.contact_name:set_color(COLOR_CELL_MENU_UNHIGHLIGHT_TEXT.R,COLOR_CELL_MENU_UNHIGHLIGHT_TEXT.G,COLOR_CELL_MENU_UNHIGHLIGHT_TEXT.B) 
  56. 		self.highlight_grp:set_visible(false) 
  57. 	end 
  58.  
  59. end 
  60.  
  61. function Vdo_cell_missions_button:get_selected_height() 
  62. 	return CELL_MISSIONS_BUTTON_SELECTED_HEIGHT 
  63. end 
  64.  
  65. function Vdo_cell_missions_button:get_unselected_height() 
  66. 	return CELL_MISSIONS_BUTTON_UNSELECTED_HEIGHT 
  67. end 
  68.  
  69.  
  70.