./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) 
  41.  
  42.  
  43. 	self.current_img_name = image 
  44. 	self.current_img:set_image(image) 
  45. 	self.current_img:set_visible(true) 
  46. 	self.level_req_grp:set_visible(is_locked) 
  47. 	 
  48.  
  49. 	--dims item if locked 
  50. 	if is_locked == true then  
  51. 		self.current_img:set_color(50/255, 50/255, 50/255) 
  52. 	else  
  53. 		self.current_img:set_color(255/255, 255/255, 255/255) 
  54. 	end 
  55. 	 
  56. 	local body 
  57. 	--local insert_values = { [0] = required_level } 
  58. 	--body = vint_insert_values_in_string("STORE_LEVEL_REQ", insert_values) 
  59. 	self.level_req:set_text(required_level)--body)	 
  60. 	 
  61. 	local img_width, img_height = self.current_img:get_actual_size() 
  62.  
  63. 	-- Position description 
  64. 	local desc_x = (img_width * -0.5) 
  65. 	local desc_y = (img_height * 0.5 + DESCRIPTION_PAD) 
  66. 	 
  67. 	--  
  68. 	self.description:set_anchor(desc_x, desc_y)			 
  69. 	self.description:set_property("wrap_width", img_width) 
  70. 	 
  71. 	-- Position locked grp 
  72. 	local lock_x = (img_width * 0.5 - DESCRIPTION_PAD) 
  73. 	local lock_y = (img_height * 0.5 - DESCRIPTION_PAD) 
  74. end 
  75.  
  76. function Vdo_bitmap_viewer:get_image() 
  77. 	return self.current_img_name 
  78. end 
  79.  
  80. function Vdo_bitmap_viewer:set_description(description, description_crc) 
  81.  
  82. 	if description == nil then 
  83. 		self.description:set_text_crc(description_crc) 
  84. 	else 
  85. 		self.description:set_text(description) 
  86. 	end 
  87.  
  88. end