int32 onAdAction(void* systemData, void* userData)
{
    QTrace("amazonAds::onAdAction");
    
    s3eAmazonAdsCallbackActionData* data = static_cast<s3eAmazonAdsCallbackActionData*>(systemData);

    if (data == NULL)
    {
        QTrace("onAdAction error: callback data is NULL.");
        return 1;
    }

    LUA_EVENT_PREPARE("amazonAds");
    LUA_EVENT_SET_STRING("type", "action");
    LUA_EVENT_SET_INTEGER("adId", data->m_Id);
    
    const char* type;
    if (data->m_Type == S3E_AMAZONADS_ACTION_EXPANDED)
        type = "expanded";
    else if (data->m_Type == S3E_AMAZONADS_ACTION_COLLAPSED)
        type = "collapsed";
    else
        type = "dismissed";
    
    LUA_EVENT_SET_STRING("actionType", type);
    
    LUA_EVENT_SEND();
    lua_pop(g_L, 1);
    return 0;
}
Exemplo n.º 2
0
//------------------------------------------------------------------------------
void QSystem::_sendTouchEvent(float x, float y, const char* phase)
{
    // SEND EVENT TO LUA
    //QTrace("QSystem::_sendTouchEvent");

	LUA_EVENT_PREPARE("touch");
    LUA_EVENT_SET_NUMBER("x", x);
    LUA_EVENT_SET_NUMBER("y", y);
    LUA_EVENT_SET_STRING("phase", phase);
	LUA_EVENT_SEND();
}
int32 onAdLoad(void* systemData, void* userData)
{
    QTrace("amazonAds::onAdLoad");
    
    s3eAmazonAdsCallbackLoadedData* data = static_cast<s3eAmazonAdsCallbackLoadedData*>(systemData);

    if (data == NULL || data->m_Properties == NULL)
    {
        QTrace("onAdLoad error: callback data is NULL.");
        return 1;
    }

    LUA_EVENT_PREPARE("amazonAds"); //here we have "defined" an event called "amazonAds"
    //Chosen to have a single event for amazon ads and use "type" to switch
    //between the 3 callbacks. Keeps the API small/manageable
    LUA_EVENT_SET_STRING("type", "loaded");
    LUA_EVENT_SET_INTEGER("adId", data->m_Id);
    
    const char* type;
    if (data->m_Properties->m_AdType == S3E_AMAZONADS_TYPE_IMAGE_BANNER)
        type = "imageBanner";
    else if (data->m_Properties->m_AdType == S3E_AMAZONADS_TYPE_RICH_MEDIA_MRAID1)
        type = "richMediaMraid1";
    else if (data->m_Properties->m_AdType == S3E_AMAZONADS_TYPE_RICH_MEDIA_MRAID2)
        type = "richMediaMraid2";
    else if (data->m_Properties->m_AdType == S3E_AMAZONADS_TYPE_INTERSTITIAL)
        type = "interstitial";
    else
        type = "unknown";
    
    
    LUA_EVENT_SET_STRING("adType", type);
    LUA_EVENT_SET_BOOLEAN("canPlayAudio", data->m_Properties->m_CanPlayAudio);
    LUA_EVENT_SET_BOOLEAN("canPlayAudio", data->m_Properties->m_CanPlayVideo);
    LUA_EVENT_SET_BOOLEAN("canExpand", data->m_Properties->m_CanExpand);
    
    LUA_EVENT_SEND();
    lua_pop(g_L, 1);
    return 0;
}
int32 onAdError(void* systemData, void* userData)
{
    QTrace("amazonAds::onAdError");
    
    s3eAmazonAdsCallbackErrorData* data = static_cast<s3eAmazonAdsCallbackErrorData*>(systemData);

    if (data == NULL)
    {
        QTrace("onAdError error: callback data is NULL.");
        return 1;
    }

    LUA_EVENT_PREPARE("amazonAds");
    LUA_EVENT_SET_STRING("type", "error");
    LUA_EVENT_SET_INTEGER("adId", data->m_Id);
    
    const char* error;
    if (data->m_Error == S3E_AMAZONADS_ERR_LOAD_NETWORK_ERROR)
        error = "networkError";
    else if (data->m_Error == S3E_AMAZONADS_ERR_LOAD_NETWORK_TIMEOUT)
        error = "networkTimeout";
    else if (data->m_Error == S3E_AMAZONADS_ERR_LOAD_NO_FILL)
        error = "noFill";
    else if (data->m_Error == S3E_AMAZONADS_ERR_LOAD_INTERNAL_ERROR)
        error = "internalError";
    else if (data->m_Error == S3E_AMAZONADS_ERR_LOAD_REQUEST_ERROR)
        error = "requestError";
    else
        error = "unknown";
    
    LUA_EVENT_SET_STRING("error", error);
    
    LUA_EVENT_SEND();
    lua_pop(g_L, 1);
    return 0;
}