xref: /reactos/base/applications/games/winmine/main.h (revision 580574fb)
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 #ifdef __REACTOS__
75     BOOL IsSoundEnabled;
76 #endif
77     HDC    hdc;
78     HINSTANCE hInst;
79     HWND    hWnd;
80     HBITMAP hMinesBMP;
81     HBITMAP hFacesBMP;
82     HBITMAP hLedsBMP;
83     RECT mines_rect;
84     RECT face_rect;
85     RECT timer_rect;
86     RECT counter_rect;
87 
88     unsigned width;
89     unsigned height;
90     POINT pos;
91 
92     unsigned time;
93     unsigned num_flags;
94     unsigned boxes_left;
95     unsigned num_mines;
96 
97     /* difficulty info */
98     unsigned rows;
99     unsigned cols;
100     unsigned mines;
101     WCHAR best_name [3][MAX_PLAYER_NAME_SIZE+1];
102     DWORD best_time [3];
103     DIFFICULTY difficulty;
104 
105     POINT press;
106 
107     /* defines for mb */
108 #define MB_NONE 0
109 #define MB_LEFTDOWN 1
110 #define MB_LEFTUP 2
111 #define MB_RIGHTDOWN 3
112 #define MB_RIGHTUP 4
113 #define MB_BOTHDOWN 5
114 #define MB_BOTHUP 6
115     unsigned mb;
116 
117     FACE_BMP face_bmp;
118     GAME_STATUS status;
119     struct BOX_STRUCT
120     {
121         unsigned IsMine    : 1;
122         unsigned IsPressed : 1;
123         unsigned FlagType  : 2;
124         unsigned NumMines  : 4;
125     } box [MAX_COLS + 2] [MAX_ROWS + 2];
126 
127     /* defines for FlagType */
128 #define NORMAL 0
129 #define QUESTION 1
130 #define FLAG 2
131 #define COMPLETE 3
132 
133 } BOARD;
134 
135 void CheckLevel( BOARD *p_board );
136 
137 INT_PTR CALLBACK CustomDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
138 
139 INT_PTR CALLBACK CongratsDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
140 
141 INT_PTR CALLBACK TimesDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
142 
143 #endif /* _WINMINE_H_ */
144