📄 gameframedlg.h
字号:
// ***************************************************************
// GameFrameDlg version: 1.0
// -------------------------------------------------------------
// File Name: GameFrameDlg.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_DLG_HEAD_FILE
#define GAME_FRAME_DLG_HEAD_FILE
#pragma once
#include "GameFrame.h"
#include "ResourceLib.h"
#include "SoundHelper.h"
#include "BufferTemplet.h"
#include "PropertiesManager.h"
#include "Mouse.h"
//////////////////////////////////////////////////////////////////////////
//键盘输入缓冲结构
struct tagKeyBoardBuffer{
UINT nMessage; //up/down/char
UINT nKey; //vk-code/char
UINT nFlag; //flag for window
};
//鼠标输入缓冲结构
struct tagMouseBuffer{
int nType; //move/down/up
UINT nMessage; //msg id
UINT nComboKey; //MK_CONTROL/MK_LBUTTON/MK_MBUTTON/MK_RBUTTON/MK_SHIFT
UINT nWheel; //wheel value
float x; //x
float y; //y
};
//帧统计结构
struct tagFrameCount{
long ElapseFrames; // 总共过去了的帧数计数器
unsigned int PreNetworkPacketElapseFrames; // 每个通信包之间已过去了的帧数计数器
unsigned int PreStatusElapseFrames; // 每次状态检查测后已过去了的帧数计数器
unsigned int PreSecondElapseFrames; // 每秒已过去了的帧数计数器
};
#define INPUT_MOUSE_MASK MK_LBUTTON|MK_MBUTTON|MK_RBUTTON
//***************************************************************
// 游戏框架窗口,封装了游戏主要流程。大体上将游戏划分为初始
// 化、开始、结束三个环节,并在每帧处理上,将鼠标、键盘的消
// 息分发至下层的游戏主体处理。
// 所有的系统级管理对象均由游戏框架窗口初始化,并一级级传递
// 至下层对象。
//***************************************************************
class GAME_FRAME_CLASS CGameFrameDlg
{
protected:
tagFrameCount m_FrameCount;
//内部数据
protected:
//框架设定
GAMEFRAMESETTING m_GameFrameSetting;
//事件控制
private:
hgeInputEvent m_hgeInputEvent; // 输入事件
bool m_bHasInputEvent; // 是否有事件
float m_fLastX, m_fLastY; // 鼠标最后坐标位置
IGameObject* m_pCurrentObject; // 当前鼠标上的对象
IGameObject* m_pFocusObject; // 当前焦点对象(被鼠标点击后的非静态对象)
CBufferTemplate<tagKeyBoardBuffer> m_pKeyBoardBuffer; // 键盘缓冲
CBufferTemplate<tagMouseBuffer> m_pMouseBuffer; // 鼠标缓冲
tagKeyBoardBuffer m_mKeyProcBuffers[DEFAULT_BUFFER_SIZE];
tagMouseBuffer m_mMouseProcBuffers[DEFAULT_BUFFER_SIZE];
//鼠标对象
protected:
CMouse* m_pMouseIcon; // 鼠标图标
protected:
FRAMEMANAGERHANDLE m_FMHandles; // 管理句柄集合
//函数定义
public:
//构造函数
CGameFrameDlg();
//析构函数
virtual ~CGameFrameDlg();
//框架事件
public:
//游戏初始化
virtual bool __cdecl GameInit();
//游戏开始
virtual void __cdecl GameStart();
//鼠标事件
virtual void __cdecl OnMouseEvent();
//键盘事件
virtual void __cdecl OnKeyPassEvent();
//游戏退出
virtual void __cdecl GameExitInstanct();
//Windows消息处理函数
virtual void __cdecl WindowMsgProce(UINT Msg,WPARAM wParam,LPARAM lParam);
//数据获取
public:
//返回绘图内核
virtual LPGDI __cdecl GetGDI();
//返回时间引擎
virtual CTimerEngine* __cdecl GetTimerEngine();
//返回动作引擎
virtual CActionEngine* __cdecl GetActionEngine();
//返回纹理库
virtual CResourceLib* __cdecl GetResourceLib();
//返回音乐库附助
virtual CSoundHelper* __cdecl GetSoundHelper();
//返回道具管理器
virtual IGamePropertiesManager* __cdecl GetPropertiesManager();
//返回框架设定
virtual GAMEFRAMESETTING* __cdecl GetGameFrameSetting();
//回调函数
public:
//每帧的回调函数
virtual bool __cdecl FrameFunc(void);
//渲染的回调函数
virtual bool __cdecl RenderFunc(void);
//设置游戏主体的事件回调接口
virtual bool __cdecl SetGameBodySink(IGameBody* pGameBody);
//帧统计
virtual void __cdecl FrameCount();
//Add By Randy at 8.27
//HEG的焦点控制处理
public:
//失去焦点回调函数
virtual bool __cdecl FocusLostFunc(void);
//重获焦点回调函数
virtual bool __cdecl FocusGainFunc(void);
//钩子函数
protected:
//帧处理的钩子函数
static bool g_FrameFunc(void);
//渲染处理的钩子函数
static bool g_RenderFunc(void);
//失去焦点回调函数 Randy 8-27
static bool g_FocusLostFunc(void);
//重获焦点回调函数 Randy 8-27
static bool g_FocusGainFunc(void);
};
//////////////////////////////////////////////////////////////////////////
extern GAME_FRAME_CLASS CGameFrameDlg* theGame;
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -