Author Topic: Android Version  (Read 6800 times)

Offline a1studmuffin

  • Zombie Food
  • *
  • Posts: 36
    • View Profile
Android Version
« on: February 02, 2017, 12:42:42 AM »
Hi everyone,

Michael here - I'm new to the forums, but I think my first post should go down pretty well. :D

I've spent the last few weeks porting Cataclysm: DDA (0.C Experimental) to Android, and have just launched an open beta test on Google Play. I'll be releasing this for free when it's done.

Google Play
APK Downloads
GitHub

Features:
- Tilesets, sound, localization, lua mod support
- Backwards compatible with desktop 0.C save games
- Stores game data in a publicly writeable location:
  /sdcard/Android/data/com.MichaelDavies.CataclysmDDA/files/
- Supports installation of custom tilesets, mods, soundpacks, and save games
- Works with a physical keyboard or virtual keyboard & touchscreen
- Auto-saves when the app loses focus (screen locked, switched apps etc.)
- Highly customizable touch controls and automatic in-game contextual shortcuts

Controls:
Swipe:                Directional movement (hold for virtual joystick)
Tap:                  Confirm selection (menu) or Pause one turn (in-game)
                      (hold to Pause several turns in-game)
Double-tap:           Cancel/Go back
Pinch:                Zoom in/out (in-game)
Back button:          Toggle virtual keyboard
                      (hold to toggle keyboard shortccode)

Tips:
- At the bottom of the screen you will sometimes see keyboard shortcuts.
- Many screens within the game already have convenient shortcuts assigned, but as you play, typing a key will add it to the shortcuts for that screen.
- Remove a shortcut by flicking up on it. Hold it down to see help text.
- Android-specific options live under Settings > Options > Android.
- Adjust terminal size under Settings > Options > Graphics (req's restart).
- For the best keyboard experience, use an SSH-friendly virtual keyboard such as "Hacker's Keyboard" on the Google Play store.

Known issues:
- On certain devices all text will appear garbled. This is a hardware acceleration bug in SDL. A temporary workaround is to rename '/sdcard/Android/data/com.MichaelDavies.CataclysmDDA/files/gfx' to 'gfx-temp', launch the game, enable 'Options > Graphics > Software rendering' and set 'Options > Android > Screen orientation' to 'Landscape', save + quit, and finally rename gfx-temp back to gfx.
- As the game uses quite a bit of memory, it's likely that Android will kill the game when you switch focus to another app, especially on devices with <= 2GB of RAM.
- Performance will obviously vary depending on your device. I've found it very playable on an HTC One M8 for reference.
- Auto-saving when the app loses focus seems to work great, but I'm still a little nervous about it, as it means a quicksave can be triggered while you're in the middle of an in-game screen (eg. talking to an NPC, modifying a vehicle etc.) So if you want to play it safe, try and only lock your screen if you're in the main game view awaiting your turn.

I plan on running the beta for the next 3-4 weeks, but once it's released I'll continue working on it periodically.

Everyone is welcome to contribute to the source code. Please don't be shy with bug reports, feedback and suggestions.

Cheers,
Michael

Screenshots:

Note the keyboard shortcuts on the bottom left. These are fully customizable and change depending on where you are in the game.


The entire screen acts as an 8-way virtual joystick for navigating the game/menus.


Hovering on a keyboard shortcut will display help text for it.


Lots of Android options, implemented within the game's native UI.


Using a 0.C Experimental build from a week or two ago.


Another example of the shortcuts. In this shot, " c and e are automatically added by the game, since it's likely you'll want to run, or close a door, or examine the vehicle.


The shortcuts' appearance can be customized in the options.
« Last Edit: April 09, 2017, 04:43:49 AM by a1studmuffin »

Offline BorkBorkGoesTheCode

  • Survivor
  • ***
  • Posts: 713
  • What could possibly go wrong....
    • View Profile
Re: Android Version
« Reply #1 on: February 02, 2017, 01:24:36 AM »
At what point did you fork the code?
Inactive.

If you have questions about my posts, send me a PM.

Offline a1studmuffin

  • Zombie Food
  • *
  • Posts: 36
    • View Profile
Re: Android Version
« Reply #2 on: February 02, 2017, 02:31:23 AM »
0.C-20818-g6ec9931: https://github.com/CleverRaven/Cataclysm-DDA/tree/6ec993170276a437ee3f8d13937799f20a67f3f1

(And in human terms, around the 23rd February 2017.)
« Last Edit: February 02, 2017, 02:40:42 AM by a1studmuffin »

Offline BorkBorkGoesTheCode

  • Survivor
  • ***
  • Posts: 713
  • What could possibly go wrong....
    • View Profile
Re: Android Version
« Reply #3 on: February 02, 2017, 03:09:10 AM »
You missed a minor fix for the chemical sprayer: https://github.com/CleverRaven/Cataclysm-DDA/pull/20095 . Just lower reload time from 900 to 10.

From what I've seen it looks good! Was it difficult to adapt the game to Android?
Inactive.

If you have questions about my posts, send me a PM.

Offline a1studmuffin

  • Zombie Food
  • *
  • Posts: 36
    • View Profile
Re: Android Version
« Reply #4 on: February 02, 2017, 04:35:30 AM »
Ah excellent, thank you - I'll slip that in the build. I wasn't sure when would be a good time to grab a snapshot, so I just held my breath and pulled tip from master. :) If there's a good time in the near future to pull latest from git I'll do that too.

The port was a challenge for sure. I've made games before for Android using Unity 3D, but this was my first time using the Android SDK + NDK natively. I had a read through COMPILING.md to get a gist of CDDA's dependencies, then started fishing around online to see if anyone else had ported an SDL2 game to Android before. I stumbled across the Android source code for Dungeon Crawl Stone Soup which helped a lot, as the author documented his process of doing the port.

The most difficult bit was just setting up the bloody SDK + NDK - it's a convoluted process because you have to run the C/C++ code through ndk-build, and then after that run the make file for the Java application, so there was lots of makefile dependencies and shenanigans to sort out. Thankfully SDL + Lua were pretty easy to get compiling under the NDK - once they were configured correctly they just worked (including sound!). I'm hoping its the same for gettext so I can get localization working.

Another obstacle was the fact that the NDK stores all your game data inside the APK ZIP, which means you can't access the files through C/C++ with standard input/output streams. SDL provide wrapper functions to read/write from the APK assets directly, but I didn't fancy rewriting all the file IO stuff in Cata so I set up a Java pre-install step which extracts the game data from inside the APK to the app's external files folder. Turns out this was a good idea anyway as it allows people to mess with the game data to change fonts, install soundpacks, mods, save games etc.

I vividly remember the first time I ran the game and instead of crashing on launch, the main menu appeared. I did a happy dance around the living room while my wife stared at me with a blank expression. Once I got to this point it was smooth sailing, I'm a commercial C++ gamedev with plenty of experience in UI design, so getting nice Android controls working within the Cata codebase was the fun part.

Offline StopSignal

  • Survivor
  • ***
  • Posts: 3414
  • Never stop drawing!
    • View Profile
    • You can see my drawings here!
Re: Android Version
« Reply #5 on: February 02, 2017, 04:54:26 AM »
Holy small potatoes. I'm gonna try this. Can you add tilesets? So I can add my own later, though I'm not sure if I need to change anything or do anything special.

I also can translate the description to Spanish, if you want!
« Last Edit: February 02, 2017, 04:56:31 AM by StopSignal »

Offline a1studmuffin

  • Zombie Food
  • *
  • Posts: 36
    • View Profile
Re: Android Version
« Reply #6 on: February 02, 2017, 05:57:36 AM »
Yeah you can mess with the data just like you would on a desktop build. Game data + user saves all live under here:
/sdcard/Android/data/com.MichaelDavies.CataclysmDDA/files/

Offline stk2008

  • Survivor
  • ***
  • Posts: 473
    • View Profile
Re: Android Version
« Reply #7 on: February 02, 2017, 08:10:52 AM »
Holy crap u wont believe me if i tell you how long i have waited for this.

You are sir are a god thank you so much.

Offline a1studmuffin

  • Zombie Food
  • *
  • Posts: 36
    • View Profile
