./vdo_grid_button_check.lua

  1. function vdo_grid_button_check_init() 
  2. end 
  3.  
  4. function vdo_grid_button_check_cleanup() 
  5. end 
  6.  
  7. -- Inherited from Vdo_base_object 
  8. Vdo_grid_button_check = Vdo_base_object:new_base() 
  9.  
  10.  
  11. function Vdo_grid_button_check:init() 
  12. 	self.bg_highlight = Vdo_base_object:new("bg_highlight", self.handle, self.doc_handle) 
  13. 	self.bg_highlight:set_visible(false) 
  14. 	 
  15. 	self.highlight_color = COLOR_STORE_WEAPON_PRIMARY 
  16. 	 
  17. 	local icon2 = Vdo_base_object:new("grid_icon2", self.handle, self.doc_handle) 
  18. 	icon2:set_visible(false) 
  19. 	 
  20. 	local checkbox = Vdo_base_object:new("checkbox", self.handle, self.doc_handle) 
  21. 	local checkbox_shadow = Vdo_base_object:new("checkbox_shadow", self.handle, self.doc_handle) 
  22. 	checkbox:set_visible(false) 
  23. 	checkbox_shadow:set_visible(false) 
  24. end 
  25.  
  26. --sets the lock icon for the grid button 
  27. function Vdo_grid_button_check:set_lock(is_locked) 
  28. end 
  29.  
  30. --sets the icon for the grid button 
  31. function Vdo_grid_button_check:set_icon(new_icon, dual_is_visible) 
  32. 	local icon = Vdo_base_object:new("grid_icon", self.handle, self.doc_handle) 
  33. 	local icon2 = Vdo_base_object:new("grid_icon2", self.handle, self.doc_handle) 
  34. 	icon:set_property("image", new_icon) 
  35. 	icon2:set_property("image", new_icon) 
  36. 	 
  37. 	if dual_is_visible == true then 
  38. 		icon2:set_visible(true) 
  39. 	end 
  40. end 
  41.  
  42. --sets the icon for the grid button using a crc of the image name 
  43. --Used by the mp badge selection screen 
  44. function Vdo_grid_button_check:set_icon_crc(new_icon_crc) 
  45. 	local icon = Vdo_base_object:new("grid_icon", self.handle, self.doc_handle) 
  46. 	icon:set_property("image_crc", new_icon_crc) 
  47. end 
  48.  
  49. -- Sets the width of the grid button 
  50. function Vdo_grid_button_check:set_size(width,height) 
  51. 	--[[local bg = vint_object_find("bg", self.handle, self.doc_handle) 
  52. 	local checkbox = Vdo_base_object:new("checkbox", self.handle, self.doc_handle) 
  53. 	 
  54. 	element_set_actual_size(bg, width, height) 
  55. 	 
  56. 	-- Reposition checkbox to fit bg size 
  57. 	local CHECKBOX_BUFFER = 40 
  58. 	checkbox:set_anchor((width * 0.5) - CHECKBOX_BUFFER, (width * 0.5) - CHECKBOX_BUFFER) 
  59. 	]]-- 
  60. end 
  61.  
  62. -- Sets the highlighted state of the grid button to on or off 
  63. function Vdo_grid_button_check:set_highlight(is_highlighted, dual_is_visible) 
  64. 	local icon = Vdo_base_object:new("grid_icon", self.handle, self.doc_handle) 
  65. 	local icon2 = Vdo_base_object:new("grid_icon2", self.handle, self.doc_handle) 
  66. 	local bg = Vdo_base_object:new("bg", self.handle, self.doc_handle) 
  67. 	local main =  Vdo_base_object:new("safe_frame", self.handle, self.doc_handle) 
  68. 	 
  69. 	if dual_is_visible == true then 
  70. 		icon2:set_visible(true) 
  71. 	end 
  72. 	 
  73. 	if is_highlighted then 
  74. 		icon:set_alpha(1.0) 
  75. 		icon2:set_alpha(1.0) 
  76. 		self.bg_highlight:set_color(self.highlight_color.R,self.highlight_color.G,self.highlight_color.B)		 
  77. 		self.bg_highlight:set_visible(true) 
  78. 		main:set_property("alpha",1.0) 
  79. 		main:set_property("scale",1.1,1.1) 
  80. 	else		 
  81. 		main:set_property("scale",1,1) 
  82. 		self.bg_highlight:set_visible(false)		 
  83. 	end 
  84. end 
  85.  
  86. -- Set checkbox status 
  87. -- -1 	-Hidden 
  88. -- 0		-Empty Box 
  89. -- 1		-Checked 
  90. -- 2		-Locked 
  91. function Vdo_grid_button_check:set_checkbox(check_status,color) 
  92. 	local checkbox = Vdo_base_object:new("checkbox", self.handle, self.doc_handle) 
  93. 	local checkbox_shadow = Vdo_base_object:new("checkbox_shadow", self.handle, self.doc_handle) 
  94. 	 
  95. 	if color ~= nil then 
  96. 		checkbox:set_color(color.R,color.G,color.B) 
  97. 	end 
  98. 	 
  99. 	if check_status == -1 then 
  100. 		checkbox:set_visible(false) 
  101. 		checkbox_shadow:set_visible(false) 
  102. 	elseif check_status == 0 then 
  103. 		checkbox:set_image("ui_store_icon_box") 
  104. 		checkbox_shadow:set_image("ui_store_icon_box") 
  105. 		checkbox:set_visible(true) 
  106. 		checkbox_shadow:set_visible(true) 
  107. 	elseif check_status == 1 then 
  108. 		checkbox:set_image("ui_store_icon_checkbox") 
  109. 		checkbox_shadow:set_image("ui_store_icon_checkbox") 
  110. 		checkbox:set_visible(true) 
  111. 		checkbox_shadow:set_visible(true) 
  112. 	elseif check_status == 2 then 
  113. 		checkbox:set_image("ui_store_icon_lock_sm") 
  114. 		checkbox_shadow:set_image("ui_store_icon_checkbox") 
  115. 		checkbox:set_visible(true) 
  116. 		checkbox_shadow:set_visible(true) 
  117. 	end 
  118. end 
  119.  
  120. function Vdo_grid_button_check:set_highlight_color(color) 
  121. 	self.highlight_color = color 
  122. 	self.bg_highlight:set_color(color.R,color.G,color.B)		 
  123. end