How to add levels to android version

Discussion about Rocks'n'Diamonds, Boulder Dash, Supaplex, Emerald Mine and any other BD hybrid.

Moderators: Zomis, Flumminator

Post Reply
jorgerhv
Posts: 2
Joined: Tue May 30, 2017 10:36 pm

How to add levels to android version

Post by jorgerhv » Sun Jun 25, 2017 11:56 pm

Is there anyway to add some levels to android version ?

User avatar
Holger
Site Admin
Posts: 3225
Joined: Fri Jun 18, 2004 4:13 pm
Location: Germany
Contact:

Re: How to add levels to android version

Post by Holger » Mon Jun 26, 2017 5:52 pm

To be honest, I've never really tried this so far (even though this is indeed a very obvious thing one might want to do sooner or later) -- I've always thought about it like "Should be no problem -- simply download and extract an arbitrary R'n'D level archive file into the personal level folder somewhere in the file system on the phone or tablet, just like one would do on a laptop or desktop computer running Windows/Mac/Linux". Apparently I couldn't have been more wrong than that! :-o

Just by chance I wanted to do something similar a few days ago: Copy some files from the Timidity project from the PC to the phone, to check if I could easily enable MIDI support that way (which would be needed for the music in BD2K3 (without having tried to copy that level set itself to the Android R'n'D installation, so we come back to your question here)). And there I had the same problem, as it seems: As far as I have figured out just before writing this post by some googling, you cannot simply copy files to the Android file system. And apparently this is not only limited to system files (which would be understandable), but extends to all files of all applications, even those that one has manually installed from an APK file! Very irritating, even with security concerns in mind (as the phone could simply ask for a system administration password in such cases, just as any modern operating system does).

So apparently this simple action is not nearly as easy as I thought it would be! :-o

Has anybody any idea how other apps on phones handle this? (And no, the solution could really not be to "just root your phone", as this would be far, far away from being a solution for the intended target audience of R'n'D, I think...)

A nice solution would of course be adding the possibility to select, download and install additional level sets from within R'n'D itself (as the application can access its own app directories), but this would definitely not be a short-term solution for this problem... :-/

User avatar
Holger
Site Admin
Posts: 3225
Joined: Fri Jun 18, 2004 4:13 pm
Location: Germany
Contact:

Re: How to add levels to android version

Post by Holger » Tue Jun 27, 2017 2:27 pm

OK, did some more googling on this topic, and it seems this problem should be solvable. Apparently the following steps are needed to (more or less) easily add levels to the Android version of R'n'D:

First, R'n'D itself has to be modified to use the external storage for its files instead of the internal storage, because the internal storage is not accessible by other apps or even by the user itself on normal (not rooted) Android devices, so it is impossible to add your own levels to the "levels" directory of the R'n'D application's data directory. (I decided to use the internal storage as not all Android devices have an external storage (SD card) available. The solution would be to check for an external storage and use it, if available, and only fall back to the internal storage otherwise.)

Second, extracting a Zip archive to an application's external storage directory still seems to be surprisingly complicated, as ordinary third-party applications (like file managers or unzip tools) apparently are allowed to read, but not to write to that location, which is only allowed for system applications (like the "My Files" application on Samsung Android devices). As it seems to be impossible to extract zip files with on-board tools, apparently one has to do the following:

- download the zip archive with R'n'D levels
- extract the zip archive with a third-party tool like "RAR" to the "RAR" application's "files" directory
- using "My Files", move the extracted levels directory from the "RAR" files directory to the R'n'D levels directory

To make this work, I have to release an update to R'n'D to use the external storage path, if possible.

If anybody knows of an easier solution to accomplish this simple task, please let me know! :-)

User avatar
Holger
Site Admin
Posts: 3225
Joined: Fri Jun 18, 2004 4:13 pm
Location: Germany
Contact:

Re: How to add levels to android version

Post by Holger » Tue Jun 27, 2017 8:58 pm

I have tested around a bit with the solution described above, and apparently it works quite well! As far as I can tell, "external storage" does not neccessarily mean "external SD card", but apparently something like "application storage area which is not private/internal to the application" -- at least it looks like the new "external" R'n'D data directory is still on the internal device, and not on the SD card.

I successfully downloaded, extracted and copied the level set "BD2K3" to the R'n'D level directory in the new game data location, and it works as expected.

I will try to release this fix as soon as possible with a new version 4.0.0.3.

filbo
Posts: 358
Joined: Fri Jun 20, 2014 10:06 am

Re: How to add levels to android version

Post by filbo » Tue Jun 27, 2017 11:36 pm

Reading your first comment, I was going to add something like your 2nd, but it became unnecessary. Yes, there is some sort of concept of 'external' storage which is external-to-the-app, not -to-the-device.

I expect if you included an unzip binary and whatever else might be needed (unrar, gunzip, tar, cpio?!? -- and maybe bash to let the user manually operate them, and code in RnD to shell out to bash) in the RnD .apk, you could then use those to do the various associated tasks. I am not thinking of this as suitable for a 'production release' package!, but as a potentially helpful temp solution.

All of those formats are, of course, available as C-linkable libraries; and presumably Java as well. Adding a specialized whatever-ball-extractor to the game sounds like a pain in the ass, but, well, it's one possible route forward... (Is RnD-Android a Java port or have you got some method of dynamically munging C source into compiled-Java-bytecode without ever actually looking at Java source code?)

User avatar
Holger
Site Admin
Posts: 3225
Joined: Fri Jun 18, 2004 4:13 pm
Location: Germany
Contact:

Re: How to add levels to android version

Post by Holger » Fri Jul 14, 2017 9:33 am

I expect if you included an unzip binary and whatever else might be needed (unrar, gunzip, tar, cpio?!? -- and maybe bash to let the user manually operate them, and code in RnD to shell out to bash) in the RnD .apk, you could then use those to do the various associated tasks. I am not thinking of this as suitable for a 'production release' package!, but as a potentially helpful temp solution.
That sounds a bit crazy indeed! :-D

I think everyone who would be able to use bash or unzip that way should also be able to execute the steps I described two posts above. ;-)
All of those formats are, of course, available as C-linkable libraries; and presumably Java as well. Adding a specialized whatever-ball-extractor to the game sounds like a pain in the ass, but, well, it's one possible route forward...
Yes, that's right. Getting the code to download and extract a zip file inside R'n'D should be the easiest part, I think -- the main part of the work would be to create a decent user interface on the client side (R'n'D) and some sort of "level store" on the server side, to be able to select and download/install additional level sets.
(Is RnD-Android a Java port or have you got some method of dynamically munging C source into compiled-Java-bytecode without ever actually looking at Java source code?)
It's the second one. :-)

This is where the SDL library really shines -- it contains a generic Java stub which makes it possible to just throw in your own game's C source and compile it using the Android SDK/NDK, so I never have to bother fiddling around with Java code directly. :-)

Post Reply