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

📄 gameframe.h

📁 游戏框架
💻 H
字号:
// ***************************************************************
//  GameFrame   version:  1.0
//  -------------------------------------------------------------
//	File Name:	GameFrame.h
//	Created:	2007/07/18
//	Modified:	2007/07/18   17:42
//	Author:		William.Liang
//  Msn:		lwq49@msn.com
//  Email:		lwq49@21cn.com, lwq49@msn.com
//	Description:
//
//	Purpose:	
//  -------------------------------------------------------------
//  license:
//
//  The contents of this file are subject to the Mozilla Public
//  License Version 1.1 (the "License"); you may not use this file
//  except in compliance with the License. You may obtain a copy
//  of the License at http://www.mozilla.org/MPL/ Software dis-
//  tributed under the License is distributed on an "AS IS" 
//  basis, WITHOUT WARRANTY OF ANY KIND, either express or im-
//  plied. See the License for the specific language governing
//  rights and limitations under the License.
//
//  The Initial Developer of the Original Code is William.Liang .
//  Copyright (C) 2007 - All Rights Reserved.
// ***************************************************************
#ifndef GAME_FRAME_HEAD_FILE
#define GAME_FRAME_HEAD_FILE

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

//导入类头文件
#include "../ObjectCom/ObjectCom.h"
#include "../FrameCom/FrameCom.h"
#include "../ComService/ComService.h"
#include "../ServiceEnginer/ServiceEnginer.h"

interface IGameBody;
interface IGameSection;
interface IGameLayouterSink;
interface IGamePropertiesManager;
class CGameFrameDlg;
class CResourceLib;
class CSoundHelper;

//导出定义
#ifndef GAME_FRAME_CLASS
	#ifdef  GAME_FRAME_DLL
		#define GAME_FRAME_CLASS _declspec(dllexport)
	#else
		#define GAME_FRAME_CLASS _declspec(dllimport)
	#endif
#endif

//模块定义
#ifdef _DEBUG
	#define GAME_FRAME_DLL_NAME	TEXT("GameFrameD.dll")					//组件 DLL 名字
#else
	#define GAME_FRAME_DLL_NAME	TEXT("GameFrame.dll")					//组件 DLL 名字
#endif

//框架管理指针
typedef struct tagFrameManagerHandle{
	CGameFrameDlg*					pGameFrameDlg;				//框架指针
	LPGDI							lpGDI;						//HGE引擎指针
	CResourceLib*					pResourceLib;				//资源库
	CSoundHelper*					pSoundHelper;				//声音协助
	IGameBody*						pGameBody;					//游戏主体回调钩子
	CAttemperEngine*				pAttemperEngine;			//调度管理器
	CTimerEngine*					pTimerEngine;				//计时器引擎
	CActionEngine*					pActionEngine;				//动作引擎
	IClientSocket*					pClientSocket;				//客户网络引擎
	IGamePropertiesManager*			pIPropertiesManager;		//道具管理器
}FRAMEMANAGERHANDLE, *LPFRAMEMANAGERHANDLE;
//鼠标设置结构
struct tagMouseIconSetting{
	_CString			szMouseNormal;				//鼠标普通状态图标
	_CString			szMouseDown;				//鼠标点击状态图标
	_CString			szMouseWait;				//鼠标等待状态图标
	_CString			szMouseIcons;				//将普通/点击/等待3状态图标整合在一个纹理内
	UINT			nMouseNormalFrames;			//动画帧的长度
	UINT			nMouseDownFrames;
	UINT			nMouseWaitFrames;
};

struct tagPropertiesInfection{
	WORD						wMethod;
	WORD						wValueType;
	LPARAM						lpNumber;
	LPARAM						lpOriginal;
	LPVOID						lpTarget;
	LPVOID						lpParams;
};

struct tagPropertiesInfections{
	WORD						wType;
	WORD						wCount;
	union Times{
		DWORD					dwTimeLength;
		DWORD					dwTimes;
	}unTimes;
	tagPropertiesInfection*		pInfection;
};

//框架设置结构
typedef struct tagGameFrameSetting{
	_CString			szWindowTitle;				//窗体标题
	_CString			szLogFile;					//记录文件
	_CString			szAppPath;					//程序目录(含最后\符)
	bool			bHiddenMouse;				//隐藏鼠标
	bool			bDoNTSuspend;				//NT挂起
	bool			bWindowMode;				//窗口模式
	bool			bUseSound;					//使用声音
	bool			bUseSocketEngine;			//是否使用网络引擎
	bool			bEncrypted;					//是否加密网络数据
	bool			bUseTimerEngine;			//是否使用计时器
	bool			bUseActionEngine;			//是否使用动作引擎
	bool			bMouseMoveNotify;			//是否传递鼠标移动的消息给对象
	bool			bUsePropertiesManager;		//是否使用系统的道具管理器
	WORD			wScreenWidth;				//屏幕宽度
	WORD			wScreenHeight;				//屏幕高度
	WORD			wScreenBpp;					//屏幕颜色深度
	WORD			wFPS;						//FPS
	tagMouseIconSetting	tagMouseSet;			//鼠标设置
}GAMEFRAMESETTING;
//////////////////////////////////////////////////////////////////////////

#define VER_IGameLayouter INTERFACE_VERSION(1,1)
static const GUID IID_IGameLayouter={0xbd02b27d,0x7274,0x46a5,0x82,0x7b,0xc4,0x49,0x83,0xfe,0x9b,0x87};

//框架接口
interface IGameLayouter : public IUnknownEx
{
public:
	//加载布局
	virtual bool __cdecl LoadLayout(_CString szFileName="OMF.xml", _CString szRoot="", bool bIsAsync=false)=NULL;
	//是否异步
	virtual bool __cdecl IsAsynchronous()=NULL;
	//下一结点
	virtual bool __cdecl NextNode()=NULL;
	//返回结点
	virtual bool __cdecl GetNodePath(_CString szPath, LPVOID* lpParam=NULL, bool bBackwards=true)=NULL;
	//校验路径
	virtual bool __cdecl ValidNodePath(_CString szPath)=NULL;
	//注册回调处理器
	virtual bool __cdecl RegisterLayouterSink(IGameLayouterSink* pIGameLayouterSink)=NULL;
};

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

#define VER_IGameLayouterSink INTERFACE_VERSION(1,1)
static const GUID IID_IGameLayouterSink={0xbd02b27d,0x7274,0x46a5,0x82,0x7b,0xc4,0x49,0x83,0xfe,0x9b,0x88};

//框架接口
interface IGameLayouterSink : public IUnknownEx
{
public:
	//回调处理方法
	virtual void __cdecl Processer(_CString szNodeName, _CString szParentName, LPVOID lpParam)=NULL;
	//设置上级接口
	virtual void __cdecl SetGameLayouter(IGameLayouter*	pIGameLayouter, LPFRAMEMANAGERHANDLE pFMHandles)=NULL;
};

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

#define VER_IGameSectionEvent INTERFACE_VERSION(1,1)
static const GUID IID_IGameSectionEvent={0xbd02b27d,0x7274,0x46a5,0x82,0x7b,0xc4,0x49,0x83,0xfe,0x9b,0x96};

//框架接口
interface IGameSectionEvent : public IAttemperEngineSink// : public IUnknownEx
{
	//资源事件
public:
	//资源加载事件
	virtual void __cdecl OnLoading()=NULL;
	//资源加载完毕
	virtual void __cdecl OnLoadingFinish()=NULL;

	//事件回调
public:
	//环节初始化
	virtual bool __cdecl OnInitialize()=NULL;
	//环节非初始化
	virtual bool __cdecl OnUnInitialize()=NULL;
	//进入环节事件
	virtual bool __cdecl OnSectionIn(WORD wBeforeSection)=NULL;
	//离开环节事件
	virtual bool __cdecl OnSectionOut(WORD wAfterSection)=NULL;

	//事件回调
public:
	//鼠标移动
	virtual bool __cdecl OnMouseMove(float x, float y, UINT nComboKey)=NULL;
	//鼠标点击
	virtual bool __cdecl OnMouseClick(IGameObject* pGameObject, float x, float y, int nType, UINT nMessage, UINT nComboKey)=NULL;
	//鼠标点击
	virtual bool __cdecl OnMouseDBClick(IGameObject* pGameObject, float x, float y, UINT nMessage, UINT nComboKey)=NULL;
	//鼠标点击
	virtual bool __cdecl OnMouseUp(IGameObject* pGameObject, float x, float y, UINT nMessage, UINT nComboKey)=NULL;
	//鼠标点击
	virtual bool __cdecl OnMouseDown(IGameObject* pGameObject, float x, float y, UINT nMessage, UINT nComboKey)=NULL;
	//鼠标移入
	virtual bool __cdecl OnMouseIn(IGameObject* pGameObject, float x, float y, int nType, UINT nMessage, UINT nComboKey)=NULL;
	//鼠标移出
	virtual bool __cdecl OnMouseOut(IGameObject* pGameObject, float x, float y, int nType, UINT nMessage, UINT nComboKey)=NULL;
	//鼠标移过
	virtual bool __cdecl OnMouseOver(IGameObject* pGameObject, float x, float y, int nType, UINT nMessage, UINT nComboKey)=NULL;
	//键盘事件
	virtual bool __cdecl OnKeyPass(TCHAR nKey, UINT nFlag)=NULL;
	//键盘事件
	virtual bool __cdecl OnKeyUp(UINT nKey, UINT nFlag)=NULL;
	//键盘事件
	virtual bool __cdecl OnKeyDown(UINT nKey, UINT nFlag)=NULL;
	//视图激活
	virtual bool __cdecl OnActionAreaActive(WORD wActionArea)=NULL;
	//网络事件
	virtual void __cdecl OnNetworkEvent(COPYDATASTRUCT* lpCopyData)=NULL;
	//游戏事件
	virtual void __cdecl OnGameEvent()=NULL;
	//每帧事件
	virtual void __cdecl OnFrame()=NULL;
	//预渲染事件
	virtual void __cdecl OnPreRender(WPARAM wParam=NULL)=NULL;
	//渲染事件
	virtual void __cdecl OnRender(WPARAM wParam=NULL)=NULL;
	//系统控件消息
	virtual void __cdecl OnControlMessage(IGameObject* pIGameObject, WPARAM wParam,LPARAM lParam)=NULL;
	//用户消息
	virtual void __cdecl OnUserMessage(WPARAM wParam,LPARAM lParam)=NULL;
	//Windows消息处理函数
	virtual void __cdecl OnWindowMsgProce(UINT Msg, WPARAM wParam, LPARAM lParam)=NULL;

	//Add By Randy at 8.27
	//HEG的焦点控制处理
public:
	//失去焦点 Randy 8-27
	virtual void __cdecl OnFocusLostFunc()=NULL;
	//重获焦点 Randy 8-27
	virtual void __cdecl OnFocusGainFunc()=NULL;
};

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

#define VER_IGameBody INTERFACE_VERSION(1,1)
static const GUID IID_IGameBody={0xbd02b27d,0x7274,0x46a5,0x82,0x7b,0xc4,0x49,0x83,0xfe,0xAb,0x11};

//游戏主体接口
interface IGameBody : public IGameSectionEvent
{
	//公共方法
public:
	//设置游戏框架指针
	virtual void __cdecl SetFrameManagerHandles(LPFRAMEMANAGERHANDLE lpFMH)=NULL;
	//添加环节
	virtual bool __cdecl Add(IGameSection* pIGameSection, WORD wSectionID)=NULL;
	//切换环节
	virtual bool __cdecl SwitchSection(WORD wSectionID)=NULL;
	//返回环节
	virtual IGameSection* __cdecl GetSection(WORD wSectionID)=NULL;
	//返回当前环节
	virtual IGameSection* __cdecl GetCurrentSection()=NULL;
	//注册布局管理器
	virtual bool __cdecl RegisterLayouter(IGameLayouterSink* pGameLayouterSink=NULL)=NULL;
	//返回布局管理器
	virtual IGameLayouter* __cdecl GetLayouter()=NULL;
};

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

#define VER_IGameSection INTERFACE_VERSION(1,1)
static const GUID IID_IGameSection={0xbd02b27d,0x7274,0x46a5,0x82,0x7b,0xc4,0x49,0x83,0xfe,0x9b,0x86};

//框架接口
interface IGameSection : public IGameSectionEvent
{
	//公共方法
public:
	//设置游戏框架指针
	virtual void __cdecl SetFrameManagerHandles(LPFRAMEMANAGERHANDLE lpFMH)=NULL;
	//返回环节ID
	virtual WORD __cdecl GetSectionID()=NULL;
	//设置环节ID
	virtual void __cdecl SetSectionID(WORD wSectionID)=NULL;
	//环节切换是否有效
	virtual bool __cdecl IsValidSwitch(WORD wBeforeSectionID)=NULL;
	//资源标记为已加载
	virtual void __cdecl SetLoaded(bool bFlag)=NULL;
	//资源是否已加载
	virtual bool __cdecl IsLoaded()=NULL;
	//返回视图指针
	virtual CGameView* __cdecl GetGameView()=NULL;
};

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

#define VER_IGamePropertiesEvent INTERFACE_VERSION(1,1)
static const GUID IID_IGamePropertiesEvent={0xbd02b27d,0x7274,0x46a5,0x82,0x7b,0xb4,0x49,0x83,0xfe,0xac,0x96};

interface IGamePropertiesEvent
{
public:
	// 目标选择后的回调事件
	virtual void __cdecl OnChoosedTarget(LPVOID lpParams, IGameObject* pIGameObject)=NULL;
	// 道具使用时间过后的回调事件
	virtual void __cdecl OnTimeOut(IGameObject* pIGameObject=NULL)=NULL;
	// 效果结束
	virtual void __cdecl OnEffectFinished(IGameObject* pIGameObject=NULL)=NULL;
};

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

#define VER_IGameProperties INTERFACE_VERSION(1,1)
static const GUID IID_IGameProperties={0xbd02b27d,0x7274,0x46a5,0x82,0x7b,0xb4,0x49,0x83,0xfe,0xac,0x87};

interface IGameProperties : public IGamePropertiesEvent, public IUnknownEx
{
public:
	// 设置道具ID
	virtual void __cdecl SetPropertiesID(DWORD dwID)=NULL;
	// 返回道具ID
	virtual DWORD __cdecl GetPropertiesID()=NULL;
	// 选择目标
	virtual void __cdecl ChooseTarget()=NULL;
	// 放弃使用
	virtual void __cdecl ChooseCancel()=NULL;
	// 是否选择目标中
	virtual bool __cdecl IsChoosing()=NULL;

	// 设置影响效果
	virtual void __cdecl SetInfection(tagPropertiesInfections* pInfections)=NULL;
	// 执行道具作用
	virtual void __cdecl Execute(LPVOID lpParams=NULL, IGameObject* pIGameObject=NULL)=NULL;
	// 执行道具作用
	virtual void __cdecl Infection(LPVOID lpParams=NULL, IGameObject* pIGameObject=NULL)=NULL;
	// 执行特殊道具
	virtual void __cdecl SpecialInfectionAction(LPVOID lpParams=NULL, IGameObject* pIGameObject=NULL)=NULL;
	// 复原道具影响
	virtual void __cdecl UnInfection(IGameObject* pIGameObject=NULL)=NULL;
	// 是否执行中
	virtual bool __cdecl IsExecuting()=NULL;

	// 显示效果
	virtual void __cdecl ShowEffect(LPVOID lpParams=NULL, IGameObject* pIGameObject=NULL)=NULL;
	// 是否效果播放中
	virtual bool __cdecl IsEffecting()=NULL;

	// 返回描述
	virtual LPCTSTR __cdecl GetDescription()=NULL;
	// 返回道具执行时长
	virtual DWORD __cdecl GetInfectionTime()=NULL;
	// 返回可选定目标
	virtual DWORD __cdecl GetTargetCount()=NULL;
};

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

#define VER_IGamePropertiesManager INTERFACE_VERSION(1,1)
static const GUID IID_IGamePropertiesManager={0xbd02b27d,0x7274,0x46a5,0x82,0x7b,0xb4,0x49,0x83,0xfe,0xac,0x89};

interface IGamePropertiesManager : public IUnknownEx
{
	// 添加道具
	virtual void __cdecl Add(IGameProperties* pIGameProp, INT_PTR nPosition = LISTTEMPLATE_LAST_ITEM)=NULL;
	// 移除道具
	virtual void __cdecl Remove(INT_PTR nIndex)=NULL;
	// 返回道具
	virtual IGameProperties* __cdecl Get(INT_PTR nIndex)=NULL;

	// 设置为选择目标模式
	virtual void __cdecl SetChoose(IGameProperties* pGameProperties)=NULL;
	// 系统使用道具(通知使用)
	virtual bool __cdecl SystemExecute(LPVOID lpParams)=NULL;
	// 设置当前道具
	virtual void __cdecl ExecuteNotify(IGameProperties* pGameProperties, WORD wType = 0, bool bFlag=true)=NULL;
	// 返回当前道具
	virtual IGameProperties* __cdecl GetCurrent(DWORD dwPropertiesID=0, bool bFlag=false)=NULL;
	// 返回当前要选择目标的道具
	virtual IGameProperties* __cdecl GetChoose()=NULL;
	// 是否有道具使用中
	virtual BOOL __cdecl IsUsing(DWORD dwPropertiesID=0)=NULL;
	// 是否有道具选择目标中
	virtual BOOL __cdecl IsChoosing()=NULL;
	// 设置最大道具携带数
	virtual void __cdecl SetMax(WORD wMax)=NULL;
	// 设置关联的层对象
	virtual void __cdecl SetLayer(CGameLayer* pLayer)=NULL;
};

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

//导出类头文件
#ifndef GAME_FRAME_DLL
	#include "./GameLayouter.h"
	#include "./GameFrameDlg.h"
	#include "./GameBody.h"
	#include "./GameSection.h"
	#include "./Properties.h"
	#include "./SoundHelper.h"
	#include "./PropertiesManager.h"
#endif

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

#endif

⌨️ 快捷键说明

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