local DESCRIPTION_PAD = 8
function vdo_bitmap_viewer_init()
end
-- Inherited from Vdo_base_object
Vdo_bitmap_viewer = Vdo_base_object:new_base()
function Vdo_bitmap_viewer:init()
self.current_img_name = nil
self.current_img = Vdo_base_object:new("current_img", self.handle)
self.description = Vdo_base_object:new("description", self.handle)
self.level_req_grp = Vdo_base_object:new("level_req_grp",self.handle)
self.level_req_lock_grp = Vdo_base_object:new("level_req_lock_grp",self.handle)
self.level_req = Vdo_base_object:new("level_req", self.handle)
self.level_req_label = Vdo_base_object:new("level_req_label", self.handle)
-- Hide until we have an image that is locked
self.level_req_grp:set_visible(false)
self.level_req_label:set_text("STORE_UPGRADES_REQUIRED")
end
-------------------------------------------
-- Vdo_bitmap_viewer:draw_items(data)
-- ****************************************
-- Data items
-- ****************************************
-- image
-- required_level
-- reward_level
-- is_locked
-- is_owned
-------------------------------------------
function Vdo_bitmap_viewer:set_image(image, is_locked, is_owned, reward_level, required_level, scale_x, scale_y, is_gameplay_gated)
self.current_img_name = image
self.current_img:set_image(image)
self.current_img:set_visible(true)
self.current_img:set_scale(scale_x, scale_y)
--dims item if locked
if is_locked == true or (is_gameplay_gated ~= nil and is_gameplay_gated ~= "") then
self.current_img:set_color(50/255, 50/255, 50/255)
self.description:set_alpha(.5)
else
self.current_img:set_color(255/255, 255/255, 255/255)
self.description:set_alpha(1)
end
if (is_gameplay_gated ~= nil and is_gameplay_gated ~= "") then
self.level_req_grp:set_visible(false)
else
self.level_req_grp:set_visible(is_locked)
end
local body
--local insert_values = { [0] = required_level }
--body = vint_insert_values_in_string("STORE_LEVEL_REQ", insert_values)
self.level_req:set_text(var_to_string(required_level))--body)
local img_width, img_height = self.current_img:get_actual_size()
-- Position description
local desc_x = (img_width * -0.5)
local desc_y = (img_height * 0.5 + DESCRIPTION_PAD)
--
self.description:set_anchor(desc_x, desc_y)
self.description:set_property("wrap_width", img_width)
-- Position locked grp
local lock_x = (img_width * 0.5 - DESCRIPTION_PAD)
local lock_y = (img_height * 0.5 - DESCRIPTION_PAD)
end
function Vdo_bitmap_viewer:get_image()
return self.current_img_name
end
function Vdo_bitmap_viewer:set_description(description, description_crc)
if description == nil then
self.description:set_text_crc(description_crc)
else
self.description:set_text(description)
end
end