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

📄 te_team.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 "vu2.h"
#include "team.h"
#include "division.h"
#include "chandler.h"
#include "ui95_ext.h"
#include "cmap.h"
#include "uicomms.h"
#include "userids.h"
#include "textids.h"
#include "teamdata.h"

void tactical_territory_editor_clear (long ID, short hittype, C_Base *control);
void tactical_territory_editor_restore (long ID, short hittype, C_Base *control);
void tactical_set_drawmode (long ID, short hittype, C_Base *control);
void tactical_set_erasemode (long ID, short hittype, C_Base *control);
void tactical_territory_map_edit (long ID, short hittype, C_Base *control);
void UpdateOccupationMap(void);
void update_team_victory_window();
void SetupOOBWindow();
void UpdateTeamName(long team);
void RebuildTeamLists();
void AddTeam (int teamNum, int defaultStance);

extern C_Handler *gMainHandler;
extern uchar gSelectedTeam;

long gDrawTeam=1;

extern C_Map *gMapMgr;

long TeamBtnIDs[NUM_TEAMS]=
{
	GROUP1_FLAG,
	GROUP2_FLAG,
	GROUP3_FLAG,
	GROUP4_FLAG,
	GROUP5_FLAG,
	GROUP6_FLAG,
	GROUP7_FLAG,
	GROUP8_FLAG,
};

long TeamLineIDs[NUM_TEAMS]=
{
	GROUP1_COLOR,
	GROUP2_COLOR,
	GROUP3_COLOR,
	GROUP4_COLOR,
	GROUP5_COLOR,
	GROUP6_COLOR,
	GROUP7_COLOR,
	GROUP8_COLOR,
};

void Init_Flag_Color_Used()
{
	short i;

	for(i=0;i<TOTAL_FLAGS;i++)
		FlagImageID[i][FLAG_STATUS]=0;

	for(i=0;i<NUM_TEAMS;i++)
		TeamColorUse[i]=0;
}

static uchar GetUnusedFlag()
{
	int i=1;

	while(i < TOTAL_FLAGS)
	{
		if(!FlagImageID[i][FLAG_STATUS])
			return(static_cast<uchar>(i));
		i++;
	}
	return(0);
}

static uchar GetUnusedColor()
{
	int i=1;
	while(i < NUM_TEAMS)
	{
		if(!TeamColorUse[i])
			return(static_cast<uchar>(i));
		i++;
	}
	return(0);
}

void SetupTeamFlags()
{
	C_Window *win=NULL;
	C_Button *EditMap=NULL,*SmallMap=NULL,*BigMap=NULL;
	short i;

	win=gMainHandler->FindWindow(TAC_EDIT_WIN);
	if(win)
		EditMap=(C_Button*)win->FindControl(TEAM_SELECTOR);

	win=gMainHandler->FindWindow(TAC_PUA_MAP);
	if(win)
		SmallMap=(C_Button*)win->FindControl(TEAM_SELECTOR);

	win=gMainHandler->FindWindow(TAC_FULLMAP_WIN);
	if(win)
		BigMap=(C_Button*)win->FindControl(TEAM_SELECTOR);

	for(i=0;i<NUM_TEAMS;i++)
	{
		// Setup flags used
		if(TeamInfo[i] && (TeamInfo[i]->flags & TEAM_ACTIVE))
		{
			if(EditMap)
				EditMap->SetImage(i,FlagImageID[TeamInfo[i]->GetFlag()][SMALL_HORIZ]);
			if(SmallMap)
				SmallMap->SetImage(i,FlagImageID[TeamInfo[i]->GetFlag()][SMALL_HORIZ]);
			if(BigMap)
				BigMap->SetImage(i,FlagImageID[TeamInfo[i]->GetFlag()][SMALL_HORIZ]);
		}
	}
	if(EditMap)
		EditMap->SetState(gSelectedTeam);
	if(SmallMap)
	{
		SmallMap->SetCallback(NULL);
		SmallMap->SetState(FalconLocalSession->GetTeam());
	}
	if(BigMap)
	{
		SmallMap->SetCallback(NULL);
		BigMap->SetState(FalconLocalSession->GetTeam());
	}
	update_team_victory_window ();
}

void SetupTeamColors()
{ // Set ATO & OOB & Camp Map
	C_Window *win;
	C_Line   *line;

	gDrawTeam=gSelectedTeam;

	win=gMainHandler->FindWindow(TAC_EDIT_WIN);
	if(win)
	{
		line=(C_Line*)win->FindControl(TEAM_COLOR);
		if(line)
		{
			if (TeamInfo[gSelectedTeam])
			{
				line->SetColor(TeamColorList[TeamInfo[gSelectedTeam]->GetColor()]);
			}
			line->Refresh();
		}
	}

	win=gMainHandler->FindWindow(TAC_PUA_MAP);
	if(win)
	{
		line=(C_Line*)win->FindControl(TEAM_COLOR);
		if(line)
		{
			if (TeamInfo[gSelectedTeam])
			{
				line->SetColor(TeamColorList[TeamInfo[gSelectedTeam]->GetColor()]);
			}
			line->Refresh();
		}
	}

	win=gMainHandler->FindWindow(TAC_FULLMAP_WIN);
	if(win)
	{
		line=(C_Line*)win->FindControl(TEAM_COLOR);
		if(line)
		{
			if (TeamInfo[gSelectedTeam])
			{
				line->SetColor(TeamColorList[TeamInfo[gSelectedTeam]->GetColor()]);
			}
			line->Refresh();
		}
	}
	SetupOOBWindow();
	update_team_victory_window ();
}

void SetupTeamNames()
{ // Set ATO & OOB & Camp Map
	RebuildTeamLists();
	SetupOOBWindow();
	update_team_victory_window ();
}

void SetupTeamData(void)
{
	SetupTeamFlags();
	SetupTeamColors();
	SetupTeamNames();
	SetupOOBWindow();
	update_team_victory_window ();
}

void UpdateBigMapColors(long team)
{
	long idx,j;
	if(TeamInfo[team])
		idx=TeamInfo[team]->GetColor();
	else
		idx=0;
	for(j=0;j<8;j++)
	{
		gMapMgr->SetAirIcons(team,j,TeamFlightColorIconIDs[idx][j][0],TeamFlightColorIconIDs[idx][j][1]);
	}
	gMapMgr->SetArmyIcons(team,TeamColorIconIDs[idx][0],TeamColorIconIDs[idx][1]);
	gMapMgr->SetNavyIcons(team,TeamColorIconIDs[idx][0],TeamColorIconIDs[idx][1]);
	gMapMgr->SetObjectiveIcons(team,TeamColorIconIDs[idx][0],TeamColorIconIDs[idx][1]);
	gMapMgr->RemapTeamColors(team);
}

// NOTE: Automatically fixes duplicate flags & colors
void SetupTeamListValues()
{
	C_Window *win;
	C_Line *line;
	C_Button *btn;
	long i;
	long btnidx;

	win=gMainHandler->FindWindow(TAC_TEAM_WIN);
	if(win)
	{
		Init_Flag_Color_Used();
		btnidx=0;
		for(i=0;i<NUM_TEAMS;i++)
		{
			if(TeamInfo[i] && (TeamInfo[i]->flags & TEAM_ACTIVE))
			{
				if(FlagImageID[TeamInfo[i]->GetFlag()][FLAG_STATUS])
					TeamInfo[i]->SetFlag(GetUnusedFlag());
				FlagImageID[TeamInfo[i]->GetFlag()][FLAG_STATUS]=1;
				btn=(C_Button*)win->FindControl(TeamBtnIDs[btnidx]);
				if(btn)
				{
					if(i == gSelectedTeam)
						btn->SetState(1);
					else
						btn->SetState(0);

					btn->SetImage(0,FlagImageID[TeamInfo[i]->GetFlag()][BIG_VERT_DARK]);
					btn->SetImage(1,FlagImageID[TeamInfo[i]->GetFlag()][BIG_VERT]);
					btn->SetFlagBitOff(C_BIT_INVISIBLE);
					btn->Refresh();
					btn->SetUserNumber(0,i);
				}

				if(TeamColorUse[TeamInfo[i]->GetColor()])
					TeamInfo[i]->SetColor(GetUnusedColor());

				TeamColorUse[TeamInfo[i]->GetColor()]=1;
				line=(C_Line*)win->FindControl(TeamLineIDs[btnidx]);
				if(line)
				{
					line->SetColor(TeamColorList[TeamInfo[i]->GetColor()]);
					line->SetFlagBitOff(C_BIT_INVISIBLE);
					line->Refresh();
				}
				btnidx++;
			}
		}
		while(btnidx < NUM_TEAMS)
		{
			btn=(C_Button*)win->FindControl(TeamBtnIDs[btnidx]);
			if(btn)
			{
				btn->Refresh();
				btn->SetFlagBitOn(C_BIT_INVISIBLE);
				btn->SetUserNumber(0,0);
			}
			line=(C_Line*)win->FindControl(TeamLineIDs[btnidx]);
			if(line)
			{
				line->Refresh();
				line->SetFlagBitOn(C_BIT_INVISIBLE);
			}
			btnidx++;
		}
		UpdateOccupationMap();
	}
	update_team_victory_window ();
}

void SetupCurrentTeamValues(long team)
{
	C_Window *win;
	C_EditBox *ebox;
	C_ListBox *lbox;
	C_Box *box;
	C_Button *btn;

	if(team >= NUM_TEAMS) // Out of range
		return;

	if(!TeamInfo[team]) // Team undefined
		return;

	win=gMainHandler->FindWindow(TAC_TEAM_WIN);
	if(win)
	{
		btn=(C_Button*)win->FindControl(CURRENT_FLAG);
		if(btn)
		{
			btn->SetImage(0,FlagImageID[TeamInfo[team]->GetFlag()][BIG_HORIZ]);
			btn->Refresh();
		}
		box=(C_Box*)win->FindControl(CURRENT_COLOR);
		if(box)
		{
			box->SetColor(TeamColorList[TeamInfo[team]->GetColor()]);
			box->Refresh();
		}
		lbox=(C_ListBox*)win->FindControl(PILOT_SKILL);
		if(lbox)
		{
			lbox->SetValue(TeamInfo[team]->airExperience);
			lbox->Refresh();
		}
		lbox=(C_ListBox*)win->FindControl(SAM_SKILL);
		if(lbox)
		{
			lbox->SetValue(TeamInfo[team]->airDefenseExperience);
			lbox->Refresh();
		}
		ebox=(C_EditBox*)win->FindControl(CURRENT_NAME);
		if(ebox)
		{
			ebox->SetText(TeamInfo[team]->GetName());
			ebox->Refresh();
		}
		ebox=(C_EditBox*)win->FindControl(MISSION_STATEMENT);
		if(ebox)
		{
			ebox->SetText(TeamInfo[team]->GetMotto());
			ebox->Refresh();
		}
	}
}

void MakeNewTeamCB(long,short hittype,C_Base *)
{
	long i;
	int	tid;
	_TCHAR buffer[30];

	if(hittype != C_TYPE_LMOUSEUP)
		return;

	i=1;
	while(TeamInfo[i] && i < NUM_TEAMS)
		i++;

	if(i < NUM_TEAMS)
	{
		gSelectedTeam=static_cast<uchar>(i);
		gDrawTeam=i;
		AddTeam(gSelectedTeam,War);
		if(TeamInfo[gSelectedTeam])
		{
			TeamInfo[gSelectedTeam]->flags |= TEAM_ACTIVE;
			TeamInfo[gSelectedTeam]->SetFlag(GetUnusedFlag());
			FlagImageID[TeamInfo[gSelectedTeam]->GetFlag()][FLAG_STATUS]=1;
			TeamInfo[gSelectedTeam]->SetColor(GetUnusedColor());
			TeamColorUse[TeamInfo[gSelectedTeam]->GetColor()]=1;
			_stprintf(buffer,"%s #%1ld",gStringMgr->GetString(TXT_TEAM),gSelectedTeam);
			TeamInfo[gSelectedTeam]->SetName(buffer);
			_stprintf(buffer," ");
			TeamInfo[gSelectedTeam]->SetMotto(buffer);
			// Set this team at war with everyone
			for (tid=0; tid<NUM_TEAMS; tid++)
				{
				if (tid == gSelectedTeam)
					TeamInfo[gSelectedTeam]->stance[tid] = Allied;
				else

⌨️ 快捷键说明

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