TanksDlg.h
上传用户:royluo
上传日期:2007-01-05
资源大小:1584k
文件大小:7k
源码类别:

游戏

开发平台:

Visual C++

  1. /*****************************************************************************
  2. *                                                                             
  3. *   TanksDlg.h
  4. *                                                                             
  5. *   Electrical Engineering Faculty - Software Lab                             
  6. *   Spring semester 1998                                                      
  7. *                                                                             
  8. *   Tanks game                                                                
  9. *                                                                             
  10. *   Module description: Interface of the main tanks dialog class.
  11. *                       
  12. *                                                                             
  13. *   Authors: Eran Yariv - 28484475                                           
  14. *            Moshe Zur  - 24070856                                           
  15. *                                                                            
  16. *                                                                            
  17. *   Date: 23/09/98                                                           
  18. *                                                                            
  19. ******************************************************************************/
  20. #if !defined(AFX_TANKSDLG_H__22F0A6A7_E0C9_11D1_9738_E570871C4325__INCLUDED_)
  21. #define AFX_TANKSDLG_H__22F0A6A7_E0C9_11D1_9738_E570871C4325__INCLUDED_
  22. #if _MSC_VER >= 1000
  23. #pragma once
  24. #endif // _MSC_VER >= 1000
  25. #include "resource.h"
  26. #include "ShieldStatus.h"
  27. #include "AmmoStatus.h"
  28. #include "BonusStatus.h"
  29. #include "GameConsts.h"
  30. #include "DrawDib.h"
  31. #include "KbdManager.h"
  32. #include "GameManager.h"
  33. #include <servermgmtdlg.h>
  34. #include "chatdlg.h"
  35. class CTanksApp;    // Pre-declaration
  36. /////////////////////////////////////////////////////////////////////////////
  37. // CTanksDlg dialog
  38. typedef enum {
  39.     GAME_OFF,   // Game is not active, all threads are dead
  40.     GAME_ON,    // Game is active, threads are alive, local tank is alive
  41.     GAME_OVER   // Game is active, threads are alive, local tank is dead
  42. } GameStateType;
  43.                 
  44. /* The following table describes how the game changes from state to state:
  45.     This table might change in the future as comm. with the server is introduced.
  46.    +---------------+-----------------+-------------------+------------------+
  47.    | From state    | to GAME_OFF     | to GAME_ON        | to GAME_OVER     |
  48.    +===============+=================+===================+==================+
  49.    | GAME_OFF      | (already there) | User starts a new | (no direct path) |
  50.    |               |                 | game              |                  |
  51.    +---------------+-----------------+-------------------+------------------+
  52.    | GAME_ON       | (no direct path)| (already there)   | Local tank dies  |
  53.    |               |                 |                   |                  |
  54.    +---------------+-----------------+-------------------+------------------+
  55.    | GAME_OVER     | User presses any| (no direct path)  | (already there)  |
  56.    |               | key             |                   |                  |
  57.    +---------------+-----------------+-------------------+------------------+
  58. */
  59. class CTanksDlg : public CDialog
  60. {
  61. // Construction
  62. public:
  63. CTanksDlg(CWnd* pParent = NULL); // standard constructor
  64.     virtual ~CTanksDlg ();
  65.     // Local tank report functions:
  66.     void SetShieldLevel (UINT);
  67.     void SetShellsCount (UINT);
  68.     void SetBulletsCount (UINT);
  69.     void SetMinesCount (UINT);
  70.     void SetAerialSupport (BOOL);
  71.     void SetFastFireRate (BOOL);
  72.     BOOL OnEraseBkgnd(CDC* pDC);
  73.     BOOL IsGameOn ()
  74.     {   return (GAME_OFF != m_GameState); }
  75.     BOOL PreTranslateMessage(MSG* pMsg);    // respond for user input
  76.     void MarshalChatMsg(DPID dwDPlayID, DWORD dwTankID, LPCSTR szMsg);
  77. // Dialog Data
  78. //{{AFX_DATA(CTanksDlg)
  79. enum { IDD = IDD_TANKS_DIALOG };
  80. CAmmoStatus     m_AmmoStatus;
  81. CBonusStatus    m_BonusStatus;
  82. CShieldStatus   m_ShieldStatus;
  83. CButton         m_Map;
  84. //}}AFX_DATA
  85. // ClassWizard generated virtual function overrides
  86. //{{AFX_VIRTUAL(CTanksDlg)
  87. protected:
  88. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
  89. //}}AFX_VIRTUAL
  90. // Implementation
  91. protected:
  92. HICON m_hIcon;
  93. // Generated message map functions
  94. //{{AFX_MSG(CTanksDlg)
  95. virtual BOOL OnInitDialog();
  96. afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
  97. afx_msg void OnPaint();
  98. afx_msg HCURSOR OnQueryDragIcon();
  99. afx_msg void OnExit();
  100. afx_msg void OnHelpAbout();
  101. afx_msg void OnKbdMapping();
  102. afx_msg void OnNewGame();
  103. afx_msg void OnSetComm();
  104. afx_msg void OnSetGame();
  105. afx_msg void OnStopGame();
  106. afx_msg void OnSoundMute();
  107. afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct);
  108. afx_msg void OnClose();
  109. afx_msg BOOL OnQueryNewPalette();
  110. afx_msg void OnPaletteChanged(CWnd* pFocusWnd);
  111. afx_msg void OnServerMgmt();
  112. afx_msg void OnPlayersGuide();
  113.     afx_msg void OnChatOpen();
  114. //}}AFX_MSG
  115. DECLARE_MESSAGE_MAP()
  116. public:
  117. void GameOver (void);   // Called by a dying tank object
  118. private:
  119. void CheckDPlayVersion ();
  120. void StartDIBDrawingEngine ();
  121. void CreateStatusPanes ();
  122. void HideGameControl (CWnd &ctrl, BOOL bHide);
  123. void AlignControls ();
  124.     void OnOK ();
  125.     GameStateType    m_GameState;       // Current game state
  126.     CKbdManager     &m_KbdManager;      // Alias to kbd manager
  127.     CGameManager    &m_GameManager;     // Alias to the game manager
  128.     CServerMgmtDlg   m_SrvMgmtDlg;
  129.     CChatDlg         m_ChatDlg;
  130. };
  131. void CALLBACK EXPORT BonusGenerator(
  132.        HWND hWnd,      // handle of CWnd that called SetTimer
  133.        UINT nMsg,      // WM_TIMER
  134.        UINT nIDEvent,  // timer identification
  135.        DWORD dwTime    // system time
  136.     );
  137. #endif // !defined(AFX_TANKSDLG_H__22F0A6A7_E0C9_11D1_9738_E570871C4325__INCLUDED_)
  138. inline void CTanksDlg::SetShieldLevel (UINT uLevel)
  139. {
  140.     m_ShieldStatus.SetLevel (uLevel);
  141. }
  142.         
  143. inline void CTanksDlg::SetShellsCount (UINT uCount)
  144. {
  145.     m_AmmoStatus.SetShellsCount (uCount);
  146. }
  147. inline void CTanksDlg::SetBulletsCount (UINT uCount)
  148. {
  149.     m_AmmoStatus.SetBulletsCount (uCount);
  150. }
  151. inline void CTanksDlg::SetMinesCount (UINT uCount)
  152. {
  153.     m_AmmoStatus.SetMinesCount (uCount);
  154. }
  155. inline void CTanksDlg::SetAerialSupport (BOOL bOn)
  156. {
  157.     m_BonusStatus.SetAerialSupport (bOn);
  158. }
  159. inline void CTanksDlg::SetFastFireRate (BOOL bOn)
  160. {
  161.     m_BonusStatus.SetFastFireRate (bOn);
  162. }
  163. inline void 
  164. CTanksDlg::MarshalChatMsg(DPID dwDPlayID, DWORD dwTankID, LPCSTR szMsg)
  165. {
  166.     m_ChatDlg.AddMessage (dwDPlayID, dwTankID, szMsg);
  167. }