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

📄 interfa1.cpp

📁 赤壁之战的游戏源代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/////////////
//	Interface-1.cpp	:	v0010
//	Written by		:	Li Haijun
//	Compiler		:	Microsoft Visual C++ 4.0 & DirectX
//	Library			:	DDraw.Lib
//	Copyright (C)	:	1996 WayAhead Corporation 
//	v0010			:	Jan.3.1997
/////////////
// implementation file
// This file provide basic interface function 
//////////////////////////////
#include "stdafx.h"
#include <stdio.h>

#include "Assert.h"		// debug function
#include "puthz.h"		// to include the string output function
#include "DDCompo.h"
#include "CBGame.h"		// to include the GAME
#include "cbdraw.h"		// Liu Gang
#include "cbdata.h"
#include "cbmini.h"		// to use the function MINI_Update 
#include "cbbuild.h"	// for function BUILD_IfEnable  only
#include "cbmouse.h"	// for set the mouse state
#include "cbrun.h"		// for the functio RUN_FIGHT_Single and RUN_IfFight



////////////////////////Donghai///////////////////////////
#include "Network.h"
#include "net_face.h"

extern	BYTE    DP_SendMessageBuff[BUFFER_MAX_BYTE];
extern int						DP_NetworkInterface(int	Action, HWND   MainWndHandle);
extern int						DP_ProviderNO;
extern LPDIRECTPLAY				DP_lpIDC;
extern struct	EnumSessionCallback		DP_EnumSessionCb[256];
extern LPSTR	DP_FullName;
extern LPSTR	DP_NickName;
extern struct	EnumSessionCallback		DP_EnumSessionCb[256];
extern int		DP_SessionNO;
struct	DP_NetworkInfor		DP_NetPlayerInfor[5];
void	DP_SendInitNetwork();
extern	BOOL				GAME_bNetwork;
extern	int					DH_JoinPlayer[5];
extern	PlayerInfo			DP_PlayerInformation[MAX_PLAYERS];
extern	int	Send_Destroy_Me(void);
extern	int	Send_Destroy_Other(int	PlayerNum);
extern	int	CB_Counter;
/////////////////////////////////////////////////////////////////////////
//例子:
//DP_EnumSessionCb[i].PointDPGameDesc.szSessionName[j]='\0';
//DP_EnumSessionCb[i].PointDPGameDesc.dwSession=0;
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////


#include "Marco.h"		// the define of all macro
#include "DDButton.h"	// to include button's define 
#include "DDComUn.h"	// to include command unit's defnie
#include "DDBitmap.h"	// to include class CDBitmap's define
#include "DDMenu.h"		// to include the menu
#include "DDCheck.h"	// to include the check-box
#include "DDList.h"		// to include the list
#include "DDCombo.h"	// to include the combo-box
#include "DDScroll.h"	// to include the scroll-bar
#include "cbperbar.h"	// to inlcude the percent bar
#include "cbavi.h"
#include "ddtext.h"

#include "Interfac.h"
#include "Interfa1.h"
#include "interfa2.h"


#include "cbarray.h"	// to include the array operation define
#include "l_text.h"		// to include the read prompt information function writeen by LWC
// temperory
#include "cbprompt.h"

////////////////////////////
#include "l_scan.h"
#include "l_allbmp.h"
extern char	bmpfilename[30];
extern char	listfilename[30];
/////////////////////////////////////

//#define	FACE_DEBUG

extern class CDDCursor MAIN_Cursors[4];	// declared in CBMain.cpp
//////////////////////////////////////
// this is the main palettes in play state
extern	class CDDPalette	pal, palMain;
////////////////////////////////////////
//	the flag for pause button
BOOL	bPause = FALSE;
// the following four string is used to store the network message that passed from the others
extern class	CDDString	Net_Message_1 ;
extern class	CDDString	Net_Message_2 ;
extern class	CDDString	Net_Message_3 ;
extern class	CDDString	Net_Message_4 ;

extern class	CDDString	Net_EchoPrompt_Message ;
////////////////////////////////////////
///
extern char	DIALOG_BUF[MAX_DIALOG_LETTER+1];	//to restore the string input to dialog
/////////////////////////////////////////////
//		the flag for message box
extern	BOOL	FACE_bMessageBox;
//////////////////////////////////
extern class	CDDBitmap	*	pAllBitmap[MAX_BITMAP];		//to store all bitmap's pointer 
extern class	CDDButton	*	pAllButton[MAX_BUTTON];		//to restore all button's pointer
extern class	CDDButton	*	pCurrentButton;		// a pointer point to the current button
extern class	CDDButton	*	pAllCommandButton[MAX_COMMANDBUTTON];		//to restore all command button's pointer
extern class	CDDCheckBoxUnit	*	pAllCheckBoxUnit[MAX_CHECKBOXUNIT];	//to restore all check-box's pointer
extern class	CDDListUnit	*	pAllListUnit[MAX_LISTUNIT]; //to record all list-unit's pointer
extern class	CDDComboBox	*	pAllComboBox[MAX_COMBOBOX];	//to record all combo-box's pointer
extern class	CDDString	*	pAllString[MAX_TEXT] ;		// to store the four network game player's name in this

extern class	CDDScrollBar *	pAllScrollBar[MAX_SCROLLBAR];
// the array to record all saving files
extern class	CMyFile		AllFile[ MAX_SAVEFILE ];	// to handle all save file
extern class	CMyFile		MapFile[ MAX_MAPS ] ;		// to handle all maps file
//	the pointer array for all you general that can been select for establish battle unit
extern	struct DATA_GENERAL_STRUCT * pAllGeneral[ MAX_ONEKINGGENERAL ];
// major parameter for bitmap(it record the current state of operate)
extern	int		nPreviousButtonState;	// previous button's state,0-up,1-down,2-disable,3-focus,4-disable,5-hide
extern	int		nCurrentButtonState;	// current button's state,0-up,1-down,2-disable,3-focus,4-disable,5-hide
extern	int		nPreviousCheckBoxState;	// previous check-box's state,0-uncheck-up,1-uncheck-down,2-check-up,3-check-down,4-disable
extern	int		nCurrentCheckBoxState;	// current check-box's state,0-uncheck-up,1-uncheck-down,2-check-up,3-check-down,4-disable
extern	int		nCurrentListState;	// current List's state,0-up,1-down,2-focus,3-disable,4-hide
// current command unit pointer
extern class	CDDCommandUnit	* pCurrentMainCommandUnit;
extern class	CDDCommandUnit	* pCurrentCommandUnit;	// a pointer point to the name of current command unit
// to store these value for the command unit when save and load 
int		FACE_CurrentCommandUnitID = COMMANDUNIT_NONE ;
DWORD	FACE_CurrentCommandUnitFlag = 0 ;

extern struct	PROMPT_BLOCK	FACE_CURRENT_PROMPT_BLOCK; // a extern struct of current prompt block
///////////////////////////////////////////
//	to decide which unit of number to show
///////////////////////////////////////////
extern BOOL	nNumState;			//	0 -> to show   1 --- 10
								//  1 -> to show   11 -- 20
// a pointer of the wait picture
extern class CDDBitmap	* FACE_pWaitBitmap ;


////////////////////////////////////
//	       all menu
////////////////////////////////////
CDDMenu		* CurrentMenu;
CDDMenu		Menu_Main;
CDDMenu		Menu_NewGame;
CDDMenu		Menu_MainLoad;
CDDMenu		Menu_NetWork;
CDDMenu		Menu_NetWork_InputName;
CDDMenu		Menu_NetWork_Serial;
CDDMenu		Menu_NetWork_Internet;
CDDMenu		Menu_NetWork_Ipx;
CDDMenu		Menu_NetWork_SetNet;
CDDMenu		Menu_NetWork_SetNet_SelectMap;
CDDMenu		Menu_NetWork_SetNet_SelectKing;
CDDMenu		Menu_NetWork_Modem;
/////////////////////////////
//	system menu structure
CDDMenu		Menu_System;
CDDMenu		Menu_System_Save;
CDDMenu		Menu_System_Load;
CDDMenu		Menu_System_Query;
CDDMenu		Menu_System_Query_General_1;
CDDMenu		Menu_System_Query_General_2;
CDDMenu		Menu_System_Query_Army;
CDDMenu		Menu_System_Query_Building;
CDDMenu		Menu_System_Query_Campaign_Mission;
CDDMenu		Menu_System_Option;
CDDMenu		Menu_System_Help;
CDDMenu		Menu_System_Help_Operate;
CDDMenu		Menu_System_Help_Icon;
CDDMenu		Menu_System_Help_Game;
CDDMenu		Menu_System_Exit;
///////////////////////////
//	menu to select general
CDDMenu		Menu_Select_General;
//	menu to show the information of the generals want to single battle
CDDMenu		Menu_Single ;
CDDMenu		Menu_Single_Reject ;
CDDMenu		Menu_Single_Result ;
/////////////////////////////////////
// menu to show some error and prompt information
CDDMenu		Menu_Outter_Link_Error ;
CDDMenu		Menu_Inner_Link_Error ;
CDDMenu		Menu_Inner_Player_Lose ;
////////////////////////////////////////////////////
// menu to show the result of this game
CDDMenu		Menu_Battle_Result ;

///////////////////////////////
// to declear command unit
///////////////////////////////
extern class	CDDCommandUnit	buCancel;

extern class	CDDCommandUnit	buPeasant_Chao;
	extern class	CDDCommandUnit	buBuild_Chao_PageOne;
	extern class	CDDCommandUnit	buBuild_Chao_PageTwo;
extern class	CDDCommandUnit	buPeasant_Liu;
	extern class	CDDCommandUnit	buBuild_Liu_PageOne;
	extern class	CDDCommandUnit	buBuild_Liu_PageTwo;
extern class	CDDCommandUnit	buFightUnit;
	extern class	CDDCommandUnit	buLineUp_PageOne;
	extern class	CDDCommandUnit	buLineUp_PageTwo;
	extern class	CDDCommandUnit	buStratagem;	// stratagem --> 计谋

extern class	CDDCommandUnit	buSingleSoldier;
extern class	CDDCommandUnit	buRegimentSoldier;
extern class	CDDCommandUnit	buTransportShip;

extern class	CDDCommandUnit	buMainBuilding_Chao;
extern class	CDDCommandUnit	buMainBuilding_Liu;
extern class	CDDCommandUnit	buLumber;
extern class	CDDCommandUnit	buWeaponFactory;
extern class	CDDCommandUnit	buShop;
extern class	CDDCommandUnit	buFootmanSchool;
extern class	CDDCommandUnit	buKnightSchool;
extern class	CDDCommandUnit	buBowmanSchool;
extern class	CDDCommandUnit	buVehiclemanSchool;
extern class	CDDCommandUnit	buShipyard;

extern class	CDDButtonUnit	m_nSmallNumber;
extern class	CDDButtonUnit	m_nBigNumber;
/////////////////////////////////////
//	main interface frame (four part)
/////////////////////////////////////
//	process bar veriable
extern class	CPercentBar FACE_Power;		// to show the power of a general
extern class	CPercentBar FACE_Blood;		// to show the blood of a general
extern class	CPercentBar FACE_Process;	// to show the process of a product to be producted

//			  ClassName   VaribleName         BitmapSize   top-left point	 bottom-right point
extern class CDDBitmap	bmGeneralBackground;	// the background of the general head picture when it show in prompt region or in the single_battle menu
extern class CDDBitmap	FACE_GeneralFace;

extern class CDDBitmap		bmPromptArea;	//(120, 169) -> (501, 158) ---------------

extern class CDDBitmap	sTop;			//(640,50)  -> (0,0)-----------------(639,49)
extern class CDDBitmap	sBottom;		//(640,24)  -> (0,456)---------------(639,479)
extern class CDDBitmap	sLeft;		//(24,406)  -> (0,50)----------------(23,455)
extern class CDDBitmap	sRight;		//(157,406) -> (483,50)--------------(639,455)

extern class CDDBitmap	sInputName;		//(216,26) -> (211,337)--------------(427,362)
/////////////////////////////////////
// to store the six golbal list pointers for establish menu
////////////////////////////////////
extern class	CDDList	* pEstablishList_1;
extern class	CDDList	* pEstablishList_2;
extern class	CDDList	* pEstablishList_3;
extern class	CDDList	* pEstablishList_4;
extern class	CDDList	* pEstablishList_5;
extern class	CDDList	* pEstablishList_6;

/////////////////////////////////////
// to define the single battle unit
/////////////////////////////////////
struct	SINGLE_UNIT		Single_Battle ;
/////////////////////////////////////
//	extern function
/////////////////////////////////////
extern int	 ChangeProgramState( int nState, int nButtonID );


//////////////////////////////////////////////////////////
// to define this global veriable just used in cbmain.cpp
BOOL		IsInSetNetMenu = FALSE ;
////////////////////////////////////////
//		 to show the spececal menu
////////////////////////////////////////
BOOL	FACE_ShowMenu( LPARAM lParam, int CommandId /*= 0 */)
{
	CScan_read	FSCAN;

	int		BitmapFileId;
	char	fname[30];
	POINT	pShow;
	int		nWidth;
	int		nHeight;
	int		nID;
	int		nState;
	
	MOUSE_SetState( MOUSE_STATE_NONE, TRUE ) ;

	if( lParam == MENU_MAIN )
	{
		strcpy( fname,"set\\m_main.exp" );
		FSCAN.scan_open (fname);
    
		CurrentMenu = &Menu_Main;
		Menu_Main.SetID( lParam );
		// to set the smallest box of this menu
		FSCAN.l_scan(sscanf (FSCAN.expand_buf,"%d%d%d%d", &pShow.x, &pShow.y, &nWidth, &nHeight)); 
		//fscanf( fp, "%d%d%d%d", &pShow.x, &pShow.y, &nWidth, &nHeight);
		Menu_Main.SetPosition(pShow.x, pShow.y);
		Menu_Main.SetSize(nWidth, nHeight);
		// to preload all button of this menu
		for(int i=0; i<5; i++ )
		{
			Menu_Main.m_MenuButtonUnit.m_pButton[i] = new CDDButton;
			FSCAN.l_scan(sscanf (FSCAN.expand_buf,"%d%d%d%d%d%d\n", &BitmapFileId, &pShow.x, &pShow.y, &nWidth, &nHeight, &nID)); 
			//fscanf( fp, "%d%d%d%d%d%d", &BitmapFileId, &pShow.x, &pShow.y, &nWidth, &nHeight, &nID);
			if( !Menu_Main.m_MenuButtonUnit.m_pButton[i]->PreLoad( BitmapFileId, pShow.x, pShow.y, nWidth, nHeight) )
			{
				FSCAN.scan_close ();
				return FALSE;
			}
			Menu_Main.m_MenuButtonUnit.m_pButton[i]->SetID(nID);
		}
		FSCAN.scan_close ();
		Menu_Main.Show();
		Menu_Main.Update();
		//WriteLogFile( "AAA.log", "BBB\n" );
		return TRUE;
	}
	else if( lParam == MENU_MAIN_NEWGAME )
	{
		strcpy( fname, "set\\M_newgam.exp" );
		FSCAN.scan_open (fname);

⌨️ 快捷键说明

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