📄 cmap.cpp
字号:
CurWP_->SetLineColor(0x40000000+campID+i,0x00ffffff,0x0000ffff,0x000000ff);
if(!(TheCampaign.Flags & CAMP_TACTICAL_EDIT))
{
if(firstwp != unit->GetCurrentUnitWP())
{
wpl->Icon->SetText(0,TXT_SPACE);
wpl->Icon->SetText(1,TXT_SPACE);
wpl->Icon->SetText(2,TXT_SPACE);
wpl->Icon->SetFlagBitOff(C_BIT_ENABLED);
}
}
wpl->Flags |= UseFlag;
}
}
// Set 2d Waypoint
if(UseFlag)
_stprintf(buf,"%1d",i);
else
{
if(wp->GetWPAction() == WP_LAND)
{
_sntprintf(buf,39,"%s",gStringMgr->GetString(TXT_ALTERNATE_FIELD));
buf[39] = 0;
}
else if(wp->GetWPAction() == WP_REFUEL)
{
_sntprintf(buf,39,"%s",gStringMgr->GetString(TXT_TANKER));
buf[39] = 0;
}
else
buf[0]=0;
}
if(buf[0])
{
if(airwps)
{
if(i == 1)
wpl=CurWP_->AddWaypointToList(campID+i,0,normID,selID,othrID,y,maxy-x,FALSE);
else
wpl=CurWP_->AddWaypointToList(campID+i,0,normID,selID,othrID,y,maxy-x,TRUE);
}
else
{
if(lastwp)
wpl=CurWP_->AddWaypointToList(campID+i,0,normID,selID,othrID,y,maxy-x,TRUE);
else
wpl=CurWP_->AddWaypointToList(campID+i,0,0,0,0,y,maxy-x,FALSE);
}
if(wpl)
{
CurWP_->SetWPGroup(campID+i,campID);
CurWP_->SetUserNumber(C_STATE_0, static_cast<long>(maxy));
if(airwps)
{
CurWP_->SetLabel(campID+i,gStringMgr->GetText(gStringMgr->AddText(buf)));
CurWP_->SetTextOffset(campID+i,0,-15);
}
CurWP_->SetState(campID+i,state);
CurWP_->SetLabelColor(campID+i,0x00ffffff,0x0000ffff,0x000000ff);
CurWP_->SetLineColor(campID+i,0x00ffffff,0x0000ffff,0x000000ff);
tmpID=new VU_ID;
*tmpID=unit->Id();
wpl->Flags |= UseFlag;
wpl->Icon->SetUserCleanupPtr(C_STATE_0,tmpID);
wpl->Icon->SetUserNumber(C_STATE_1,i);
}
// Set Z Waypoint
xval=(i-1)*(650 / numwp) + 60;
if (airwps)
{
if(wp->GetWPAction() == WP_LAND || wp->GetWPAction() == WP_TAKEOFF)
ZDrag=FALSE;
else
ZDrag=TRUE;
wpl=CurWPZ_->AddWaypointToList(static_cast<short>(campID+i),0,normID,selID,othrID,static_cast<float>(xval),z,static_cast<short>(ZDrag));
if(wpl)
{
CurWPZ_->SetWPGroup(campID+i,campID);
CurWPZ_->SetLabel(campID+i,gStringMgr->GetText(gStringMgr->AddText(buf)));
CurWPZ_->SetState(campID+i,state);
CurWPZ_->SetLabelColor(campID+i,0x00ffffff,0x0000ffff,0x000000ff);
CurWPZ_->SetLineColor(campID+i,0x00ffffff,0x0000ffff,0x000000ff);
CurWPZ_->SetTextOffset(campID+i,0,-15);
tmpID=new VU_ID;
*tmpID=unit->Id();
wpl->Flags |= UseFlag;
wpl->Icon->SetUserCleanupPtr(C_STATE_0,tmpID);
wpl->Icon->SetUserNumber(C_STATE_1,i);
if(!(TheCampaign.Flags & CAMP_TACTICAL_EDIT))
if(firstwp != unit->GetCurrentUnitWP())
wpl->Dragable=0;
}
}
dx=lx-x;
dy=ly-y;
dz=lz-z;
lx=x;
ly=y;
lz=z;
i++;
distance += sqrt(dx*dx + dy*dy + dz*dz);
if(wp->GetWPAction() == WP_LAND && UseFlag)
{
endtime=wp->GetWPArrivalTime();
UseFlag=0;
}
}
prevwp=wp;
wp=wp->GetNextWP();
}
if(airwps)
{
wp=((Flight)unit)->GetOverrideWP();
if(wp)
{
wp->GetLocation(&x,&y,&z); // Note: for Sim -> UI (UI's) X = (Sim's) Y, (UI's Y) = (Sim's) [max y] - X (UI's) Z = (Sim's) -Z
_sntprintf(buf,39,"%s",gStringMgr->GetString(TXT_DIVERT));
buf[39] = 0;
wpl=CurWP_->AddWaypointToList(campID+i,0,TGT_CUR,TGT_CUR_SEL,TGT_CUR_ERROR,y,maxy-x,FALSE);
if(wpl)
{
CurWP_->SetWPGroup(campID+i,campID);
CurWP_->SetUserNumber(C_STATE_0, static_cast<long>(maxy));
CurWP_->SetLabel(campID+i,gStringMgr->GetText(gStringMgr->AddText(buf)));
CurWP_->SetTextOffset(campID+i,0,-15);
CurWP_->SetState(campID+i,0);
CurWP_->SetLabelColor(campID+i,0x00ffffff,0x0000ffff,0x000000ff);
CurWP_->SetLineColor(campID+i,0x00ffffff,0x0000ffff,0x000000ff);
tmpID=new VU_ID;
*tmpID=unit->Id();
wpl->Icon->SetUserCleanupPtr(C_STATE_0,tmpID);
wpl->Icon->SetUserNumber(C_STATE_1,-1);
}
// Set Z Waypoint
xval=(i-1)*(650 / numwp) + 60;
wpl=CurWPZ_->AddWaypointToList(campID+i,0,TGT_CUR,TGT_CUR_SEL,TGT_CUR_ERROR,static_cast<float>(xval),z,FALSE);
if(wpl)
{
CurWPZ_->SetWPGroup(campID+i,campID);
CurWPZ_->SetUserNumber(C_STATE_0, static_cast<long>(maxy));
CurWPZ_->SetLabel(campID+i,gStringMgr->GetText(gStringMgr->AddText(buf)));
CurWPZ_->SetState(campID+i,0);
CurWPZ_->SetLabelColor(campID+i,0x00ffffff,0x0000ffff,0x000000ff);
CurWPZ_->SetLineColor(campID+i,0x00ffffff,0x0000ffff,0x000000ff);
CurWPZ_->SetTextOffset(campID+i,0,-15);
tmpID=new VU_ID;
*tmpID=unit->Id();
wpl->Icon->SetUserCleanupPtr(C_STATE_0,tmpID);
wpl->Icon->SetUserNumber(C_STATE_1,-1);
if(!(TheCampaign.Flags & CAMP_TACTICAL_EDIT))
if(firstwp != unit->GetCurrentUnitWP())
wpl->Dragable=0;
}
}
}
CurWPZ_->SetUserNumber(C_STATE_1,endtime - starttime);
CurWPZ_->SetUserNumber(C_STATE_2,(long)distance);
CurWPZ_->SetUserNumber(C_STATE_3,0 /* MPG */ );
}
void C_Map::AddToCurIcons(MAPICONLIST *MapItem)
{
if(MapItem)
CurIcons_->Add(MapItem);
}
void C_Map::CenterOnIcon(MAPICONLIST *MapItem)
{
if(MapItem)
{
//cx=(CurWPArea_.top/1640 + CurWPArea_.bottom/1640)/2;
//cy=((maxy - CurWPArea_.left)/1640 + (maxy - CurWPArea_.right)/1640)/2;
SetMapCenter(static_cast<long>(MapItem->worldx/FEET_PER_PIXEL),static_cast<long>(MapItem->worldy/FEET_PER_PIXEL));
if(DrawWindow_)
DrawWindow_->RefreshWindow();
}
}
void C_Map::BuildWPList(C_Waypoint *wplist,C_Waypoint *,Unit unit)
{
WayPoint wp=NULL;
float x,y,z;
long normID,selID,othrID;
long i;
long campID;
long UseFlag;
WAYPOINTLIST *wpl=NULL;
short state;
_TCHAR buf[20];
VU_ID *tmpID=NULL;
short airwps,lastwp;
if(unit == NULL) return;
if(!unit->Final()) return;
airwps=static_cast<short>(unit->IsFlight());
if (!airwps)
{
wp=unit->GetCurrentUnitWP();
if (wp && wp->GetPrevWP())
wp = wp->GetPrevWP();
}
if (!wp || airwps)
wp=unit->GetFirstUnitWP();
if (!wp) return;
campID=unit->GetCampID() << 8;
// set to 0 after Landing WP so we don't connect lines to following waypoints which are not on the agenda (Alt Land cit,Tanker etc)
UseFlag=C_BIT_USELINE;
i=1;
lastwp=0;
while(wp)
{
if(!wp->GetNextWP())
lastwp=1;
if(wp->GetWPFlags() & WPF_TARGET)
{
normID=TGT_OTR;
selID=TGT_OTR_SEL;
othrID=TGT_OTR_OTHER;
}
else if(wp->GetWPFlags() & WPF_IP)
{
normID=IP_OTR;
selID=IP_OTR_SEL;
othrID=IP_OTR_OTHER;
}
else
{
normID=STPT_OTR;
selID=STPT_OTR_SEL;
othrID=STPT_OTR_OTHER;
}
if (wp == unit->GetCurrentUnitWP())
state=1;
else
state=0;
wp->GetLocation(&x,&y,&z); // Note: for Sim -> UI (UI's) X = (Sim's) Y, (UI's Y) = (Sim's) [max y] - X (UI's) Z = (Sim's) -Z
// Set 2d Waypoint
if(UseFlag)
_stprintf(buf,"%1d",i);
else
{
if(wp->GetWPAction() == WP_LAND)
{
_sntprintf(buf,39,"%s",gStringMgr->GetString(TXT_ALTERNATE_FIELD));
buf[39] = 0;
}
else if(wp->GetWPAction() == WP_REFUEL)
{
_sntprintf(buf,39,_T("%s"),gStringMgr->GetString(TXT_TANKER));
buf[39] = 0;
}
else
buf[0]=0;
}
if(buf[0])
{
if(airwps)
{
if(i == 1)
wpl=wplist->AddWaypointToList(campID+i,0,normID,selID,othrID,y,maxy-x,FALSE);
else
wpl=wplist->AddWaypointToList(campID+i,0,normID,selID,othrID,y,maxy-x,FALSE);
}
else
{
if(lastwp)
wpl=wplist->AddWaypointToList(campID+i,0,normID,selID,othrID,y,maxy-x,FALSE);
else
wpl=wplist->AddWaypointToList(campID+i,0,0,0,0,y,maxy-x,FALSE);
}
if(wpl)
{
wplist->SetWPGroup(campID+i,campID);
wplist->SetLabelColor(campID+i,0,0x00500000,0);
wplist->SetLineColor(campID+i,0,0x00500000,0);
tmpID=new VU_ID;
*tmpID=unit->Id();
wpl->Flags |= UseFlag;
wpl->Icon->SetUserCleanupPtr(C_STATE_0,tmpID);
wpl->Icon->SetUserNumber(C_STATE_1,i);
}
}
i++;
wp=wp->GetNextWP();
}
}
BOOL C_Map::SetWaypointList(VU_ID unitID)
{
F4CSECTIONHANDLE *Leave=NULL;
Unit unit;
if(unitID == FalconNullId)
return(FALSE);
unit=(Unit)FindUnit(unitID);
if(unit == NULL) return(FALSE);
if(DrawWindow_)
Leave=UI_Enter(DrawWindow_);
Team_[unit->GetTeam()].Waypoints->EraseWaypointGroup(unit->GetCampID() << 8);
CampEnterCriticalSection();
BuildWPList(Team_[unit->GetTeam()].Waypoints,NULL,unit);
CampLeaveCriticalSection();
Team_[unit->GetTeam()].Waypoints->Refresh();
UI_Leave(Leave);
return(TRUE);
}
BOOL C_Map::SetCurrentWaypointList(VU_ID unitID)
{
F4CSECTIONHANDLE *Leave=NULL;
Unit unit;
if(CurWP_->Dragging()) return(FALSE);
if(CurWPZ_->Dragging()) return(FALSE);
CampEnterCriticalSection();
if(DrawWindow_)
Leave=UI_Enter(DrawWindow_);
CurWP_->Refresh();
CurWPZ_->Refresh();
CurWP_->EraseWaypointList();
CurWPZ_->EraseWaypointList();
CurWPArea_.top=-1;
CurWPArea_.left=-1;
CurWPArea_.bottom=-1;
CurWPArea_.right=-1;
WPUnitID_=unitID;
gActiveFlightID=unitID;
if(unitID == FalconNullId)
{
UI_Leave(Leave);
CampLeaveCriticalSection();
return(FALSE);
}
unit=(Unit)FindUnit(unitID);
if(unit == NULL)
{
UI_Leave(Leave);
CampLeaveCriticalSection();
return(FALSE);
}
BuildCurrentWPList(unit);
flags_ |= I_NEED_TO_DRAW;
UI_Leave(Leave);
CampLeaveCriticalSection();
return(TRUE);
}
void C_Map::UpdateWaypoint(Flight flt)
{
WayPoint wp;
WAYPOINTLIST *nub;
short i,check;
if(flt->Id() == WPUnitID_)
{
// We have to traverse all our waypoints to check for validity
if(flt->GetCurrentUnitWP() == flt->GetFirstUnitWP())
check=1;
else
check=0;
i=1;
wp=flt->GetFirstUnitWP();
while(wp)
{
if (!IsValidWP(wp,flt) && check)
{
CurWP_->SetState((flt->GetCampID() << 8)+i,2);
CurWP_->SetState(0x40000000|(flt->GetCampID() << 8)+i,2);
CurWPZ_->SetState((flt->GetCampID() << 8)+i,2);
}
else if (wp == flt->GetCurrentUnitWP())
{
CurWP_->SetState((flt->GetCampID() << 8)+i,1);
CurWP_->SetState(0x40000000|(flt->GetCampID() << 8)+i,1);
CurWPZ_->SetState((flt->GetCampID() << 8)+i,1);
}
else
{
CurWP_->SetState((flt->GetCampID() << 8)+i,0);
CurWP_->SetState(0x40000000|(flt->GetCampID() << 8)+i,0);
CurWPZ_->SetState((flt->GetCampID() << 8)+i,0);
}
i++;
wp=wp->GetNextWP();
}
if(!(TheCampaign.Flags & CAMP_TACTICAL_EDIT))
{
if(i > 1)
{
nub=CurWP_->GetRoot();
while(nub)
{
if(nub->ID & 0x40000000)
{
nub->Icon->SetText(0,TXT_SPACE);
nub->Icon->SetText(1,TXT_SPACE);
nub->Icon->SetText(2,TXT_SPACE);
nub->Icon->SetFlagBitOff(C_BIT_ENABLED);
}
nub=nub->Next;
}
CurWP_->SetFlagBitOff(C_BIT_DRAGABLE);
CurWPZ_->SetFlagBitOff(C_BIT_DRAGABLE);
}
}
CurWP_->Refresh();
CurWPZ_->Refresh();
}
else
{
i=1;
wp=flt->GetFirstUnitWP();
while(wp && wp != flt->GetCurrentUnitWP())
{
i++;
wp=wp->GetNextWP();
}
Team_[flt->GetTeam()].Waypoints->SetGroupState(flt->GetCampID() << 8,0);
Team_[flt->GetTeam()].Waypoints->SetState((flt->GetCampID() << 8)+i,1);
Team_[flt->GetTeam()].Waypoints->SetState(0x40000000|(flt->GetCampID() << 8)+i,1);
Team_[flt->GetTeam()].Waypoints->Refresh();
}
}
void C_Map::RemoveCurWPList()
{
CurWP_->Refresh();
CurWP_->EraseWaypointList();
CurWPZ_->Refresh();
CurWPZ_->EraseWaypointList();
CurIcons_->Cleanup();
CurIcons_->Setup(CurIcons_->GetID(),0);
WPUnitID_=FalconNullId;
}
void C_Map::RemoveWaypoints(short team,long group)
{
Team_[team].Waypoints->Refresh();
Team_[team].Waypoints->EraseWaypointGroup(group);
}
// this is called like every 5 or 10 seconds by a callback...
void C_Map::RemoveOldWaypoints()
{
Unit un;
// remove current set
if(WPUnitID_ != FalconNullId)
{
un=(Unit)vuDatabase->Find(WPUnitID_);
if(!un)
RemoveCurWPList();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -