emscripten Humble Cloud interface
Edward Rudd
2014-10-02 149719452955ac2d021297637a75e7bbf2374464

add API for humble_demo_ended so demo games can notify the player when they are over.

3 files modified
42 ■■■■ changed files
client/CMakeLists.txt 1 ●●●● patch | view | raw | blame | history
client/library/humble_api.h 5 ●●●●● patch | view | raw | blame | history
client/library/library_humble.js 36 ●●●● patch | view | raw | blame | history
client/CMakeLists.txt
@@ -17,6 +17,7 @@
    test_preload
    data/
    TEST_DATA
    --use-preload-cache
)
CreateProgram(TestApp
client/library/humble_api.h
@@ -28,6 +28,11 @@
     */
    int humble_get_player_size(int *width, int *height);
    /**
     * Called to let the humble player know the demo has ended.
     */
    void humble_demo_ended();
#ifdef __cplusplus
};
#endif
client/library/library_humble.js
@@ -2,14 +2,28 @@
    $HUMBLE_API: {
        file_cache: {},
        options: {
            // allows altering the incoming URL before it is fetched from the network
            locateAsset: null, // function(path) { return path; }
            // returns a key for the specified path. return null to NOT cache the specific resource
            // for scoped keys..  return { scope: 'deadbeef', path: 'path' }, otherwise just return a string
            buildCacheKey: null, // function(path) { return path; }
            // function returning a hash like {width: 800, height: 600, locked: true}
            // locked specifies whether the game should ONLY use that width/height
            playerSize: null // function() { return { width: 800, height: 600, locked: true } }
            /**
             * allows altering the incoming URL before it is fetched from the network
             * ex. function(path) { return path; }
             */
            locateAsset: null,
            /**
             * returns a key for the specified path. return null to NOT cache the specific resource
             * for scoped keys..  return { scope: 'deadbeef', path: 'path' }, otherwise just return a string
             * ex. function(path) { return path; }
             */
            buildCacheKey: null,
            /**
             * function returning a hash like {width: 800, height: 600, locked: true}
             * locked specifies whether the game should use that width/height.
             * ex. function() { return { width: 800, height: 600, locked: true } }
             */
            playerSize: null,
            /**
             * callback to handle the demo_ended API from in the game
             * the callback takes no parameters.
             */
            demoEndedCallback: null
        },
        /**
         * allows configuring the HUMBLE_API  simply call this method in a preRun to initialize..
@@ -208,6 +222,12 @@
        if (w) {{{ makeSetValue('w', '0', 'ret.width', 'i32') }}};
        if (h) {{{ makeSetValue('h', '0', 'ret.height', 'i32') }}};
        return ret.locked ? 1 : 0;
    },
    humble_demo_ended: ['$HUMBLE_API'],
    humble_demo_ended: function() {
        if (HUMBLE_API.options.demoEndedCallback) {
            return HUMBLE_API.options.demoEndedCallback.call(HUMBLE_API);
        }
    }
};