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 19 #ifndef _WINMINE_H_ 20 #define _WINMINE_H_ 21 22 #include <stdarg.h> 23 24 #define WIN32_NO_STATUS 25 #include <windef.h> 26 #include <winuser.h> 27 28 #include "resource.h" 29 30 #define BEGINNER_MINES 10 31 #define BEGINNER_COLS 9 32 #define BEGINNER_ROWS 9 33 34 #define ADVANCED_MINES 40 35 #define ADVANCED_COLS 16 36 #define ADVANCED_ROWS 16 37 38 #define EXPERT_MINES 99 39 #define EXPERT_COLS 30 40 #define EXPERT_ROWS 16 41 42 #define MAX_COLS 30 43 #define MAX_ROWS 24 44 45 #define BOTTOM_MARGIN 20 46 #define BOARD_WMARGIN 5 47 #define BOARD_HMARGIN 5 48 49 /* mine defines */ 50 #define MINE_WIDTH 16 51 #define MINE_HEIGHT 16 52 #define LED_WIDTH 12 53 #define LED_HEIGHT 23 54 #define FACE_WIDTH 24 55 #define FACE_HEIGHT 24 56 57 #define MAX_PLAYER_NAME_SIZE 31 58 59 typedef enum { SPRESS_BMP, COOL_BMP, DEAD_BMP, OOH_BMP, SMILE_BMP } FACE_BMP; 60 61 typedef enum { WAITING, PLAYING, GAMEOVER, WON } GAME_STATUS; 62 63 typedef enum { 64 MPRESS_BMP, ONE_BMP, TWO_BMP, THREE_BMP, FOUR_BMP, FIVE_BMP, SIX_BMP, 65 SEVEN_BMP, EIGHT_BMP, BOX_BMP, FLAG_BMP, QUESTION_BMP, EXPLODE_BMP, 66 WRONG_BMP, MINE_BMP, QPRESS_BMP 67 } MINEBMP_OFFSET; 68 69 typedef enum { BEGINNER, ADVANCED, EXPERT, CUSTOM } DIFFICULTY; 70 71 typedef struct tagBOARD 72 { 73 BOOL IsMarkQ; 74 HDC hdc; 75 HINSTANCE hInst; 76 HWND hWnd; 77 HBITMAP hMinesBMP; 78 HBITMAP hFacesBMP; 79 HBITMAP hLedsBMP; 80 RECT mines_rect; 81 RECT face_rect; 82 RECT timer_rect; 83 RECT counter_rect; 84 85 unsigned width; 86 unsigned height; 87 POINT pos; 88 89 unsigned time; 90 unsigned num_flags; 91 unsigned boxes_left; 92 unsigned num_mines; 93 94 /* difficulty info */ 95 unsigned rows; 96 unsigned cols; 97 unsigned mines; 98 WCHAR best_name [3][MAX_PLAYER_NAME_SIZE+1]; 99 DWORD best_time [3]; 100 DIFFICULTY difficulty; 101 102 POINT press; 103 104 /* defines for mb */ 105 #define MB_NONE 0 106 #define MB_LEFTDOWN 1 107 #define MB_LEFTUP 2 108 #define MB_RIGHTDOWN 3 109 #define MB_RIGHTUP 4 110 #define MB_BOTHDOWN 5 111 #define MB_BOTHUP 6 112 unsigned mb; 113 114 FACE_BMP face_bmp; 115 GAME_STATUS status; 116 struct BOX_STRUCT 117 { 118 unsigned IsMine : 1; 119 unsigned IsPressed : 1; 120 unsigned FlagType : 2; 121 unsigned NumMines : 4; 122 } box [MAX_COLS + 2] [MAX_ROWS + 2]; 123 124 /* defines for FlagType */ 125 #define NORMAL 0 126 #define QUESTION 1 127 #define FLAG 2 128 #define COMPLETE 3 129 130 } BOARD; 131 132 void CheckLevel( BOARD *p_board ); 133 134 INT_PTR CALLBACK CustomDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ); 135 136 INT_PTR CALLBACK CongratsDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ); 137 138 INT_PTR CALLBACK TimesDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ); 139 140 #endif /* _WINMINE_H_ */ 141