📄 cmap.cpp
字号:
// go through the teams and remove old WP lists
}
void C_Map::RemoveAllWaypoints (short owner)
{
if ((DrawWindow_) && (Team_[owner].Waypoints))
Team_[owner].Waypoints->EraseWaypointList ();
}
void C_Map::RemoveFromCurIcons (long ID)
{
if (CurIcons_)
CurIcons_->Remove(ID);
}
void C_Map::SetBullsEye(float x,float y)
{
BullsEyeX_=x;
BullsEyeY_=y;
if(BullsEye_)
BullsEye_->SetPos(x,y); // Real World XY (where 0,0 is top left corner)
}
void C_Map::TurnOnBullseye()
{
if(BullsEye_)
{
BullsEye_->SetFlagBitOff(C_BIT_INVISIBLE);
if(DrawWindow_)
DrawWindow_->RefreshWindow();
}
}
void C_Map::TurnOffBullseye()
{
if(BullsEye_)
{
BullsEye_->SetFlagBitOn(C_BIT_INVISIBLE);
if(DrawWindow_)
DrawWindow_->RefreshWindow();
}
}
void C_Map::RemapTeamColors(long team)
{
short j,k;
if(team >= NUM_TEAMS)
return;
if(Team_[team].Objectives)
{
for(j=0;j<_MAP_NUM_OBJ_TYPES_;j++)
{
Team_[team].Objectives->Type[j]->SetMainImage(ObjIconIDs_[team][0],ObjIconIDs_[team][1]);
Team_[team].Objectives->Type[j]->RemapIconImages();
}
}
if(Team_[team].NavalUnits)
{
for(j=0;j<_MAP_NUM_NAV_TYPES_;j++)
{
Team_[team].NavalUnits->Type[j]->SetMainImage(NavyIconIDs_[team][0],NavyIconIDs_[team][1]);
Team_[team].NavalUnits->Type[j]->RemapIconImages();
}
}
if(Team_[team].Units)
{
for(j=0;j<_MAP_NUM_GND_TYPES_;j++)
{
for(k=0;k<_MAP_NUM_GND_LEVELS_;k++)
{
Team_[team].Units->Type[j]->Levels[k]->SetMainImage(ArmyIconIDs_[team][0],ArmyIconIDs_[team][1]);
Team_[team].Units->Type[j]->Levels[k]->RemapIconImages();
}
}
}
if(Team_[team].AirUnits)
{
for(j=0;j<_MAP_NUM_AIR_TYPES_;j++)
{
Team_[team].AirUnits->Type[j]->SetMainImage(C_STATE_0,AirIconIDs_[team][0][0],AirIconIDs_[team][0][1]);
Team_[team].AirUnits->Type[j]->SetMainImage(C_STATE_1,AirIconIDs_[team][1][0],AirIconIDs_[team][1][1]);
Team_[team].AirUnits->Type[j]->SetMainImage(C_STATE_2,AirIconIDs_[team][2][0],AirIconIDs_[team][2][1]);
Team_[team].AirUnits->Type[j]->SetMainImage(C_STATE_3,AirIconIDs_[team][3][0],AirIconIDs_[team][3][1]);
Team_[team].AirUnits->Type[j]->SetMainImage(C_STATE_4,AirIconIDs_[team][4][0],AirIconIDs_[team][4][1]);
Team_[team].AirUnits->Type[j]->SetMainImage(C_STATE_5,AirIconIDs_[team][5][0],AirIconIDs_[team][5][1]);
Team_[team].AirUnits->Type[j]->SetMainImage(C_STATE_6,AirIconIDs_[team][6][0],AirIconIDs_[team][6][1]);
Team_[team].AirUnits->Type[j]->SetMainImage(C_STATE_7,AirIconIDs_[team][7][0],AirIconIDs_[team][7][1]);
Team_[team].AirUnits->Type[j]->RemapIconImages();
}
}
}
void C_Map::FitFlightPlan()
{ // Based on CurWP_'s x & y (ie: CurWPArea_)
long cx,cy;
long w,h;
if(CurWPArea_.left < 0 || CurWPArea_.top < 0 || CurWPArea_.right < 0 || CurWPArea_.bottom < 0)
return;
w=(CurWPArea_.right - CurWPArea_.left) / 1000; // 1100 = ft -> 500m * 1.64 (allow for icons to fit on map also)
h=(CurWPArea_.bottom - CurWPArea_.top) / 1000;
if(w > h)
ZoomLevel_=w;
else
ZoomLevel_=h;
if(ZoomLevel_ < MaxZoomLevel_)
ZoomLevel_=MaxZoomLevel_;
if(ZoomLevel_ > MinZoomLevel_)
ZoomLevel_=MinZoomLevel_;
cx=(CurWPArea_.top/1640 + CurWPArea_.bottom/1640)/2;
cy=static_cast<long>(((maxy - CurWPArea_.left)/1640 + (maxy - CurWPArea_.right)/1640)/2);
SetMapCenter(cx,cy);
}
// Public
void C_Map::ShowObjectiveType(long mask)
{
short i,j;
F4CSECTIONHANDLE *Leave;
ObjectiveMask_ |= (1 << FindTypeIndex(mask,OBJ_TypeList,_MAP_NUM_OBJ_TYPES_));
Leave=UI_Enter(DrawWindow_);
for(i=0;i<_MAX_TEAMS_;i++)
if(Team_[i].Objectives)
{
for(j=0;j<_MAP_NUM_OBJ_TYPES_;j++)
if(!Team_[i].Objectives->Flags[j] && (ObjectiveMask_ & (1 << j)))
{
Team_[i].Objectives->Flags[j]=1;
Team_[i].Objectives->Type[j]->SetFlagBitOff(C_BIT_INVISIBLE);
Team_[i].Objectives->Type[j]->Refresh();
}
}
UI_Leave(Leave);
}
void C_Map::HideObjectiveType(long mask)
{
short i,j;
long offflag;
F4CSECTIONHANDLE *Leave;
offflag = (1 << FindTypeIndex(mask,OBJ_TypeList,_MAP_NUM_OBJ_TYPES_));
Leave=UI_Enter(DrawWindow_);
for(i=0;i<_MAX_TEAMS_;i++)
if(Team_[i].Objectives)
{
for(j=0;j<_MAP_NUM_OBJ_TYPES_;j++)
if(Team_[i].Objectives->Flags[j] && (offflag & (1 << j)))
{
Team_[i].Objectives->Type[j]->Refresh();
Team_[i].Objectives->Flags[j]=0;
Team_[i].Objectives->Type[j]->SetFlagBitOn(C_BIT_INVISIBLE);
}
}
UI_Leave(Leave);
ObjectiveMask_ &= ~offflag;
}
void C_Map::ShowUnitType(long mask)
{
short i,j,k;
F4CSECTIONHANDLE *Leave;
UnitMask_ |= (1 << FindTypeIndex(mask,GND_TypeList,_MAP_NUM_GND_TYPES_));
Leave=UI_Enter(DrawWindow_);
for(i=0;i<_MAX_TEAMS_;i++)
if(Team_[i].Units)
{
for(j=0;j<_MAP_NUM_GND_TYPES_;j++)
{
if(!Team_[i].Units->Flags[j] && (UnitMask_ & (1 << j)))
{
Team_[i].Units->Flags[j]=1;
for(k=0;k<_MAP_NUM_GND_LEVELS_;k++)
{
if(Team_[i].Units->Type[j]->Flags[k] == 1)
{
Team_[i].Units->Type[j]->Levels[k]->SetFlagBitOff(C_BIT_INVISIBLE);
Team_[i].Units->Type[j]->Levels[k]->Refresh();
}
}
}
}
}
UI_Leave(Leave);
}
void C_Map::HideUnitType(long mask)
{
short i,j,k;
long offflag;
F4CSECTIONHANDLE *Leave;
offflag = (1 << FindTypeIndex(mask,GND_TypeList,_MAP_NUM_GND_TYPES_));
Leave=UI_Enter(DrawWindow_);
for(i=0;i<_MAX_TEAMS_;i++)
if(Team_[i].Units)
{
for(j=0;j<_MAP_NUM_GND_TYPES_;j++)
{
if(Team_[i].Units->Flags[j] && (offflag & (1 << j)))
{
Team_[i].Units->Flags[j]=0;
for(k=0;k<_MAP_NUM_GND_LEVELS_;k++)
{
if(Team_[i].Units->Type[j]->Flags[k] == 1)
{
Team_[i].Units->Type[j]->Levels[k]->Refresh();
Team_[i].Units->Type[j]->Levels[k]->SetFlagBitOn(C_BIT_INVISIBLE);
}
}
}
}
}
UI_Leave(Leave);
UnitMask_ &= ~offflag;
}
void C_Map::SetUnitLevel(long level)
{
short i,j;
F4CSECTIONHANDLE *Leave;
Leave=UI_Enter(DrawWindow_);
for(i=0;i<_MAX_TEAMS_;i++)
if(Team_[i].Units)
{
for(j=0;j<_MAP_NUM_GND_TYPES_;j++)
if(Team_[i].Units->Type[j])
{
if(level >= 0 && level < _MAP_NUM_GND_LEVELS_)
{
Team_[i].Units->Type[j]->Flags[0]=0;
if(level)
Team_[i].Units->Type[j]->Levels[0]->Refresh();
Team_[i].Units->Type[j]->Levels[0]->SetFlagBitOn(C_BIT_INVISIBLE);
Team_[i].Units->Type[j]->Flags[1]=0;
if(level != 1)
Team_[i].Units->Type[j]->Levels[1]->Refresh();
Team_[i].Units->Type[j]->Levels[1]->SetFlagBitOn(C_BIT_INVISIBLE);
Team_[i].Units->Type[j]->Flags[2]=0;
if(level != 2)
Team_[i].Units->Type[j]->Levels[2]->Refresh();
Team_[i].Units->Type[j]->Levels[2]->SetFlagBitOn(C_BIT_INVISIBLE);
Team_[i].Units->Type[j]->Flags[level]=1;
if(Team_[i].Units->Flags[j])
{
Team_[i].Units->Type[j]->Levels[level]->SetFlagBitOff(C_BIT_INVISIBLE);
Team_[i].Units->Type[j]->Levels[level]->Refresh();
}
}
}
}
UI_Leave(Leave);
}
void C_Map::ShowAirUnitType(long mask)
{
short i,j;
F4CSECTIONHANDLE *Leave;
AirUnitMask_ |= (1 << FindTypeIndex(mask,AIR_TypeList,_MAP_NUM_AIR_TYPES_));
Leave=UI_Enter(DrawWindow_);
for(i=0;i<_MAX_TEAMS_;i++)
if(Team_[i].AirUnits)
{
for(j=0;j<_MAP_NUM_AIR_TYPES_;j++)
if(!Team_[i].AirUnits->Flags[j] && (AirUnitMask_ & (1 << j)))
{
Team_[i].AirUnits->Flags[j]=1;
Team_[i].AirUnits->Type[j]->SetFlagBitOff(C_BIT_INVISIBLE);
Team_[i].AirUnits->Type[j]->Refresh();
}
}
UI_Leave(Leave);
}
void C_Map::HideAirUnitType(long mask)
{
short i,j;
long offflag;
F4CSECTIONHANDLE *Leave;
offflag = (1 << FindTypeIndex(mask,AIR_TypeList,_MAP_NUM_AIR_TYPES_));
Leave=UI_Enter(DrawWindow_);
for(i=0;i<_MAX_TEAMS_;i++)
if(Team_[i].AirUnits)
{
for(j=0;j<_MAP_NUM_AIR_TYPES_;j++)
if(Team_[i].AirUnits->Flags[j] && (offflag & (1 << j)))
{
Team_[i].AirUnits->Type[j]->Refresh();
Team_[i].AirUnits->Flags[j]=0;
Team_[i].AirUnits->Type[j]->SetFlagBitOn(C_BIT_INVISIBLE);
}
}
UI_Leave(Leave);
AirUnitMask_ &= ~offflag;
}
void C_Map::ShowNavalUnitType(long mask)
{
short i,j;
F4CSECTIONHANDLE *Leave;
NavalUnitMask_ |= (1 << FindTypeIndex(mask,NAV_TypeList,_MAP_NUM_NAV_TYPES_));
Leave=UI_Enter(DrawWindow_);
for(i=0;i<_MAX_TEAMS_;i++)
if(Team_[i].NavalUnits)
{
for(j=0;j<_MAP_NUM_NAV_TYPES_;j++)
if(!Team_[i].NavalUnits->Flags[j] && (NavalUnitMask_ & (1 << j)))
{
Team_[i].NavalUnits->Flags[j]=1;
Team_[i].NavalUnits->Type[j]->SetFlagBitOff(C_BIT_INVISIBLE);
Team_[i].NavalUnits->Type[j]->Refresh();
}
}
UI_Leave(Leave);
}
void C_Map::HideNavalUnitType(long mask)
{
short i,j;
long offflag;
F4CSECTIONHANDLE *Leave;
offflag = (1 << FindTypeIndex(mask,NAV_TypeList,_MAP_NUM_NAV_TYPES_));
Leave=UI_Enter(DrawWindow_);
for(i=0;i<_MAX_TEAMS_;i++)
if(Team_[i].NavalUnits)
{
for(j=0;j<_MAP_NUM_NAV_TYPES_;j++)
if(Team_[i].NavalUnits->Flags[j] && (offflag & (1 << j)))
{
Team_[i].NavalUnits->Type[j]->Refresh();
Team_[i].NavalUnits->Flags[j]=0;
Team_[i].NavalUnits->Type[j]->SetFlagBitOn(C_BIT_INVISIBLE);
}
}
UI_Leave(Leave);
NavalUnitMask_ &= ~offflag;
}
void C_Map::ShowThreatType(long mask)
{
short i,j;
long timestamp;
F4CSECTIONHANDLE *Leave;
ThreatMask_ = (1 << FindTypeIndex(mask,THR_TypeList,_MAP_NUM_THREAT_TYPES_));
timestamp=GetCurrentTime();
MonoPrint("Start at %1ld...",timestamp);
Leave=UI_Enter(DrawWindow_);
for(i=0;i<_MAX_TEAMS_;i++)
if(Team_[i].Threats)
{
for(j=0;j<_MAP_NUM_THREAT_TYPES_;j++)
if(!Team_[i].Threats->Flags[j] && (ThreatMask_ & (1 << j)))
{
Team_[i].Threats->Flags[j]=1;
Team_[i].Threats->Type[j]->SetFlagBitOff(C_BIT_INVISIBLE);
Team_[i].Threats->Type[j]->Refresh();
}
}
if(ThreatMask_ & _THR_SAM_LOW)
{
Map_->PreparePalette(0x0000ff);
Map_->ClearOverlay();
for(i=0;i<_MAX_TEAMS_;i++)
if(Team_[i].Threats)
{
if(Team_[i].Threats->Flags[_THREAT_SAM_LOW_])
{
Team_[i].Threats->Type[_THREAT_SAM_LOW_]->BuildOverlay(Map_->GetOverlay(),Map_->GetW(),Map_->GetH(),2);
}
}
Map_->UseOverlay();
}
else if(ThreatMask_ & _THR_SAM_HIGH)
{
Map_->PreparePalette(0x00ffff);
Map_->ClearOverlay();
for(i=0;i<_MAX_TEAMS_;i++)
if(Team_[i].Threats)
{
if(Team_[i].Threats->Flags[_THREAT_SAM_HIGH_])
{
Team_[i].Threats->Type[_THREAT_SAM_HIGH_]->BuildOverlay(Map_->GetOverlay(),Map_->GetW(),Map_->GetH(),2);
}
}
Map_->UseOverlay();
}
else if(ThreatMask_ & _THR_RADAR_LOW)
{
Map_->PreparePalette(0xffff00);
Map_->ClearOverlay();
for(i=0;i<_MAX_TEAMS_;i++)
if(Team_[i].Threats)
{
if(Team_[i].Threats->Flags[_THREAT_RADAR_LOW_])
{
Team_[i].Threats->Type[_THREAT_RADAR_LOW_]->BuildOverlay(Map_->GetOverlay(),Map_->GetW(),Map_->GetH(),2);
}
}
Map_->UseOverlay();
}
else if(ThreatMask_ & _THR_RADAR_HIGH)
{
Map_->PreparePalette(0xff0000);
Map_->ClearOverlay();
for(i=0;i<_MAX_TEAMS_;i++)
if(Team_[i].Threats)
{
if(Team_[i].Threats->Flags[_THREAT_RADAR_HIGH_])
{
Team_[i].Threats->Type[_THREAT_RADAR_HIGH_]->BuildOverlay(Map_->GetOverlay(),Map_->GetW(),Map_->GetH(),2);
}
}
Map_->UseOverlay();
}
timestamp=GetCurrentTime() - timestamp;
MonoPrint("Total time=%1ld\n",timestamp);
#if 0
Circles_=ThreatMask_;
for(i=0;i<_MAX_TEAMS_;i++)
for(j=0;j<_MAP_NUM_GND_TYPES_;j++)
Team_[i].Units->Type[j]->Levels[2]->ShowCircles(Circles_);
#endif
flags_ |= I_NEED_TO_DRAW_MAP;
UI_Leave(Leave);
}
void C_Map::HideThreatType(long mask)
{
short i,j;
long offflag;
F4CSECTIONHANDLE *Leave;
offflag = (1 << FindTypeIndex(mask,THR_TypeList,_MAP_NUM_THREAT_TYPES_));
Leave=UI_Enter(DrawWindow_);
for(i=0;i<_MAX_TEAMS_;i++)
if(Team_[i].Threats)
{
for(j=0;j<_MAP_NUM_THREAT_TYPES_;j++)
if(Team_[i].Threats->Flags[j] && (offflag & (1 << j)))
{
Team_[i].Threats->Type[j]->Refresh();
Team_[i].Threats->Flags[j]=0;
Team_[i].Threats->Type[j]->SetFlagBitOn(C_BIT_INVISIBLE);
}
}
ThreatMask_ &= ~offflag;
Map_->NoOverlay();
#if 0
Circles_=ThreatMask_;
for(i=0;i<_MAX_TEAMS_;i++)
for(j=0;j<_MAP_NUM_GND_TYPES_;j++)
Team_[i].Units->Type[j]->Levels[2]->ShowCircles(Circles_);
#endif
flags_ |= I_NEED_TO_DRAW_MAP;
UI_Leave(Leave);
}
void C_Map::SetMapImage(long ID)
{
MapID=ID;
if(Map_ == NULL)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -