Welcome to the sponsor-exclusive content for the Ren'Py Patreon. Sponsors like you ensure this page exists. Thank you.

_images/2021-08.jpg

Ren’Py Developer Update - August 2021 link

It’s the end of August. Summer is nearly over, at least for us here in the northern hemisphere, but Ren’Py development is still nice and hot. This month’s developer update will talk about some of the changes that happened in August, and for the Android changes, how those will affect you and your players.

August 2021 link

7.4.8 link

The first thing that happened this month was the release of Ren’Py 7.4.8, which was a fairly small release of Ren’Py intended to fix a major issue. There were a few features that were done in time for the release, like the ability to pause Movies as you would any other audio. Still, the main purpose of the release was to provide a stable version as I worked on 7.4.9, and the release accomplished it.

Android link

The main focus of Ren’Py 7.4.9 is going to be updating the Android build process to make sure Ren’Py games can continue to be distributed through Google Play. This involved three major changes this month.

The first was that the target SDK version had to be bumped up to 30, which corresponds to Android 11. This shouldn’t have any effect on most Ren’Py games, but if you access Android APIs outside of Ren’Py, you might want to read the Android documentation.

The other two changes are the move to Android App Bundles, and the replacement of Expansion APKs with Play Asset Delivery, each of which is a big enough change that it should get its own section.

Android - AABs link

Google Play now requires you to upload new games, and soon will require you to upload game updates, in a new format called Android App Bundle. This format simplifies things, as it allows a single file to include everything required for a version of the game, including the Ren’Py base, the libraries for each of the platforms, and bundles of assets that are needed for the game to run.

When a player downloads your game from Google Play, the servers will take the app bundle you uploaded, and choose the parts of it required for the game to run on a player’s device. Those parts will be combined to make an APK (Android Package) file that is signed by Google, then downloaded to the player’s device.

This change does affect how you develop for Android in a few different ways.

The first is that you’ll need to have an Android device connected locally to upload an app produced in the bundle format. The device can be connected via USB, and Android 11 devices can be connected through wireless debugging. Ren’Py will use Android tools to determine what portions of your app need to be uploaded to a particular device, and only those will be installed and run.

A second change is that a different signing key will be use for AABs and APKs, as Google Play doesn’t allow the two formats to use the same key. When developing locally, it might be necessary to uninstall the application from your device when switching from AAB to APK, or vice versa.

Finally, this means that you won’t be able to use an APK to upgrade apps delivered by Google Play. Previously, if your app was removed from the Play Store, you could give a player APK updates. With AABs, that will no longer work. This is something you might want to consider if your game could potentially be removed for content reasons.

Android - Play Asset Delivery link

Another big change in Android is support for Play Asset Delivery, which is the replacement for Expansion APKs. Play Asset Delivery is now required for games that are larger than a minimal size (100 MB or so), and to make Ren’Py simpler, it’s used for all games built as Android App Bundles.

The way that Play Asset Delivery works is to divide the assets of your game up into 4 bundles, each of which can be up to 500 MB in size. After your game is installed on the player’s device, the Play Store will download these asset bundles, provided the player is connected via Wi-Fi.

Android allows the player to start the game even though the assets are still being downloaded. As Ren’Py won’t be able to start until the game fully exists, what will happen is that the player will be kept at the splashscreen until the downloads finish. To inform the player, a bar keeps track of the download process.

There are a couple of ways this might affect how you’ll make your game. The first is that while both Play Asset Delivery and the old Expansion APK system supported games of up to 2 GB in size, with the new system it’s possible to have files that are smaller in size, and yet still can’t fit.

This problem is caused by the way the assets have to be packaged into four 500 MB files, rather than a single 2 GB (2,000 MB) file. Say we have 5 files, each 300 MB in size. That is 1,500 MB total, so it seems like it might fit. However, what will happen is that Ren’Py will put the first 4 300 MB files into each of the four bundles. When it comes time to place the last file, each bundle will have 200 MB of free space, and so there will be no place to place the remaining file.

Generally, the smaller the file is, the easier it will be to fit it in a bundle. I’d recommend limiting the size of movie and sound files that will be placed on mobile devices, to prevent this problem.

The second thing you might want to do is to customize the new downloading screen that is displayed when Ren’Py is trying to download a game. To do this, create a file, android-downloading.jpg, in the base directory of the game. This file will be displayed in a manner similar to the existing Android presplash screen, except that it will have a system-provided progress bar to display the progress of the download. Unfortunately, there isn’t a way to customize the progress bar.

Updater link

Another thing that got a bit of work in August was the updater built into Ren’Py.

Previously, the updater in Ren’Py was sophisticated, computing a small set of differences between the player’s game and the update on the server, and only downloading those changes. While this has worked great for distributing updates to Ren’Py itself, it’s proven hard to get working. The zsync tool used by the updater doesn’t support HTTPS, which almost every website has moved to, and it requires a web server that supports range queries, which many hosting providers seem not to.

Ren’Py 7.4.9 supports a new mode, in which the update is downloaded in its entirety from a web server. This mode can be enabled by setting the new patch argument to the updater to False, or simply by providing a URL beginning with https. In this new mode, Ren’Py will download the new game from the web server, and install it. This is about the same size as the player downloading the game themselves, and the installation is done automatically.

To produce an update, you’ll first want to enable updates by adding:

define build.include_update = True

at the end of options.rpy. With that in place, the Build Distributions section of the launcher will include a Build Updates option - please make sure that remains checked.

Building the game will produce quite a few files. In addition to the package files, the updater will produce .json, .sums, and .update.gz files that will need to be uploaded to a web server.

Once that’s done, you can update by adding a single button to your game that runs the updater.Update() action.

screen update_example():
    textbutton "Update" action updater.Update("https://www.myserver.com/path/to/files/update.json")

You can also use the update.UpdateVersion function to get the current version of the game, to show that to the player. Ren’Py will check at most 4 times a day, and will not slow the game down to check - the check happens in the background, and your screen will be updated if a new version is found

screen update_example():
    $ UPDATE_URL = "https://www.myserver.com/path/to/files/update.json"
    $ update_version = updater.UpdateVersion(UPDATE_URL)

    if update_version:
        textbutton "Update to [update_version]" action updater.Update(UPDATE_URL)
_images/high-contrast.jpg

Accessibility - High Contrast Text link

Finally, I added a new High Contrast Text mode to Ren’Py. What this does is to force the text color to white (or slightly off white for buttons), with the area underneath the text filled in with black. This can be accessed through the shift+A accessibility menu, and games created with 7.4.9 and later will have this by default.

Like all of the accessibility options, the Preference() action will allow you to create buttons in a more themed accessibility menu to provide more direct access to this function.

This functionality came about from a comment here on Patreon, and now it’ll be in future versions of Ren’Py.

Looking Forwards link

Looking forwards, Ren’Py 7.4.9 is feeling close to done, and so I’d expect a prerelease shortly, followed by a full release. I’ll probably be keeping the 7.4 branch alive for fixes, but I think my next big project will be to try to get Python 3 releases working in the nightly builds.

As always, thank you for your support.