⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 oob.cpp

📁 空战游戏flacon源码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
		{
			root=gOOBTree->Find((j << 24) | OOBCategories[i]);
			if(root)
			{
				root=root->Child;
				while(root)
				{
					if(TurnOn)
					{
						if(root->Item_->GetUserNumber(0) == owner || FindChildren(root->Child,owner))
						{
							root->Item_->SetFlagBitOff(C_BIT_INVISIBLE);
							child=root->Child;
							while(child)
							{
								if(child->Item_->GetUserNumber(0) == owner)
									child->Item_->SetFlagBitOff(C_BIT_INVISIBLE);
								child=child->Next;
							}
						}
					}
					else
					{
						if(root->Item_->GetUserNumber(0) == owner && !FindOtherChildren(root->Child,owner))
							root->Item_->SetFlagBitOn(C_BIT_INVISIBLE);
						else
						{
							child=root->Child;
							while(child)
							{
								if(child->Item_->GetUserNumber(0) == owner)
									child->Item_->SetFlagBitOn(C_BIT_INVISIBLE);
								child=child->Next;
							}
						}
					}
					root=root->Next;
				}
			}
		}
	}

	gOOBTree->RecalcSize();
	gOOBTree->Parent_->RefreshClient(gOOBTree->GetClient());
	UI_Leave(Leave);
}

C_Entity *BuildObjectiveInfo(Objective obj)
{
	C_Resmgr *res;
	IMAGE_RSC *rsc;
	C_Entity *newinfo;
	_TCHAR buffer[200];
	ObjClassDataType *ObjPtr;
	short type=0,TypeID;
	long ObjType;

	ObjPtr=obj->GetObjectiveClassData();
	if(ObjPtr == NULL)
		return(NULL);

	ObjType=GetObjectiveType(obj);
	TypeID=static_cast<short>(FindTypeIndex(ObjType,OBJ_TypeList,_MAP_NUM_OBJ_TYPES_));

	// Create new parent class
	newinfo=new C_Entity;
	newinfo->Setup(obj->GetCampID(),TypeID);
	newinfo->SetWH(286,37);
	newinfo->InitEntity();

	newinfo->SetVUID(obj->Id());
	newinfo->SetUserNumber(0,obj->GetOwner()); // MUST be GetOwner not GetTeam

	newinfo->SetOperational(obj->GetObjectiveStatus());

	res=gImageMgr->GetImageRes(TeamColorIconIDs[TeamInfo[obj->GetTeam()]->GetColor()][0]);
	if(res)
	{
		rsc=(IMAGE_RSC*)res->Find(ObjPtr->IconIndex);
		if(rsc && rsc->Header->Type == _RSC_IS_IMAGE_)
			type=rsc->Header->h;
		else
			type=0;
	}
	else
		rsc=NULL;

	if(type > 35)
		newinfo->SetH(type+2);
	else
		type=35;

	// Set BG Area behind Airplane Icon
	newinfo->SetIconBgColor(0x7c5600,0);
	newinfo->SetIconBg(0,0,32,type);

	// Set BG Area behind rest of Squadron text
	newinfo->SetInfoBgColor(0,0x7c5600);
	newinfo->SetInfoBg(32,0,254,type);

	// Set Icon Image
	newinfo->SetIcon(15,static_cast<short>(type/2),rsc);

	// Set Name
	obj->GetName(buffer,40,TRUE);
	newinfo->SetName(35,0,gStringMgr->GetText(gStringMgr->AddText(buffer)));

	// Set # & Airplane type
	_stprintf(buffer,"%1d%% %s",newinfo->GetOperational(),gStringMgr->GetString(TXT_OPERATIONAL));
	newinfo->SetStatus(35,15,gStringMgr->GetText(gStringMgr->AddText(buffer)));

	return(newinfo);
}

C_Entity *BuildDivisionInfo(Division div,Unit unit)
{
	C_Resmgr *res;
	IMAGE_RSC *rsc;
	C_Entity *newinfo;
	_TCHAR buffer[200];
	short type=0;
	long totalstr,curstr,perc;

	UnitClassDataType *UnitPtr;

	UnitPtr=unit->GetUnitClassData();
	if(UnitPtr == NULL)
		return(NULL);

	//if(!UnitPtr->IconIndex)
	//	return(NULL);

	// Create new parent class
	newinfo=new C_Entity;
	newinfo->Setup((unit->GetTeam() << 24) | div->nid | UR_DIVISION,C_TYPE_MENU);
	newinfo->SetWH(286,37);
	newinfo->InitEntity();

	newinfo->SetUserNumber(0,unit->GetOwner()); // MUST be GetOwner not GetTeam

	curstr=unit->GetTotalVehicles();
	totalstr=unit->GetFullstrengthVehicles();
	if(totalstr < 1) totalstr=1;
	perc=(curstr * 100)/totalstr;
	if(perc > 100) perc=100;

	newinfo->SetOperational(static_cast<uchar>(perc));

	res=gImageMgr->GetImageRes(TeamColorIconIDs[TeamInfo[unit->GetTeam()]->GetColor()][0]);
	if(res)
	{
		rsc=(IMAGE_RSC*)res->Find(UnitPtr->IconIndex);
		if(rsc && rsc->Header->Type == _RSC_IS_IMAGE_)
			type=rsc->Header->h;
		else
			type=0;
	}
	else
		rsc=NULL;

	if(type > 35)
		newinfo->SetH(type+2);
	else
		type=35;

	// Set BG Area behind Airplane Icon
	newinfo->SetIconBgColor(0x7c5600,0);
	newinfo->SetIconBg(0,0,32,type);

	// Set BG Area behind rest of Squadron text
	newinfo->SetInfoBgColor(0,0x7c5600);
	newinfo->SetInfoBg(32,0,254,type);

	// Set Icon Image
	newinfo->SetIcon(15,static_cast<short>(type/2),rsc);

	// Set Name
	div->GetName(buffer,40,FALSE);
	newinfo->SetName(35,0,gStringMgr->GetText(gStringMgr->AddText(buffer)));

	// Set # & Airplane type
	MonoPrint("[Wrong]\n");
	_stprintf(buffer,"%1d%% %s",newinfo->GetOperational(),gStringMgr->GetString(TXT_OPERATIONAL));
	newinfo->SetStatus(35,15,gStringMgr->GetText(gStringMgr->AddText(buffer)));

	return(newinfo);
}

C_Entity *BuildUnitInfo(Unit unit)
{
	C_Resmgr *res;
	IMAGE_RSC *rsc;
	C_Entity *newinfo;
	_TCHAR buffer[200];
	short type=0;
	long totalstr,curstr,perc;

	UnitClassDataType *UnitPtr;

	UnitPtr=unit->GetUnitClassData();
	if(UnitPtr == NULL)
		return(NULL);

	//if(!UnitPtr->IconIndex)
	//	return(NULL);

	// Create new parent class
	newinfo=new C_Entity;
	newinfo->Setup(unit->GetCampID(),C_TYPE_MENU);
	newinfo->SetWH(286,37);
	newinfo->InitEntity();

	newinfo->SetVUID(unit->Id());
	newinfo->SetUserNumber(0,unit->GetOwner()); // MUST be GetOwner not GetTeam

	curstr=unit->GetTotalVehicles();
	totalstr=unit->GetFullstrengthVehicles();
	if(totalstr < 1) totalstr=1;
	perc=(curstr * 100)/totalstr;
	if(perc > 100) perc=100;

	newinfo->SetOperational(static_cast<char>(perc));

	res=gImageMgr->GetImageRes(TeamColorIconIDs[TeamInfo[unit->GetTeam()]->GetColor()][0]);
	if(res)
	{
		rsc=(IMAGE_RSC*)res->Find(UnitPtr->IconIndex);
		if(rsc && rsc->Header->Type == _RSC_IS_IMAGE_)
			type=rsc->Header->h;
		else
			type=0;
	}
	else
		rsc=NULL;

	if(type > 35)
		newinfo->SetH(type+2);
	else
		type=35;

	// Set BG Area behind Airplane Icon
	newinfo->SetIconBgColor(0x7c5600,0);
	newinfo->SetIconBg(0,0,32,type);

	// Set BG Area behind rest of Squadron text
	newinfo->SetInfoBgColor(0,0x7c5600);
	newinfo->SetInfoBg(32,0,254,type);

	// Set Icon Image
	newinfo->SetIcon(15,static_cast<short>(type/2),rsc);

	// Set Name
	if (unit->IsFlight())
		GetCallsign (((Flight)unit)->callsign_id, ((Flight)unit)->callsign_num, buffer);
	else
		unit->GetName(buffer,40,FALSE);
	newinfo->SetName(35,0,gStringMgr->GetText(gStringMgr->AddText(buffer)));

	// Set # & Airplane type
	_stprintf(buffer,"%1d%% %s",newinfo->GetOperational(),gStringMgr->GetString(TXT_OPERATIONAL));
	newinfo->SetStatus(35,15,gStringMgr->GetText(gStringMgr->AddText(buffer)));

	return(newinfo);
}

C_Entity *BuildNavalUnitInfo(Unit unit)
{
	C_Resmgr *res=NULL;
	IMAGE_RSC *rsc=NULL;
	C_Entity *newinfo=NULL;
	_TCHAR buffer[200]={0};
	short type=32;
	long totalstr=0,curstr=0,perc=0;

	UnitClassDataType *UnitPtr=NULL;

	UnitPtr=unit->GetUnitClassData();
	if(UnitPtr == NULL)
		return(NULL);

	// Create new parent class
	newinfo=new C_Entity;
	newinfo->Setup(unit->GetCampID(),C_TYPE_MENU);
	newinfo->SetWH(270,32);
	newinfo->InitEntity();

	newinfo->SetVUID(unit->Id());
	newinfo->SetUserNumber(0,unit->GetOwner()); // MUST be GetOwner not GetTeam

	curstr=unit->GetTotalVehicles();
	totalstr=unit->GetFullstrengthVehicles();
	if(totalstr < 1) totalstr=1;
	perc=(curstr * 100)/totalstr;
	if(perc > 100) perc=100;

	newinfo->SetOperational(static_cast<uchar>(perc));

	res=gImageMgr->GetImageRes(TeamColorIconIDs[TeamInfo[unit->GetTeam()]->GetColor()][0]);
	if(res)
	{
		rsc=(IMAGE_RSC*)res->Find(UnitPtr->IconIndex);
		if(rsc && rsc->Header->Type == _RSC_IS_IMAGE_)
			type=rsc->Header->h;
		else
			type=0;
	}
	else
		rsc=NULL;

	if(type > 32)
		newinfo->SetH(type+2);
	else
		type=32;

	// Set BG Area behind Airplane Icon
	newinfo->SetIconBgColor(0x7c5600,0);
	newinfo->SetIconBg(0,0,80,type);

	// Set BG Area behind rest of Squadron text
	newinfo->SetInfoBgColor(0,0x7c5600);
	newinfo->SetInfoBg(80,0,190,type);

	// Set Icon Image
	newinfo->SetIcon(40,static_cast<short>(type/2),rsc);

	// Set Name
	unit->GetName(buffer,40,FALSE);
	newinfo->SetName(84,0,gStringMgr->GetText(gStringMgr->AddText(buffer)));

	// Set # & Airplane type
	_stprintf(buffer,"%1d%% %s",newinfo->GetOperational(),gStringMgr->GetString(TXT_OPERATIONAL));
	newinfo->SetStatus(84,15,gStringMgr->GetText(gStringMgr->AddText(buffer)));

	return(newinfo);
}

void TallyPlayerSquadrons()
{
	SQUADRONPLAYER *cur,*prev;
	FalconSessionEntity *session;
	int done;

	cur=gPlayerSquadrons;
	while(cur)
	{
		prev=cur;
		cur=cur->Next;
		delete prev;
	}
	gPlayerSquadrons=NULL;

	if (gCommsMgr->GetGame())
	{
		VuSessionsIterator sessionWalker(gCommsMgr->GetGame());
		session = (FalconSessionEntity*)sessionWalker.GetFirst();
		while(session)
		{
			done=0;
			cur=gPlayerSquadrons;
			while(cur && !done)
			{
				if(cur->SquadronID == session->GetPlayerSquadronID())
				{
					cur->PlayerCount++;
					done=1;
				}
				else
					cur=cur->Next;
			}
			if(!cur)
			{
				prev=new SQUADRONPLAYER;
				prev->SquadronID=session->GetPlayerSquadronID();
				prev->PlayerCount=1;
				prev->Next=NULL;

				if(!gPlayerSquadrons)
					gPlayerSquadrons=prev;
				else
				{
					cur=gPlayerSquadrons;
					while(cur->Next)
						cur=cur->Next;
					cur->Next=prev;
				}
			}
			session = (FalconSessionEntity*)sessionWalker.GetNext();
		}
	}
}

void GetPlayerInfo(VU_ID ID)
{
	UI_RequestLogbook *rlb;
	FalconSessionEntity *session;

	session=(FalconSessionEntity*)vuDatabase->Find(ID);
	if(session && session != FalconLocalSession)
	{
		rlb=new UI_RequestLogbook(FalconNullId,session);
		rlb->dataBlock.fromID=FalconLocalSessionId;

		FalconSendMessage(rlb,true);
	}
}


short GetSquadronPlayerCount(VU_ID SquadID)
{
	SQUADRONPLAYER *cur;

	cur=gPlayerSquadrons;
	while(cur)
	{
		if(cur->SquadronID == SquadID)
			return(cur->PlayerCount);
		cur=cur->Next;
	}
	return(0);
}

C_Squadron *BuildSquadronInfo(Squadron sqd)
{
	C_Squadron *newinfo;
	_TCHAR buffer[200];
	IMAGE_RSC *img;
	short type;
	UnitClassDataType *UnitPtr;

	UnitPtr=sqd->GetUnitClassData();
	if(UnitPtr == NULL)
		return(NULL);

	// Create new parent class
	newinfo=new C_Squadron;
	newinfo->Setup(sqd->GetCampID(),C_TYPE_MENU);
	newinfo->SetWH(286,52);
	newinfo->InitSquadron();

	newinfo->SetVUID(sqd->Id());
	newinfo->SetUserNumber(0,sqd->GetOwner()); // MUST be GetOwner not GetTeam

	newinfo->SetNumVehicles(static_cast<short>(sqd->GetTotalVehicles()));
	newinfo->SetNumPilots(static_cast<short>(sqd->NumActivePilots()));
	newinfo->SetNumPlayers(GetSquadronPlayerCount(sqd->Id()));

	img=gImageMgr->GetImage(UnitPtr->IconIndex);
	if(img)
		type=img->Header->h;
	else
		type=0;

	if(type > 50)
		newinfo->SetH(type+2);
	else
		type=50;

	// Set BG Area behind Airplane Icon
	newinfo->SetIconBgColor(0x7c5600,0);
	newinfo->SetIconBg(0,0,46,type);

	// Set BG Area behind rest of Squadron text
	newinfo->SetInfoBgColor(0,0x7c5600);
	newinfo->SetInfoBg(46,0,240,type);

	// Set Icon Image
	newinfo->SetIcon(23,static_cast<short>(type/2),UnitPtr->IconIndex);

	// Set Name
	sqd->GetName(buffer,40,FALSE);
	newinfo->SetName(54,5,gStringMgr->GetText(gStringMgr->AddText(buffer)));

	// Set # & Airplane type
	_stprintf(buffer,"%1d %s",newinfo->GetNumVehicles(),GetVehicleName(sqd->GetVehicleID(0)));
	newinfo->SetPlanes(54,20,gStringMgr->GetText(gStringMgr->AddText(buffer)));

	// Set Total # of Pilots
	_stprintf(buffer,"%1d %s",newinfo->GetNumPilots()+newinfo->GetNumPlayers(),gStringMgr->GetString(TXT_PILOTS));
	newinfo->SetPilots(160,20,gStringMgr->GetText(gStringMgr->AddText(buffer)));

	// Set #  of Human Pilots
	_stprintf(buffer,"%1d %s",newinfo->GetNumPlayers(),gStringMgr->GetString(TXT_PLAYERS));
	newinfo->SetPlayers(54,35,gStringMgr->GetText(gStringMgr->AddText(buffer)));
	return(newinfo);
}

C_Base *BuildOOBItem(CampEntity entity)
{
	C_Base *builder;

	if(entity->IsSquadron())
	{
		builder=BuildSquadronInfo((Squadron)entity);
		if(builder)
		{
			((C_Squadron*)builder)->SetCallback(SelectOOBSquadronCB);
			return(builder);
		}
	}
	else if(entity->IsBattalion() || entity->IsBrigade())
	{
		builder=BuildUnitInfo((Unit)entity);
		if(builder)
		{
			((C_Entity*)builder)->SetCallback(SelectOOBEntityCB);
			return(builder);
		}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -