{"id":86,"date":"2023-07-09T12:44:57","date_gmt":"2023-07-09T12:44:57","guid":{"rendered":"https:\/\/blogs.scummvm.org\/ankushdutt\/?p=86"},"modified":"2023-07-10T11:26:05","modified_gmt":"2023-07-10T11:26:05","slug":"dlc-downloader-flow","status":"publish","type":"post","link":"https:\/\/blogs.scummvm.org\/ankushdutt\/2023\/07\/09\/dlc-downloader-flow\/","title":{"rendered":"DLC Downloader Flow"},"content":{"rendered":"<p>This week I came up with a DLC downloader design and implemented some of the functions in DLC Manager.<\/p>\n<p>DLC Manager before was just a shell with empty definitions, and I had not given much thought to what the functions or how the DLC Manager should behave.<\/p>\n<p>Now that I have given some thought, here is a rough flow of the DLC Downloader: For downloading DLCs, we are providing a GUI with an available downloadable games list. Users can select a DLC and click the Download button to start the download. However, the download button under the hood adds this DLC as a download task in the DLCManager&#8217;s queue. The queue maintains the queued download tasks. We will be processing each download task one at a time. Once a download task is finished\/canceled\/interrupted, then the next one in the queue starts downloading.<\/p>\n<p>But how are we achieving this? We have a <code>processDownload()<\/code> function which looks at this queue. If it&#8217;s not empty (i.e., there is\/are pending download task(s) that we need to handle), we will use an async function called <code>startDownloadAsync()<\/code> to handle the downloading from the distribution store. The <code>startDownloadAsync()<\/code> will, of course, be different for different distribution stores and will be executed in another thread to not block the GUI.<\/p>\n<p>The callback function provided in the <code>startDownloadAsync()<\/code> will run the <code>processDownload()<\/code> after <code>startDownloadAsync()<\/code> finishes executing. The callback function will do two things &#8211; first, notify download has finished\/canceled\/interrupted and then, invoke the <code>processDownload()<\/code> function again to process the next download task in the queue.<\/p>\n<p>There is now a further GUI requirement; since users will need a way to see what is currently downloading and its progress, we would need another modal that can be opened from a button. I have the rough UI design in mind for this new &#8220;downloading&#8221; modal.<\/p>\n<p>Finally, here&#8217;s the overall flow of the DLC downloader:<br \/>\n<a href=\"https:\/\/blogs.scummvm.org\/ankushdutt\/wp-content\/uploads\/sites\/67\/2023\/07\/9jul.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-94\" src=\"https:\/\/blogs.scummvm.org\/ankushdutt\/wp-content\/uploads\/sites\/67\/2023\/07\/9jul.png\" alt=\"\" width=\"2714\" height=\"1307\" srcset=\"https:\/\/blogs.scummvm.org\/ankushdutt\/wp-content\/uploads\/sites\/67\/2023\/07\/9jul.png 2714w, https:\/\/blogs.scummvm.org\/ankushdutt\/wp-content\/uploads\/sites\/67\/2023\/07\/9jul-300x144.png 300w, https:\/\/blogs.scummvm.org\/ankushdutt\/wp-content\/uploads\/sites\/67\/2023\/07\/9jul-1024x493.png 1024w, https:\/\/blogs.scummvm.org\/ankushdutt\/wp-content\/uploads\/sites\/67\/2023\/07\/9jul-768x370.png 768w, https:\/\/blogs.scummvm.org\/ankushdutt\/wp-content\/uploads\/sites\/67\/2023\/07\/9jul-1536x740.png 1536w, https:\/\/blogs.scummvm.org\/ankushdutt\/wp-content\/uploads\/sites\/67\/2023\/07\/9jul-2048x986.png 2048w, https:\/\/blogs.scummvm.org\/ankushdutt\/wp-content\/uploads\/sites\/67\/2023\/07\/9jul-1200x578.png 1200w, https:\/\/blogs.scummvm.org\/ankushdutt\/wp-content\/uploads\/sites\/67\/2023\/07\/9jul-1980x954.png 1980w\" sizes=\"auto, (max-width: 2714px) 100vw, 2714px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This week I came up with a DLC downloader design and implemented some of the functions in DLC Manager. DLC Manager before was just a shell with empty definitions, and I had not given much thought to what the functions or how the DLC Manager should behave. Now that I have given some thought, here [&hellip;]<\/p>\n","protected":false},"author":15,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-86","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.scummvm.org\/ankushdutt\/wp-json\/wp\/v2\/posts\/86","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.scummvm.org\/ankushdutt\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.scummvm.org\/ankushdutt\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/ankushdutt\/wp-json\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/ankushdutt\/wp-json\/wp\/v2\/comments?post=86"}],"version-history":[{"count":12,"href":"https:\/\/blogs.scummvm.org\/ankushdutt\/wp-json\/wp\/v2\/posts\/86\/revisions"}],"predecessor-version":[{"id":102,"href":"https:\/\/blogs.scummvm.org\/ankushdutt\/wp-json\/wp\/v2\/posts\/86\/revisions\/102"}],"wp:attachment":[{"href":"https:\/\/blogs.scummvm.org\/ankushdutt\/wp-json\/wp\/v2\/media?parent=86"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/ankushdutt\/wp-json\/wp\/v2\/categories?post=86"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/ankushdutt\/wp-json\/wp\/v2\/tags?post=86"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}