Added LGPL standard comment, and copyright notices where necessary.
[wine] / programs / winemine / main.h
1 /*
2  * Copyright 2000 Joshua Thielen <jt85296@ltu.edu>
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18
19 #include <windows.h>
20
21 #define BEGINNER_MINES        10
22 #define BEGINNER_COLS         8
23 #define BEGINNER_ROWS         8
24
25 #define ADVANCED_MINES        40
26 #define ADVANCED_COLS         16
27 #define ADVANCED_ROWS         16
28
29 #define EXPERT_MINES          99
30 #define EXPERT_COLS           30
31 #define EXPERT_ROWS           16
32
33 #define MAX_COLS        30
34 #define MAX_ROWS        24
35
36 #define BOTTOM_MARGIN 20
37 #define BOARD_WMARGIN 5
38 #define BOARD_HMARGIN 5
39
40 /* mine defines */
41 #define MINE_WIDTH       16
42 #define MINE_HEIGHT      16
43 #define LED_WIDTH        12
44 #define LED_HEIGHT       23
45 #define FACE_WIDTH       24
46 #define FACE_HEIGHT      24
47
48 typedef enum { SPRESS_BMP, COOL_BMP, DEAD_BMP, OOH_BMP, SMILE_BMP } FACE_BMP;
49
50 typedef enum { WAITING, PLAYING, GAMEOVER, WON } GAME_STATUS;
51
52 typedef enum {
53      MPRESS_BMP, ONE_BMP, TWO_BMP, THREE_BMP, FOUR_BMP, FIVE_BMP, SIX_BMP,
54      SEVEN_BMP, EIGHT_BMP, BOX_BMP, FLAG_BMP, QUESTION_BMP, EXPLODE_BMP,
55      WRONG_BMP, MINE_BMP, QPRESS_BMP
56 } MINEBMP_OFFSET;
57
58 typedef enum { BEGINNER, ADVANCED, EXPERT, CUSTOM } DIFFICULTY;
59
60 typedef struct tagBOARD
61 {
62     BOOL IsMarkQ;
63     HDC    hdc;
64     HINSTANCE hInst;
65     HWND    hWnd;
66     HBITMAP hMinesBMP;
67     HBITMAP hFacesBMP;
68     HBITMAP hLedsBMP;
69     RECT mines_rect;
70     RECT face_rect;
71     RECT timer_rect;
72     RECT counter_rect;    
73
74     unsigned width;
75     unsigned height;
76     POINT pos;
77
78     unsigned time;
79     unsigned num_flags;     
80     unsigned boxes_left;
81     unsigned num_mines;
82
83     /* difficulty info */
84     unsigned rows;
85     unsigned cols;
86     unsigned mines;
87     char best_name [3][16];
88     unsigned best_time [3];
89     DIFFICULTY difficulty;
90
91     POINT press;
92     
93     /* defines for mb */
94     #define MB_NONE 0
95     #define MB_LEFTDOWN 1
96     #define MB_LEFTUP 2
97     #define MB_RIGHTDOWN 3
98     #define MB_RIGHTUP 4
99     #define MB_BOTHDOWN 5
100     #define MB_BOTHUP 6
101     unsigned mb;
102     
103     FACE_BMP face_bmp;
104     GAME_STATUS status;
105     struct BOX_STRUCT
106     {
107         unsigned IsMine    : 1;
108         unsigned IsPressed : 1;
109         unsigned FlagType  : 2;
110         unsigned NumMines  : 4;
111     } box [MAX_COLS + 2] [MAX_ROWS + 2];
112
113     /* defines for FlagType */
114     #define NORMAL 0
115     #define QUESTION 1
116     #define FLAG 2
117     #define COMPLETE 3
118
119 } BOARD;
120
121 void ExitApp( int error );
122
123 void InitBoard( BOARD *p_board );
124
125 void LoadBoard( BOARD *p_board );
126
127 void SaveBoard( BOARD *p_board );
128
129 void DestroyBoard( BOARD *p_board );
130
131 void SetDifficulty( BOARD *p_board, DIFFICULTY difficulty );
132
133 void CheckLevel( BOARD *p_board );
134
135 void CreateBoard( BOARD *p_board );
136
137 void CreateBoxes( BOARD *p_board );
138
139 void TestBoard( HWND hWnd, BOARD *p_board, unsigned x, unsigned y, int msg );
140
141 void TestMines( BOARD *p_board, POINT pt, int msg );
142
143 void TestFace( BOARD *p_board, POINT pt, int msg );
144
145 void DrawBoard( HDC hdc, HDC hMemDC, PAINTSTRUCT *ps, BOARD *p_board );
146
147 void DrawMines( HDC hdc, HDC hMemDC, BOARD *p_board );
148
149 void DrawMine( HDC hdc, HDC hMemDC, BOARD *p_board, unsigned col, unsigned row, BOOL IsPressed );
150
151 void AddFlag( BOARD *p_board, unsigned col, unsigned row );
152
153 void CompleteBox( BOARD *p_board, unsigned col, unsigned row );
154
155 void CompleteBoxes( BOARD *p_board, unsigned col, unsigned row );
156
157 void PressBox( BOARD *p_board, unsigned col, unsigned row );
158
159 void PressBoxes( BOARD *p_board, unsigned col, unsigned row );
160
161 void UnpressBox( BOARD *p_board, unsigned col, unsigned row );
162
163 void UnpressBoxes( BOARD *p_board, unsigned col, unsigned row );
164
165 void UpdateTimer( BOARD *p_board );
166
167 void DrawLeds( HDC hdc, HDC hMemDC, BOARD *p_board, int number, int x, int y);
168
169 void DrawFace( HDC hdc, HDC hMemDC, BOARD *p_board );
170
171 LRESULT WINAPI MainProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
172
173 BOOL CALLBACK CustomDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
174
175 BOOL CALLBACK CongratsDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
176
177 BOOL CALLBACK TimesDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
178
179 BOOL CALLBACK AboutDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
180
181 /* end of header */