📄 targets.cpp
字号:
// Targetting Code goes here
#include <windows.h>
#include "Graphics\Include\TimeMgr.h"
#include "Graphics\Include\imagebuf.h"
#include "Graphics\Include\renderow.h"
#include "Graphics\Include\RViewPnt.h"
#include "Graphics\Include\drawbrdg.h"
#include "Graphics\Include\drawplat.h"
#include "Graphics\Include\drawbsp.h"
#include "vu2.h"
#include "F4vu.h"
#include "team.h"
//#include "simbase.h"
//#include "simlib.h"
//#include "initdata.h"
//#include "simfiltr.h"
//#include "simdrive.h"
//#include "simfeat.h"
#include "vehicle.h"
#include "objectiv.h"
#include "division.h"
#include "feature.h"
#include "find.h"
#include "dispcfg.h"
#include "Graphics\Include\setup.h"
#include "Graphics\Include\loader.h"
#include "chandler.h"
#include "ui95_ext.h"
#include "cmap.h"
#include "gps.h"
#include "cbsplist.h"
#include "c3dview.h"
#include "userids.h"
#include "textids.h"
#include "teamdata.h"
#include "classtbl.h"
#include "PtData.h"
void CenterOnFeatureCB(long ID,short hittype,C_Base *control);
void SetBullsEye(C_Window *);
void SetSlantRange(C_Window *);
void SetHeading(C_Window *);
void PositionCamera(OBJECTINFO *Info,C_Window *win,long client);
void CloseAllRenderers(long openID);
extern C_Handler *gMainHandler;
extern C_TreeList *TargetTree;
extern C_3dViewer *gUIViewer;
extern OBJECTINFO Recon;
extern GlobalPositioningSystem *gGps;
extern VU_ID FeatureID;
extern long FeatureNo;
void PickFirstChildCB(long,short hittype,C_Base *control)
{
TREELIST *parent,*item;
C_Entity *cent;
if(hittype != C_TYPE_LMOUSEUP)
return;
cent=(C_Entity*)control;
if(!cent)
return;
parent=cent->GetOwner();
if(parent)
return;
FeatureID=cent->GetVUID();
FeatureNo=0;
item=parent->Child;
if(item)
CenterOnFeatureCB(RECON_TREE,hittype,item->Item_);
}
C_Entity *BuildObjective(Objective obj)
{
C_Resmgr *res;
IMAGE_RSC *rsc;
C_Entity *newinfo;
_TCHAR buffer[200];
ObjClassDataType *ObjPtr;
int type=0;
ObjPtr=obj->GetObjectiveClassData();
if(ObjPtr == NULL)
return(NULL);
// Create new parent class
newinfo=new C_Entity;
newinfo->Setup(obj->GetCampID(),C_TYPE_ITEM);
newinfo->SetWH(500,37);
newinfo->SetFlagBitOff(C_BIT_USEBGFILL);
newinfo->InitEntity();
newinfo->SetVUID(obj->Id());
newinfo->SetUserNumber(0,obj->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 Icon Image
newinfo->SetIcon(15,static_cast<short>(type/2),rsc);
// Set Name
obj->GetName(buffer,40,TRUE);
newinfo->SetName(35,10,gStringMgr->GetText(gStringMgr->AddText(buffer)));
// Set # & Airplane type
_stprintf(buffer,"%1d%% %s",newinfo->GetOperational(),gStringMgr->GetString(TXT_OPERATIONAL));
newinfo->SetStatus(300,10,gStringMgr->GetText(gStringMgr->AddText(buffer)));
return(newinfo);
}
C_Feature *BuildFeature(Objective obj,long featureID,Tpoint *)
{
C_Feature *feat;
long TextID;
FeatureClassDataType* fc;
long classID;
classID = obj->GetFeatureID(featureID);
if (classID)
{
fc = GetFeatureClassData (classID);
if (!fc || fc->Flags & FEAT_VIRTUAL)
return(NULL);
feat=new C_Feature;
feat->Setup(obj->GetCampID() << 16 | featureID,0);
feat->SetFlagBitOff(C_BIT_USEBGFILL);
feat->SetColor(0xc0c0c0,0x00ff00);
feat->InitEntity();
feat->SetName(25,0,fc->Name);
switch(obj->GetFeatureStatus(featureID))
{
case 0:
TextID=TXT_NO_DAMAGE;
break;
case 1:
TextID=TXT_REPAIRED;
break;
case 2:
TextID=TXT_DAMAGED;
break;
case 3:
TextID=TXT_DESTROYED;
break;
default:
TextID=TXT_NO_DAMAGE;
break;
}
feat->SetStatus(280,0,TextID);
if(obj->GetFeatureValue(featureID) < 10)
TextID=TXT_VERYLOW;
else if(obj->GetFeatureValue(featureID) < 25)
TextID=TXT_LOW;
else if(obj->GetFeatureValue(featureID) < 40)
TextID=TXT_MEDIUM;
else if(obj->GetFeatureValue(featureID) < 50)
TextID=TXT_HIGH;
else
TextID=TXT_VERYHIGH;
feat->SetValue(390,0,TextID);
feat->SetCallback(CenterOnFeatureCB);
feat->SetVUID(obj->Id());
feat->SetFeatureID(featureID);
feat->SetFeatureValue(static_cast<uchar>(obj->GetFeatureValue(featureID)));
return(feat);
}
return(NULL);
}
C_Entity *BuildUnitParent(Unit unit)
{
C_Resmgr *res;
IMAGE_RSC *rsc;
C_Entity *newinfo;
_TCHAR buffer[200];
UnitClassDataType *UnitPtr;
long type=0;
UnitPtr=unit->GetUnitClassData();
if(UnitPtr == NULL)
return(NULL);
// Create new parent class
newinfo=new C_Entity;
newinfo->Setup(unit->GetCampID(),C_TYPE_ITEM);
newinfo->SetWH(500,37);
newinfo->SetFlagBitOff(C_BIT_USEBGFILL);
newinfo->InitEntity();
newinfo->SetVUID(unit->Id());
newinfo->SetUserNumber(0,unit->GetTeam());
if(unit->GetFullstrengthVehicles())
{
if(unit->IsFlight())
{
short planecount;
Flight flt=(Flight)unit;
planecount=0;
while(flt->plane_stats[planecount] != AIRCRAFT_NOT_ASSIGNED && planecount < PILOTS_PER_FLIGHT)
planecount++;
if(planecount)
newinfo->SetOperational(static_cast<uchar>(unit->GetTotalVehicles()*100/planecount));
else
newinfo->SetOperational(0);
}
else
newinfo->SetOperational(static_cast<uchar>(unit->GetTotalVehicles()*100/unit->GetFullstrengthVehicles()));
}
else
newinfo->SetOperational(0);
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 Icon Image
newinfo->SetIcon(15,static_cast<short>(type/2),rsc);
// Set Name
unit->GetName(buffer,40,FALSE);
newinfo->SetName(35,10,gStringMgr->GetText(gStringMgr->AddText(buffer)));
// Set # & Airplane type
_stprintf(buffer,"%1d%% %s",newinfo->GetOperational(),gStringMgr->GetString(TXT_OPERATIONAL));
newinfo->SetStatus(300,10,gStringMgr->GetText(gStringMgr->AddText(buffer)));
return(newinfo);
}
C_Feature *BuildUnit(Unit un,long vehno,long vehid,Tpoint *)
{
C_Feature *veh;
long TextID;
VehicleClassDataType *vc;
long classID;
classID = un->GetVehicleID(vehno);
if (classID)
{
vc = GetVehicleClassData(classID);
veh=new C_Feature;
veh->Setup(un->GetCampID() << 16 | vehid,0);
veh->SetFlagBitOff(C_BIT_USEBGFILL);
veh->SetColor(0xc0c0c0,0x00ff00);
veh->InitEntity();
veh->SetName(25,0,vc->Name);
TextID=TXT_NO_DAMAGE;
veh->SetStatus(280,0,TextID);
TextID=TXT_VERYHIGH;
veh->SetValue(390,0,TextID);
veh->SetCallback(CenterOnFeatureCB);
veh->SetVUID(un->Id());
veh->SetFeatureID(vehno);
veh->SetFeatureValue(100);
return(veh);
}
return(NULL);
}
void AddUnitToTargetTree(Unit unit)
{
Tpoint objPos;
TREELIST *item,*parent;
C_Entity *recon_ent;
C_Feature *veh;
if(gGps->GetTeamNo() >= 0 && unit->GetTeam() != gGps->GetTeamNo())
if(!unit->GetSpotted(static_cast<uchar>(gGps->GetTeamNo())) && !unit->IsFlight())
return;
if(TargetTree)
{
SimInitDataClass simdata;
int v,vehs,motiontype,inslot,visType;
VehicleID classID;
VehicleClassDataType *vc;
// Check for possible problems
if (unit->IsFlight() && !unit->ShouldDeaggregate())
return;
// Now add all the vehicles
recon_ent=BuildUnitParent(unit);
if(recon_ent)
recon_ent->SetCallback(PickFirstChildCB);
parent=TargetTree->CreateItem(unit->GetCampID(),C_TYPE_MENU,recon_ent);
if(parent)
{
TargetTree->AddItem(TargetTree->GetRoot(),parent);
if(recon_ent)
recon_ent->SetOwner(parent);
}
simdata.vehicleInUnit = -1;
for (v=0; v<VEHICLES_PER_UNIT; v++)
{
vehs = unit->GetNumVehicles(v);
classID = unit->GetVehicleID(v);
inslot = 0;
while (vehs && classID)
{
vc = GetVehicleClassData(classID);
simdata.campUnit = unit;
simdata.campSlot = v;
simdata.inSlot = inslot;
simdata.descriptionIndex = classID + VU_LAST_ENTITY_TYPE;
simdata.flags = vc->Flags;
// Set the position initially to the unit's real position
simdata.x = unit->XPos();
simdata.y = unit->YPos();
simdata.z = unit->ZPos();
// Now query for any offsets
motiontype = unit->GetVehicleDeagData(&simdata,FALSE);
objPos.x = simdata.x;
objPos.y = simdata.y;
objPos.z = simdata.z;
visType = Falcon4ClassTable[classID].visType[VIS_NORMAL];
gUIViewer->LoadDrawableUnit(unit->GetCampID() << 16 | (v << 8) | (vehs+1),visType,&objPos,simdata.heading,Falcon4ClassTable[classID].vuClassData.classInfo_[VU_DOMAIN],Falcon4ClassTable[classID].vuClassData.classInfo_[VU_TYPE],Falcon4ClassTable[classID].vuClassData.classInfo_[VU_STYPE]);
veh=BuildUnit(unit,v,(v << 8) | vehs+1,&objPos);
if(veh)
{
item=TargetTree->CreateItem(unit->GetCampID() << 16 | (v << 8) | (vehs+1),C_TYPE_ITEM,veh);
if(item)
{
TargetTree->AddChildItem(parent,item);
veh->SetOwner(item);
}
}
vehs--;
inslot++;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -