⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 te_list.cpp

📁 空战游戏flacon源码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//
// Tactical Engagement - Robin Heydon
//
// Implements the user interface for the tactical engagement section
// of falcon 4.0
//
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

#include <windows.h>
#include <ddraw.h>
#include "unit.h"
#include "team.h"
#include "CmpGlobl.h"
#include "CampCell.h"
#include "CampTerr.h"
#include "Listadt.h"
#include "objectiv.h"
#include "Campaign.h"
#include "campmap.h"
#include "campwp.h"
#include "campstr.h"
#include "squadron.h"
#include "feature.h"
#include "pilot.h"
#include "team.h"
#include "find.h"
#include "misseval.h"
#include "cmpclass.h"
#include "ui95_dd.h"
#include "chandler.h"
#include "ui95_ext.h"
#include "AirUnit.h"
#include "uicomms.h"
#include "userids.h"
#include "classtbl.h"
#include "textids.h"
#include "tac_class.h"
#include "te_defs.h"
#include "division.h"
#include "cmap.h"
#include "teamdata.h"
#include "f4find.h"

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

#define TAC_JOIN 30208

#ifdef _DEBUG
extern HWND mainAppWnd;
#endif
#ifdef CAMPTOOL
// Renaming tool stuff
extern int gRenameIds;
#endif CAMPTOOL

extern uchar gSelectedTeam;

_TCHAR gLastTEFilename[MAX_PATH];

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

void SetDeleteCallback(void (*cb)(long,short,C_Base*));
void tactical_select_training (long, short, C_Base *);
static void update_sua_load_list (void);
static void update_pua_list (void);
void tactical_edit_mission (tactical_mission *);
void ActivateTacMissionBuilder();
BOOL CheckExclude(_TCHAR *filename,_TCHAR *directory,_TCHAR *ExcludeList[],_TCHAR *extension);
void VerifyDelete(long TitleID, void (*YesCB)(long,short,C_Base*),void (*NoCB)(long,short,C_Base*));
int tactical_is_training (void);
void SetupOccupationMap (void);

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

void CampaignListCB();
void GetMissionTarget(Package curpackage,Flight curflight,_TCHAR Buffer[]);
void TacEngListCB(void);
void RefreshMapEventList(long winID, long client);
void CleanupTacticalEngagementUI (void);
_TCHAR *UI_WordWrap(C_Window *win,_TCHAR *str,long fontid,short width,BOOL *status);
void GetFileListTree(C_TreeList *tree,_TCHAR *fspec,_TCHAR *excludelist[],long group,BOOL cutext,long UseMenu);
BOOL FileNameSortCB(TREELIST *list,TREELIST *newitem);
void EnableScenarioInfo(long ID);
void DisableScenarioInfo();
void DelSTRFileCB(long ID,short hittype,C_Base *control);
void DelDFSFileCB(long ID,short hittype,C_Base *control);
void DelLSTFileCB(long ID,short hittype,C_Base *control);
void DelCamFileCB(long ID,short hittype,C_Base *control);
void DelTacFileCB(long ID,short hittype,C_Base *control);
void DelTGAFileCB(long ID,short hittype,C_Base *control);
void DelVHSFileCB(long ID,short hittype,C_Base *control);
void DelKeyFileCB(long ID,short hittype,C_Base *control);

_TCHAR *TEExcludeList[]=
{
	"te_new",
	NULL,
};

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

tactical_mission
	*current_tactical_mission = NULL;

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

extern VU_ID gCurrentFlightID;
extern C_Map
	*gMapMgr;

extern long TeamBtnIDs[NUM_TEAMS];
extern long TeamLineIDs[NUM_TEAMS];

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

void create_tactical_scenario_info (void)
{
	TheCampaign.Flags |= CAMP_TACTICAL;

	update_sua_load_list ();

	update_pua_list ();
}

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

static void tactical_mission_selection (int hack_training)
{
	current_tactical_mission->preload ();

	if (hack_training)
	{
		current_tactical_mission->set_type (tt_training);
	}

	update_sua_load_list ();

	update_pua_list ();

#ifdef _DEBUG
	PostMessage(mainAppWnd,FM_GIVE_FOCUS,NULL,NULL);
#endif

}

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

void TE_LoadMissionCB(long,short hittype,C_Base *control)
{
	C_TreeList *tree;
	TREELIST *item;
	C_Button   *btn;
	_TCHAR buffer[MAX_PATH];

	if(hittype != C_TYPE_LMOUSEUP)
		return;

	tree=(C_TreeList*)control;
	if(tree)
	{
		item=tree->GetLastItem();
		if(item)
		{
			btn=(C_Button*)item->Item_;

			if(btn)
			{
				tree->SetAllControlStates(0,tree->GetRoot());
				btn->SetState(1);
				tree->Refresh();

				strcpy (buffer, "campaign\\save\\");
				strcat (buffer, btn->GetText(0));
				strcat (buffer, ".tac");

				strcpy(gLastTEFilename,buffer);

				if (current_tactical_mission)
				{
					delete current_tactical_mission;
				}

				current_tactical_mission = new tactical_mission (buffer);

				tactical_mission_selection (FALSE);
			}
		}
	}
}

void TE_LoadTrainingMissionCB(long,short hittype,C_Base *control)
{
	C_TreeList *tree;
	TREELIST *item;
	C_Button   *btn;
	_TCHAR buffer[MAX_PATH];

	if(hittype != C_TYPE_LMOUSEUP)
		return;

	tree=(C_TreeList*)control;
	if(tree)
	{
		item=tree->GetLastItem();
		if(item)
		{
			btn=(C_Button*)item->Item_;

			if(btn)
			{
				tree->SetAllControlStates(0,tree->GetRoot());
				btn->SetState(1);
				tree->Refresh();

				strcpy (buffer, "campaign\\save\\");
				strcat (buffer, btn->GetText(0));
				strcat (buffer, ".trn");

				if (current_tactical_mission)
				{
					delete current_tactical_mission;
				}

				current_tactical_mission = new tactical_mission (buffer);

				tactical_mission_selection (TRUE);
			}
		}
	}
}

void GetTrainingFileList()
{
	C_Window *win;
	C_TreeList *tree;

	win=gMainHandler->FindWindow(TAC_MISSION_WIN);
	if(win)
	{
		tree=(C_TreeList *)win->FindControl(TRAINLIST_TREE);
		if(tree)
		{
			tree->DeleteBranch(tree->GetRoot());
			tree->SetUserNumber(0,1);
			tree->SetSortType(TREE_SORT_CALLBACK);
			tree->SetSortCallback(FileNameSortCB);
			tree->SetCallback(TE_LoadTrainingMissionCB);
			GetFileListTree(tree,"campaign\\save\\*.TRN",NULL,C_TYPE_ITEM,TRUE,0);
			tree->RecalcSize();
			win->RefreshClient(tree->GetClient());
		}
	}
	gLastTEFilename[0]=0;
}

void GetTacticalFileList()
{
	C_Window *win;
	C_TreeList *tree;
	

	win=gMainHandler->FindWindow(TAC_MISSION_WIN);
	if(win)
	{
		tree=(C_TreeList *)win->FindControl(FILELIST_TREE);
		if(tree)
		{
			tree->DeleteBranch(tree->GetRoot());
			tree->SetUserNumber(0,1);
			tree->SetSortType(TREE_SORT_CALLBACK);
			tree->SetSortCallback(FileNameSortCB);
			tree->SetCallback(TE_LoadMissionCB);
			GetFileListTree(tree,"campaign\\save\\*.TAC",TEExcludeList,C_TYPE_ITEM,TRUE,0);
			tree->RecalcSize();
			win->RefreshClient(tree->GetClient());
		}
	}
	gLastTEFilename[0]=0;
}


void TEDelFileCB(long,short hittype,C_Base *control)
{
	if(hittype != C_TYPE_LMOUSEUP)
		return;

	gMainHandler->HideWindow(control->Parent_); // Close Verify Window

	if(!CheckExclude(gLastTEFilename,FalconCampUserSaveDirectory,TEExcludeList,"tac"))
		DeleteFile(gLastTEFilename);

	gLastTEFilename[0]=0;

	if (current_tactical_mission)
	{
		delete current_tactical_mission;
		current_tactical_mission=NULL;
	}
	DisableScenarioInfo();
	GetTacticalFileList();
}

void TEDelVerifyCB(long,short hittype,C_Base *)
{
	if(hittype != C_TYPE_LMOUSEUP)
		return;

	if(gLastTEFilename[0])
		VerifyDelete(0,TEDelFileCB,CloseWindowCB);
}

void tac_flag_btn_cb(long, short hittype, C_Base *ctrl)
{
	if(hittype != C_TYPE_LMOUSEUP)
		return;

	if(current_tactical_mission)
	{
		if( ctrl->GetState())
		{
			current_tactical_mission->set_flag(ctrl->GetUserNumber(0));
		}
		else
		{
			current_tactical_mission->clear_flag(ctrl->GetUserNumber(0));
		}
	}
}

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

void choose_eng_type_cb(long , short hittype, C_Base *ctrl)
{
	if(hittype != C_TYPE_SELECT)
		return;

	short type = static_cast<short>(((C_ListBox *)ctrl)->GetTextID());

	switch(type)
	{
	//need to set engagement type appropriately
	case TYPE_CONTINUOUS:
		current_tactical_mission->set_type(tt_engagement);
		break;
	case TYPE_SINGLE:
		current_tactical_mission->set_type(tt_single);
		break;
	case TYPE_TRAINING:
		current_tactical_mission->set_type(tt_training);
		break;
	}
}

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////


void hookup_edit_controls (C_Window *win)
{
	if(!win)
		return;

	C_Button *btn;
	C_ListBox *lbox;

	lbox = (C_ListBox *)win->FindControl(TAC_TYPE);
	if(lbox)
	{
		lbox->SetCallback(choose_eng_type_cb);
	}

	btn = (C_Button *)win->FindControl(HIDE_ENEMY);
	if(btn)
	{
		btn->SetUserNumber(0,tf_hide_enemy);
		btn->SetCallback(tac_flag_btn_cb);
	}

	btn = (C_Button *)win->FindControl(LOCK_OOB);
	if(btn)
	{
		btn->SetUserNumber(0,tf_lock_oob);
		btn->SetCallback(tac_flag_btn_cb);
	}

	btn = (C_Button *)win->FindControl(LOCK_ATO);
	if(btn)
	{
		btn->SetUserNumber(0,tf_lock_ato);
		btn->SetCallback(tac_flag_btn_cb);
	}

	btn = (C_Button *)win->FindControl(FROZEN_START);
	if(btn)
	{
		btn->SetUserNumber(0,tf_start_paused);
		btn->SetCallback(tac_flag_btn_cb);
	}
}

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

void hookup_list_buttons (C_Window *winme)
{
	C_Button
		*ctrl;

	// Training Button
	ctrl = (C_Button *) winme->FindControl (TAC_TRAIN_CTRL);

	if (ctrl)
	{
		ctrl->SetCallback (tactical_select_training);
		ctrl->SetState (1);
	}

	// Load Button
	ctrl = (C_Button *) winme->FindControl (TAC_LOAD_CTRL);

	if (ctrl)
	{
		ctrl->SetCallback (tactical_select_load);
		ctrl->SetState (0);
	}

	// Join Button
	ctrl = (C_Button *) winme->FindControl (TAC_JOIN_CTRL);

	if (ctrl)
	{
		ctrl->SetCallback (tactical_select_join);
		ctrl->SetState (0);
	}
}

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

#if 0

void create_tactical_list (void)
{
	C_Window
		*win;

	C_Button
		*but;

	int
		group,
		loop,
		y;

	long
		id;

	char
		buffer[100];

	tactical_mission
		*miss;
	
	y = 0;
	id = 3000000;

	win = gMainHandler->FindWindow (TAC_MISSION_WIN);

	if (!win)
	{
		MonoPrint ("Cannot Find TAC_MISSION_WIN\n");
		return;
	}

	
	current_tactical_mission = NULL;

	DeleteGroupList (TAC_MISSION_WIN);

	miss = tactical_mission::get_first_mission (current_tactical_mode);

	for (loop = 0; miss; loop ++)
	{
		if (current_tactical_mode == tm_load)
		{
			strcpy (buffer, miss->get_title ());
			group = 3001;
		}
		else if (current_tactical_mode == tm_join)
		{
			sprintf (buffer, "Join %d", loop);
			group = 3002;
		}
		else
		{
			strcpy (buffer, miss->get_title ());
			group = 3003;
		}

		but = new C_Button;

		but->Setup (id, C_TYPE_RADIO, 0, y);
		but->SetFlagBitOn (C_BIT_ENABLED);

		but->SetText (C_STATE_0, buffer);
		but->SetText (C_STATE_1, buffer);
		but->SetFont (win->Font_);

		but->SetUserNumber (0, (int) miss);
		but->SetUserNumber(_UI95_DELGROUP_SLOT_,_UI95_DELGROUP_ID_);

		but->SetFgColor (C_STATE_0, 0x00e0e0e0);
		but->SetFgColor (C_STATE_1, 0x0000ff00);
		but->SetGroup (group);

		if (loop == 0)
		{
			current_tactical_mission = miss;

			but->SetState (1);
		}
		else
		{
			but->SetState (0);
		}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -