📄 campaign.cpp
字号:
gMainHandler->HideWindow(win);
AreYouSure(TXT_FLIGHT_CANCELED,TXT_YOUR_FLIGHT_CANCELED,CloseWindowCB,CloseWindowCB);
}
void UI_HandleFlightScrub()
{
C_Window *win;
SetTimeCompression(1);
UpdateRemoteCompression();
win=gMainHandler->FindWindow(CP_COUNTDOWN_WIN);
if(win)
gMainHandler->HideWindow(win);
AreYouSure(TXT_FLIGHT_CANCELED,TXT_THIS_FLIGHT_SCRUBBED,CloseWindowCB,CloseWindowCB);
}
void UI_HandleAircraftDestroyed()
{
C_Window *win;
SetTimeCompression(1);
UpdateRemoteCompression();
win=gMainHandler->FindWindow(CP_COUNTDOWN_WIN);
if(win)
gMainHandler->HideWindow(win);
AreYouSure(TXT_AC_DESTROYED,TXT_YOUR_AC_DESTROYED,CloseWindowCB,CloseWindowCB);
}
// All this really does is notify the player of an impending attack.
// Scramble_Intercept_CB() is the accept callback
// Cancel_Scramble_CB() is the cancel callback
void UIScramblePlayerFlight(void)
{
C_Window *win;
if(!gMainHandler)
return;
gSoundMgr->PlaySound(500017); // Airraid sound?
CampEnterCriticalSection();
if (gCompressTillTime)
{
gOldCompressTillTime = gCompressTillTime;
gOldCompressionRatio = 0xffffffff;//-1;
gCompressTillTime = 0;
}
else
{
gOldCompressTillTime = 0;
gOldCompressionRatio = targetCompressionRatio;
}
SetTimeCompression(1);
UpdateRemoteCompression();
CampLeaveCriticalSection();
win=gMainHandler->FindWindow(SCRAMBLE_WIN);
if(win)
{
gMainHandler->ShowWindow(win);
gMainHandler->WindowToFront(win);
gSoundMgr->PlaySound(CSM1);
gAWWTimeout = 60000; // 60 second timeout period
gMainHandler->EnterCritical();
gMainHandler->AddUserCallback(CloseAWWWindowTimer);
gMainHandler->LeaveCritical();
}
}
// This just closes the SCRAMBLE_WIN and resets compression to what we had previously
// PETER TODO: The close window 'X' should call this as well but currently doesn't.
void Cancel_Scramble_CB(long, short hittype, C_Base *)
{
C_Window *win;
if(hittype != C_TYPE_LMOUSEUP || gOldCompressionRatio < 0)
return;
win=gMainHandler->FindWindow(SCRAMBLE_WIN);
if(win)
gMainHandler->HideWindow(win);
gMainHandler->EnterCritical();
gMainHandler->RemoveUserCallback(CloseAWWWindowTimer);
gMainHandler->LeaveCritical();
if (gOldCompressTillTime)
{
gCompressTillTime = gOldCompressTillTime;
gOldCompressTillTime = 0;
}
else
{
SetTimeCompression(gOldCompressionRatio);
UpdateRemoteCompression();
gOldCompressionRatio = 0xffffffff;//-1;
}
}
// KCK: This should attempt to pick one of the interceptor aircraft in addition to
// closing the box and resetting the previous compression ratio (done in Cancel_Scramble)
void Scramble_Intercept_CB(long ID,short hittype,C_Base *control)
{
C_Window *win;
Flight flight = (Flight)vuDatabase->Find(gInterceptersId);
if(hittype != C_TYPE_LMOUSEUP)
return;
// Try to find the correct list item
if (flight)
{
UI_Refresher *urec;
urec = FindMissionItem(flight);
if (urec)
{
// Update this item
// if(urec->Mission_)
// urec->RemoveMission();
// urec->AddMission(flight);
//... renumber... or set final
RequestACSlot(flight, 0, static_cast<uchar>(flight->GetAdjustedAircraftSlot(0)), 0, 0, 1);
gCurrentFlightID=gInterceptersId;
UpdateMissionWindow(CB_MISSION_SCREEN);
// Close the waiting screen, if we're there.
win=gMainHandler->FindWindow(CP_COUNTDOWN_WIN);
if(win)
gMainHandler->HideWindow(win);
gOldCompressionRatio = 1;
}
}
Cancel_Scramble_CB(ID,hittype,control);
}
void UI_AddMovieToList(long ID,long timestamp,_TCHAR *Description)
{
if(MovieCount < MOVIE_Q_SIZE)
{
MovieQTime[MovieCount]=timestamp;
MovieQ[MovieCount]=ID;
_tcsnccpy(MovieQDesc[MovieCount],Description,79);
MovieQDesc[MovieCount][79];
MovieCount++;
}
if(gMainHandler && ReadyToPlayMovie)
StartMovieQ();
}
void UI_UpdateOccupationMap()
{
if(gOccupationMap && gMainHandler)
{
C_Window *win;
C_Bitmap *bmp;
MakeOccupationMap(gOccupationMap);
win=gMainHandler->FindWindow(CP_SUA);
if(win)
{
bmp=(C_Bitmap*)win->FindControl(CP_SUA);
if(bmp)
bmp->Refresh();
}
win=gMainHandler->FindWindow(TAC_MISSION_SUA);
if(win)
{
bmp=(C_Bitmap*)win->FindControl(TAC_OVERLAY);
if(bmp)
bmp->Refresh();
}
}
}
void AircraftLaunch(Flight f)
{
if(f && gMainHandler && FalconLocalSession->GetPlayerSquadronID())
{
if(f->GetUnitSquadronID() == FalconLocalSession->GetPlayerSquadronID())
CampEventSoundID=SND_TAKEOFF;
}
}
void PlayAmbientSound()
{
}
void SetupMover (C_Window *win, long MoverMenu, void (*callback) (long ID,short hittype,C_Base *control))
{
C_MapMover *mover;
mover=(C_MapMover *)win->FindControl(MAP_MOVER);
if(mover)
{
mover->SetXYWH(win->ClientArea_[mover->GetClient()].left,win->ClientArea_[mover->GetClient()].top,win->ClientArea_[mover->GetClient()].right-win->ClientArea_[mover->GetClient()].left,win->ClientArea_[mover->GetClient()].bottom-win->ClientArea_[mover->GetClient()].top);
mover->SetDrawCallback(MapMgrDrawCB);
mover->SetFlagBitOn(C_BIT_ABSOLUTE);
mover->SetCallback(callback);
mover->SetMenu(MoverMenu);
}
else
{
mover=new C_MapMover;
mover->Setup(MAP_MOVER,0);
mover->SetXYWH(win->ClientArea_[mover->GetClient()].left,win->ClientArea_[mover->GetClient()].top,win->ClientArea_[mover->GetClient()].right-win->ClientArea_[mover->GetClient()].left,win->ClientArea_[mover->GetClient()].bottom-win->ClientArea_[mover->GetClient()].top);
mover->SetDrawCallback(MapMgrDrawCB);
mover->SetFlagBitOn(C_BIT_ABSOLUTE);
mover->SetCallback(callback);
mover->SetMenu(MoverMenu);
win->AddControl(mover);
}
}
void SetupMapMgr()
{
long i,j,idx;
C_Window *win;
if(!gMapMgr)
{
gMapMgr=new C_Map;
gMapMgr->SetMapCenter(1536/2,2048/2);
gMapMgr->SetMapImage(BIG_MAP_ID);
gMapMgr->SetZoomLevel(1);
gMapMgr->SetTeamFlags(0,_MAP_OBJECTIVES_|_MAP_UNITS_);
gMapMgr->SetLogRanges(0.0f,0.0f,740.0f,70.0f);
gMapMgr->SetStrtRanges(0.0f,0.0f,740.0f,1000.0f);
// Set Icon Image IDs (Really the C_Resmgr ID)
for(i=0;i<NUM_TEAMS;i++)
{
if(TeamInfo[i] && (TeamInfo[i]->flags & TEAM_ACTIVE))
idx=TeamInfo[i]->GetColor();
else
idx=0;
for(j=0;j<8;j++)
{
gMapMgr->SetAirIcons(i,j,TeamFlightColorIconIDs[idx][j][0],TeamFlightColorIconIDs[idx][j][1]);
}
gMapMgr->SetArmyIcons(i,TeamColorIconIDs[idx][0],TeamColorIconIDs[idx][1]);
gMapMgr->SetNavyIcons(i,TeamColorIconIDs[idx][0],TeamColorIconIDs[idx][1]);
gMapMgr->SetObjectiveIcons(i,TeamColorIconIDs[idx][0],TeamColorIconIDs[idx][1]);
}
}
if(TheCampaign.Flags & CAMP_TACTICAL_EDIT)
win=gMainHandler->FindWindow(MB_CSECT_WIN);
else
win=gMainHandler->FindWindow(CSECT_WIN);
gMapMgr->SetWPZWindow(win);
}
void SetupGPS(C_TreeList *MissionTree)
{
if(!gGps)
{
gGps=new GlobalPositioningSystem;
gGps->Setup();
}
gGps->SetMap(gMapMgr);
gGps->SetMissionTree(MissionTree);
gGps->SetATOTree(gATOAll);
gGps->SetOOBTree(gOOBTree);
gGps->SetAllowed(UR_MISSION|UR_MAP);
gGps->SetObjectiveMenu(OBJECTIVE_POP);
gGps->SetUnitMenu(UNIT_POP);
gGps->SetMissionMenu(0); // Don't know what these are yet
gGps->SetSquadronMenu(UNIT_POP); // Don't know what these are yet
}
static void CampSaveFileCB (long,short hittype,C_Base *control)
{
C_Window *win;
C_EditBox *edit_box;
long saveIP,saveIter;
char buffer[MAX_PATH];
if(hittype != C_TYPE_LMOUSEUP)
return;
win=gMainHandler->FindWindow(SAVE_WIN);
if(!win)
return;
gMainHandler->HideWindow(control->Parent_); // verify window...
gMainHandler->HideWindow(win);
edit_box = (C_EditBox*) win->FindControl (FILE_NAME);
if (edit_box)
{
_tcscpy (buffer, edit_box->GetText ());
}
// Save As Campaign file
if(FalconLocalGame->IsLocal())
{
gCommsMgr->SaveStats();
TheCampaign.SetCreationIter(TheCampaign.GetCreationIter()+1);
TheCampaign.SaveCampaign(game_Campaign, buffer ,0);
if(gCommsMgr->Online())
{
// Send messages to remote players with new Iter Number
// So they can save their stats & update Iter in their campaign
gCommsMgr->UpdateGameIter();
}
}
else
{ // This person is making a LOCAL copy of someone elses game...
// we can save His stats... but remote people will be SOL if he
// tries to make this a remote game for them
saveIP=TheCampaign.GetCreatorIP();
saveIter=TheCampaign.GetCreationIter();
TheCampaign.SetCreatorIP(FalconLocalSessionId.creator_);
TheCampaign.SetCreationIter(1);
gCommsMgr->SaveStats();
TheCampaign.SaveCampaign(game_Campaign, buffer ,0);
TheCampaign.SetCreatorIP(saveIP);
TheCampaign.SetCreationIter(saveIter);
}
}
static void CampVerifySaveFileCB (long ID,short hittype,C_Base *control)
{
C_EditBox *edit_box;
FILE *fp;
char buffer[MAX_PATH];
if(hittype != C_TYPE_LMOUSEUP)
return;
edit_box = (C_EditBox*) control->Parent_->FindControl (FILE_NAME);
if (edit_box)
{
_stprintf(buffer,"%s\\%s.cam",FalconCampUserSaveDirectory,edit_box->GetText ());
fp=fopen(buffer,"r");
if(fp)
{
fclose(fp);
if(CheckExclude(buffer,FalconCampUserSaveDirectory,CampExcludeList,"cam"))
AreYouSure(TXT_ERROR,TXT_CANT_OVERWRITE,CloseWindowCB,CloseWindowCB);
else
AreYouSure(TXT_SAVE_CAMPAIGN,TXT_FILE_EXISTS,CampSaveFileCB,CloseWindowCB);
}
else
{
if(CheckExclude(buffer,FalconCampUserSaveDirectory,CampExcludeList,"cam"))
AreYouSure(TXT_ERROR,TXT_CANT_OVERWRITE,CloseWindowCB,CloseWindowCB);
else
CampSaveFileCB(ID,hittype,control);
}
}
}
void CampSaveAsCB (long, short hittype, C_Base *)
{
C_Window *win;
C_EditBox *ebox;
_TCHAR buffer[MAX_PATH];
if (hittype != C_TYPE_LMOUSEUP)
return;
sprintf (buffer, "%s\\*.cam", FalconCampUserSaveDirectory);
SetDeleteCallback(DelCamFileCB);
SaveAFile(TXT_SAVE_CAMPAIGN,buffer,CampExcludeList,CampVerifySaveFileCB,CloseWindowCB);
win=gMainHandler->FindWindow(SAVE_WIN);
if(win)
{
ebox=(C_EditBox *)win->FindControl(FILE_NAME);
if(ebox)
{
_stprintf(buffer,"%s-%s %1ld %02d %02d %02d",gStringMgr->GetString(TXT_SAVE),gStringMgr->GetString(TXT_DAY),(long)(TheCampaign.CurrentTime/(24 * 60 * 60 * VU_TICS_PER_SECOND))+1,(long)(TheCampaign.CurrentTime/(60 * 60 * VU_TICS_PER_SECOND))%24,(long)(TheCampaign.CurrentTime/(60 * VU_TICS_PER_SECOND))%60,(long)(TheCampaign.CurrentTime/(VU_TICS_PER_SECOND))%60);
ebox->SetText(buffer);
ebox->Refresh();
}
}
}
//
// DO NOT USE THIS FUNCTION FOR TACENG
//
void CampaignSetup() // Everything that needs to be done to start the campaign (except loading the window)
{
C_Window *win;
C_Text *txt;
C_TreeList *tree;
C_Bitmap *bmp;
C_Button *btn;
C_Blip *blip;
_TCHAR buffer[200];
Squadron ps;
GridIndex x,y;
InCleanup=0;
MovieY=5;
gMusic->ClearQ();
gMusic->FadeOut_Stop();
gMusic->ToggleStream();
SetupMapMgr();
SetupOOBWindow();
InitPAKNames();
TallyPlayerSquadrons();
SetupCampaignMenus();
StupidHackToCloseCSECT=0;
StopLookingforMission=0;
CurMapTool=NULL;
win=gMainHandler->FindWindow(CP_PUA_MAP);
if(win)
{
SetupMover(win,MAP_POP,MapMgrMoveCB);
gMapMgr->SetWindow(win);
gMapMgr->SetupOverlay();
}
win=gMainHandler->FindWindow(CB_FULLMAP_WIN);
if(win)
SetupMover(win,MAP_POP,MapMgrMoveCB);
win=gMainHandler->FindWindow(CB_MISSION_SCREEN);
if(win)
{
tree=(C_TreeList*)win->FindControl(MISSION_LIST_TREE);
SetupGPS(tree);
}
win=gMainHandler->FindWindow(CB_MISSION_SCREEN);
if(win)
{
txt=(C_Text *)win->FindControl(CB_MISS_TITLE);
if(txt)
{
ps = FalconLocalSession->GetPlayerSquadron();
if(ps)
{
_stprintf(buffer,"%s %s %s",OrdinalString(ps->GetUnitNameID()),gStringMgr->GetString(TXT_FS),gStringMgr->GetString(TXT_FRAG_ORDER));
txt->SetText(buffer);
}
}
}
win=gMainHandler->FindWindow(CB_MAIN_SCREEN);
if(win)
{
FalconLocalSession->SetPlayerFlight(NULL);
btn=(C_Button*)win->FindControl(CO_MAIN_CTRL);
if(btn)
{
if(!gCommsMgr->Online())
btn->SetFlagBitOff(C_BIT_ENABLED);
else
btn->SetFlagBitOn(C_BIT_ENABLED);
}
}
win=gMainHandler->FindWindow(CP_SUA);
if(win)
{
bmp=(C_Bitmap*)win->FindControl(CP_SUA);
if(bmp)
bmp->SetImage(gOccupationMap);
}
InitNewFlash();
SetSingle_Comms_Ctrls();
gSelectedFlightID=FalconNullId;
gLoadoutFlightID=FalconNullId;
gActiveFlightID=FalconNullId;
gActiveWPNum=0;
gCurrentFlightID=FalconNullId;
gPlayerFlightID=FalconNullId;
gPlayerPlane=-1;
mcnt=0;
atocnt=0;
uintcnt=0;
gLastUpdateGround=0l;
gLastUpdateAir=0l;
gATOAll->SetMenu (0);
gATOPackage->SetMenu (0);
gGps->SetTeamNo(FalconLocalSession->GetTeam()); // See ONLY what is spotted
gGps->Update();
win=gMainHandler->FindWindow(CP_SUA);
if(win)
{
short i,j;
blip=(C_Blip*)win->FindControl(9000000);
if(blip)
{
for(i=0;i<8;i++)
{
if(TeamInfo[i] && TeamInfo[i]->flags & TEAM_ACTIVE)
{
for(j=0;j<8;j++)
blip->SetImage(BLIP_IDS[TeamInfo[i]->GetColor()][j],static_cast<uchar>(i),static_cast<uchar>(j));
}
else
{
for(j=0;j<8;j++)
blip->SetImage(BLIP_IDS[0][j],static_cast<uchar>(i),static_cast<uchar>(j));
}
}
}
}
RefreshEventList();
RefreshMapEventList(CP_SUA, 0);
// Now finally startup up the Campaign loop
SetTimeCompression(1);
UpdateRemoteCompression();
InitTimeCompressionBox(1);
if(CampaignLastGroup)
{
win=gMainHandler->FindWindow(DEBRIEF_WIN);
// KCK: Added the check for a pilot list so that we don't debrief after a
// discarded mission
if(win && TheCampaign.MissionEvaluator && TheCampaign.MissionEvaluator->flight_data)
{
BuildCampDebrief(win);
gMainHandler->EnableWindowGroup(win->GetGroup());
}
}
gMainHandler->AddUserCallback(CampaignListCB);
gMainHandler->AddUserCallback(CampaignSoundEventCB);
// Choose our next mission (default)
if (!gTimeModeServer)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -