?? asl_winapp.h
字號(hào):
//-----------------------------------------------------------------------------
//
// ____ Azure Star Game Engine 藍(lán)星游戲引擎 ____
//
// Copyright (c) 2006, 藍(lán)星工作室
// All rights reserved.
//
// 文件名稱: asl_winapp.h
// 摘 要: 應(yīng)用程序框架類定義
//
// 當(dāng)前版本: 1.0
// 作 者: 湯 祺
// 創(chuàng)建日期: 2006-7-23
//
//-----------------------------------------------------------------------------
#ifndef ASL_WINAPP_INCLUDE
#define ASL_WINAPP_INCLUDE
#pragma once
#include "asl_utils.h"
#include "asl_timer.h"
#include "asl_screen.h"
#include "asl_input.h"
#include "asl_audio.h"
#include "asl_gui.h"
//-----------------------------------------------------------------------------
namespace ASL
{
//-----------------------------------------------------------------------------
// 類名: ASLWinApp
// 功能: 應(yīng)用程序框架類
// 本類提供了基本的應(yīng)用程序框架, 封裝了窗口創(chuàng)建, 程序運(yùn)行, 消息處理等
// 函數(shù)開發(fā)者只需自行定義Init()函數(shù)和OnIdle()函數(shù), 即可運(yùn)行程序, 極大
// 的簡化了開發(fā)過程.
//-----------------------------------------------------------------------------
class ASLWinApp
{
// 構(gòu)造/析構(gòu)函數(shù)
public:
ASLWinApp(void);
virtual ~ASLWinApp(void);
// 操作函數(shù)
public:
// 初始化應(yīng)用程序
virtual void Init(void) = 0;
// 運(yùn)行應(yīng)用程序
void Run(void);
// 顯示異常內(nèi)容
inline void ShowException(const ASLException &e) const
{ MessageBox(m_hWnd, e.GetErrorMessage(), "錯(cuò)誤", MB_OK | MB_ICONSTOP); }
// 退出程序
inline void Quit(void) { PostQuitMessage(0); }
// 鎖定每秒幀速
inline void LockFPS(int fps)
{ m_dwFixedDelta = fps > 0 ? TIMER_PRECISION / fps : 0; }
// 取窗口句柄
inline HWND GetWindowHandle(void) const { return m_hWnd; }
// 取應(yīng)用程序句柄
inline HINSTANCE GetInstanceHandle(void) const { return m_hInst; }
// 取每秒幀速
inline int GetFPS(void) const { return m_nFps; }
// 取幀間隔時(shí)間
inline float GetDelta(void) const { return m_fDelta; }
// 程序是否在活動(dòng)狀態(tài)
inline bool IsActive(void) const { return m_bActive; }
// 保護(hù)函數(shù)
protected:
// 消息處理回調(diào)函數(shù)
static LRESULT CALLBACK _WndProc(HWND hWnd, UINT message, WPARAM wParam,
LPARAM lParam);
// 創(chuàng)建應(yīng)用程序
void Create(int width, int height, LPCSTR wndName, bool fullScreen = false,
bool showCursor = false, bool waitVSync = true, LPCSTR iconName = NULL);
// 空閑處理
virtual void OnIdle(void) {}
// 關(guān)閉前處理
virtual bool OnClose(void) { return true; }
// 激活/取消激活處理
virtual void OnActivate(bool bActive) {}
// 私有變量
private:
bool m_bActive; // 是否活動(dòng)
bool m_bShowCursor; // 是否顯示鼠標(biāo)光標(biāo)
HWND m_hWnd; // 主窗口句柄
HINSTANCE m_hInst; // 應(yīng)用程序句柄
DWORD m_dwFixedDelta; // 設(shè)定的幀間隔
ASLTimer m_Timer; // 計(jì)時(shí)器
int m_nFps; // 實(shí)際每秒幀速
float m_fDelta; // 實(shí)際幀間隔
private:
static const int TIMER_PRECISION = 10000;
};
extern ASLWinApp *Application;
} // namespace ASL
#endif // ASL_WINAPP_INCLUDE
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -