./vdo_bitmap_viewer.lua

  1.  
  2. local DESCRIPTION_PAD = 8 
  3.  
  4. function vdo_bitmap_viewer_init() 
  5. end 
  6.  
  7. -- Inherited from Vdo_base_object 
  8. Vdo_bitmap_viewer = Vdo_base_object:new_base() 
  9.  
  10. function Vdo_bitmap_viewer:init() 
  11. 	 
  12. 	self.current_img_name = nil 
  13. 	self.current_img = Vdo_base_object:new("current_img", self.handle) 
  14. 	self.description = Vdo_base_object:new("description", self.handle) 
  15. 	self.level_req_grp = Vdo_base_object:new("level_req_grp",self.handle) 
  16. 	self.level_req_lock_grp = Vdo_base_object:new("level_req_lock_grp",self.handle) 
  17. 	self.level_req = Vdo_base_object:new("level_req", self.handle) 
  18. 	self.level_req_label = Vdo_base_object:new("level_req_label", self.handle) 
  19.  
  20. 	 
  21. 	-- Hide until we have an image that is locked 
  22. 	self.level_req_grp:set_visible(false) 
  23. 	 
  24. 	self.level_req_label:set_text("STORE_UPGRADES_REQUIRED") 
  25. 	 
  26. end 
  27.  
  28.  
  29. ------------------------------------------- 
  30. -- Vdo_bitmap_viewer:draw_items(data) 
  31. -- **************************************** 
  32. -- Data items 
  33. -- **************************************** 
  34. -- image 
  35. -- required_level 
  36. -- reward_level 
  37. --	is_locked 
  38. -- is_owned 
  39. ------------------------------------------- 
  40. function Vdo_bitmap_viewer:set_image(image, is_locked, is_owned, reward_level, required_level, scale_x, scale_y, is_gameplay_gated) 
  41.  
  42.  
  43. 	self.current_img_name = image 
  44. 	self.current_img:set_image(image) 
  45. 	self.current_img:set_visible(true) 
  46. 	self.current_img:set_scale(scale_x, scale_y) 
  47. 	 
  48. 	 
  49. 	--dims item if locked 
  50. 	if is_locked == true or (is_gameplay_gated ~= nil and is_gameplay_gated ~= "") then  
  51. 		self.current_img:set_color(50/255, 50/255, 50/255) 
  52. 		self.description:set_alpha(.5) 
  53. 	else  
  54. 		self.current_img:set_color(255/255, 255/255, 255/255) 
  55. 		self.description:set_alpha(1) 
  56. 	end 
  57. 	 
  58. 	if (is_gameplay_gated ~= nil and is_gameplay_gated ~= "") then 
  59. 		self.level_req_grp:set_visible(false) 
  60. 	else 
  61. 		self.level_req_grp:set_visible(is_locked) 
  62. 	end 
  63. 	 
  64. 	local body 
  65. 	--local insert_values = { [0] = required_level } 
  66. 	--body = vint_insert_values_in_string("STORE_LEVEL_REQ", insert_values) 
  67. 	self.level_req:set_text(var_to_string(required_level))--body)	 
  68. 	 
  69. 	local img_width, img_height = self.current_img:get_actual_size() 
  70.  
  71. 	-- Position description 
  72. 	local desc_x = (img_width * -0.5) 
  73. 	local desc_y = (img_height * 0.5 + DESCRIPTION_PAD) 
  74. 	 
  75. 	--  
  76. 	self.description:set_anchor(desc_x, desc_y)			 
  77. 	self.description:set_property("wrap_width", img_width) 
  78. 	 
  79. 	-- Position locked grp 
  80. 	local lock_x = (img_width * 0.5 - DESCRIPTION_PAD) 
  81. 	local lock_y = (img_height * 0.5 - DESCRIPTION_PAD) 
  82. 	 
  83. end 
  84.  
  85. function Vdo_bitmap_viewer:get_image() 
  86. 	return self.current_img_name 
  87. end 
  88.  
  89. function Vdo_bitmap_viewer:set_description(description, description_crc) 
  90. 	 
  91. 	if description == nil then 
  92. 		self.description:set_text_crc(description_crc) 
  93. 	else 
  94. 		self.description:set_text(description) 
  95. 	end 
  96.  
  97. end