Beispiel #1
0
static void handleNavigatorEvent(bps_event_t *event) {
	switch (bps_event_get_code(event)) {
	case NAVIGATOR_SWIPE_DOWN:
		clear_cubes();
		break;
	case NAVIGATOR_EXIT:
		shutdown = true;
		break;
	}
}
Beispiel #2
0
/**
 * Loads binary config of cubes.
 * @deprecated Replaced by text config - remove pending.
 */
long load_cube_file(void)
{
    char *buf;
    long len;
    TbBool result;
    char *fname;
    static const char textname[] = "binary cubes config";
    fname = prepare_file_path(FGrp_StdData,"cube.dat");
    SYNCDBG(0,"%s %s file \"%s\".","Reading",textname,fname);
    //return _DK_load_cube_file();
    clear_cubes();
    len = LbFileLengthRnc(fname);
    if (len < MIN_CONFIG_FILE_SIZE)
    {
        WARNMSG("The %s file \"%s\" doesn't exist or is too small.",textname,fname);
        return false;
    }
    if (len > MAX_CONFIG_FILE_SIZE)
    {
        WARNMSG("The %s file \"%s\" is too large.",textname,fname);
        return false;
    }
    buf = (char *)LbMemoryAlloc(len+256);
    if (buf == NULL)
        return false;
    // Loading file data
    len = LbFileLoadAt(fname, buf);
    result = (len > 0);
    // Parse the config file
    if (result)
    {
        long i,count;
        count = *(long *)&buf[0];
        if (count > len/sizeof(struct CubeAttribs)) {
            count = len/sizeof(struct CubeAttribs);
            WARNMSG("The %s file \"%s\" seem truncated.",textname,fname);
        }
        if (count > CUBE_ITEMS_MAX-1)
            count = CUBE_ITEMS_MAX-1;
        if (count < 0)
            count = 0;
        struct CubeAttribs * cubuf;
        cubuf = (struct CubeAttribs *)&buf[4];
        for (i=0; i < count; i++)
        {
            struct CubeAttribs * cubed;
            cubed = &game.cubes_data[i];
            int n;
            for (n=0; n < CUBE_TEXTURES; n++) {
                cubed->texture_id[n] = cubuf->texture_id[n];
            }
            for (n=0; n < CUBE_TEXTURES; n++) {
                cubed->field_C[n] = cubuf->field_C[n];
            }
            cubuf++;
        }
        result = true;
    }
    //Freeing and exiting
    LbMemoryFree(buf);
    return result;
}