?? gsapp.h
字號(hào):
// GsApp.h: interface for the CGsApp class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_GSAPP_H__7842FD95_EC83_46C5_B9BC_AD2098485F8A__INCLUDED_)
#define AFX_GSAPP_H__7842FD95_EC83_46C5_B9BC_AD2098485F8A__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class GSLIB_API CGsTimer
{
DWORD m_start_time;
DWORD m_delay_time;
BOOL m_is_set;
public:
CGsTimer(DWORD delay=0)
{
m_start_time = timeGetTime();
m_delay_time = delay;
m_is_set = false;
}
void Start(DWORD delay=0)
{
m_start_time = timeGetTime();
if(delay>0)
m_delay_time = delay;
m_is_set = true;
}
void Stop()
{
m_is_set = false;
m_delay_time = 0;
}
BOOL IsRuning()
{
if(timeGetTime()-m_start_time>m_delay_time)
{
return false;
}
return true;
}
BOOL IsEnd()
{
if(m_is_set)
{
if(timeGetTime()-m_start_time>m_delay_time)
{
m_is_set = false;
return true;
}
}
return false;
}
};
typedef std::map<int,CGsEngine*> GSES;
typedef std::list<CGsTask*> TASK_LIST;
class GSLIB_API CGsApp
{
friend CGsEngine;
friend CGsAppEx;
struct _WAIT_MSG{
UINT msg;
DWORD time_out;
DWORD time_pass;
DWORD time_start;
};
typedef std::list<_WAIT_MSG> WAIT_MSG_LIST;
protected:
BOOL m_isActive;
BOOL m_isReady;
DWORD m_dwAppTime;
DWORD m_dwBaseTime;
DWORD m_dwStopTime;
HWND m_hWnd;
HACCEL m_hAccel;
HMENU m_popupMenu, m_hMainMenu;
GSES m_gses;
float m_fLps;
BOOL m_isMMXSupport;
TCHAR m_strAppPath[255];
WAIT_MSG_LIST m_wait_msg_list;
TASK_LIST m_task_list;
public:
void SetAppTitle(LPCSTR strTitle);
VOID SetActive(BOOL bActive = TRUE);
void ProcessTask();
void SetTask(CGsTask* pTask, BOOL bAddOrDel=TRUE);
//應(yīng)用程序時(shí)間計(jì)數(shù),單位1ms
DWORD GetAppTimeEx(); //更新并獲取當(dāng)前時(shí)間
DWORD GetAppTime() { return m_dwAppTime; } //獲取當(dāng)前循環(huán)時(shí)間
DWORD GetCurTime();
DWORD GetWaitMSGTime() { return (m_wait_msg_list.empty()) ? 0 : !m_wait_msg_list.front().time_pass; }
float GetLoopPerSecond() { return m_fLps; }
//設(shè)備環(huán)境
SDxDeviceInfo* GetDxDeviceInfoPtr() { return m_pDeviceInfo; }
TCHAR* GetAppPath(TCHAR* szBuf);
HWND GetMainWnd() { return m_hWnd; }
BOOL IsMMXSupport() { return m_isMMXSupport; }
BOOL IsWaitingMSG() { return !m_wait_msg_list.empty(); }
BOOL InitApp(HWND hWnd);
HRESULT CleanupAllEngines();
VOID UpgrateAppMenu();
//if TRUE then run idle
virtual BOOL ProcessMSG(MSG &msg);
//Advance Wait msg loop
virtual UINT WaitForMessage(UINT msg_wait, DWORD time_out=0);
// Overridable power management (APM) functions
virtual LRESULT OnQuerySuspend( DWORD dwFlags );
virtual LRESULT OnResumeSuspend( DWORD dwData );
virtual VOID OnEngineConnected(CGsEngine* pEngine) { return; }
virtual BOOL DoIdle();
virtual VOID OnLpsChange(float fLps) { return; }
virtual VOID OnInitApp() { return; }
virtual VOID OnCleanupApp() { return; }
virtual VOID OnUpdateMenu(HMENU hMenu) { return; }
virtual INT Run();
virtual LRESULT MsgProc( UINT uMsg, WPARAM wParam, LPARAM lParam );
virtual VOID Pause( BOOL bPause );
virtual HRESULT MainLoop( DWORD dwTime ) { return S_OK; } //主循環(huán),由run()自動(dòng)調(diào)用
CGsApp();
virtual ~CGsApp();
protected:
//重載成員
BOOL m_isFrameMoving; // 自動(dòng)/單步運(yùn)行開(kāi)關(guān)
DWORD m_dwStepRate; // 單步模式的步速,單位1/10ms
BOOL m_isFullspeedMode; // 全速開(kāi)關(guān)
DWORD m_dwSpeedRate; // 主循環(huán)速率,單位ms,為1時(shí)Lps大約是800,為2時(shí)400
BOOL m_enableBackgroundActive; // 后臺(tái)工作開(kāi)關(guān)
TCHAR m_strWindowTitle[255]; // 應(yīng)用程序標(biāo)題
TCHAR m_strConfigFile[255];
WORD idr_main_accel; // Keyboard accelerator
WORD idr_main_menu; // Application menu
WORD idr_command_pause; // Command to pause
WORD idr_popup_menu; // Popup menu
WORD idr_full_speed_mode; // Let the application use all CPU time to reflash frame
WORD idr_choose_mode; // Choose display mode
WORD idr_app_exit;
SDxDeviceInfo *m_pDeviceInfo;
HRESULT (*m_fnConfirmDevice)(DDCAPS*, D3DDEVICEDESC7*);
HRESULT UpdateAllEngines( );
private:
VOID _UpdateMenu(HMENU hMenu);
};
//這是應(yīng)用程序的一個(gè)特殊情況,應(yīng)用程序只有唯一的engine
class GSLIB_API CGsAppEx : public CGsApp
{
CGsEngine* m_pEngine;
public:
CGsAppEx();
virtual ~CGsAppEx();
virtual VOID OnEngineConnected(CGsEngine* pEngine);
BOOL CreateApp( HINSTANCE hInst, TCHAR* strCmdLine, WORD idrIcon,
BOOL bFullScreen = false,
DWORD dwWindowWidth = 800, DWORD dwWindowHeight = 600,
WORD idr_menu = 0,
WORD idr_accel = 0,
WORD idr_command_speed = 0);
virtual BOOL DoIdle();
virtual LRESULT MsgProc( UINT uMsg, WPARAM wParam, LPARAM lParam );
protected:
};
#endif // !defined(AFX_GSAPP_H__7842FD95_EC83_46C5_B9BC_AD2098485F8A__INCLUDED_)
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -