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

📄 planner.cpp

📁 空战游戏flacon源码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
	{
		CloseAllRenderers(RECON_WIN);
		if(TargetTree)
			TargetTree->DeleteBranch(TargetTree->GetRoot());

		if(!OldReconCWCB)
		{
			btn=win->FindControl(CLOSE_WINDOW);
			if(btn)
			{
				OldReconCWCB=btn->GetCallback();
				btn->SetCallback(TgtAssignCWCB);
			}
		}
		btn=win->FindControl(SET_TARGET);
		if(btn)
			btn->SetFlagBitOff(C_BIT_INVISIBLE);

		flight=(Flight)vuDatabase->Find(gActiveFlightID);
		if(flight == NULL) return;
		i=1;
		wp=flight->GetFirstUnitWP();
		while(i < gActiveWPNum && wp)
		{
			wp=wp->GetNextWP();
			i++;
		}
		if(wp)
		{
			wp->GetLocation(&x,&y,&z);
			BuildTargetList(x,y,18000.0f);
		}
	}
}

void OpenReconForVCCB(long,short hittype,C_Base *)
{
	C_Window *win;
	C_Base *btn;

	if(hittype != C_TYPE_LMOUSEUP)
		return;

	SetCursor(gCursors[CRSR_WAIT]);

	win=gMainHandler->FindWindow(RECON_LIST_WIN);
	if(win)
	{
		CloseAllRenderers(RECON_WIN);
		if(TargetTree)
			TargetTree->DeleteBranch(TargetTree->GetRoot());

		if(!OldReconCWCB)
		{
			btn=win->FindControl(CLOSE_WINDOW);
			if(btn)
			{
				OldReconCWCB=btn->GetCallback();
				btn->SetCallback(TgtAssignCWCB);
			}
		}
		btn=win->FindControl(SET_VC);
		if(btn)
			btn->SetFlagBitOff(C_BIT_INVISIBLE);

		// Find where user clicked... and do recon, OR pick as target
		// Set Cur VC's Target
	}
}

void ClosePlannerWindowCB(long,short hittype,C_Base *control)
{
	if(hittype != C_TYPE_LMOUSEUP)
		return;

	if(control->GetGroup())
		gMainHandler->DisableWindowGroup(control->GetGroup());
}

static void ObjectPannerCB(long,short hittype,C_Base *control)
{
	float dx,dy;
	C_Panner *pnr;

	if(hittype != C_TYPE_LMOUSEUP && hittype != C_TYPE_REPEAT)
		return;

	pnr=(C_Panner*)control;
	dx=static_cast<float>(pnr->GetHRange());
	dy=static_cast<float>(pnr->GetVRange());

	Object.Heading+=dx;
	Object.Pitch+=dy;
	if(Object.Heading < 0) Object.Heading+=360;
	if(Object.Heading > 360) Object.Heading-=360;
	if(Object.CheckPitch)
	{
		if(Object.Pitch < Object.MinPitch) Object.Pitch=Object.MinPitch;
		if(Object.Pitch < Object.MaxPitch) Object.Pitch=Object.MaxPitch;
	}
	else
	{
		if(Object.Pitch < 0) Object.Pitch+=360;
		if(Object.Pitch > 360) Object.Pitch-=360;
	}
	PositionCamera(&Object,control->Parent_,control->GetClient());
}

static void ObjectZoomCB(long,short hittype,C_Base *control)
{
	float dy;
	C_Panner *pnr;

	if(hittype != C_TYPE_LMOUSEUP && hittype != C_TYPE_REPEAT)
		return;

	pnr=(C_Panner*)control;
	dy=static_cast<float>(pnr->GetVRange());

	Object.Distance+=dy;
	if(Object.Distance < Object.MinDistance) Object.Distance=Object.MinDistance;
	if(Object.Distance > Object.MaxDistance) Object.Distance=Object.MaxDistance;

	PositionCamera(&Object,control->Parent_,control->GetClient());
}

void OpenMunitionsWindowCB(long,short hittype,C_Base *control)
{
	F4CSECTIONHANDLE *Leave;
	Flight flight;
	C_Window *win;

	if(hittype != C_TYPE_LMOUSEUP)
		return;

	if(gSelectedFlightID == FalconNullId)
		return;

	SetCursor(gCursors[CRSR_WAIT]);

	// TODO: Check to see if the flight has already taken off
	// if so... open Error window... and don't do anything
	flight=(Flight)vuDatabase->Find(gSelectedFlightID);
	if(!flight) return;
	if(!flight->IsFlight()) return;

	if(control->GetGroup())
	{
		if(UIrend3d == NULL)
		{
			win=gMainHandler->FindWindow(MUNITIONS_WIN);
			if(win)
			{
				CloseAllRenderers(MUNITIONS_WIN);
				Leave=UI_Enter(win);
				if(gUIViewer)
				{
					gUIViewer->Cleanup();
					delete gUIViewer;
				}
				gUIViewer=new C_3dViewer;
				gUIViewer->Setup();
				gUIViewer->Viewport(win,2);
				gUIViewer->Init3d(30.0f);

				gLoadoutFlightID=gSelectedFlightID;
				SetupMunitionsWindow(gLoadoutFlightID);
				LoadFlight(gLoadoutFlightID);
				SetupLoadoutDisplay();
				UpdateInventoryCount();
				MakeStoresList(win,1);
				win->RefreshClient(1);
				TheLoader.WaitForLoader();

				PositionCamera(&Object,win,2);
				UI_Leave(Leave);
			}
		}
		gMainHandler->EnableWindowGroup(control->GetGroup());
	}
	SetCursor(gCursors[CRSR_F16]);
}

void CloseMunitionsWindowCB(long,short hittype,C_Base *control)
{
	if(hittype != C_TYPE_LMOUSEUP)
		return;

	if(control->GetGroup())
		gMainHandler->DisableWindowGroup(control->GetGroup());

	if(gUIViewer)
	{
		gUIViewer->Cleanup();
		delete gUIViewer;
		gUIViewer=NULL;
	}
}

static void SelectPlaneToArmCB(long ID,short hittype,C_Base *control)
{
	int i,idx,count;

	if(hittype != C_TYPE_LMOUSEUP)
		return;

	switch(ID)
	{
		case AIR_1:
			idx=0;
			break;
		case AIR_2:
			idx=1;
			break;
		case AIR_3:
			idx=2;
			break;
		case AIR_4:
			idx=3;
			break;
		default:
			return;
	}

	count=0;
	for(i=0;i<4;i++)
		if(PlaneEditList[i])
			count++;

	if(((C_Button *)control)->GetState())
	{
		if(count < 2)
			return;

		((C_Button *)control)->SetState(0);
		SetPlaneToArm(idx,FALSE);
	}
	else
	{
		((C_Button *)control)->SetState(1);
		SetPlaneToArm(idx,TRUE);
	}
	SetCurrentLoadout();
	control->Refresh();
	control->Parent_->RefreshClient(2);
}

static void ChooseWeaponListCB(long,short hittype,C_Base *)
{
	C_Window *win;
	F4CSECTIONHANDLE *Leave;
	if(hittype != C_TYPE_SELECT)
		return;

	win=gMainHandler->FindWindow(MUNITIONS_WIN);
	if(win)
	{
		Leave=UI_Enter(win);
		MakeStoresList(win,1);
		win->RefreshWindow();
		//win->RefreshClient(1);
		UI_Leave(Leave);
	}
}

static void LoadTheStoresCB(long,short hittype,C_Base *control)
{
	FILE *ifp;
	LoadoutStruct hp;
	long i,j;
	_TCHAR fname[MAX_PATH];
	C_EditBox *ebox;
	C_Window *win;
	F4CSECTIONHANDLE *Leave;

	if(hittype != C_TYPE_LMOUSEUP)
		return;

	gMainHandler->HideWindow(control->Parent_);

	ebox=(C_EditBox*)control->Parent_->FindControl(FILE_NAME);
	if(ebox)
	{
		_stprintf(fname,"%s\\%s.str",FalconCampUserSaveDirectory,ebox->GetText());
		ifp=fopen(fname,"rb");
		if(ifp == NULL)
			return;

		fread(&hp,sizeof(LoadoutStruct),1,ifp);
		fclose(ifp);

		PlaceLoadedWeapons(&hp);

		win=gMainHandler->FindWindow(MUNITIONS_WIN);
		if(win)
		{
			Leave=UI_Enter(win);
			for(i=0;i<4;i++)
				if(PlaneEditList[i])
					for(j=1;j<HardPoints;j++)
					{
						ClearHardPoint(i,j,static_cast<short>(HardPoints/2),&gCurRails[i].rail[j]);
						if(GetRackAndWeapon(gVCPtr,static_cast<short>(gVehID),gCurStores[i].WeaponID[j],gCurStores[i].WeaponCount[j],static_cast<short>(j),static_cast<short>(HardPoints / 2),&gCurRails[i].rail[j]))
							LoadHardPoint(i,j,static_cast<short>(HardPoints/2),&gCurRails[i].rail[j]);
					}

			MakeStoresList(win,1);
			win->RefreshWindow();
			UI_Leave(Leave);
		}
	}
}

static void LoadStoresCB(long,short hittype,C_Base *)
{
	_TCHAR fname[MAX_PATH];

	if(hittype != C_TYPE_LMOUSEUP)
		return;

	SetDeleteCallback(DelSTRFileCB);
	_stprintf(fname,"%s\\*.str",FalconCampUserSaveDirectory);
	LoadAFile(TXT_LOAD_STORES,fname,NULL,LoadTheStoresCB,CloseWindowCB);
}

static void SaveTheStoresCB(long,short hittype,C_Base *control)
{
	_TCHAR fname[MAX_PATH];
	FILE *ofp;
	C_EditBox *ebox;
	C_Window *win;

	if(hittype != C_TYPE_LMOUSEUP)
		return;

	win=gMainHandler->FindWindow(SAVE_WIN);
	if(!win)
		return;

	gMainHandler->HideWindow(win);
	gMainHandler->HideWindow(control->Parent_);

	ebox=(C_EditBox*)win->FindControl(FILE_NAME);
	if(ebox)
	{
		_stprintf(fname,"%s\\%s.str",FalconCampUserSaveDirectory,ebox->GetText());
		ofp=fopen(fname,"wb");
		if(ofp == NULL)
			return;

		fwrite(&gCurStores[FirstPlane],sizeof(LoadoutStruct),1,ofp);
		fclose(ofp);
	}
}

static void VerifySaveTheStoresCB(long ID,short hittype,C_Base *control)
{
	_TCHAR fname[MAX_PATH];
	FILE *ofp;
	C_EditBox *ebox;

	if(hittype != C_TYPE_LMOUSEUP)
		return;

	ebox=(C_EditBox*)control->Parent_->FindControl(FILE_NAME);
	if(ebox)
	{
		_stprintf(fname,"%s\\%s.str",FalconCampUserSaveDirectory,ebox->GetText());
		ofp=fopen(fname,"r");
		if(ofp)
		{
			fclose(ofp);
			AreYouSure(TXT_SAVE_STORES,TXT_FILE_EXISTS,SaveTheStoresCB,CloseWindowCB);
		}
		else
			SaveTheStoresCB(ID,hittype,control);
	}
}

static void SaveStoresCB(long,short hittype,C_Base *)
{
	if(hittype != C_TYPE_LMOUSEUP)
		return;

	SetDeleteCallback(DelSTRFileCB);
	SaveAFile(TXT_SAVE_STORES,"*.str",NULL,VerifySaveTheStoresCB,CloseWindowCB);
}

static void RestoreStoresCB(long,short hittype,C_Base *control)
{
	if(hittype != C_TYPE_LMOUSEUP)
		return;

	RestoreStores(control->Parent_);
}

static void ClearStoresCB(long,short hittype,C_Base *control)
{
	if(hittype != C_TYPE_LMOUSEUP)
		return;

	ClearStores(control->Parent_);
}

static void UseStoresCB(long,short hittype,C_Base *control)
{
	if(hittype != C_TYPE_LMOUSEUP)
		return;

	if(gFlightOverloaded)
	{
		AreYouSure(TXT_ERROR,TXT_OVERLOADED,NULL,CloseWindowCB);
		return;
	}

	UseStores();
	if(control->GetGroup())
		gMainHandler->DisableWindowGroup(control->GetGroup());

	if(gUIViewer)
	{
		gUIViewer->Cleanup();
		delete gUIViewer;
		gUIViewer=NULL;
	}

	// KCK: We need to update the mission evaluation stuff if this is the selected flight
	if (gLoadoutFlightID == gPlayerFlightID)
	{
		Flight	flight = (Flight) vuDatabase->Find(gLoadoutFlightID);
		int		pilotSlot = 255;
		if (!flight)
			return;
		pilotSlot = FalconLocalSession->GetPilotSlot();

⌨️ 快捷键说明

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