main.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*
  2. * Copyright 2000 Joshua Thielen
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2.1 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with this library; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  17. */
  18. #include <windows.h>
  19. #define BEGINNER_MINES 10
  20. #define BEGINNER_COLS 9
  21. #define BEGINNER_ROWS 9
  22. #define ADVANCED_MINES 40
  23. #define ADVANCED_COLS 16
  24. #define ADVANCED_ROWS 16
  25. #define EXPERT_MINES 99
  26. #define EXPERT_COLS 30
  27. #define EXPERT_ROWS 16
  28. #define MAX_COLS 30
  29. #define MAX_ROWS 24
  30. #define BOTTOM_MARGIN 20
  31. #define BOARD_WMARGIN 5
  32. #define BOARD_HMARGIN 5
  33. /* mine defines */
  34. #define MINE_WIDTH 16
  35. #define MINE_HEIGHT 16
  36. #define LED_WIDTH 12
  37. #define LED_HEIGHT 23
  38. #define FACE_WIDTH 24
  39. #define FACE_HEIGHT 24
  40. #define MAX_PLAYER_NAME_SIZE 31
  41. typedef enum { SPRESS_BMP, COOL_BMP, DEAD_BMP, OOH_BMP, SMILE_BMP } FACE_BMP;
  42. typedef enum { WAITING, PLAYING, GAMEOVER, WON } GAME_STATUS;
  43. typedef enum {
  44. MPRESS_BMP, ONE_BMP, TWO_BMP, THREE_BMP, FOUR_BMP, FIVE_BMP, SIX_BMP,
  45. SEVEN_BMP, EIGHT_BMP, BOX_BMP, FLAG_BMP, QUESTION_BMP, EXPLODE_BMP,
  46. WRONG_BMP, MINE_BMP, QPRESS_BMP
  47. } MINEBMP_OFFSET;
  48. typedef enum { BEGINNER, ADVANCED, EXPERT, CUSTOM } DIFFICULTY;
  49. typedef struct tagBOARD
  50. {
  51. BOOL IsMarkQ;
  52. HDC hdc;
  53. HINSTANCE hInst;
  54. HWND hWnd;
  55. HBITMAP hMinesBMP;
  56. HBITMAP hFacesBMP;
  57. HBITMAP hLedsBMP;
  58. RECT mines_rect;
  59. RECT face_rect;
  60. RECT timer_rect;
  61. RECT counter_rect;
  62. unsigned width;
  63. unsigned height;
  64. POINT pos;
  65. unsigned time;
  66. unsigned num_flags;
  67. unsigned boxes_left;
  68. unsigned num_mines;
  69. /* difficulty info */
  70. unsigned rows;
  71. unsigned cols;
  72. unsigned mines;
  73. WCHAR best_name [3][MAX_PLAYER_NAME_SIZE+1];
  74. DWORD best_time [3];
  75. DIFFICULTY difficulty;
  76. POINT press;
  77. /* defines for mb */
  78. #define MB_NONE 0
  79. #define MB_LEFTDOWN 1
  80. #define MB_LEFTUP 2
  81. #define MB_RIGHTDOWN 3
  82. #define MB_RIGHTUP 4
  83. #define MB_BOTHDOWN 5
  84. #define MB_BOTHUP 6
  85. unsigned mb;
  86. FACE_BMP face_bmp;
  87. GAME_STATUS status;
  88. struct BOX_STRUCT
  89. {
  90. unsigned IsMine : 1;
  91. unsigned IsPressed : 1;
  92. unsigned FlagType : 2;
  93. unsigned NumMines : 4;
  94. } box [MAX_COLS + 2] [MAX_ROWS + 2];
  95. /* defines for FlagType */
  96. #define NORMAL 0
  97. #define QUESTION 1
  98. #define FLAG 2
  99. #define COMPLETE 3
  100. } BOARD;
  101. void CheckLevel( BOARD *p_board );
  102. void SaveBoard( BOARD *p_board );
  103. void ResetResults( BOARD *p_board );
  104. INT_PTR CALLBACK CustomDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
  105. INT_PTR CALLBACK CongratsDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
  106. INT_PTR CALLBACK TimesDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
  107. /* end of header */