int Container::insertFileList(FileList *fl,UserData *parent)
{
    UserData *ud;
    UserData *first;
    int i,num_items;
    HPOINTER the_icon;
    
    num_items = fl->getNumFiles();
    
    // Build up insertion information
    RECORDINSERT ri;   
    memset(&ri,0,sizeof(RECORDINSERT));
    ri.cb = sizeof(RECORDINSERT);
    ri.zOrder = CMA_END;                    // add on top of siblings
//    ri.fInvalidateRecord = TRUE;            // re-arrange after insert
    ri.pRecordParent = (PRECORDCORE)parent; // set tree hierarchy
    ri.pRecordOrder = (RECORDCORE*)CMA_END; // add to end of list
    
    
    if (num_items > 0)
    {
        ri.cRecordsInsert = num_items;          // number of records to insert
        first = allocateRecords(num_items);
        ud = first;
        if (ud)
        {
            for (i=0; i<num_items; i++)
            {
                num_objects++;
                ud->setName(fl->getFile(i));
                the_icon = determineIcon(fl->getFile(i));
                ud->setIcons(the_icon,the_icon);
                ud->setType(TYPE_FILE);
                ud->setParent(parent);
// NEW STUFF
/*
                    char *kkk = new char[4096];
                    strcpy(kkk,fl->getBasePath());
                    strcat(kkk,fl->getFile(i));
                    
                    the_icon = WinLoadFileIcon(kkk,FALSE);
                    if (the_icon != NULL)
                    {
                        ud->setIcons(the_icon,the_icon);
                        WinSendMsg(cont,CM_INVALIDATERECORD,MPFROMP(&ud),MPFROM2SHORT(1,CMA_TEXTCHANGED|CMA_REPOSITION));
                    }
                    delete[] kkk;
*/
// ENDE NEW STUFF
                    
                PRECORDCORE pr = (PRECORDCORE)ud;
                ud = (UserData*)pr->preccNextRecord;
            }
            
            MRESULT rc = WinSendMsg(cont,CM_INSERTRECORD,MPFROMP((PRECORDCORE)first),MPFROMP(&ri));
            return 1;
        }
    }
    return 0;
}
// Insert a Server Object
int Container::insert(char *name,char *user,char *pass,ULONG arg1,ULONG arg2)
{
    UserData *ud;
    UserData *parent = NULL;
    
    ud = allocateRecords(1);
    if (ud)
    {
        last_insert = ud;
        
        num_objects++;
        
        // set all the stuff in our record
        ud->setName(name);
        ud->setUsername(user);
        ud->setPassword(pass);
        ud->setType(TYPE_SERVER);
        ud->setIcons(icon_server,icon_server);
        ud->setCull(arg1);
        ud->setStart(arg2);
        
        // Build up insertion information
        RECORDINSERT ri;   
        memset(&ri,0,sizeof(RECORDINSERT));
        ri.cb = sizeof(RECORDINSERT);
        ri.zOrder = CMA_END;                    // add on top of siblings
        if (!parent || !parent->getCollapsed())
            ri.fInvalidateRecord = TRUE;            // re-arrange after insert
        ri.pRecordParent = (PRECORDCORE)parent; // set tree hierarchy
        ri.cRecordsInsert = 1;                  // number of records to insert
        ri.pRecordOrder = (RECORDCORE*)CMA_END; // add to end of list

        MRESULT rc = WinSendMsg(cont,CM_INSERTRECORD,MPFROMP((PRECORDCORE)ud),MPFROMP(&ri));
        if (rc == 0)
            message("CM_INSERTRECORD returned %d",rc);
        
        return 1;
    }
    else
    {
        DosBeep(100,100);
        return 0;
    }
}
int Container::insert(char *name,UserData *parent,ULONG arg1,ULONG arg2)
{
    UserData *ud;
    
    ud = allocateRecords(1);
    if (ud)
    {
        last_insert = ud;
        
//        objects[num_objects] = ud;  // keep a pointer to the block
        num_objects++;
        
        // set all the stuff in our record
        ud->setName(name);
        if (arg1 == arg2 && arg1 == 7777L)
        {
            ud->setType(TYPE_GROUP);
            ud->setIcons(icon_group_o,icon_group_c);
        }
        else if (arg1 == arg2 && arg1 == 8888L)
        {
            ud->setType(TYPE_FILE);
            ud->setParent(parent);
            HPOINTER the_icon;
            if (*name)
            {
                the_icon = determineIcon(name);
//
//                if (the_icon != icon_dunno)
//                {
                    ud->setIcons(the_icon,the_icon);
//                }
//                else
//                {
//                    // TRY TO LOAD THE Shared WPS ICON
//                    the_icon = WinLoadFileIcon(name,FALSE);
//                    if (the_icon != NULL)
//                    {
//                        ud->setIcons(the_icon,the_icon);
//                        WinSendMsg(cont,CM_INVALIDATERECORD,MPFROMP(&ud),MPFROM2SHORT(1,CMA_TEXTCHANGED|CMA_REPOSITION));
//                    }
//                }
            }
            
        }
        else if (parent == NULL)
        {
            ud->setType(TYPE_SERVER);
            ud->setIcons(icon_server,icon_server);
        }
        else
        {
            ud->setType(TYPE_GROUP);
            ud->setParent(parent);
            ud->setIcons(icon_group_o,icon_group_c);
        }
        
        ud->setCull(arg1);
        ud->setStart(arg2);
        
        // Build up insertion information
        RECORDINSERT ri;   
        memset(&ri,0,sizeof(RECORDINSERT));
        ri.cb = sizeof(RECORDINSERT);
        ri.zOrder = CMA_END;                    // add on top of siblings
        if (!parent || !parent->getCollapsed())
            ri.fInvalidateRecord = TRUE;            // re-arrange after insert
        ri.pRecordParent = (PRECORDCORE)parent; // set tree hierarchy
        ri.cRecordsInsert = 1;                  // number of records to insert
        ri.pRecordOrder = (RECORDCORE*)CMA_END; // add to end of list

//        MRESULT rc = WinSendDlgItemMsg(dialog,id,CM_INSERTRECORD,MPFROMP((PRECORDCORE)ud),MPFROMP(&ri));
        MRESULT rc = WinSendMsg(cont,CM_INSERTRECORD,MPFROMP((PRECORDCORE)ud),MPFROMP(&ri));
        if (rc == 0)
            message("CM_INSERTRECORD returned %d",rc);
        
        return 1;
    }
    else
    {
        DosBeep(100,100);
        return 0;
    }
}
Пример #4
0
//连接网关服务器成功后,服务器自动推送消息,返回网关服务器列表
bool LoginLayerUC::ProcessMsg(int type, google::protobuf::Message *msg)
{
	m_iCurrentType = type;
	switch (type)
	{
	case ServerListMsg:
		{
			unschedule(schedule_selector(LoginLayerUC::scheduleForConnectGateServer));

			CCLOG("ServerListMsg");
			ServerList* serverInfo = (ServerList*)msg;
			m_serverInfo = *serverInfo;
			m_pLoading->setVisible(false);

			//没有服务器列表弹框提示
			if(m_serverInfo.server_list().size()<=0)
			{
				ShowPopTextTip(GETLANGSTR(207));
				return false;
			}

			//读取上一次登录选择的服务器
			std::string sServerGame = CCUserDefault::sharedUserDefault()->getStringForKey(SERVER_FOR_GAME);
			m_iSelectServerIndex = getServerIndex(sServerGame);


			//读取更新服务器列表
			std::string sUpdateServer = serverInfo->update_server();
			if(sUpdateServer.compare("") != 0)
			{
				CCUserDefault::sharedUserDefault()->setStringForKey(SERVER_FOR_UPDATE, sUpdateServer);
				CCUserDefault::sharedUserDefault()->flush();
			}

			//版本更新
			bool bUpdate = GamePlatformMgr->VersionUpdateWithPlatform( serverInfo->game_version() );
			if(!bUpdate)
			{
				initLogin();
			}
		}
		break;
	case LoginResponseMsg:
		{
			LoginResponse *loginResponse = (LoginResponse *)msg;
			printf("%d,%d,",loginResponse->authrecode(),loginResponse->hasrole());
			printf("\n name = %s ,...", loginResponse->GetDescriptor()->name().c_str());
			int res =loginResponse->authrecode();			//登录成功,
			if (res==0)
			{
				if (loginResponse->hasrole())
				{
					for (int i=0; i<loginResponse->rolelist_size();i++)
					{
						protos::common::Role role = loginResponse->rolelist(i);
						printf("role id:%d  rolename:%s, rolelv: %d", role.roleid(), U8(role.rolename().c_str()),role.rolelv());
						CNetClient::getShareInstance()->sendInGameReq(role.roleid());
						break;
					}
				}
				else
				{
					m_armature->getAnimation()->play("enter");
					this->runAction(CCSequence::createWithTwoActions(CCDelayTime::create(0.7f), CCCallFunc::create(this, callfunc_selector(LoginLayerUC::callbackForSound))));
					removeLogin();
				}
			}
			//0x01服务器人数上限,0x02账号禁止登录,0x03账号验证错误)
			else if (res==1)
			{
				ShowTexttip(GETLANGSTR(227),RGB_RED,0,ccp(VCENTER.x,VCENTER.y+150),0.0f,2.0f,0.0f,20.0f);
			}
			else if (res==2)
			{
				ShowTexttip(GETLANGSTR(228),RGB_RED,0,ccp(VCENTER.x,VCENTER.y+150),0.0f,2.0f,0.0f,20.0f);
			}
			else if (res==3)
			{
				ShowTexttip(GETLANGSTR(165),RGB_RED,0,ccp(VCENTER.x,VCENTER.y+150),0.0f,2.0f,0.0f,20.0f);
			}
			else if(res==4)
			{
				ShowTexttip(GETLANGSTR(1155),RGB_RED,0,ccp(VCENTER.x,VCENTER.y+150),0.0f,2.0f,0.0f,20.0f);
			}
			return true;
		}
		break;
		//进入游戏
	case InGameResponseMsg:
		{
			InGameResponse *inRespon = (InGameResponse*)msg;
			protos::common::Role role = inRespon->myrole();
			printf("role id:%d  rolename:%s, rolelv: %d", role.roleid(), U8(role.rolename().c_str()),role.rolelv());

			UserData* userData = DataCenter::sharedData()->getUser()->getUserData();
			userData->setRaceType(role.rolenation());
			userData->setAliveID(role.roleid());
			userData->setRoleID(role.roleid());
			userData->setLevel(role.rolelv());
			userData->setName(role.rolename().c_str());
			userData->setCoin(role.rolecoin());
			userData->setExp(role.roleexp());
			userData->setNextExp(role.nextexp());
			userData->setRoleAction(role.roleaction());
			userData->setRoleGold(role.rolegold());
			userData->read(role);
			m_armature->getAnimation()->play("enter");
			this->runAction(CCSequence::createWithTwoActions(CCDelayTime::create(0.7f), CCCallFunc::create(this, callfunc_selector(LoginLayerUC::callbackForSound))));
			removeLogin();
			return true;
		}
		break;
	default:
		break;
	}
	return false;
}