{"id":60,"date":"2023-06-23T21:18:25","date_gmt":"2023-06-23T21:18:25","guid":{"rendered":"https:\/\/blogs.scummvm.org\/ankushdutt\/?p=60"},"modified":"2023-06-24T14:34:22","modified_gmt":"2023-06-24T14:34:22","slug":"dlc-backend","status":"publish","type":"post","link":"https:\/\/blogs.scummvm.org\/ankushdutt\/2023\/06\/23\/dlc-backend\/","title":{"rendered":"Laying The Groundwork For Implementing DLC Downloading Functions"},"content":{"rendered":"<p>This week I worked on the backend part for integrating DLC downloader in ScummVM. In the backend, I need to implement download-related functions like requesting a download, getting downloaded progress, getting downloadable games list (with information like name, size, id, etc.), getting downloaded location, handling errors, etc.<\/p>\n<p>Since every distribution stores have its own API\/SDKs for implementing these functionalities, I required a way to make the ScummVM know which implementation to run. We can do this via dynamic polymorphism.\u00a0In my case, I had to create a new <a href=\"https:\/\/www.ibm.com\/docs\/en\/zos\/2.4.0?topic=only-abstract-classes-c\">abstract class<\/a> called <code>Store<\/code> containing prototype for store-specific functions. Using <code>Store<\/code>, we can derive different classes like <code>PlayStore<\/code> with implementations specific to the distribution stores.<\/p>\n<p>I need a way to use these download-related functions in my downloader GUI or even in the background. For this, I have created a new class called <code>DLC<\/code><code>Manager<\/code>, which gets instantiated as <code>DLCMan<\/code> on startup (in <code>scummvm_main()<\/code>). <code>DLCMan<\/code> will provide the interface for all the functions I will require for the DLC downloader, handling errors appropriately and also showing what went wrong in a message modal.<\/p>\n<p>Here&#8217;s the complete overview:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-71 aligncenter\" src=\"https:\/\/blogs.scummvm.org\/ankushdutt\/wp-content\/uploads\/sites\/67\/2023\/06\/scummvm4-300x214.png\" alt=\"\" width=\"895\" height=\"639\" srcset=\"https:\/\/blogs.scummvm.org\/ankushdutt\/wp-content\/uploads\/sites\/67\/2023\/06\/scummvm4-300x214.png 300w, https:\/\/blogs.scummvm.org\/ankushdutt\/wp-content\/uploads\/sites\/67\/2023\/06\/scummvm4-768x547.png 768w\" sizes=\"auto, (max-width: 895px) 100vw, 895px\" \/><\/p>\n<p>Additionally, in the non-android ScummVM executable, I was able to hide the &#8220;Download Games&#8221; button, which opens the DLC browser. I have introduced a new <code>OSystem<\/code> feature, <code>kFeatureDLC<\/code>, that would determine whether the ScummVM executable supports downloading DLC. If it doesn&#8217;t, then I have to hide DLC-related widgets.<\/p>\n<p>You can check all the code changes <a href=\"https:\/\/github.com\/ankushdutt\/scummvm\/commit\/e65865846ab1fa4fb9be83e2d4b71245d96c9ce9\">here<\/a>.<\/p>\n<p>The backend code is pretty complex. Initially, it was very intimidating to get something done. Thanks to my mentors, I&#8217;ve made some decent progress in sorting out the classes and functions. I learned some advanced C++ concepts as well. Hopefully, by next week I will be able to implement the download-related functions for Android Play Store.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This week I worked on the backend part for integrating DLC downloader in ScummVM. In the backend, I need to implement download-related functions like requesting a download, getting downloaded progress, getting downloadable games list (with information like name, size, id, etc.), getting downloaded location, handling errors, etc. Since every distribution stores have its own API\/SDKs [&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-60","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.scummvm.org\/ankushdutt\/wp-json\/wp\/v2\/posts\/60","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=60"}],"version-history":[{"count":16,"href":"https:\/\/blogs.scummvm.org\/ankushdutt\/wp-json\/wp\/v2\/posts\/60\/revisions"}],"predecessor-version":[{"id":77,"href":"https:\/\/blogs.scummvm.org\/ankushdutt\/wp-json\/wp\/v2\/posts\/60\/revisions\/77"}],"wp:attachment":[{"href":"https:\/\/blogs.scummvm.org\/ankushdutt\/wp-json\/wp\/v2\/media?parent=60"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/ankushdutt\/wp-json\/wp\/v2\/categories?post=60"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/ankushdutt\/wp-json\/wp\/v2\/tags?post=60"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}