📄 te_units.cpp
字号:
gLastEquipment = 0;
PickTeamColors();
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
void tactical_show_ato_window (void)
{
gGps->SetAllowed(gGps->GetAllowed() | UR_ATO | UR_SQUADRON);
gGps->Update();
gMainHandler->EnableWindowGroup (7001);
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
void tactical_show_oob_window (void)
{
gGps->SetAllowed(gGps->GetAllowed() | UR_OOB);
gMainHandler->EnableWindowGroup (7009);
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
void tactical_new_flight_select(long,short hittype,C_Base *control)
{
C_TreeList *tree;
TREELIST *item;
if(hittype != C_TYPE_LMOUSEUP)
return;
if(!control)
return;
tree=(C_TreeList*)control;
item=tree->GetLastItem();
tree->SetAllControlStates(0,tree->GetRoot());
if(item && item->Item_)
{
item->Item_->SetState(1);
gNewSelectFlight=((C_ATO_Flight*)item->Item_)->GetVUID();
}
tree->Refresh();
}
void FillListBoxWithSquadrons(C_ListBox *lbox,long team,long aircraft_dindex)
{
VU_ID id=FalconNullId;
_TCHAR buffer[50];
VuListIterator iter(AllAirList);
CampEntity entity,sq=NULL;
short count=0;
if(TheCampaign.Flags & CAMP_TACTICAL_EDIT)
{
// Add the new item
lbox->AddItem(1,C_TYPE_ITEM,TXT_NEW);
lbox->SetValue(1);
}
// Add the squadrons
entity=GetFirstEntity(&iter);
while(entity)
{
if(entity->IsSquadron())
{
if(entity->GetTeam() == team && entity->GetSType() == Falcon4ClassTable[aircraft_dindex].vuClassData.classInfo_[VU_STYPE] && entity->GetSPType() == Falcon4ClassTable[aircraft_dindex].vuClassData.classInfo_[VU_SPTYPE])
{
entity->GetName(buffer,40,FALSE);
lbox->AddItem(entity->GetCampID(),C_TYPE_ITEM,buffer);
if(!count)
{
lbox->SetValue(entity->GetCampID());
sq = entity;
}
count++;
}
}
entity=GetNextEntity(&iter);
}
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Squadron Stuff
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
void tac_select_squadron_aircraft (long,short hittype,C_Base *control)
{
C_Window *win;
if(hittype != C_TYPE_SELECT)
return;
win=gMainHandler->FindWindow(NEW_SQUAD_WIN);
if (!win)
return;
gLastAircraftType = ((C_ListBox*)control)->GetTextID();
}
void tac_select_squadron_airbase (long,short hittype,C_Base *control)
{
C_Window *win;
CampBaseClass* airbase;
if(hittype != C_TYPE_SELECT)
return;
win=gMainHandler->FindWindow(NEW_SQUAD_WIN);
if (!win)
return;
airbase = GetEntityByCampID(((C_ListBox*)control)->GetTextID());
if (airbase && airbase->IsObjective() && airbase->GetType() == TYPE_AIRBASE)
{
gLastAirbaseID = airbase->Id();
gLastAirbase = airbase->GetCampID();
}
}
SquadronClass* tactical_make_squadron (VU_ID id, long ac_type)
{
GridIndex x,y;
CampBaseClass* airbase;
Squadron new_squadron;
airbase = (CampBaseClass*) FindEntity(id);
if (!airbase || !airbase->IsObjective() || airbase->GetType() != TYPE_AIRBASE)
// KCK: Should probably just pick one
return NULL;
gLastAirbaseID = airbase->Id();
gLastAirbase = airbase->GetCampID();
new_squadron = NewSquadron(ac_type);
new_squadron->SetOwner(airbase->GetOwner());
new_squadron->SetUnitAirbase(airbase->Id());
new_squadron->BuildElements();
airbase->GetLocation(&x,&y);
new_squadron->SetLocation(x,y);
vuDatabase->QuickInsert (new_squadron);
return new_squadron;
}
// This is called when we want to create a new squadron (ID is the ID of the airbase)
void tactical_add_squadron (VU_ID id)
{
C_ListBox *lbox;
C_Window *win;
CampBaseClass* airbase;
win = gMainHandler->FindWindow(NEW_SQUAD_WIN);
if (!win)
return;
airbase = (CampBaseClass*) FindEntity(id);
if (!airbase || !airbase->IsObjective() || airbase->GetType() != TYPE_AIRBASE)
// KCK: Should probably just pick one
return;
lbox=(C_ListBox*)win->FindControl(TAC_AIRCRAFT_TYPE);
if(lbox)
{
lbox->RemoveAllItems();
FillListBoxWithACTypes(lbox);
lbox->SetValue(gLastAircraftType);
}
// Setup the airbase list box
gLastAirbaseID = airbase->Id();
gLastAirbase = airbase->GetCampID();
lbox=(C_ListBox*)win->FindControl(TAC_AIRBASE_LIST);
if(lbox)
{
VuListIterator ait(AllObjList);
Objective o;
_TCHAR name[80];
lbox->RemoveAllItems();
o = (Objective) ait.GetFirst();
while (o)
{
if (o->GetType() == TYPE_AIRBASE && GetRoE(gSelectedTeam,o->GetTeam(),ROE_AIR_USE_BASES) == ROE_ALLOWED)
{
// Add airbase name to listbox
o->GetName(name,79,TRUE);
lbox->AddItem(o->GetCampID(),C_TYPE_ITEM,name);
if (!gLastAirbase)
gLastAirbase = o->GetCampID();
if (o->GetCampID() == gLastAirbase)
lbox->SetValue(gLastAirbase);
}
o = (Objective) ait.GetNext();
}
lbox->Refresh();
}
gMainHandler->EnableWindowGroup (31000);
}
void tactical_create_squadron (long, short hittype, C_Base *)
{
int tid;
Squadron squadron;
C_PopupList *menu;
if (hittype != C_TYPE_LMOUSEUP)
return;
gMainHandler->DisableWindowGroup (31000);
tid = gLastAircraftType-VU_LAST_ENTITY_TYPE;
if (tid < 0)
tid = GetClassID (DOMAIN_AIR, CLASS_UNIT, TYPE_SQUADRON, STYPE_UNIT_FIGHTER_BOMBER, SPTYPE_F16C,0,0,0);
if (!tid)
return;
squadron = tactical_make_squadron(gLastAirbaseID, tid+VU_LAST_ENTITY_TYPE);
if (!squadron)
return;
menu=gPopupMgr->GetMenu(MAP_POP);
if (!menu)
return;
// Make sure we can see this squadron
menu->SetItemState(MID_UNITS_SQUAD_SQUADRON,1);
MenuToggleUnitCB(MID_UNITS_SQUAD_SQUADRON,0,menu);
display_air_units(squadron);
gGps->Update();
}
void tactical_cancel_squadron (long, short hittype, C_Base *)
{
if (hittype != C_TYPE_LMOUSEUP)
return;
gMainHandler->DisableWindowGroup (31000);
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Package Stuff
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
void LockTakeoffTimeCB (long,short hittype,C_Base *)
{
C_Button *btn;
C_Window *win;
if(hittype != C_TYPE_LMOUSEUP)
return;
win=gMainHandler->FindWindow(PACKAGE_WIN);
if(win)
{
btn = (C_Button*)win->FindControl(PAK_TAKEOFF_LOCK);
if (btn && btn->GetState() == 1)
{
// Clear lock on TOT, if any
btn = (C_Button*)win->FindControl(PAK_TOT_LOCK);
if (btn)
{
btn->SetState(0);
btn->Refresh();
}
}
else
{
btn = (C_Button*)win->FindControl(PAK_TOT_LOCK);
if (btn)
{
btn->SetState(1);
btn->Refresh();
}
}
}
}
void LockTimeOnTargetCB (long,short hittype,C_Base *)
{
C_Button *btn;
C_Window *win;
if(hittype != C_TYPE_LMOUSEUP)
return;
win=gMainHandler->FindWindow(PACKAGE_WIN);
if(win)
{
btn = (C_Button*)win->FindControl(PAK_TOT_LOCK);
if (btn && btn->GetState() == 1)
{
// Clear lock on TOT, if any
btn = (C_Button*)win->FindControl(PAK_TAKEOFF_LOCK);
if (btn)
{
btn->SetState(0);
btn->Refresh();
}
}
else
{
btn = (C_Button*)win->FindControl(PAK_TAKEOFF_LOCK);
if (btn)
{
btn->SetState(1);
btn->Refresh();
}
}
}
}
void ChangePackTimeCB(long ID,short hittype,C_Base *control)
{
ChangeTimeCB(ID,hittype,control);
if(hittype == C_TYPE_LMOUSEUP)
tactical_update_package();
}
void tactical_update_package (void)
{
C_Window *win;
C_ListBox *lbox;
C_Text *text;
C_EditBox *edit;
C_Button *btn;
C_Clock *clock;
Unit element = NULL;
int start_day = 0;
if (new_package)
element = new_package->GetFirstUnitElement();
win=gMainHandler->FindWindow(PACKAGE_WIN);
if(win)
{
text=(C_Text *)win->FindControl(PACKAGE_TARGET);
if (text)
{
_TCHAR buffer[80] = {0};
if (new_package_target)
{
if (new_package_target->IsFlight())
GetCallsign (((Flight)new_package_target)->callsign_id, ((Flight)new_package_target)->callsign_num, buffer);
else
new_package_target->GetName(buffer,79,FALSE);
}
else
{
// KCK: Need to figure out where we clicked
AddLocationToBuffer ('n', MapX, MapY, buffer);
}
text->SetText(buffer);
text->Refresh();
}
// Set Package Type listbox
lbox=(C_ListBox *)win->FindControl(TAC_PACKAGE_TYPE);
if(lbox)
{
if (element)
lbox->SetValue(MissionToATOMiss(element->GetUnitMission()));
else
lbox->SetValue(ATO_OTHER);
lbox->Refresh();
}
lbox=(C_ListBox *)win->FindControl(PACKAGE_PRIORITY_LIST);
if (lbox)
{
gPackagePriority = lbox->GetTextID();
switch(gPackagePriority)
{
case 1:
gPackagePriority = 255;
break;
case 2:
gPackagePriority = 175;
break;
case 3:
gPackagePriority = 125;
break;
case 4:
gPackagePriority = 75;
break;
case 5:
gPackagePriority = 5;
break;
default:
gPackagePriority = 0;
break;
}
}
edit = (C_EditBox*)win->FindControl(PACKAGE_DAY);
if (edit)
start_day = edit->GetInteger() - 1;
if (start_day < 0)
start_day = 0;
gTakeoffTime = gPackageTOT = 0;
btn = (C_Button*)win->FindControl(PAK_TOT_LOCK);
if (btn && btn->GetState() == 1)
{
// Get our _locked_ time on target
clock=(C_Clock*)win->FindControl(PAK_TOT_TIME);
if (clock)
{
int hr,mn,se;
hr = clock->GetHour();
mn = clock->GetMinute();
se = clock->GetSecond();
gPackageTOT = start_day * CampaignDay + hr * CampaignHours + mn * CampaignMinutes + se * CampaignSeconds;
// KCK: We should make sure the package times are all set to this
// (in case the user changed this control after creating the flights)
SetPackageTimes(new_package,0,gPackageTOT);
}
}
btn = (C_Button*)win->FindControl(PAK_TAKEOFF_LOCK);
if (btn && btn->GetState() == 1 && !gPackageTOT)
{
// Get our _locked_ takeoff time
clock=(C_Clock*)win->FindControl(PAK_TAKEOFF_TIME);
if (clock)
{
int hr,mn,se;
hr = clock->GetHour();
mn = clock->GetMinute();
se = clock->GetSecond();
gTakeoffTime = start_day * CampaignDay + hr * CampaignHours + mn * CampaignMinutes + se * CampaignSeconds;
// Check for bad takeoff time in running mode
if(!(TheCampaign.Flags & CAMP_TACTICAL_EDIT) && gTakeoffTime < TheCampaign.CurrentTime)
{
gTakeoffTime = TheCampaign.CurrentTime + CampaignSeconds;
hr = gTakeoffTime / CampaignHours;
hr = hr % 24;
mn = (gTakeoffTime / CampaignMinutes) % 60;
se = (gTakeoffTime / CampaignSeconds) % 60;
clock->SetHour(hr);
clock->SetMinute(mn);
clock->SetSecond(se);
clock->Refresh ();
}
// KCK: We should make sure the package times are all set to this
// (in case the user changed this control after creating the flights)
SetPackageTimes(new_package,gTakeoffTime,0);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -