📄 dogfight.cpp
字号:
if (FalconLocalGame && FalconLocalGame->GetGameType() == game_Dogfight && !SimDogfight.ReadyToStart())
Enabled = FALSE;
if(Enabled)
{
btn1->SetFlagBitOn(C_BIT_ENABLED);
btn2->SetFlagBitOn(C_BIT_ENABLED);
}
btn1->Refresh();
btn2->Refresh();
}
static void SetDogFightStartup()
{
C_Window *win;
if((MainLastGroup == 2000))
{
// these functions (with scoring) MUST be in this order to work properly
win=gMainHandler->FindWindow(DF_DBRF_WIN);
if(win)
{
ProcessEventList(win,1);
DisplayDogfightResults();
win->ScanClientAreas();
win->RefreshWindow();
gMainHandler->EnableWindowGroup(win->GetGroup());
CopyDFSettingsToWindow();
gMainHandler->EnableWindowGroup(2020);
}
}
}
extern _TCHAR DogfightTeamNames[NUM_TEAMS][20];
void LoadDogFightWindows()
{
C_Window *win;
C_TreeList *tree;
C_TimerHook *tmr;
long ID;
if(!DFLoaded)
{
if( _LOAD_ART_RESOURCES_)
gMainParser->LoadImageList("art\\df_res.lst");
else
gMainParser->LoadImageList("art\\df_art.lst");
gMainParser->LoadSoundList("art\\df_snd.lst");
if(!gDogfightBites)
gDogfightBites=gMainParser->ParseSoundBite("art\\dgft\\play\\uiddf.scf");
gMainParser->LoadWindowList("art\\df_scf.lst");
ID=gMainParser->GetFirstWindowLoaded();
while(ID)
{
HookupDogFightControls(ID);
ID=gMainParser->GetNextWindowLoaded();
}
win=gMainHandler->FindWindow(DGFT_MAIN_SCREEN);
if(win)
{
tmr=new C_TimerHook;
tmr->Setup(C_DONT_CARE,C_TYPE_TIMER);
tmr->SetUpdateCallback(GenericTimerCB);
tmr->SetRefreshCallback(BlinkCommsButtonTimerCB);
tmr->SetUserNumber(_UI95_TIMER_DELAY_,1*_UI95_TICKS_PER_SECOND_); // Timer activates every 2 seconds (Only when this window is open)
win->AddControl(tmr);
}
DFLoaded++;
}
_tcscpy(DogfightTeamNames[1],gStringMgr->GetString(TXT_CRIMSONFLIGHT));
_tcscpy(DogfightTeamNames[2],gStringMgr->GetString(TXT_SHARKFLIGHT));
_tcscpy(DogfightTeamNames[3],gStringMgr->GetString(TXT_VIPREFLIGHT));
_tcscpy(DogfightTeamNames[4],gStringMgr->GetString(TXT_TIGERFLIGHT));
SetDogFightStartup();
SetSingle_Comms_Ctrls();
if(gCommsMgr->Online())
RebuildGameTree();
win=gMainHandler->FindWindow(DF_LOAD_WIN);
if(win)
{
tree=(C_TreeList*)win->FindControl(FILELIST_TREE);
if(tree)
{
tree->DeleteBranch(tree->GetRoot());
tree->SetUserNumber(0,0);
tree->SetSortType(TREE_SORT_CALLBACK);
tree->SetSortCallback(FileNameSortCB);
tree->SetCallback(SelectDFSettingsFileCB);
GetFileListTree(tree,"campaign\\save\\*.DFS",DFExcludeList,C_TYPE_ITEM,TRUE,0);
tree->RecalcSize();
if(tree->Parent_)
tree->Parent_->RefreshClient(tree->GetClient());
}
}
}
static void DogFightSLDRCB(long ID,short hittype,C_Base *control)
{
C_Slider *sldr=NULL;
C_Window *winme=NULL;
C_EditBox *ebox=NULL;
long value=0,step=0,temp=0;
if(hittype != C_TYPE_MOUSEMOVE)
return;
if(gCommsMgr->Online() && SimDogfight.GetDogfightGameStatus() != dog_Waiting)
{
GameHasStarted();
gMainHandler->DropControl();
CopyDFSettingsToWindow();
return;
}
winme=control->Parent_;
ebox=NULL;
switch(ID)
{
case RADAR_SLIDER:
ebox=(C_EditBox *)winme->FindControl(RADAR_READOUT);
step=2;
break;
case ALLIR_SLIDER:
ebox=(C_EditBox *)winme->FindControl(ALLIR_READOUT);
step=2;
break;
case RIR_SLIDER:
ebox=(C_EditBox *)winme->FindControl(RIR_READOUT);
step=2;
break;
case RANGE_SLIDER:
ebox=(C_EditBox *)winme->FindControl(RANGE_READOUT);
step=5;
break;
case ALTITUDE_SLIDER:
ebox=(C_EditBox *)winme->FindControl(ALTITUDE_READOUT);
step=1000;
break;
case MP_SLIDER:
ebox=(C_EditBox *)winme->FindControl(MP_READOUT);
step=1;
break;
}
if(ebox)
{
sldr=(C_Slider *)control;
value=((ebox->GetMaxInteger()-ebox->GetMinInteger()) * sldr->GetSliderPos() / (sldr->GetSliderMax() - sldr->GetSliderMin()))+1;
value+=ebox->GetMinInteger();
if(step > 1)
temp=value % step;
else
temp=step;
value -= temp;
if(ebox->GetInteger() == value)
return;
// Minimum starting range
if (ID == RANGE_SLIDER && value < 5)
value = 5;
ebox->SetInteger(value);
PositionSlider(sldr,value,ebox->GetMinInteger(),ebox->GetMaxInteger());
if(ID == MP_SLIDER)
{
if(value > 100)
{
ebox->SetText(TXT_FOREVER);
}
else if(value < 1)
{
value=1;
ebox->SetInteger(value);
}
}
ebox->Refresh();
}
CopyDFSettingsFromWindow();
}
void ClearDFTeamLists()
{
C_Window *win;
C_TreeList *list;
win=gMainHandler->FindWindow(DF_TEAM_WIN);
if(win)
{
list=(C_TreeList *)win->FindControl(CRIMSON_TREE);
if(list)
{
list->DeleteBranch(list->GetRoot());
list->RecalcSize();
if(!(list->GetFlags() & C_BIT_INVISIBLE))
win->RefreshClient(list->GetClient());
}
list=(C_TreeList *)win->FindControl(SHARK_TREE);
if(list)
{
list->DeleteBranch(list->GetRoot());
list->RecalcSize();
if(!(list->GetFlags() & C_BIT_INVISIBLE))
win->RefreshClient(list->GetClient());
}
list=(C_TreeList *)win->FindControl(TIGER_TREE);
if(list)
{
list->DeleteBranch(list->GetRoot());
list->RecalcSize();
if(!(list->GetFlags() & C_BIT_INVISIBLE))
win->RefreshClient(list->GetClient());
}
list=(C_TreeList *)win->FindControl(VIPER_TREE);
if(list)
{
list->DeleteBranch(list->GetRoot());
list->RecalcSize();
if(!(list->GetFlags() & C_BIT_INVISIBLE))
win->RefreshClient(list->GetClient());
}
list=(C_TreeList *)win->FindControl(FURBALL_TREE);
if(list)
{
list->DeleteBranch(list->GetRoot());
list->RecalcSize();
if(!(list->GetFlags() & C_BIT_INVISIBLE))
win->RefreshClient(list->GetClient());
}
}
}
void ClearDFTeamButtons()
{
C_Window *win;
C_Button *btn;
win=gMainHandler->FindWindow(DF_TEAM_WIN);
if(win)
{
btn=(C_Button *)win->FindControl(DF_CRIMSON);
if(btn)
{
if(btn->GetState())
{
btn->SetState(0);
btn->Refresh();
}
}
btn=(C_Button *)win->FindControl(DF_SHARK);
if(btn)
{
if(btn->GetState())
{
btn->SetState(0);
btn->Refresh();
}
}
btn=(C_Button *)win->FindControl(DF_TIGER);
if(btn)
{
if(btn->GetState())
{
btn->SetState(0);
btn->Refresh();
}
}
btn=(C_Button *)win->FindControl(DF_VIPER);
if(btn)
{
if(btn->GetState())
{
btn->SetState(0);
btn->Refresh();
}
}
btn=(C_Button *)win->FindControl(DF_MARK_CRIMSON);
if(btn)
{
if(btn->GetState())
{
btn->SetState(0);
btn->Refresh();
}
}
btn=(C_Button *)win->FindControl(DF_MARK_SHARK);
if(btn)
{
if(btn->GetState())
{
btn->SetState(0);
btn->Refresh();
}
}
btn=(C_Button *)win->FindControl(DF_MARK_TIGER);
if(btn)
{
if(btn->GetState())
{
btn->SetState(0);
btn->Refresh();
}
}
btn=(C_Button *)win->FindControl(DF_MARK_VIPER);
if(btn)
{
if(btn->GetState())
{
btn->SetState(0);
btn->Refresh();
}
}
}
}
void LeaveDogfight()
{
TheCampaign.EndCampaign();
if(gCommsMgr->Online())
{
if(VuLocalGame != vuPlayerPoolGroup)
{
SetCurrentGameState(DogfightGames,C_STATE_0);
vuLocalSessionEntity->JoinGame(vuPlayerPoolGroup);
}
gCommsMgr->LookAtGame(NULL);
}
ClearDFTeamLists();
ClearDFTeamButtons();
FalconLocalSession->SetPlayerSquadron(NULL);
FalconLocalSession->SetPlayerFlight(NULL);
FalconLocalSession->SetCountry(255);
FalconLocalSession->SetPilotSlot(255);
SendMessage(gMainHandler->GetAppWnd(),FM_SHUTDOWN_CAMPAIGN,0,0);
CheckFlyButton();
}
void EnableDFTeamGroup()
{
CheckFlyButton();
}
void InfoButtonCB(long,short hittype,C_Base *control)
{
VU_ID gameID;
if(hittype != C_TYPE_LMOUSEUP)
return;
SetupInfoWindow(NULL,NULL);
gMainHandler->EnableWindowGroup(control->GetGroup());
}
void SaveItCB(long,short hittype,C_Base *control)
{
C_EditBox *ebox;
C_Window *win;
C_TreeList *tree;
char filename[MAX_PATH];
if(hittype != C_TYPE_LMOUSEUP)
return;
win=gMainHandler->FindWindow(SAVE_WIN);
if(!win)
return;
gMainHandler->HideWindow(win);
gMainHandler->HideWindow(control->Parent_);
ebox=(C_EditBox*)win->FindControl(FILE_NAME);
if(ebox)
{
_stprintf(filename,"%s\\%s.dfs",FalconCampUserSaveDirectory,ebox->GetText());
// SAVE SETTINGS HERE
SimDogfight.SaveSettings(filename);
}
win=gMainHandler->FindWindow(DF_LOAD_WIN);
if(win)
{
tree=(C_TreeList*)win->FindControl(FILELIST_TREE);
if(tree)
{
_stprintf(filename,"%s\\*.dfs",FalconCampUserSaveDirectory);
tree->DeleteBranch(tree->GetRoot());
GetFileListTree(tree,filename,DFExcludeList,C_TYPE_ITEM,TRUE,0);
tree->RecalcSize();
if(tree->Parent_)
tree->Parent_->RefreshClient(tree->GetClient());
}
}
}
void VerifySaveItCB(long ID,short hittype,C_Base *control)
{
C_EditBox *ebox;
FILE *fp;
char filename[MAX_PATH];
if(hittype != C_TYPE_LMOUSEUP)
return;
ebox=(C_EditBox*)control->Parent_->FindControl(FILE_NAME);
if(ebox)
{
_stprintf(filename,"%s\\%s.dfs",FalconCampUserSaveDirectory,ebox->GetText());
fp=fopen(filename,"r");
if(fp)
{
fclose(fp);
if(CheckExclude(filename,FalconCampUserSaveDirectory,DFExcludeList,"dfs"))
AreYouSure(TXT_ERROR,TXT_CANT_OVERWRITE,CloseWindowCB,CloseWindowCB);
else
AreYouSure(TXT_WARNING,TXT_FILE_EXISTS,SaveItCB,CloseWindowCB);
}
else
{
if(CheckExclude(filename,FalconCampUserSaveDirectory,DFExcludeList,"dfs"))
AreYouSure(TXT_ERROR,TXT_CANT_OVERWRITE,CloseWindowCB,CloseWindowCB);
else
SaveItCB(ID,hittype,control);
}
}
}
static void SaveDFSettingsCB(long,short hittype,C_Base *)
{
_TCHAR fname[MAX_PATH];
if(hittype != C_TYPE_LMOUSEUP)
return;
SetDeleteCallback(DelDFSFileCB);
_stprintf(fname,"%s\\*.dfs",FalconCampUserSaveDirectory);
SaveAFile(TXT_SAVE_DOGFIGHT,fname,DFExcludeList,VerifySaveItCB,CloseWindowCB);
}
// Callback from clicking on a saved game's name
static void SelectDFSettingsFileCB(long,short hittype,C_Base *control)
{
C_TreeList *tree;
TREELIST *item;
C_Button *btn;
if(hittype != C_TYPE_LMOUSEUP)
return;
tree=(C_TreeList*)control;
if(tree)
{
item=tree->GetLastItem();
if(item)
{
btn=(C_Button*)item->Item_;
if(btn)
{
if(!btn->GetState())
{
tree->SetAllControlStates(0,tree->GetRoot());
btn->SetState(1);
tree->Refresh();
_stprintf(gCurDogfightFile,"%s\\%s.DFS",FalconCampUserSaveDirectory,btn->GetText(C_STATE_0));
SimDogfight.SetFilename(gCurDogfightFile);
SimDogfight.LoadSettings();
CopyDFSettingsToSelectWindow();
}
else
{
tree->SetAllControlStates(0,tree->GetRoot());
tree->Refresh();
gCurDogfightFile[0]=0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -