Skip to content

Commit

Permalink
Adds Downloads tab
Browse files Browse the repository at this point in the history
Closes #91
Thanks @leafo for async tip!
Thanks ThatTreeOverThere for making me think!
  • Loading branch information
josefnpat committed Sep 7, 2013
1 parent 2960701 commit 59aa44c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/core/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ ui.conditions.all = function(g) return true end
ui.conditions.favorites = function(g)
return settings.data.games[g.id].favorite
end
ui.conditions.downloaded = function(g)
return love.filesystem.exists(fname(g,g.stable)..".sha1")
end

function ui.create_list(condition)
local list = loveframes.Create("columnlist")
Expand Down Expand Up @@ -120,6 +123,9 @@ function ui.load()

ui.list.favorites = ui.create_list(ui.conditions.favorites)
tabs:AddTab("Favorites",ui.list.favorites,"Your favorite games")

ui.list.downloaded = ui.create_list(ui.conditions.downloaded)
tabs:AddTab("Downloaded",ui.list.downloaded,"Downloaded games.")

ui.buttons = {}

Expand Down Expand Up @@ -173,7 +179,6 @@ function ui.load()
visitwebsite_tooltip:SetObject(ui.buttons.visitwebsite)
visitwebsite_tooltip:SetPadding(4)
visitwebsite_tooltip:SetText("Visit the author's website.")


end

Expand All @@ -198,7 +203,12 @@ function ui.update(dt)
end

ui.update_buttons()


if ui.download_change then
ui.download_change = nil
ui.list.downloaded = ui.update_list(ui.list.downloaded,ui.conditions.downloaded)
end

end

function ui.header()
Expand Down
2 changes: 2 additions & 0 deletions src/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ function dogame(gameobj)
currently_downloading[fn] = true
downloader:request(url, async.love_filesystem_sink(fn,true), function()
currently_downloading[fn] = nil
ui.download_change = true
end)
end

Expand All @@ -78,6 +79,7 @@ function deletegame(index)
love.filesystem.remove(imgname(gameobj))
ui.images[index] = nil
gameobj.invalid = nil
ui.download_change = true
end
end

Expand Down

0 comments on commit 59aa44c

Please sign in to comment.