当前位置: 首页>>代码示例>>C++>>正文


C++ CCLuaStack::pushCCLuaValueDict方法代码示例

本文整理汇总了C++中CCLuaStack::pushCCLuaValueDict方法的典型用法代码示例。如果您正苦于以下问题:C++ CCLuaStack::pushCCLuaValueDict方法的具体用法?C++ CCLuaStack::pushCCLuaValueDict怎么用?C++ CCLuaStack::pushCCLuaValueDict使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCLuaStack的用法示例。


在下文中一共展示了CCLuaStack::pushCCLuaValueDict方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: title

void CCNativeWin32::showAlertViewWithLuaListener(LUA_FUNCTION listener)
{
    /*
    wstring title(m_alertViewTitle.begin(), m_alertViewTitle.end());
    wstring message(m_alertViewMessage.begin(), m_alertViewMessage.end());
    int button = MessageBox(NULL, message.c_str(), title.c_str(), MB_OKCANCEL);
    */
    WCHAR *wszTitleBuf;
    WCHAR *wszMessageBuf;

    int titleBufLen = MultiByteToWideChar(CP_UTF8, 0, m_alertViewTitle.c_str(), -1, NULL, 0);
    int messageBufLen = MultiByteToWideChar(CP_UTF8, 0, m_alertViewMessage.c_str(), -1, NULL, 0);

    wszTitleBuf = new WCHAR[titleBufLen+1];
    wszMessageBuf = new WCHAR[messageBufLen+1];

    memset(wszTitleBuf, 0, sizeof(WCHAR)*(titleBufLen + 1) );

    memset(wszMessageBuf, 0, sizeof(WCHAR)*(messageBufLen + 1) );
    MultiByteToWideChar(CP_UTF8, 0, m_alertViewTitle.c_str(), -1, wszTitleBuf, titleBufLen);
    MultiByteToWideChar(CP_UTF8, 0, m_alertViewMessage.c_str(),-1, wszMessageBuf, messageBufLen);

    int button = MessageBox(NULL,wszMessageBuf, wszTitleBuf, MB_OKCANCEL);

    delete [] wszTitleBuf;
    delete [] wszMessageBuf;

    CCLuaValueDict event;
    event["action"] = CCLuaValue::stringValue("clicked");
    if (button == IDOK || button == IDYES)
    {
        event["buttonIndex"] = CCLuaValue::intValue(1);
    }
    else
    {
        event["buttonIndex"] = CCLuaValue::intValue(2);
    }

    CCLuaStack* stack = CCLuaEngine::defaultEngine()->getLuaStack();
    stack->pushCCLuaValueDict(event);
    stack->executeFunctionByHandler(listener, 1);
}
开发者ID:fordream,项目名称:quick,代码行数:42,代码来源:CCNativeWin32.cpp

示例2: update

void CCHTTPRequest::update(float dt)
{
    if (m_state == kCCHTTPRequestStateInProgress)
    {
#if CC_LUA_ENGINE_ENABLED > 0
        if (m_listener)
        {
            CCLuaValueDict dict;

            dict["name"] = CCLuaValue::stringValue("inprogress");
            dict["dltotal"] = CCLuaValue::floatValue((float)m_dltotal);
            dict["dlnow"] = CCLuaValue::floatValue((float)m_dlnow);
            dict["ultotal"] = CCLuaValue::floatValue((float)m_ultotal);
            dict["ulnow"] = CCLuaValue::floatValue((float)m_ulnow);
            dict["request"] = CCLuaValue::ccobjectValue(this, "CCHTTPRequest");
            CCLuaStack *stack = CCLuaEngine::defaultEngine()->getLuaStack();
            stack->clean();
            stack->pushCCLuaValueDict(dict);
            stack->executeFunctionByHandler(m_listener, 1);
        }
#endif
        return;
    }
    CCDirector::sharedDirector()->getScheduler()->unscheduleAllForTarget(this);
    if (m_curlState != kCCHTTPRequestCURLStateIdle)
    {
        CCDirector::sharedDirector()->getScheduler()->scheduleSelector(schedule_selector(CCHTTPRequest::checkCURLState), this, 0, false);
    }

    if (m_state == kCCHTTPRequestStateCompleted)
    {
        CCLOG("CCHTTPRequest[0x%04x] - request completed", m_id);
        if (m_delegate) m_delegate->requestFinished(this);
    }
    else
    {
        CCLOG("CCHTTPRequest[0x%04x] - request failed", m_id);
        if (m_delegate) m_delegate->requestFailed(this);
    }

#if CC_LUA_ENGINE_ENABLED > 0
    if (m_listener)
    {
        CCLuaValueDict dict;

        switch (m_state)
        {
            case kCCHTTPRequestStateCompleted:
                dict["name"] = CCLuaValue::stringValue("completed");
                break;

            case kCCHTTPRequestStateCancelled:
                dict["name"] = CCLuaValue::stringValue("cancelled");
                break;

            case kCCHTTPRequestStateFailed:
                dict["name"] = CCLuaValue::stringValue("failed");
                break;

            default:
                dict["name"] = CCLuaValue::stringValue("unknown");
        }
        dict["request"] = CCLuaValue::ccobjectValue(this, "CCHTTPRequest");
        CCLuaStack *stack = CCLuaEngine::defaultEngine()->getLuaStack();
        stack->clean();
        stack->pushCCLuaValueDict(dict);
        stack->executeFunctionByHandler(m_listener, 1);
    }
#endif
}
开发者ID:yinjimmy,项目名称:qmm,代码行数:70,代码来源:CCHTTPRequest.cpp


注:本文中的CCLuaStack::pushCCLuaValueDict方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。