./vdo_pause_button_toggle.lua

  1. ---------------------------------------------------------------------------  
  2. -- Vdo_pm_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. function vdo_pause_button_toggle_init() 
  8. end 
  9. function vdo_pause_button_toggle_cleanup() 
  10. end 
  11.  
  12. -- Inherited from Vdo_base_object 
  13. Vdo_pause_button_toggle = Vdo_base_object:new_base() 
  14.  
  15. COLOR_PAUSE_BUTTON_TOGGLE_TEXT_UNSELECTED = {R = 194/255, G = 201/255; B = 204/255} 
  16. COLOR_PAUSE_BUTTON_TOGGLE_TEXT_SELECTED = {R = 0/255, G = 0/255; B = 0/255} 
  17.  
  18. --COLOR_MAINMENU_TOGGLE_TEXT_UNSELECTED 	= {R = 160/255, G = 160/255; B = 160/255} 
  19. COLOR_MAINMENU_TOGGLE_TEXT_UNSELECTED 	= {R = 180/255, G = 180/255; B = 180/255} 
  20. COLOR_MAINMENU_TOGGLE_TEXT_SELECTED 	= {R = 160/255, G = 0/255; B = 224/255} 
  21.  
  22. local SELECTED_SCALE = 1.0 
  23. local UNSELECTED_SCALE = 1.0 
  24.  
  25. function Vdo_pause_button_toggle:init() 
  26. 	self:set_color(COLOR_PAUSE_BUTTON_TOGGLE_TEXT_SELECTED, COLOR_PAUSE_BUTTON_TOGGLE_TEXT_UNSELECTED) 
  27. end 
  28.  
  29.  
  30. -- Sets the label of the button object 
  31. function Vdo_pause_button_toggle:set_label(new_label) 
  32. 	local text = Vdo_base_object:new("toggle_text", self.handle) 
  33. 	 
  34. 	if text.handle ~= 0 then 
  35. 		text:set_property("text_tag", new_label) 
  36. 	end 
  37. end 
  38.  
  39. -- Sets the value of the button toggle object 
  40. function Vdo_pause_button_toggle:set_value(new_value) 
  41. 	local value = Vdo_base_object:new("toggle_value", self.handle) 
  42. 	 
  43. 	if value.handle ~= 0 then 
  44. 		value:set_property("text_tag", new_value) 
  45. 	end 
  46. end 
  47.  
  48. -- Sets the width of the button toggle object 
  49. function Vdo_pause_button_toggle:set_width(width) 
  50. --[[ 
  51. 	local techno_text = Vdo_base_object:new("toggle_techno_text", self.handle) 
  52. 	 
  53. 	local rand_texts = { 
  54. 		"ui_hud_small_text1", 
  55. 		"ui_hud_small_text2", 
  56. 	} 
  57. 	 
  58. 	local rand_idx = rand_int(1, #rand_texts) 
  59. 	techno_text:set_property("image", rand_texts[rand_idx]) 
  60.  
  61. 	local value = Vdo_base_object:new("toggle_value", self.handle) 
  62. 	--get the old value anchor 
  63. 	local bogus_x, value_y = value:get_property("anchor") 
  64. 	local value_x = width * 0.75 
  65. 	value:set_property("anchor", value_x, value_y) 
  66. 	 
  67. 	]] 
  68. end 
  69.  
  70. ---------------------------------------------------------------------------  
  71. -- Sets the highlighted state of the button to on or off 
  72. -- @param is_highlighted	Boolean determining if the button is in the  
  73. --									highlight state or not. 
  74. --------------------------------------------------------------------------- 
  75. function Vdo_pause_button_toggle:set_highlight(is_highlighted) 
  76. 	--Get Object References 
  77. 	local value_obj = Vdo_base_object:new("toggle_value", self.handle) 
  78. 	local text_obj = Vdo_base_object:new("toggle_text", self.handle) 
  79. 		 
  80. 	if is_highlighted then 
  81. 		--Set color 
  82. 		value_obj:set_color(self.selected_color.R, self.selected_color.G, self.selected_color.B) 
  83. 		text_obj:set_color(self.selected_color.R, self.selected_color.G, self.selected_color.B) 
  84. 		 
  85. 		--Set Scale 
  86. 		value_obj:set_scale(SELECTED_SCALE, SELECTED_SCALE) 
  87. 		text_obj:set_scale(SELECTED_SCALE, SELECTED_SCALE) 
  88. 	else 
  89. 		--Set Color 
  90. 		value_obj:set_color(self.unselected_color.R, self.unselected_color.G, self.unselected_color.B) 
  91. 		text_obj:set_color(self.unselected_color.R, self.unselected_color.G, self.unselected_color.B) 
  92. 		 
  93. 		--Set Scale 
  94. 		value_obj:set_scale(UNSELECTED_SCALE, UNSELECTED_SCALE) 
  95. 		text_obj:set_scale(UNSELECTED_SCALE, UNSELECTED_SCALE) 
  96. 	end 
  97. end 
  98.  
  99. -- Sets the enabled state of the button to on or off 
  100. function Vdo_pause_button_toggle:set_enabled(enabled) 
  101. end 
  102.  
  103. function Vdo_pause_button_toggle:get_text_width() 
  104. 	local text_obj = Vdo_base_object:new("toggle_text", self.handle) 
  105. 	local width, height = text_obj:get_actual_size() 
  106. 	 
  107. 	local text_obj_scale = text_obj:get_scale() 
  108. 	 
  109. 	--Always return the max size of the text string 
  110. 	if text_obj_scale == SELECTED_SCALE then 
  111. 		return width 
  112. 	else 
  113. 		return width * SELECTED_SCALE 
  114. 	end 
  115. end 
  116.  
  117. -- Sets the color of the pause button... 
  118. function Vdo_pause_button_toggle:set_color(selected_color, unselected_color) 
  119. 	self.selected_color 		= selected_color 
  120. 	self.unselected_color 	= unselected_color 
  121. end 
  122.  
  123. function Vdo_pause_button_toggle:set_shadow(has_shadow) 
  124.  
  125. 	--This does more than set shadow but gets us what we want on the main menu for sr3... 
  126. 	local text_h = vint_object_find("toggle_text", self.handle) 
  127. 	 
  128. 	vint_set_property(text_h, "font", "header_n") 
  129. 	vint_set_property(text_h, "text_scale", .4, .4) 
  130. 	 
  131. 	 
  132. 	if has_shadow then 
  133. 		vint_set_property(text_h, "shadow_enabled", true) 
  134. 		vint_set_property(text_h, "shadow_offset", 1.5,1.5) 
  135. 		vint_set_property(text_h, "shadow_alpha", 0.8) 
  136. 		 
  137. 		--vint_set_property(text_h, "line_frame_w", "ui_fnt_body_s_w") 
  138. 		--vint_set_property(text_h, "line_frame_m", "ui_fnt_body_s_m") 
  139. 		--vint_set_property(text_h, "line_frame_e", "ui_fnt_body_s_e") 
  140. 		--vint_set_property(text_h, "line_frame_enable", true) 
  141. 	 
  142. 	else 
  143. 		vint_set_property(text_h, "shadow_enabled", false) 
  144. 	end 
  145. end