static int SendBinaryMessageToLua(int nHandler,const unsigned char* pTable,int nLength)
{
    if (NULL == pTable || nHandler <= 0) {
        return 0;
    }
    
    if (NULL == CCScriptEngineManager::sharedManager()->getScriptEngine()) {
        return 0;
    }
    
    CCLuaStack *pStack = CCLuaEngine::defaultEngine()->getLuaStack();
    if (NULL == pStack) {
        return 0;
    }

    lua_State *tolua_s = pStack->getLuaState();
    if (NULL == tolua_s) {
        return 0;
    }
    
    int nRet = 0;
    CCLuaValueArray array;
    for (int i = 0 ; i < nLength; i++) {
        CCLuaValue value = CCLuaValue::intValue(pTable[i]);
        array.push_back(value);
    }
    
    pStack->pushCCLuaValueArray(array);
    nRet = pStack->executeFunctionByHandler(nHandler, 1);
    pStack->clean();
    return nRet;
}
Пример #2
0
void CCZipFile::getFileList()
{
	if(!m_hasGenFlist)
	{
		genFileList();
	}
    CCLuaValueArray array;
	for(auto a:m_fileList)
	{
        CCLuaValue value = CCLuaValue::stringValue(a.first);
        array.push_back(value);
    }    
    CCLuaStack* stack = CCLuaEngine::defaultEngine()->getLuaStack();
    stack->clean();
    stack->pushCCLuaValueArray(array);
	return;
}
Пример #3
0
int main(int argc, char *argv[])
{
    //
    // save the argv first
    // crash sometimes on OSX
    //
    std::vector<std::string> args;
    for (int i = 1; i < argc; i++)
    {
        args.push_back(argv[i]);
    }

    trackerStart();
    AppDelegate app(argc, argv);
    MsgHandlerWapper::instance();
    Player *player = Player::instance();
    player->initConsole();


    // mac: ~/Library/Preferences/com.com-cocoachina-quick.quick-cocos2d-x player.plist
    // win: regedit
    qApp->setOrganizationDomain("com.cocoachina.quick");
    qApp->setApplicationName("quick-cocos2d-x player");

    // set quick root path from env
    QString quickCocos2dxRoot = player->getQuickRootPathFromSystem();
    if (!quickCocos2dxRoot.isEmpty())
    {
        SimulatorConfig::sharedDefaults()->setQuickCocos2dxRootPath(quickCocos2dxRoot.toLocal8Bit().constData());
    }

    // recent files
    CCLuaValueArray recentArray;
    QSettings settings;
    QVariantList recents = settings.value(kOpenRecentFiles).toList();
    Q_FOREACH(QVariant recentItem, recents)
    {
        QVariantMap item = recentItem.toMap();
        QString title = item.value(kRecentItemTitle).toString();
        recentArray.push_back(CCLuaValue::stringValue(title.toUtf8().constData()));
    }