コード例 #1
0
bool TranslateOptimizeCommand::handleRecieve(cocos2d::CCDictionary *dict){
    
    CCLOGFUNC("");
    if (dict->valueForKey("cmd")->compare(TRANSLATE_IMPROVE) != 0)
        return false;
    
    CCDictionary *params=_dict(dict->objectForKey("params"));
    if (!params) {
        return false;
    }
    
    const CCString *pStr = params->valueForKey("errorCode");
    if (pStr->compare("")!=0) {
        return false;
    }
    
    if (params->objectForKey("url") && (m_method == METHOD_ADD_TRANSLATE || m_method == METHOD_VOTE_TRANSLATE)) {
        string url = params->valueForKey("url")->getCString();
        
        CCLOGFUNCF("url:%s",url.c_str());
        if(url!="")
        {
            ChatController::getInstance()->translateOptimizationUrl = url;
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
            ChatServiceCocos2dx::showTranslationOptimizationFrom2dx(url.c_str());
#endif
        }
    }
    
    return true;
}
コード例 #2
0
ファイル: SecondScene.cpp プロジェクト: ZhangKuixun/aincc-lib
void SecondScene::onTouchClicked(CCTouch *touch, CCEvent *event, CCPoint location)
{
	CCLOGFUNC();
	
	CCNode *image = this->getChildByTag(kTagSecondSceneImage);
	
	if (image->boundingBox().containsPoint(location))
	{
		this->popScene();
	}
}
コード例 #3
0
void GetFriendListCommand::onGetFriendInfoSuccess(CCObject* pObj)
{
    CCLOGFUNC("");
    CCDictionary* params = dynamic_cast<CCDictionary*>(pObj);
    if (params==NULL || ChatController::getInstance()->m_chatUserInfoDic==NULL) {
        return;
    }
    CCArray* members = dynamic_cast<CCArray*>(params->objectForKey("contactList"));
    string uidStr="";
    string lastUpdateTimeStr="";
    if(members)
    {
        vector<std::string> *uids = new vector<std::string>();
        CCLOGFUNCF("members->count():%d",members->count());
        for (int i=0; i < members->count(); i++) {
            CCDictionary* member = (CCDictionary*)members->objectAtIndex(i);

            string uid=member->valueForKey("uid")->getCString();
            if(uid!="")
            {
                if (ChatController::getInstance()->m_chatUserInfoDic->objectForKey(uid)==NULL) {
                    uids->push_back(uid);
                }
                string time=member->valueForKey("lastUpdateTime")->getCString();
                if (time=="") {
                    time="0";
                }
                
                if(uidStr!="")
                {
                    uidStr.append("_").append(uid);
                    lastUpdateTimeStr.append("_").append(time);
                }
                else
                {
                    uidStr=uid;
                    lastUpdateTimeStr=time;
                }
            }

        }

        CCLOGFUNCF("uidStr:%s",uidStr.c_str());
    }
#if(CC_TARGET_PLATFORM==CC_PLATFORM_ANDROID)
    if (uidStr!="") {
        ChatServiceCocos2dx::notifyUserUids(uidStr,lastUpdateTimeStr,GET_MUTIUSER_TYPE_FRIEND);
    }
#endif
}
コード例 #4
0
FlySystemUpdateHint *FlySystemUpdateHint::create(double countDown, bool isLogin,string tip,FlyHintType type,string icon){
    if (type == FLY_HINT_SHAKEALLIANCE) {
        FlySystemUpdateHint *ret = new FlySystemUpdateHint(countDown, isLogin,tip,type,icon);
        if(ret && ret->init()){
            ret->autorelease();
        }else{
            CC_SAFE_DELETE(ret);
        }
        CCLOGFUNC("shakealliance!");
        return ret;
    }
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    if(ChatServiceCocos2dx::isChatShowing){
        //两种情况:由java触发,由2dx触发
        if(true){
            double curTime = GlobalData::shared()->getWorldTime();
            double countDownTime = GlobalData::shared()->changeTime(countDown/1000);
            bool isFlyHintLogin=false;
            if(type==FLY_HINT_LOGIN)
                isFlyHintLogin=true;
            ChatServiceCocos2dx::flySystemUpdateHint(floor( countDownTime - curTime ), isFlyHintLogin,isLogin, tip, icon);
        }else{
//            scheduleOnce(schedule_selector(FlySystemUpdateHint::showInNativeUI), 0.1f);
        }
        return NULL;
    }
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    if(ChatServiceCocos2dx::isChatShowing_fun()){
        if(true){
            double curTime = GlobalData::shared()->getWorldTime();
            double countDownTime = GlobalData::shared()->changeTime(countDown/1000);
            bool isFlyHintLogin=false;
            if(type==FLY_HINT_LOGIN)
                isFlyHintLogin=true;
            ChatServiceCocos2dx::flySystemUpdateHint(floor( countDownTime - curTime ), isFlyHintLogin,isLogin, tip, icon);
        }else{
        
        }
        
        return NULL;
    }
#endif
    FlySystemUpdateHint *ret = new FlySystemUpdateHint(countDown, isLogin,tip,type,icon);
    if(ret && ret->init()){
        ret->autorelease();
    }else{
        CC_SAFE_DELETE(ret);
    }
    return ret;
}
コード例 #5
0
ファイル: ChatTestCommand.cpp プロジェクト: ourgames/dc208
bool ChatTestCommand::handleRecieve(cocos2d::CCDictionary *dict){
    
    CCLOGFUNC("");
    if (dict->valueForKey("cmd")->compare(CHAT_ROOM_CREATE) != 0)
        return false;
    
    CCDictionary *params=_dict(dict->objectForKey("params"));
    if (!params) {
        return false;
    }
    
    const CCString *pStr = params->valueForKey("errorCode");
    if (pStr->compare("")!=0) {
        return false;
    }
   
    return true;
}
コード例 #6
0
bool CreateChatRoomCommand::handleRecieve(cocos2d::CCDictionary *dict){
    
    CCLOGFUNC("");
    if (dict->valueForKey("cmd")->compare(CHAT_ROOM_CREATE) != 0)
        return false;

    CCDictionary *params=_dict(dict->objectForKey("params"));
    if (!params) {
        return false;
    }

    const CCString *pStr = params->valueForKey("errorCode");
    if (pStr->compare("")!=0) {
        return false;
    }
    string groupIdStr = params->valueForKey("id")->getCString();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)    
    auto interator = GlobalData::shared()->mailList.find(groupIdStr);
    
    if (interator!=GlobalData::shared()->mailList.end()) {
        MailInfo* mailInfo=dynamic_cast<MailInfo*>(interator->second);
        if (mailInfo) {
            if(!MailController::getInstance()->getIsNewMailListEnable()){
                ChatServiceCocos2dx::setMailInfo(groupIdStr.c_str(),mailInfo->uid.c_str(),mailInfo->fromName.c_str(),CHAT_ROOM);
                
                if(!ChatServiceCocos2dx::isChatShowing){
                    CCLOGFUNC("!ChatServiceCocos2dx::isChatShowing");
                }
                else
                {
                    CCLOGFUNC("ChatServiceCocos2dx::isChatShowing");
                    ChatServiceCocos2dx::exitChatActivityFrom2dx();
                }
                ChatServiceCocos2dx::m_channelType=CHANNEL_TYPE_CHATROOM;
                ChatServiceCocos2dx::m_isNoticItemUsed=false;
                MailController::getInstance()->setOldOpenMailInfo(mailInfo);
                ChatServiceCocos2dx::showChatActivityFrom2dx();
            }else{
                
                ChatServiceCocos2dx::m_channelType=CHANNEL_TYPE_CHATROOM;
                ChatServiceCocos2dx::m_isNoticItemUsed=false;
                MailController::getInstance()->setOldOpenMailInfo(mailInfo);
                ChatServiceCocos2dx::setMailInfo(groupIdStr.c_str(),mailInfo->uid.c_str(),mailInfo->fromName.c_str(),CHAT_ROOM);
                ChatServiceCocos2dx::onCreateChatroomSuccess();
            }
        }
    }
#elif(CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    auto interator = GlobalData::shared()->mailList.find(groupIdStr);
    CCLOGFUNC("创建聊天室");
    if (interator!=GlobalData::shared()->mailList.end()) {
        MailInfo* mailInfo=dynamic_cast<MailInfo*>(interator->second);
        if (mailInfo) {
            ChatServiceCocos2dx::setMailInfo(groupIdStr.c_str(),mailInfo->uid.c_str(),mailInfo->fromName.c_str(),CHAT_ROOM);
            
            if(!ChatServiceCocos2dx::isChatShowing_fun()){
                CCLOGFUNC("!ChatServiceCocos2dx::isChatShowing");
            }
            else
            {
                CCLOGFUNC("ChatServiceCocos2dx::isChatShowing");
                //ChatServiceCocos2dx::exitChatActivityFrom2dx();
            }
            ChatServiceCocos2dx::settingGroupChatMailVCChatChannel();
            
            ChatServiceCocos2dx::m_channelType=CHANNEL_TYPE_CHATROOM;
            ChatServiceCocos2dx::m_isNoticItemUsed=false;
            MailController::getInstance()->setOldOpenMailInfo(mailInfo);
            ChatServiceCocos2dx::showChatIOSFrom2dx();
        }
    }
#endif
    CCSafeNotificationCenter::sharedNotificationCenter()->postNotification(MAIL_SEND_SUCCESS);
    return true;
}
コード例 #7
0
ファイル: MailAnnouncePopUp.cpp プロジェクト: ourgames/dc208
bool MailAnnouncePopUp::init(){
    bool ret = false;
    if(PopupBaseView::init()){
        setIsHDPanel(true);
        setMailUuid(m_info->uid);
//        auto cf = CCLoadSprite::getSF("Mail_diban.png");
        auto cf = CCLoadSprite::getSF("Mail_BG1.png");
        if (cf==NULL) {
            CCLoadSprite::doResourceByCommonIndex(6, true,true);
            setCleanFunction([](){
                CCLoadSprite::doResourceByCommonIndex(6, false,true);
                CCLoadSprite::releaseDynamicResourceByType(CCLoadSpriteType_GOODS);
            });
        }
        else {
            setCleanFunction([](){
                CCLoadSprite::releaseDynamicResourceByType(CCLoadSpriteType_GOODS);
            });
        }
        auto bg = CCBLoadFile("NEW_MailAnnounce", this, this);
        if(bg==NULL)
        {
            CCLOGFUNC("bg==NULL");
        }
        else
        {
            CCLOGFUNC("bg!=NULL");
        }
        if (CCCommonUtils::isIosAndroidPad()) {
            this->setContentSize(CCDirector::sharedDirector()->getWinSize());
            int extH = getExtendHeight();
            this->m_listContainer->setContentSize(CCSize(m_listContainer->getContentSize().width, m_listContainer->getContentSize().height + extH));
            m_downNode->setPositionY(m_downNode->getPositionY() - extH);
            m_bgNode->setPositionY(m_bgNode->getPositionY() - extH);
            auto tbg = CCLoadSprite::loadResource("Mail_diban.png");
            auto tBatchNode = CCSpriteBatchNode::createWithTexture(tbg->getTexture());
            auto picBg1 = CCLoadSprite::createSprite("Mail_diban.png");
            picBg1->setAnchorPoint(ccp(0, 0));
            picBg1->setPosition(ccp(0, 0));
            picBg1->setScaleX(2.4);
            tBatchNode->addChild(picBg1);
            int maxHeight = CCDirector::sharedDirector()->getWinSize().height;
            int curHeight = picBg1->getContentSize().height;
            while(curHeight < maxHeight)
            {
                auto picBg2 = CCLoadSprite::createSprite("Mail_diban.png");
                picBg2->setAnchorPoint(ccp(0, 0));
                picBg2->setPosition(ccp(0, curHeight));
                picBg2->setScaleX(2.4);
                tBatchNode->addChild(picBg2);
                curHeight += picBg2->getContentSize().height;
            }
            m_bgNode->addChild(tBatchNode);
        }
        else {
            this->setContentSize(bg->getContentSize());
            int extH = getExtendHeight();
            this->m_listContainer->setContentSize(CCSize(m_listContainer->getContentSize().width, m_listContainer->getContentSize().height + extH));
            m_downNode->setPositionY(m_downNode->getPositionY() - extH);
            m_bgNode->setPositionY(m_bgNode->getPositionY() - extH);
            auto tbg = CCLoadSprite::loadResource("Mail_diban.png");
            auto tBatchNode = CCSpriteBatchNode::createWithTexture(tbg->getTexture());
            auto picBg1 = CCLoadSprite::createSprite("Mail_diban.png");
            picBg1->setAnchorPoint(ccp(0, 0));
            picBg1->setPosition(ccp(0, 0));
            tBatchNode->addChild(picBg1);
            int maxHeight = CCDirector::sharedDirector()->getWinSize().height;
            int curHeight = picBg1->getContentSize().height;
            while(curHeight < maxHeight)
            {
                auto picBg2 = CCLoadSprite::createSprite("Mail_diban.png");
                picBg2->setAnchorPoint(ccp(0, 0));
                picBg2->setPosition(ccp(0, curHeight));
                tBatchNode->addChild(picBg2);
                curHeight += picBg2->getContentSize().height;
            }
            m_bgNode->addChild(tBatchNode);
        }
        
        m_updateBtn->setEffectStr("");
        m_listNode = CCNode::create();
//        setTitleName(_lang("102996"));
        m_mailTitle->setString(_lang("102996"));
        CCLOGFUNCF("m_info->createTime %d",m_info->createTime);
        this->m_timeText->setString(CCCommonUtils::timeStampToDate(m_info->createTime).c_str());
        m_titleText->setString(_lang_1("114107", m_info->version.c_str()));
        m_titleText->setFntFile("Arial_Bold_Regular.fnt");
        m_timeText->setFntFile("Arial_Bold_Regular.fnt");
        m_updateContent->setFntFile("Arial_Bold_Regular.fnt");
        m_rewardTitleText->setString(_lang("114109"));
        m_updateTitle->setString(_lang("114108"));
        
        m_scrollView = CCScrollView::create(m_listContainer->getContentSize());
        m_scrollView->setDirection(kCCScrollViewDirectionVertical);
        m_scrollView->setAnchorPoint(ccp(0, 0));
        m_listContainer->addChild(m_scrollView);

        
        this->m_totalNode->removeChild(this->m_moveNode);
        m_scrollView->addChild(m_listNode);
        
        m_updateContentRich= CCRichLabelTTF::create("", "Helvetica", m_updateContent->getFontSize(),m_updateContent->getDimensions(),kCCTextAlignmentLeft,kCCVerticalTextAlignmentTop);
        m_updateContent->getParent()->addChild(m_updateContentRich);
        m_updateContentRich->setPosition(m_updateContent->getPosition());
        m_updateContentRich->setAnchorPoint(m_updateContent->getAnchorPoint());
        m_updateContent->removeFromParent();
        m_updateContent=NULL;

        
        m_totalHg = 0;
        m_listNode->addChild(m_moveNode);
        if (CCCommonUtils::isIosAndroidPad()) {
            m_moveNode->setPosition(768,m_totalHg);
        }
        else
            m_moveNode->setPosition(320,m_totalHg);
        if(!m_info->isReadContent){
            getData();
        }else{
            refresh();
            this->m_listNode->setPositionY(-m_totalHg);
            m_scrollView->setContentSize(CCSize(m_listContainer->getContentSize().width, -m_totalHg));
            m_scrollView->setContentOffset(ccp(0, m_listContainer->getContentSize().height - (-m_totalHg)));
        }
        ret = true;
    }
    return ret;
}
コード例 #8
0
ファイル: LotteryRotateView.cpp プロジェクト: ourgames/dc208
void LotteryRotateView::onDelegateClose(){
    CCLOGFUNC();
    if(m_rewardsContainer->getChildByTag(100001)){
        m_rewardsContainer->getChildByTag(100001)->removeFromParentAndCleanup(true);
    }
}
コード例 #9
0
bool GetChatRoomListCommand::handleRecieve(cocos2d::CCDictionary *dict){
    
    CCLOGFUNC("");
    if (dict->valueForKey("cmd")->compare(CHAT_ROOM_GET_LIST) != 0)
        return false;
    
    CCDictionary *params=_dict(dict->objectForKey("params"));
    if (!params) {
        CCLOGFUNC("params==NULL");
        return false;
    }
    
    CCArray* roomArray = dynamic_cast<CCArray*>(params->objectForKey("rooms")) ;
    if (roomArray==NULL || roomArray->count()<=0) {
        return false;
    }
    CCLOGFUNCF("roomArray count %d",roomArray->count());
    MailController::getInstance()->getChatRoomIdArray()->removeAllObjects();
    string groupId="";
    for (int i=0;i<roomArray->count(); i++) {
        CCArray* mailInfoArr=CCArray::create();
        CCDictionary* info=dynamic_cast<CCDictionary*>(roomArray->objectAtIndex(i));
        if (info) {
            
            groupId=info->valueForKey("id")->getCString();
            if (groupId!="") {
                MailController::getInstance()->getChatRoomIdArray()->addObject(CCString::create(groupId));
            }
            string roomName=info->valueForKey("name")->getCString();
            CCArray* members=dynamic_cast<CCArray*>(info->objectForKey("members"));
            if (members==NULL || members->count()<=0) {
                return false;
            }
            
            CCArray* memberUidArray=CCArray::create();
            memberUidArray->retain();
            
            for (int j=0; j<members->count(); j++) {
                CCDictionary* dic=dynamic_cast<CCDictionary*>(members->objectAtIndex(j));
                if (dic) {
                    string uid=dic->valueForKey("uid")->getCString();
                    memberUidArray->addObject(CCString::create(uid));
                }
            }
            
            auto search = GlobalData::shared()->mailList.find(groupId);
            bool isExistMail=(search != GlobalData::shared()->mailList.end() && groupId != "");
            
            CCString* jsonMsg=dynamic_cast<CCString*>(info->objectForKey("msg"));

            if (jsonMsg) {
                MailInfo* mailInfo=NULL;
                if (!isExistMail) {
                    mailInfo=MailInfo::create();
                    mailInfo->crGroupId=groupId;
//                    mailInfo->retain();
//                    mailInfo->crMemberUidArray =memberUidArray;
                    GlobalData::shared()->mailList[groupId]=mailInfo;
                }
                else
                {
                    mailInfo=dynamic_cast<MailInfo*>(search->second);
                }

                
                string jsonStr=jsonMsg->getCString();
                CCLOGFUNCF("jsonStr %s",jsonStr.c_str());
                Json* jsonObj = Json_create(jsonStr.c_str());
                if( !jsonObj )
                    continue;
                
                Json* jsonBody=Json_getItem(jsonObj, "body");
                if( !jsonBody )
                    continue;
                
                CCDictionary* dic=MailController::getInstance()->parseChatRoomJsonMsg(jsonObj,jsonBody);
                Json_dispose(jsonObj);
                if(dic!=NULL)
                {
                    MailDialogInfo* dialogInfo=MailController::getInstance()->parseChatRoomDic(dic,true,true);
                    if (dialogInfo) {
                        ChatMailInfo* info=ChatMailInfo::create(mailInfo,dialogInfo,false,CHANNEL_TYPE_CHATROOM);
                        mailInfoArr->addObject(info);
                    }
                }
                CCLOGFUNCF("roomName %s,mailInfoArr count %d",roomName.c_str(),mailInfoArr->count());
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
                if(ChatServiceCocos2dx::enableNativeMail && MailController::getInstance()->getChatRoomEnable() && mailInfoArr->count()>0)
                {
                    ChatServiceCocos2dx::postIsChatRoomMemberFlag(groupId,true);
                    MailController::getInstance()->notifyMailMsgToAndroid(mailInfoArr,groupId);
                }
#endif
            }
        }
    }
    
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    if (!ChatServiceCocos2dx::isChatShowing) {
        CCSafeNotificationCenter::sharedNotificationCenter()->postNotification(MAIL_LIST_CHANGE);
        CCSafeNotificationCenter::sharedNotificationCenter()->postNotification(MAIL_PERSON_CHAT_CHANGE);
    }
#else
    CCSafeNotificationCenter::sharedNotificationCenter()->postNotification(MAIL_LIST_CHANGE);
    CCSafeNotificationCenter::sharedNotificationCenter()->postNotification(MAIL_PERSON_CHAT_CHANGE);
#endif
    
    return true;
}
コード例 #10
0
ファイル: MailBatchCommand.cpp プロジェクト: ourgames/dc208
bool MailBatchRewardCommand::handleRecieve(cocos2d::CCDictionary *dict){
    if (dict->valueForKey("cmd")->compare(MAIL_REWARD_BATCH_COMMAND) != 0)
        return false;

    CCDictionary* params = _dict(dict->objectForKey("params"));
    const CCString *pStr = params->valueForKey("errorCode");
    if (pStr->compare("")!=0) {
        CCCommonUtils::flyText((_lang(pStr->getCString()).c_str()));
 
        return true;
    }
    
    if (params->valueForKey("success")->intValue() == 1 ) {
    #if(CC_TARGET_PLATFORM==CC_PLATFORM_IOS)
        if (ChatServiceCocos2dx::Mail_OC_Native_Enable){
            ChatServiceCocos2dx::setMailRewardStatusForBatchToReadWithMailIDs(m_uids,1);
        }
    #endif
    }
    if(params->objectForKey("honor")){
        int honor = params->valueForKey("honor")->intValue();
        GlobalData::shared()->playerInfo.allianceInfo.accPoint = honor;
    }
    if(params->objectForKey("alliancepoint")){
        int alliancepoint = params->valueForKey("alliancepoint")->intValue();
        GlobalData::shared()->playerInfo.allianceInfo.point = alliancepoint;
    }
    string rewardStr = "{\"flyToolReward\":[";
    if(params->objectForKey("goods")){
        CCArray* arr = dynamic_cast<CCArray*>(params->objectForKey("goods"));
        
        CCLOGFUNC("111");
        
#if(CC_TARGET_PLATFORM==CC_PLATFORM_ANDROID)
        
        if(MailController::getInstance()->getIsNewMailListEnable())
        {
//            MailController::getInstance()->m_mutiFlyToolRewardArray->removeAllObjects();
//            MailController::getInstance()->m_mutiFlyToolRewardArray->addObjectsFromArray(arr);
//            if (ChatServiceCocos2dx::isChatShowing) {
//                ChatServiceCocos2dx::exitChatActivityFrom2dx(false);
//            }
            
            CCObject* obj;
            
            string rewardToolBody = "";
            CCARRAY_FOREACH(arr, obj) {
                auto tdic = _dict(obj);
                if(tdic)
                {
                    string itemId ="";
                    if (tdic->objectForKey("itemId")) {
                        itemId = tdic->valueForKey("itemId")->getCString();
                        if (itemId!="") {
                            auto &item = ToolController::getInstance()->getToolInfoById(atoi(itemId.c_str()));
                            int num = 0;
                            if (tdic->objectForKey("rewardAdd")) {
                                num = tdic->valueForKey("rewardAdd")->intValue();
                            } else if (tdic->objectForKey("count")){
                                num = tdic->valueForKey("count")->intValue() - item.getCNT();
                            }
                            if(rewardToolBody!="")
                                rewardToolBody.append(",");
                            rewardToolBody.append("{\"itemPic\":").append("\"").append(CCCommonUtils::getIcon(itemId.c_str())).append("\"").append(",\"itemNum\":").append(CC_ITOA(num)).append("}");
                        }
                    }
                }
            }
コード例 #11
0
ファイル: IFWingNode.cpp プロジェクト: ourgames/dc208
IFSkeletonAnimation* IFWingNode::setSpineState(string skeName, int state, int direction, bool repeat/*=true*/,CCCallFunc* callFunc/*=nullptr*/,int loopCnt /*= 1*/)
{
    CCLOGFUNC("");
    m_skeName = skeName;
    m_state = state;
    m_loopCnt = loopCnt;
    switch (state)
    {
        case Rs_Spreading:
            m_aniName = "RS_Spreading";
            break;
        case Rs_Flying:
        {
            m_aniName = "RS_Flying";
            
            break;
        }
        case Rs_fadeout:
            m_aniName = "RS_fadeout";
            break;
        case Rs_fadein:
            m_aniName = "RS_fadein";
            break;
        default:
            break;
    }
    
    if(!animationObj)
    {
        std::string strJsonFileName = getJsonPath(m_skeName);
        std::string strAtlasFilename = getAtlasPath();
        
        if (!isSkeExit(m_skeName) || !isSkeTextureExit())
        {
            return nullptr;
        }
        CCLOGFUNC("");
        animationObj = new IFSkeletonAnimation(strJsonFileName.c_str(), strAtlasFilename.c_str());
        CCLOGFUNC("");
        addChild(animationObj);
    }
    else
    {
        animationObj->setToSetupPose();
    }
    CCLOGFUNC("");
    m_entry = animationObj->setAnimation(0,m_aniName.c_str(), repeat);
    CCLOGFUNC("");
    if(m_entry){
        animationObj->setTimeScale(m_entry->endTime/2.0f);
        if(callFunc)
        {
            CC_SAFE_RELEASE_NULL(m_callBack);
            m_callBack = callFunc;
            CC_SAFE_RETAIN(m_callBack);
            animationObj->setCompleteListener([&] (int trackIndex, int loopCount)
            {
                CC_SAFE_RETAIN(this);
                animationStateEvent(trackIndex,loopCount);
                CC_SAFE_RELEASE(this);
            });
        }
    }
//    if(m_state == Rs_Flying ){
//        unschedule(schedule_selector(IFWingNode::onGameTick));
//        schedule(schedule_selector(IFWingNode::onGameTick), 1.0);
//        m_nowTime = WorldController::getInstance()->getTime() / 1000;;
//    }
//    else{
//        CCDelayTime*  delayTime = CCDelayTime::create(1.0);
//        CCCallFunc* callFun = CCCallFunc::create(this, callfunc_selector(IFWingNode::onDelayFun));
//        this->runAction(CCSequence::create(delayTime,callFun,NULL));
//    }
    return animationObj;
}
コード例 #12
0
ファイル: ChatRoomMsgPush.cpp プロジェクト: ourgames/dc208
void ChatRoomMsgPush::handleResponse(CCDictionary *dict)
{
    CCLOGFUNC("");
    if (!dict)
        return;
    
    cocos2d::CCDictionary *params=_dict(dict->objectForKey("params"));
    if (!params) return;
    
    string groupId=params->valueForKey("roomId")->getCString();
    string groupName=params->valueForKey("name")->getCString();
    CCLOGFUNCF(" groupId %s",groupId.c_str());
    if (groupId=="") {
        return;
    }
    
    if(!MailController::getInstance()->getChatRoomEnable())
        return;
    
    int type=-1;
    CCDictionary* bodyDic=dynamic_cast<CCDictionary*>(params->objectForKey("body"));
    if (bodyDic) {
        type=bodyDic->valueForKey("type")->intValue();
    }
    
    CCLOGFUNCF(" type %d",type);
    
    string operatorUid=params->valueForKey("senderUid")->getCString();
    
    if(type==CHAT && GlobalData::shared()->chatShieldInfo.isShield(operatorUid))
        return;
    
    string playerUid=GlobalData::shared()->playerInfo.uid;
    bool isOperator=(operatorUid==playerUid);

#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    CCArray* mailInfoArr=CCArray::create();
#elif(CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    CCArray* mailInfoArr=CCArray::createOL();
#endif
    
    MailDialogInfo* dialogInfo=MailController::getInstance()->parseChatRoomDic(params,true,false,true);
    if (dialogInfo) {
        auto search = GlobalData::shared()->mailList.find(groupId);
        bool isExistMail=(search != GlobalData::shared()->mailList.end());
        if (isExistMail) {
            MailInfo* mailInfo=dynamic_cast<MailInfo*>(search->second);
            if (mailInfo) {
                ChatMailInfo* info=ChatMailInfo::create(mailInfo,dialogInfo,true,CHANNEL_TYPE_CHATROOM);
                CCLOGFUNCF("info type:%d  msg:%s",dialogInfo->type,info->msg.c_str());
                mailInfoArr->addObject(info);
            }
        }
        string groupId = dict->valueForKey("roomId")->getCString();
        if(dict->objectForKey("sendLocalTime")){
            string sendLocalTime = dict->valueForKey("sendLocalTime")->getCString();
            MailController::getInstance()->removeChatRoomSelfMsg(groupId,dialogInfo->contents,sendLocalTime);
        }
    }
    
    if (type==MK) {
        MailController::getInstance()->getChatRoomIdArray()->addObject(CCString::create(groupId));
    }
    
    CCArray* arr=dynamic_cast<CCArray*>(params->objectForKey("invalid"));
    if (arr!=NULL) {
        for (int i=0; i<arr->count(); i++) {
            CCString* str=dynamic_cast<CCString*>(arr->objectAtIndex(i));
            CCLOGFUNCF("invalid uid: %s",str->getCString());
        }
    }
    
   string founderUid=params->valueForKey("founder")->getCString();
    CCLOGFUNCF("founderUid %s",founderUid.c_str());
    CCLOGFUNCF("groupId %s mailInfoArr count %d",groupId.c_str(),mailInfoArr->count());
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    if(ChatServiceCocos2dx::enableNativeMail && MailController::getInstance()->getChatRoomEnable() && mailInfoArr->count()>0)
    {
//        if (type==MK && MailController::getInstance()->getTempChatRoomMsgDic()!=NULL) {
//            if (isO) {
//                statements
//            }
//             CCLOGFUNC("type==MK");
//            CCArray* arr=dynamic_cast<CCArray*>(MailController::getInstance()->getTempChatRoomMsgDic()->objectForKey(groupId));
//            if (arr!=NULL || arr->count()>0) {
//                MailController::getInstance()->getTempChatRoomMsgDic()->removeObjectForKey(groupId);
//            }
//            MailController::getInstance()->getTempChatRoomMsgDic()->setObject(mailInfoArr, groupId);
//        }
//        else
//        {
//            CCLOGFUNC("type!=MK");
            MailController::getInstance()->notifyMailMsgToAndroid(mailInfoArr,groupId,groupName);
//        }
        
        if (type==NAME) {
            string modifyName=bodyDic->valueForKey("msg")->getCString();
            CCLOGFUNCF("modify name:%s",modifyName.c_str());
            ChatServiceCocos2dx::notifyChatRoomNameChanged(modifyName);
        }
        if (founderUid!="") {
            ChatServiceCocos2dx::setChatRoomFounder(groupId,founderUid);
        }
    }
    
    if (!ChatServiceCocos2dx::isChatShowing) {
        if(type==MK)
        {
            CCSafeNotificationCenter::sharedNotificationCenter()->postNotification(MAIL_SEND_SUCCESS);
        }
        CCSafeNotificationCenter::sharedNotificationCenter()->postNotification(MAIL_LIST_CHANGE);
        CCSafeNotificationCenter::sharedNotificationCenter()->postNotification(MAIL_PERSON_CHAT_CHANGE);
    }
    
#elif(CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    if(ChatServiceCocos2dx::enableChatRoom && mailInfoArr->count()>0)
    {
        //        if (type==MK && MailController::getInstance()->getTempChatRoomMsgDic()!=NULL) {
        //            if (isO) {
        //                statements
        //            }
        //             CCLOGFUNC("type==MK");
        //            CCArray* arr=dynamic_cast<CCArray*>(MailController::getInstance()->getTempChatRoomMsgDic()->objectForKey(groupId));
        //            if (arr!=NULL || arr->count()>0) {
        //                MailController::getInstance()->getTempChatRoomMsgDic()->removeObjectForKey(groupId);
        //            }
        //            MailController::getInstance()->getTempChatRoomMsgDic()->setObject(mailInfoArr, groupId);
        //        }
        //        else
        //        {
        //            CCLOGFUNC("type!=MK");
        MailController::getInstance()->notifyMailMsgToIOS(mailInfoArr,CHANNEL_TYPE_CHATROOM,groupId);
        //        }
        
        if (type==NAME) {
            string modifyName=bodyDic->valueForKey("msg")->getCString();
            ChatServiceCocos2dx::notifyChatRoomNameChanged(modifyName);
        }
        if (founderUid!="") {
            ChatServiceCocos2dx::setChatRoomFounder(groupId,founderUid);
        }
    }
    
    
    if (!ChatServiceCocos2dx::isChatShowing_fun()) {
        if(type==MK)
        {
            CCSafeNotificationCenter::sharedNotificationCenter()->postNotification(MAIL_SEND_SUCCESS);
        }
        CCSafeNotificationCenter::sharedNotificationCenter()->postNotification(MAIL_LIST_CHANGE);
        CCSafeNotificationCenter::sharedNotificationCenter()->postNotification(MAIL_PERSON_CHAT_CHANGE);
    }
#else
    
#endif
    CCSafeNotificationCenter::sharedNotificationCenter()->postNotification(CHAT_ROOM_MSG_CHANGE,CCString::create("push"));
}