When i was scrolling the gooey dynamic list, text variables are scrolled successfully but the images not scrolled successfully.
please help me ,
local LISTITEM_SELECTED = hash("blue_button04")
local LISTITEM_PRESSED = hash("blue_button04")
local LISTITEM = hash("blue_button04")
local function update_listitem(list, item)
local pos = gui.get_position(item.root)
if item.index == list.selected_item then
pos.x = 0
gui.play_flipbook(item.root, LISTITEM)
elseif item.index == list.pressed_item then
pos.x = 0
gui.play_flipbook(item.root, LISTITEM)
elseif item.index == list.over_item_now then
pos.x = 0
gui.play_flipbook(item.root, LISTITEM)
elseif item.index == list.out_item_now then
pos.x = 0
gui.play_flipbook(item.root, LISTITEM)
elseif item.index ~= list.over_item then
pos.x = 0
gui.play_flipbook(item.root, LISTITEM)
end
gui.set_position(item.root, pos)
end
local function update_dynamic_list(list)
for _,item in ipairs(list.items) do
update_listitem(list, item)
local tempData = item.data;
local imgurl = tempData.player_photo;
if imgurl then
gui.set_text(item.nodes[hash(list.id .. "/listitem_text")], tostring(tempData.player_name or "-"))
gui.set_text(item.nodes[hash(list.id .. "/place")], tostring(tempData.rank or "-"))
gui.set_text(item.nodes[hash(list.id .. "/points")], tostring(tempData.score or "-"))
load_and_set_texture(imgurl, item.nodes[hash(list.id .. "/profilepic")])
else
gui.set_text(item.nodes[hash(list.id .. "/listitem_text")], tostring(tempData.player_name or "-"))
gui.set_text(item.nodes[hash(list.id .. "/place")], tostring(tempData.rank or "-"))
gui.set_text(item.nodes[hash(list.id .. "/points")], tostring(tempData.score or "-"))
load_and_set_texture("https://fiverr-res.cloudinary.com/t_profile_original,q_auto,f_auto/profile/photos/62988106/original/facebook-default-no-profile-pic.jpg", item.nodes[hash(list.id .. "/profilepic")])
end
end
end
function load_and_set_texture(url, node)
http.request(url, "GET", function(self, id, res)
if res.status ~= 200 and res.status ~= 304 then
print("Unable to get image", res.response)
return
end
local img = image.load(res.response)
if not img then
print("Unable to load image",url)
return
end
local texture_id = url
if gui.new_texture(texture_id, img.width, img.height, img.type, img.buffer) then
gui.set_scale(node,vmath.vector3(0.12,0.12,1))
gui.set_texture(node, texture_id)
else
print("Unable to create texture",url)
end
end)
end
function dynamic_list(list_id, scrollbar_id, data, action_id, action, fn)
local list = gooey.dynamic_list(list_id, list_id .. "/stencil", list_id .. "/listitem_bg", data, action_id, action, fn, update_dynamic_list)
if scrollbar_id then
-- scrolled in list -> update scrollbar
if list.scrolling then
gooey.vertical_scrollbar(scrollbar_id .. "/handle", scrollbar_id .. "/bounds").scroll_to(0, list.scroll.y)
else
-- scroll using scrollbar -> scroll list
gooey.vertical_scrollbar(scrollbar_id .. "/handle", scrollbar_id .. "/bounds", action_id, action, function(scrollbar)
gooey.dynamic_list(list_id, list_id .. "/stencil", list_id .. "/listitem_bg", data).scroll_to(0, scrollbar.scroll.y)
end)
end
end
return list
end
function on_input(self, action_id, action)
dynamic_list("dynamiclist", "dynamicscrollbar", self.list_data, action_id, action, function(list)
--print("selected dynamic list item", list.selected_item, self.list_data[list.selected_item])
end)
end