📄 te_team_victory.cpp
字号:
//////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//
// Tactical Engagement - Robin Heydon
//
// Implements the user interface for the tactical engagement section
// of falcon 4.0
//
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
#include "falclib.h"
#include "vu2.h"
#include "chandler.h"
#include "ui95_ext.h"
#include "uicomms.h"
#include "userids.h"
#include "textids.h"
#include "unit.h"
#include "team.h"
#include "timerthread.h"
#include "CmpGlobl.h"
#include "CampCell.h"
#include "CampTerr.h"
#include "find.h"
#include "division.h"
#include "cmap.h"
#include "flight.h"
#include "campwp.h"
#include "cmpclass.h"
#include "Listadt.h"
#include "objectiv.h"
#include "feature.h"
#include "Campaign.h"
#include "classtbl.h"
#include "falcsess.h"
#include "tac_class.h"
#include "gps.h"
#include "urefresh.h"
#include "te_defs.h"
#include "teamdata.h"
#include "sim\include\otwdrive.h"
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
#define BID_DROPDOWN 50300
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
static void adjust_team_name (long ID, short hittype, C_Base *ctrl);
static void select_team_name (long ID, short hittype, C_Base *ctrl);
static void adjust_flag (long ID, short hittype, C_Base *ctrl);
static void show_all_vc (long ID, short hittype, C_Base *ctrl);
static void show_team_vc (long ID, short hittype, C_Base *ctrl);
static void show_achieved_vc (long ID, short hittype, C_Base *ctrl);
static void show_remaining_vc (long ID, short hittype, C_Base *ctrl);
static void new_victory_condition (long ID, short hittype, C_Base *ctrl);
static void change_vc_team_name (long ID, short hittype, C_Base *ctrl);
static void change_vc_team_action (long ID, short hittype, C_Base *ctrl);
static void change_vc_tolerance (long ID, short hittype, C_Base *ctrl);
static void change_vc_steerpoint (long ID, short hittype, C_Base *ctrl);
static void delete_current_vc (long ID, short hittype, C_Base *ctrl);
static void set_points_required_for_victory (long ID, short hittype, C_Base *ctrl);
static void delete_tactical_object (long ID, short hittype, C_Base *ctrl);
static void set_vc_points (long ID, short hittype, C_Base *ctrl);
static void add_vc_air_unit (long ID, short hittype, C_Base *ctrl);
static void update_victory_team_window (void);
void BuildSpecificTargetList(VU_ID targetID);
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
void delete_all_units_for_team (int team);
void tactical_remove_squadron (SquadronClass *);
void InitVCArgLists();
void SelectToolTypeCB(long ID,short hittype,C_Base *control);
void CloseReconWindowCB(long ID,short hittype,C_Base *control);
extern int check_victory_conditions (void);
void CancelCampaignCompression (void);
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
extern C_Handler *gMainHandler;
extern VU_ID
gSelectedFlightID;
extern long gRefreshScoresList;
extern C_Map
*gMapMgr;
C_TreeList *gVCTree=NULL;
long VCSortType=0;
long ShowGameOverWindow=0;
static int
team_victory_id = 3000000,
team_mapping[8];
static C_Box
*team_colour_box[8] = {NULL};
extern uchar gSelectedTeam;
static C_EditBox
*team_name[8] = {NULL};
static C_Button
*new_vc_button = NULL,
*show_all_button = NULL,
*show_team_button = NULL,
*show_achieved_button = NULL,
*show_remaining_button = NULL,
*new_team_button[8] = {NULL},
*team_flag_box[8] = {NULL};
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Targetting stuff
extern void (*OldReconCWCB)(long,short,C_Base*);
extern VU_ID FeatureID;
extern long FeatureNo;
extern C_TreeList *TargetTree;
void TgtAssignCWCB(long,short,C_Base*);
extern GlobalPositioningSystem
*gGps;
LISTBOX *team_lbox=NULL;
LISTBOX *action_lbox=NULL;
LISTBOX *percent_lbox=NULL;
LISTBOX *intercept_lbox=NULL;
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
void hookup_team_buttons
(
C_Window *winme,
int team,
long colour_id,
long new_team_id,
long team_id,
long flag_id
)
{
C_Button
*ctrl;
C_PopupList
*popup;
C_EditBox
*editbox;
C_Box
*box;
box = (C_Box *) winme->FindControl (colour_id);
if (box)
{
team_colour_box[team] = box;
}
ctrl = (C_Button *) winme->FindControl (new_team_id);
if (ctrl)
{
new_team_button[team] = ctrl;
}
editbox = (C_EditBox *) winme->FindControl (team_id);
if (editbox)
{
team_name[team] = editbox;
}
ctrl = (C_Button *) winme->FindControl (flag_id);
if (ctrl)
{
team_flag_box[team] = ctrl;
}
popup = gPopupMgr->GetMenu (DELETE_POPUP);
if (popup)
{
popup->SetCallback (LIST_DELETE, delete_tactical_object);
}
popup = gPopupMgr->GetMenu (AIRUNIT_MENU);
if (popup)
{
popup->SetCallback (LIST_VC, add_vc_air_unit);
popup->SetCallback (LIST_DELETE, delete_tactical_object);
}
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
void hookup_team_victory_window (C_Window *winme)
{
C_Button *ctrl;
C_EditBox *editbox;
ctrl = (C_Button *) winme->FindControl (NEW_VC);
if (ctrl)
ctrl->SetCallback (new_victory_condition);
ctrl = (C_Button *) winme->FindControl (TAC_DELETE_VC);
if (ctrl)
ctrl->SetCallback (delete_current_vc);
editbox = (C_EditBox *) winme->FindControl (PTS_REQ_VICTORY);
if (editbox)
editbox->SetCallback (set_points_required_for_victory);
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
static LISTBOX *mk_item(long ID,long TextID)
{
LISTBOX *lbitem;
lbitem=new LISTBOX;
lbitem->Label_=new C_Button;
lbitem->Label_->Setup(ID,C_TYPE_RADIO,0,0);
lbitem->Label_->SetText(C_STATE_0,TextID);
lbitem->Label_->SetText(C_STATE_1,TextID);
lbitem->Label_->SetGroup(5551212);
lbitem->Next=NULL;
return(lbitem);
}
static LISTBOX *mk_item(long ID,_TCHAR *Text)
{
LISTBOX *lbitem;
lbitem=new LISTBOX;
lbitem->Label_=new C_Button;
lbitem->Label_->Setup(ID,C_TYPE_RADIO,0,0);
lbitem->Label_->SetText(C_STATE_0,Text);
lbitem->Label_->SetText(C_STATE_1,Text);
lbitem->Label_->SetGroup(5551212);
lbitem->Next=NULL;
return(lbitem);
}
void RebuildTeamLists()
{
victory_condition *vc=NULL;
LISTBOX *last=NULL,*item=NULL,*cur=NULL;
C_Victory *vctrl=NULL;
short i=0;
gMainHandler->EnterCritical();
cur=team_lbox;
while(cur)
{
last=cur;
cur=cur->Next;
last->Label_->Cleanup();
delete last->Label_;
delete last;
}
team_lbox=NULL;
last = NULL;
for(i=0;i<NUM_TEAMS;i++)
{
if(TeamInfo[i] && (TeamInfo[i]->flags & TEAM_ACTIVE))
item=mk_item(i,TeamInfo[i]->GetName());
else
{
item=mk_item(i,"No Team");
item->Label_->SetFlagBitOn(C_BIT_INVISIBLE);
}
if(!team_lbox)
team_lbox=item;
else
last->Next=item;
last=item;
}
vc=current_tactical_mission->get_first_unfiltered_victory_condition();
while(vc)
{
vctrl=(C_Victory*)vc->control;
if(vctrl)
vctrl->GetTeam()->SetRoot(team_lbox);
vc=current_tactical_mission->get_next_unfiltered_victory_condition();
}
gMainHandler->LeaveCritical();
}
void InitVCArgLists()
{
LISTBOX *last=NULL,*item=NULL;
short i=0;
if(!team_lbox)
{
for(i=0;i<NUM_TEAMS;i++)
{
if(TeamInfo[i] && (TeamInfo[i]->flags & TEAM_ACTIVE))
item=mk_item(i,TeamInfo[i]->GetName());
else
{
item=mk_item(i,"No Team");
item->Label_->SetFlagBitOn(C_BIT_INVISIBLE);
}
if(!team_lbox)
team_lbox=item;
else
last->Next=item;
last=item;
}
}
if(!action_lbox)
{
last=mk_item(vt_occupy,TXT_OCCUPY);
action_lbox=last;
item=mk_item(vt_destroy,TXT_DESTROY);
last->Next=item;
last=item;
item=mk_item(vt_attrit,TXT_ATTRIT);
last->Next=item;
last=item;
item=mk_item(vt_intercept,TXT_INTERCEPT);
last->Next=item;
last=item;
item=mk_item(vt_degrade,TXT_DEGRADE);
last->Next=item;
}
// 10 -> 100 %
if(!percent_lbox)
{
last=mk_item(1,TXT_TEN_PERC);
percent_lbox=last;
item=mk_item(2,TXT_TWENTY_PERC);
last->Next=item;
last=item;
item=mk_item(3,TXT_THIRTY_PERC);
last->Next=item;
last=item;
item=mk_item(4,TXT_FORTY_PERC);
last->Next=item;
last=item;
item=mk_item(5,TXT_FIFTY_PERC);
last->Next=item;
last=item;
item=mk_item(6,TXT_SIXTY_PERC);
last->Next=item;
last=item;
item=mk_item(7,TXT_SEVENTY_PERC);
last->Next=item;
last=item;
item=mk_item(8,TXT_EIGHTY_PERC);
last->Next=item;
last=item;
item=mk_item(9,TXT_NINETY_PERC);
last->Next=item;
last=item;
item=mk_item(10,TXT_HUNDRED_PERC);
last->Next=item;
}
if(!intercept_lbox)
{
last=mk_item(1,TXT_ONE);
intercept_lbox=last;
item=mk_item(2,TXT_TWO);
last->Next=item;
last=item;
item=mk_item(3,TXT_THREE);
last->Next=item;
last=item;
item=mk_item(4,TXT_FOUR);
last->Next=item;
}
}
void CleanupVCArgLists()
{
LISTBOX *cur,*last;
if(gVCTree)
gVCTree->DeleteBranch(gVCTree->GetRoot());
cur=team_lbox;
while(cur)
{
last=cur;
cur=cur->Next;
last->Label_->Cleanup();
delete last->Label_;
delete last;
}
team_lbox=NULL;
cur=action_lbox;
while(cur)
{
last=cur;
cur=cur->Next;
last->Label_->Cleanup();
delete last->Label_;
delete last;
}
action_lbox=NULL;
cur=percent_lbox;
while(cur)
{
last=cur;
cur=cur->Next;
last->Label_->Cleanup();
delete last->Label_;
delete last;
}
percent_lbox=NULL;
cur=intercept_lbox;
while(cur)
{
last=cur;
cur=cur->Next;
last->Label_->Cleanup();
delete last->Label_;
delete last;
}
intercept_lbox=NULL;
}
void SetVCSortTypeCB(long ID,short hittype,C_Base *)
{
F4CSECTIONHANDLE *Leave;
if(hittype != C_TYPE_LMOUSEUP)
return;
VCSortType=ID;
if(gVCTree)
{
Leave=UI_Enter(gVCTree->Parent_);
gVCTree->ReorderBranch(gVCTree->GetRoot());
gVCTree->RecalcSize();
if(gVCTree->Parent_)
gVCTree->Parent_->RefreshClient(gVCTree->GetClient());
UI_Leave(Leave);
}
}
BOOL VCSortCB(TREELIST *list,TREELIST *newitem)
{
C_Victory *lvc,*nvc;
if(!list || !newitem)
return(FALSE);
lvc=(C_Victory*)list->Item_;
nvc=(C_Victory*)newitem->Item_;
if(!lvc || !nvc)
return(FALSE);
switch(VCSortType)
{
case SORT_VC_TEAM: // Sort by Team
if(nvc->GetTeam()->GetTextID() < lvc->GetTeam()->GetTextID())
return(TRUE);
else if(nvc->GetTeam()->GetTextID() == lvc->GetTeam()->GetTextID() && newitem->ID_ < list->ID_)
return(TRUE);
break;
case SORT_VC_TYPE: // Sort by Action
if(nvc->GetAction()->GetTextID() < lvc->GetAction()->GetTextID())
return(TRUE);
else if(nvc->GetAction()->GetTextID() == lvc->GetAction()->GetTextID() && newitem->ID_ < list->ID_)
return(TRUE);
break;
case SORT_VC_POINTS: // Sort by Points
if(nvc->GetPoints()->GetInteger() > lvc->GetPoints()->GetInteger())
return(TRUE);
else if(nvc->GetPoints()->GetInteger() == lvc->GetPoints()->GetInteger() && newitem->ID_ < list->ID_)
return(TRUE);
break;
case SORT_VC_NUMBER: // Sort by ID
default:
if(newitem->ID_ < list->ID_)
return(TRUE);
break;
}
return(FALSE);
}
// Called AFTER MakeVC...() is called, when the user changes Action or Target
// I've just added some error correction code...
// If the vc type doesn't match the entity type (vt_attrit with an objective for example)
// change the type to match the entity
void UpdateVCOptions(victory_condition *vc)
{ // Handles changing targets etc...
C_Victory *vctrl;
C_ListBox *lbox;
CampEntity ent;
_TCHAR buffer[60];
FeatureClassDataType *fc;
long classID,i;
if(!vc)
return;
vctrl=(C_Victory*)vc->control;
if(!vctrl || !vctrl->Parent_)
return;
ent=(CampEntity)vuDatabase->Find(vc->get_vu_id());
if(ent)
{
// Set location... on Map...
gMapMgr->UpdateVC(vc);
if (ent->IsFlight())
GetCallsign (((Flight)ent)->callsign_id, ((Flight)ent)->callsign_num, buffer);
else if (ent->IsObjective())
ent->GetName(buffer,35,TRUE);
else
ent->GetName(buffer,35,FALSE);
if(ent->IsObjective() && vc->get_type() == vt_destroy && vc->get_sub_objective() >= 0)
{
classID = ((Objective)ent)->GetFeatureID(vc->get_sub_objective());
if (classID)
{
fc = GetFeatureClassData (classID);
if (fc && !(fc->Flags & FEAT_VIRTUAL))
{
_tcscat(buffer,", ");
_tcscat(buffer,fc->Name);
}
}
}
vctrl->GetTarget()->SetText(0,buffer);
if(vc->get_type() == vt_destroy)
vctrl->GetTarget()->SetUserNumber(10,1);
else
vctrl->GetTarget()->SetUserNumber(10,0);
lbox=vctrl->GetAction();
if(lbox)
{
if(ent)
{
if(ent->IsObjective())
{
lbox->SetItemFlags(vt_occupy,C_BIT_ENABLED);
lbox->SetItemFlags(vt_destroy,C_BIT_ENABLED);
lbox->SetItemFlags(vt_degrade,C_BIT_ENABLED);
lbox->SetItemFlags(vt_attrit,C_BIT_INVISIBLE);
lbox->SetItemFlags(vt_intercept,C_BIT_INVISIBLE);
lbox->SetFlagBitOff(C_BIT_INVISIBLE);
if(vc->get_type() == vt_attrit || vc->get_type() == vt_intercept)
vc->set_type(vt_degrade);
}
else if(ent->IsFlight())
{
lbox->SetItemFlags(vt_occupy,C_BIT_INVISIBLE);
lbox->SetItemFlags(vt_destroy,C_BIT_INVISIBLE);
lbox->SetItemFlags(vt_degrade,C_BIT_INVISIBLE);
lbox->SetItemFlags(vt_attrit,C_BIT_INVISIBLE);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -