./vdo_pause_header.lua

  1. ---------------------------------------------------------------------------  
  2. -- Vdo_pause_header 
  3. -- 
  4. -- The header for each screen in the pause menu. This object gets included 
  5. -- manually in those documents that need a header. 
  6. --------------------------------------------------------------------------- 
  7.  
  8. -- Inherited from Vdo_base_object 
  9. Vdo_pause_header = Vdo_base_object:new_base() 
  10.  
  11. --Colors -  
  12. COLOR_PAUSE_HEADER = {R = 218/255, G = 226/255; B = 230/255} 
  13.  
  14. --Standard Init 
  15. function Vdo_pause_header_init() 
  16. 	--Hide the object from displaying crap on the first frame 
  17. 	local text = vint_object_find("text") 
  18. 	vint_set_property(text, "text_tag", "") 
  19. end 
  20.  
  21. --Standard Cleanup 
  22. function Vdo_pause_header_cleanup() 
  23. end 
  24.  
  25. ---------------------------------------------------------------------------  
  26. -- Initializes VDO Object 
  27. --------------------------------------------------------------------------- 
  28. function Vdo_pause_header:init() 
  29. 	--Reset color to script value 
  30. 	local text_obj = Vdo_base_object:new("text", self.handle) 
  31. 	--text_obj:set_color(COLOR_PAUSE_HEADER.R, COLOR_PAUSE_HEADER.G, COLOR_PAUSE_HEADER.B) 
  32. end 
  33.  
  34. ---------------------------------------------------------------------------  
  35. -- Sets the text of the header and causes 
  36. -- 
  37. -- @param new_text_string	Text string for header 
  38. --------------------------------------------------------------------------- 
  39. function Vdo_pause_header:set_text(new_text_string, max_width) 
  40. 	local text_obj = Vdo_base_object:new("text", self.handle) 
  41. 	text_obj:set_text(new_text_string) 
  42. 	text_obj:set_scale(1.0,1.0) 
  43. 	local text_width,text_height = self:get_size()  
  44. 	 
  45. 	--leave room for padding 
  46. 	if max_width ~= nil then 
  47. 		max_width = max_width - 40 
  48. 	end 
  49. 	 
  50. 	if max_width ~= nil and text_width > max_width then 
  51. 		local text_scale = max_width/text_width 
  52. 		self:set_scale(text_scale,text_scale) 
  53. 	else 
  54. 		self:set_scale(1.0,1.0) 
  55. 	end 
  56. 	 
  57. 	text_obj:set_alpha(1.0) 
  58. 	text_obj:set_anchor(0,0) 
  59. 	 
  60. 	local crumb_obj = Vdo_base_object:new("text_crumb", self.handle) 
  61. 	crumb_obj:set_visible(false) 
  62. 	 
  63. end 
  64.  
  65. function Vdo_pause_header:set_crumb(new_text_string) 
  66. 	local crumb_obj = Vdo_base_object:new("text_crumb", self.handle) 
  67. 	if new_text_string ~= nil or new_text_string ~= "" then 
  68. 		crumb_obj:set_visible(true) 
  69. 		crumb_obj:set_text(new_text_string) 
  70. 	else 
  71. 		crumb_obj:set_visible(false) 
  72. 		crumb_obj:set_text("") 
  73. 	end 
  74.  
  75. end 
  76.  
  77.  
  78. function Vdo_pause_header:set_alignment(alignment) 
  79. 	local text_obj_h = vint_object_find("text", self.handle) 
  80. 	vint_set_property(text_obj_h, "auto_offset", alignment) 
  81. end 
  82.  
  83. function Vdo_pause_header:set_text_scale(scale) 
  84. 	local text_obj_h = vint_object_find("text", self.handle) 
  85. 	vint_set_property(text_obj_h, "text_scale", scale, scale) 
  86. end 
  87.  
  88. function Vdo_pause_header:get_size() 
  89. 	local text_obj_h = vint_object_find("text", self.handle) 
  90. 	return element_get_actual_size(text_obj_h) 
  91. end 
  92.  
  93.  
  94.  
  95.  
  96.