本文整理汇总了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);
}
示例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
}