Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

183 lines
5.6 KiB

  1. /***************************************************************************/
  2. /** Microsoft Windows **/
  3. /** Copyright(c) Microsoft Corp., 1991, 1992 **/
  4. /***************************************************************************/
  5. /****************************************************************************
  6. main.h
  7. CMainWindow object
  8. This class encompasses most of what is interesting in the main window of
  9. Hearts.
  10. Aug 92, JimH
  11. ****************************************************************************/
  12. #ifndef STRICT
  13. #define STRICT
  14. #endif
  15. #include "regentry.h"
  16. #include "player.h"
  17. #include "computer.h"
  18. #include "dlg.h"
  19. #ifndef MAIN_INC
  20. #define MAIN_INC
  21. // non-translateable strings
  22. extern const TCHAR szRegPath[];
  23. extern const TCHAR regvalSound[];
  24. extern const TCHAR regvalName[];
  25. extern const TCHAR regvalRole[];
  26. extern const TCHAR regvalSpeed[];
  27. extern const TCHAR *regvalPName[3];
  28. extern const TCHAR szHelpFileName[];
  29. const int WINWIDTH = 540;
  30. const int WINHEIGHT = 480;
  31. const int LEFT = 0; // passdir
  32. const int RIGHT = 1;
  33. const int ACROSS = 2;
  34. const int NOPASS = 3;
  35. const int OFF = 0; // used in PlaySound
  36. const int MAXNAMELENGTH = 14;
  37. enum roletype { GAMEMEISTER, PLAYER };
  38. typedef struct { // sent out after each move
  39. int playerid;
  40. int cardid;
  41. int playerled;
  42. int turn;
  43. } MOVE;
  44. #if defined (MFC1)
  45. UINT FAR PASCAL EXPORT TimerDispatch(HWND, UINT, int, DWORD);
  46. #else
  47. void FAR PASCAL EXPORT TimerDispatch(HWND, UINT, UINT, DWORD);
  48. #endif
  49. class CMainWindow : public CFrameWnd
  50. {
  51. friend player::player(int n, int pos);
  52. friend void player::GlideToCentre(SLOT s, BOOL bFaceup);
  53. #if defined(MFC1)
  54. friend UINT FAR PASCAL EXPORT TimerDispatch(HWND, UINT, int, DWORD);
  55. #else
  56. friend void FAR PASCAL EXPORT TimerDispatch(HWND, UINT, UINT_PTR, DWORD);
  57. #endif
  58. public:
  59. CMainWindow(LPTSTR lpCmdLine);
  60. void FatalError(int errorno = -1);
  61. int GetGameNumber() { return m_gamenumber; }
  62. COLORREF GetBkColor() { return m_bkgndcolor; }
  63. CString GetPlayerName(int num) { return p[num]->GetName(); }
  64. modetype GetPlayerMode(int num) { return p[num]->GetMode(); }
  65. int GetMyId() { return m_myid; }
  66. int Id2Pos(int id) { return ((id - m_myid + 4) % 4); }
  67. BOOL IsFirstBloodEnforced() { return bEnforceFirstBlood; }
  68. void PlayerQuit(int id);
  69. int Pos2Id(int pos) { return ((pos + m_myid) % 4); }
  70. void SetGameNumber(int num) { m_gamenumber = num; }
  71. afx_msg void OnAbout();
  72. afx_msg void OnBossKey() { ShowWindow(SW_MINIMIZE); }
  73. afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
  74. afx_msg void OnCheat();
  75. afx_msg void OnClose();
  76. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  77. afx_msg BOOL OnEraseBkgnd(CDC *);
  78. afx_msg void OnExit() { bConstructed = FALSE; OnClose(); }
  79. afx_msg void OnHelp()
  80. { ::HtmlHelp(::GetDesktopWindow(), szHelpFileName, HH_DISPLAY_TOPIC, 0); }
  81. /*
  82. afx_msg void OnHelpOnHelp()
  83. { ::WinHelp(m_hWnd, NULL, HELP_HELPONHELP, 0); }
  84. */
  85. afx_msg void OnHideButton() { m_Button.EnableWindow(FALSE); }
  86. /*
  87. afx_msg void OnSearch()
  88. { ::WinHelp(m_hWnd, szHelpFileName, HELP_PARTIALKEY,
  89. (DWORD_PTR)(LPSTR)""); }
  90. */
  91. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  92. afx_msg void OnNewGame();
  93. afx_msg void OnOptions();
  94. afx_msg void OnPaint();
  95. afx_msg void OnPass();
  96. afx_msg void OnQuote();
  97. afx_msg void OnRef();
  98. afx_msg void OnShowButton() { m_Button.EnableWindow();
  99. m_Button.SetFocus(); }
  100. afx_msg void OnScore();
  101. afx_msg void OnSound();
  102. afx_msg void OnWelcome();
  103. afx_msg LRESULT OnPrintClient(WPARAM wParam, LPARAM lParam);
  104. private:
  105. int CountClients();
  106. void DoSort();
  107. void DispatchCards();
  108. void EndHand();
  109. void FirstMove();
  110. void GameOver();
  111. BOOL HandlePassing();
  112. void ResetHandInfo(int playernumber);
  113. void Shuffle();
  114. BOOL SoundInit();
  115. BOOL HeartsPlaySound(int id);
  116. CButton m_Button;
  117. int m_StatusHeight;
  118. CScoreDlg *m_pScoreDlg;
  119. BOOL bAutostarted;
  120. BOOL bCheating;
  121. BOOL bConstructed;
  122. BOOL bEnforceFirstBlood;
  123. BOOL bHasSound;
  124. BOOL bSoundOn;
  125. BOOL bTimerOn;
  126. int m_gamenumber;
  127. LPTSTR m_lpCmdLine;
  128. player *p[MAXPLAYER];
  129. int m_myid;
  130. int passdir;
  131. int m_FatalErrno;
  132. COLORREF m_bkgndcolor;
  133. handinfotype handinfo;
  134. roletype role;
  135. int tricksleft;
  136. int trickwinner;
  137. static CBrush m_BgndBrush;
  138. static CRect m_TableRect;
  139. DECLARE_MESSAGE_MAP()
  140. };
  141. // global variables
  142. extern CMainWindow *pMainWnd;
  143. extern MOVE move;
  144. extern int nStatusHeight;
  145. #endif