Hopefully create a branch and not destroy the svn repository.
[reactos.git] / base / applications / games / 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #include <windows.h>
20
21 static const TCHAR szWineMineRegKey[] = TEXT("Software\\Microsoft\\WinMine");
22
23 // Common Controls 6.0 for MSVC 2005 or later
24 #if _MSC_VER >= 1400
25 # pragma comment(linker, "/manifestdependency:\"type='win32' " \
26 "name='Microsoft.Windows.Common-Controls' " \
27 "version='6.0.0.0' " \
28 "processorArchitecture='x86' " \
29 "publicKeyToken='6595b64144ccf1df' " \
30 "language='*'\"")
31 #endif
32
33 #define ID_TIMER 1000
34
35 #define BEGINNER_MINES 10
36 #define BEGINNER_COLS 9
37 #define BEGINNER_ROWS 9
38
39 #define ADVANCED_MINES 40
40 #define ADVANCED_COLS 16
41 #define ADVANCED_ROWS 16
42
43 #define EXPERT_MINES 99
44 #define EXPERT_COLS 30
45 #define EXPERT_ROWS 16
46
47 #define MAX_COLS 30
48 #define MAX_ROWS 24
49
50 #define BOTTOM_MARGIN 20
51 #define BOARD_WMARGIN 5
52 #define BOARD_HMARGIN 5
53
54 /* mine defines */
55 #define MINE_WIDTH 16
56 #define MINE_HEIGHT 16
57 #define LED_WIDTH 12
58 #define LED_HEIGHT 23
59 #define FACE_WIDTH 24
60 #define FACE_HEIGHT 24
61
62 typedef enum { SPRESS_BMP, COOL_BMP, DEAD_BMP, OOH_BMP, SMILE_BMP } FACE_BMP;
63
64 typedef enum { WAITING, PLAYING, GAMEOVER, WON } GAME_STATUS;
65
66 typedef enum
67 {
68 MPRESS_BMP, ONE_BMP, TWO_BMP, THREE_BMP, FOUR_BMP, FIVE_BMP, SIX_BMP,
69 SEVEN_BMP, EIGHT_BMP, BOX_BMP, FLAG_BMP, QUESTION_BMP, EXPLODE_BMP,
70 WRONG_BMP, MINE_BMP, QPRESS_BMP
71 } MINEBMP_OFFSET;
72
73 typedef enum { BEGINNER, ADVANCED, EXPERT, CUSTOM } DIFFICULTY;
74
75 typedef struct tagBOARD
76 {
77 BOOL bMark;
78 HINSTANCE hInst;
79 HWND hWnd;
80 HBITMAP hMinesBMP;
81 HBITMAP hFacesBMP;
82 HBITMAP hLedsBMP;
83 RECT MinesRect;
84 RECT FaceRect;
85 RECT TimerRect;
86 RECT CounterRect;
87
88 ULONG uWidth;
89 ULONG uHeight;
90 POINT Pos;
91
92 ULONG uTime;
93 ULONG uNumFlags;
94 ULONG uBoxesLeft;
95 ULONG uNumMines;
96
97 ULONG uRows;
98 ULONG uCols;
99 ULONG uMines;
100 TCHAR szBestName[3][16];
101 ULONG uBestTime[3];
102 DIFFICULTY Difficulty;
103
104 POINT Press;
105
106 FACE_BMP FaceBmp;
107 GAME_STATUS Status;
108
109 struct BOX_STRUCT
110 {
111 UINT bIsMine : 1;
112 UINT bIsPressed : 1;
113 UINT uFlagType : 2;
114 UINT uNumMines : 4;
115 } Box [MAX_COLS + 2] [MAX_ROWS + 2];
116
117 /* defines for uFlagType */
118 #define NORMAL 0
119 #define QUESTION 1
120 #define FLAG 2
121 #define COMPLETE 3
122
123 } BOARD;
124
125 void ExitApp( int error );
126 void InitBoard( BOARD *pBoard );
127 void LoadBoard( BOARD *pBoard );
128 void SaveBoard( BOARD *pBoard );
129 void DestroyBoard( BOARD *pBoard );
130 void SetDifficulty( BOARD *pBoard, DIFFICULTY difficulty );
131 void CheckLevel( BOARD *pBoard );
132 void CreateBoard( BOARD *pBoard );
133 void CreateBoxes( BOARD *pBoard );
134 void TestBoard( HWND hWnd, BOARD *pBoard, LONG x, LONG y, int msg );
135 void TestMines( BOARD *pBoard, POINT pt, int msg );
136 void TestFace( BOARD *pBoard, POINT pt, int msg );
137 void DrawBoard( HDC hdc, HDC hMemDC, PAINTSTRUCT *ps, BOARD *pBoard );
138 void DrawMines( HDC hdc, HDC hMemDC, BOARD *pBoard );
139 void DrawMine( HDC hdc, HDC hMemDC, BOARD *pBoard, ULONG uCol, ULONG uRow, BOOL IsPressed );
140 void AddFlag( BOARD *pBoard, ULONG uCol, ULONG uRow );
141 void CompleteBox( BOARD *pBoard, ULONG uCol, ULONG uRow );
142 void CompleteBoxes( BOARD *pBoard, ULONG uCol, ULONG uRow );
143 void PressBox( BOARD *pBoard, ULONG uCol, ULONG uRow );
144 void PressBoxes( BOARD *pBoard, ULONG uCol, ULONG uRow );
145 void UnpressBox( BOARD *pBoard, ULONG uCol, ULONG uRow );
146 void UnpressBoxes( BOARD *pBoard, ULONG uCol, ULONG uRow );
147 void UpdateTimer( BOARD *pBoard );
148 void DrawLeds( HDC hdc, HDC hMemDC, BOARD *pBoard, LONG nNumber, LONG x, LONG y);
149 void DrawFace( HDC hdc, HDC hMemDC, BOARD *pBoard );
150 LRESULT WINAPI MainProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
151 INT_PTR CALLBACK CustomDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
152 INT_PTR CALLBACK CongratsDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
153 INT_PTR CALLBACK TimesDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
154
155 /* end of header */