Re: Android Version
« Reply #8 on: February 02, 2017, 08:42:26 AM »
Haha, I completely agree! The last 12 months I've been quietly hoping someone else would do it, but I had the time recently and figured it'd be a fun challenge. Plus this way I could implement the controls exactly how I wanted, I'm a bit fussy when it comes to touchscreen interfaces. (That said, if the controls annoy you or you have a suggestion, I'm happy to add extra options.)

Offline stk2008

  • Survivor
  • ***
  • Posts: 473
    • View Profile
Re: Android Version
« Reply #9 on: February 02, 2017, 08:46:10 AM »
I know I posted already but just want to say again this is freaking awesome.

I realy have waited a long ass time for this :)

Thanks again mate :)

Offline stk2008

  • Survivor
  • ***
  • Posts: 473
    • View Profile
Re: Android Version
« Reply #10 on: February 02, 2017, 08:50:04 AM »
Haha, I completely agree! The last 12 months I've been quietly hoping someone else would do it, but I had the time recently and figured it'd be a fun challenge. Plus this way I could implement the controls exactly how I wanted, I'm a bit fussy when it comes to touchscreen interfaces. (That said, if the controls annoy you or you have a suggestion, I'm happy to add extra options.)

LOL you only waited 12 months :P

Try since CDDA was released :P thats how long I waited.
I did try to get an android port with the help of some very nice people from the forums and the IRC but I was way over my head.

Any way mate truly do appriciate this I am so excited :).

One question can we use mods and sound packs?

I use the CDDA launcher on windows its amazeing and it gives you an optoin to install different sound packs and mods.

Thanks again you wizard :)

EDIT

Sorry missed the part thats mods are compatible I was in such a rush and hype to install and test that tbh I kind of just clicked the download link LOL :)
« Last Edit: February 02, 2017, 08:57:45 AM by stk2008 »

Offline a1studmuffin

  • Zombie Food
  • *
  • Posts: 36
    • View Profile
Re: Android Version
« Reply #11 on: February 02, 2017, 08:58:06 AM »
There's one bug I'm looking into at the moment which has happened on a handful of devices only. There seems to be something wacky going on with the text printing:

World create screen:


It seems like the game is running fine, but when it draws a window + prints text, certain characters are repeating several times across multiple cells (and obscuring other characters/cells in the process).

I haven't changed any of this code from the desktop build, so my gut feeling is it's perhaps an uninitialized value somewhere in the window/text printing functions that's fine on desktop and most devices by chance, but not on a handful of these Android devices.

If any of the CDDA devs have any thoughts on this I'm all ears - I'll keep looking at it on my side though I can't repro it on my device or on my Genymotion emulators so it's a bit tricky to track down, might have to enlist the help of someone testing it and dump out some logging info.
« Last Edit: February 02, 2017, 09:07:38 AM by a1studmuffin »

Offline stk2008

  • Survivor
  • ***
  • Posts: 473
    • View Profile
Re: Android Version
« Reply #12 on: February 02, 2017, 09:05:15 AM »
Seems fine on note 3 so far just for referance :).
The note 3`s are as phones go a beast though or was back in the day and tbh still are realy.

3gb ram quad core CPU etc etc

EDIT

Also if there is an admin here and IF a1studmuffin agrees this thread deserves to be stickyed like the IOS version :)
« Last Edit: February 02, 2017, 09:14:32 AM by stk2008 »

Offline Aqma

  • Zombie Food
  • *
  • Posts: 16
    • View Profile
Re: Android Version
« Reply #13 on: February 02, 2017, 09:48:07 AM »
You sir have just become my personal hero! I've been craving for this for soooo long.

I'll test and come back with feedback, THANK YOU SO SO SO MUCH!

Offline ZarenOFF

  • Zombie Food
  • *
  • Posts: 3
    • View Profile
Re: Android Version
« Reply #14 on: February 02, 2017, 10:08:09 AM »
It's fantastic!
It works fine, but plz in next time compile game with support of other languages (i create "lang" folder and place russian mo, but this didnt work).
And add your payments requisites :)
« Last Edit: February 02, 2017, 10:28:05 AM by ZarenOFF »