ReactOS  0.4.12-dev-14-gd0c8636
main.h File Reference
#include <stdarg.h>
#include <windef.h>
#include <winuser.h>
#include "resource.h"
Include dependency graph for main.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  tagBOARD
 
struct  tagBOARD::BOX_STRUCT
 

Macros

#define WIN32_NO_STATUS
 
#define BEGINNER_MINES   10
 
#define BEGINNER_COLS   9
 
#define BEGINNER_ROWS   9
 
#define ADVANCED_MINES   40
 
#define ADVANCED_COLS   16
 
#define ADVANCED_ROWS   16
 
#define EXPERT_MINES   99
 
#define EXPERT_COLS   30
 
#define EXPERT_ROWS   16
 
#define MAX_COLS   30
 
#define MAX_ROWS   24
 
#define BOTTOM_MARGIN   20
 
#define BOARD_WMARGIN   5
 
#define BOARD_HMARGIN   5
 
#define MINE_WIDTH   16
 
#define MINE_HEIGHT   16
 
#define LED_WIDTH   12
 
#define LED_HEIGHT   23
 
#define FACE_WIDTH   24
 
#define FACE_HEIGHT   24
 
#define MAX_PLAYER_NAME_SIZE   31
 
#define MB_NONE   0
 
#define MB_LEFTDOWN   1
 
#define MB_LEFTUP   2
 
#define MB_RIGHTDOWN   3
 
#define MB_RIGHTUP   4
 
#define MB_BOTHDOWN   5
 
#define MB_BOTHUP   6
 
#define NORMAL   0
 
#define QUESTION   1
 
#define FLAG   2
 
#define COMPLETE   3
 

Typedefs

typedef struct tagBOARD BOARD
 

Enumerations

enum  FACE_BMP {
  SPRESS_BMP, COOL_BMP, DEAD_BMP, OOH_BMP,
  SMILE_BMP
}
 
enum  GAME_STATUS { WAITING, PLAYING, GAMEOVER, WON }
 
enum  MINEBMP_OFFSET {
  MPRESS_BMP, ONE_BMP, TWO_BMP, THREE_BMP,
  FOUR_BMP, FIVE_BMP, SIX_BMP, SEVEN_BMP,
  EIGHT_BMP, BOX_BMP, FLAG_BMP, QUESTION_BMP,
  EXPLODE_BMP, WRONG_BMP, MINE_BMP, QPRESS_BMP
}
 
enum  DIFFICULTY { BEGINNER, ADVANCED, EXPERT, CUSTOM }
 

Functions

void CheckLevel (BOARD *p_board)
 
INT_PTR CALLBACK CustomDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
INT_PTR CALLBACK CongratsDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
INT_PTR CALLBACK TimesDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Macro Definition Documentation

◆ ADVANCED_COLS

#define ADVANCED_COLS   16

Definition at line 35 of file main.h.

Referenced by SetDifficulty().

◆ ADVANCED_MINES

#define ADVANCED_MINES   40

Definition at line 34 of file main.h.

Referenced by SetDifficulty().

◆ ADVANCED_ROWS

#define ADVANCED_ROWS   16

Definition at line 36 of file main.h.

Referenced by SetDifficulty().

◆ BEGINNER_COLS

#define BEGINNER_COLS   9

Definition at line 31 of file main.h.

Referenced by CheckLevel(), LoadBoard(), and SetDifficulty().

◆ BEGINNER_MINES

#define BEGINNER_MINES   10

Definition at line 30 of file main.h.

Referenced by CheckLevel(), LoadBoard(), and SetDifficulty().

◆ BEGINNER_ROWS

#define BEGINNER_ROWS   9

Definition at line 32 of file main.h.

Referenced by CheckLevel(), LoadBoard(), and SetDifficulty().

◆ BOARD_HMARGIN

#define BOARD_HMARGIN   5

Definition at line 47 of file main.h.

Referenced by CreateBoard().

◆ BOARD_WMARGIN

#define BOARD_WMARGIN   5

Definition at line 46 of file main.h.

Referenced by CreateBoard().

◆ BOTTOM_MARGIN

#define BOTTOM_MARGIN   20

Definition at line 45 of file main.h.

◆ COMPLETE

#define COMPLETE   3

◆ EXPERT_COLS

#define EXPERT_COLS   30

Definition at line 39 of file main.h.

Referenced by SetDifficulty().

◆ EXPERT_MINES

#define EXPERT_MINES   99

Definition at line 38 of file main.h.

Referenced by SetDifficulty().

◆ EXPERT_ROWS

#define EXPERT_ROWS   16

Definition at line 40 of file main.h.

Referenced by SetDifficulty().

◆ FACE_HEIGHT

#define FACE_HEIGHT   24

Definition at line 55 of file main.h.

Referenced by CreateBoard(), and DrawFace().

◆ FACE_WIDTH

#define FACE_WIDTH   24

Definition at line 54 of file main.h.

Referenced by CreateBoard(), and DrawFace().

◆ FLAG

#define FLAG   2

Definition at line 127 of file main.h.

◆ LED_HEIGHT

#define LED_HEIGHT   23

Definition at line 53 of file main.h.

Referenced by CreateBoard(), and DrawLeds().

◆ LED_WIDTH

#define LED_WIDTH   12

Definition at line 52 of file main.h.

Referenced by CreateBoard(), and DrawLeds().

◆ MAX_COLS

#define MAX_COLS   30

Definition at line 42 of file main.h.

Referenced by CheckLevel().

◆ MAX_PLAYER_NAME_SIZE

#define MAX_PLAYER_NAME_SIZE   31

Definition at line 57 of file main.h.

Referenced by LoadBoard(), and SaveBoard().

◆ MAX_ROWS

#define MAX_ROWS   24

Definition at line 43 of file main.h.

◆ MB_BOTHDOWN

#define MB_BOTHDOWN   5

Definition at line 110 of file main.h.

◆ MB_BOTHUP

#define MB_BOTHUP   6

Definition at line 111 of file main.h.

◆ MB_LEFTDOWN

#define MB_LEFTDOWN   1

Definition at line 106 of file main.h.

◆ MB_LEFTUP

#define MB_LEFTUP   2

Definition at line 107 of file main.h.

◆ MB_NONE

#define MB_NONE   0

Definition at line 105 of file main.h.

Referenced by CreateBoard().

◆ MB_RIGHTDOWN

#define MB_RIGHTDOWN   3

Definition at line 108 of file main.h.

◆ MB_RIGHTUP

#define MB_RIGHTUP   4

Definition at line 109 of file main.h.

◆ MINE_HEIGHT

#define MINE_HEIGHT   16

Definition at line 51 of file main.h.

Referenced by CreateBoard(), DrawMine(), and TestMines().

◆ MINE_WIDTH

#define MINE_WIDTH   16

Definition at line 50 of file main.h.

Referenced by CreateBoard(), DrawMine(), and TestMines().

◆ NORMAL

#define NORMAL   0

Definition at line 125 of file main.h.

◆ QUESTION

#define QUESTION   1

Definition at line 126 of file main.h.

Referenced by AddFlag(), and DrawMine().

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 24 of file main.h.

Typedef Documentation

◆ BOARD

Enumeration Type Documentation

◆ DIFFICULTY

Enumerator
BEGINNER 
ADVANCED 
EXPERT 
CUSTOM 

Definition at line 69 of file main.h.

Definition: main.h:69
DIFFICULTY
Definition: main.h:69
Definition: main.h:69
Definition: main.h:69
Definition: main.h:69

◆ FACE_BMP

Enumerator
SPRESS_BMP 
COOL_BMP 
DEAD_BMP 
OOH_BMP 
SMILE_BMP 

Definition at line 59 of file main.h.

Definition: main.h:59
Definition: main.h:59
Definition: main.h:59
FACE_BMP
Definition: main.h:59
Definition: main.h:59

◆ GAME_STATUS

Enumerator
WAITING 
PLAYING 
GAMEOVER 
WON 

Definition at line 61 of file main.h.

Definition: main.h:61
Definition: main.h:61
GAME_STATUS
Definition: main.h:61
Definition: main.h:61
Definition: main.h:61

◆ MINEBMP_OFFSET

Enumerator
MPRESS_BMP 
ONE_BMP 
TWO_BMP 
THREE_BMP 
FOUR_BMP 
FIVE_BMP 
SIX_BMP 
SEVEN_BMP 
EIGHT_BMP 
BOX_BMP 
FLAG_BMP 
QUESTION_BMP 
EXPLODE_BMP 
WRONG_BMP 
MINE_BMP 
QPRESS_BMP 

Definition at line 63 of file main.h.

Function Documentation

◆ CheckLevel()

void CheckLevel ( BOARD p_board)

Definition at line 49 of file main.c.

Referenced by CustomDlgProc(), and InitBoard().

50 {
51  if( p_board->rows < BEGINNER_ROWS )
52  p_board->rows = BEGINNER_ROWS;
53 
54  if( p_board->rows > MAX_ROWS )
55  p_board->rows = MAX_ROWS;
56 
57  if( p_board->cols < BEGINNER_COLS )
58  p_board->cols = BEGINNER_COLS;
59 
60  if( p_board->cols > MAX_COLS )
61  p_board->cols = MAX_COLS;
62 
63  if( p_board->mines < BEGINNER_MINES )
64  p_board->mines = BEGINNER_MINES;
65 
66  if( p_board->mines > ( p_board->cols - 1 ) * ( p_board->rows - 1 ) )
67  p_board->mines = ( p_board->cols - 1 ) * ( p_board->rows - 1 );
68 }
#define BEGINNER_MINES
Definition: main.h:30
#define MAX_COLS
Definition: main.h:42
#define BEGINNER_COLS
Definition: main.h:31
unsigned mines
Definition: main.h:97
unsigned rows
Definition: main.h:95
unsigned cols
Definition: main.h:96
#define BEGINNER_ROWS
Definition: main.h:32
#define MAX_ROWS
Definition: map.c:17

◆ CongratsDlgProc()

INT_PTR CALLBACK CongratsDlgProc ( HWND  hDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 55 of file dialog.c.

Referenced by TestBoard().

56 {
57  static BOARD *p_board;
58 
59  switch( uMsg ) {
60  case WM_INITDIALOG:
61  p_board = (BOARD*) lParam;
62  SetDlgItemTextW( hDlg, IDC_EDITNAME, p_board->best_name[p_board->difficulty] );
63  return TRUE;
64 
65  case WM_COMMAND:
66  switch( LOWORD( wParam ) ) {
67  case IDOK:
69  p_board->best_name[p_board->difficulty],
70  sizeof( p_board->best_name[p_board->difficulty] ) / sizeof(WCHAR) );
71  EndDialog( hDlg, 0 );
72  return TRUE;
73 
74  case IDCANCEL:
75  EndDialog( hDlg, 0 );
76  return TRUE;
77  }
78  break;
79  }
80  return FALSE;
81 }
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2195
#define IDC_EDITNAME
Definition: resource.h:43
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR best_name[3][MAX_PLAYER_NAME_SIZE+1]
Definition: main.h:98
WPARAM wParam
Definition: combotst.c:138
Definition: main.h:71
BOOL WINAPI SetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPCWSTR lpString)
Definition: dialog.c:2748
DIFFICULTY difficulty
Definition: main.h:100
#define WM_COMMAND
Definition: winuser.h:1716
BOOL WINAPI EndDialog(HWND hwnd, INT_PTR retval)
Definition: dialog.c:2015
#define IDCANCEL
Definition: winuser.h:825
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82

◆ CustomDlgProc()

INT_PTR CALLBACK CustomDlgProc ( HWND  hDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 23 of file dialog.c.

Referenced by SetDifficulty().

24 {
25  BOOL IsRet;
26  static BOARD *p_board;
27 
28  switch( uMsg ) {
29  case WM_INITDIALOG:
30  p_board = (BOARD*) lParam;
31  SetDlgItemInt( hDlg, IDC_EDITROWS, p_board->rows, FALSE );
32  SetDlgItemInt( hDlg, IDC_EDITCOLS, p_board->cols, FALSE );
33  SetDlgItemInt( hDlg, IDC_EDITMINES, p_board->mines, FALSE );
34  return TRUE;
35 
36  case WM_COMMAND:
37  switch( LOWORD( wParam ) ) {
38  case IDOK:
39  p_board->rows = GetDlgItemInt( hDlg, IDC_EDITROWS, &IsRet, FALSE );
40  p_board->cols = GetDlgItemInt( hDlg, IDC_EDITCOLS, &IsRet, FALSE );
41  p_board->mines = GetDlgItemInt( hDlg, IDC_EDITMINES, &IsRet, FALSE );
42  CheckLevel( p_board );
43  EndDialog( hDlg, 0 );
44  return TRUE;
45 
46  case IDCANCEL:
47  EndDialog( hDlg, 1 );
48  return TRUE;
49  }
50  break;
51  }
52  return FALSE;
53 }
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
BOOL WINAPI SetDlgItemInt(HWND hDlg, int nIDDlgItem, UINT uValue, BOOL bSigned)
Definition: dialog.c:2712
unsigned mines
Definition: main.h:97
void CheckLevel(BOARD *p_board)
Definition: main.c:49
WPARAM wParam
Definition: combotst.c:138
#define IDC_EDITROWS
Definition: resource.h:46
Definition: main.h:71
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned rows
Definition: main.h:95
unsigned cols
Definition: main.h:96
#define WM_COMMAND
Definition: winuser.h:1716
UINT WINAPI GetDlgItemInt(HWND hDlg, int nIDDlgItem, BOOL *lpTranslated, BOOL bSigned)
Definition: dialog.c:2139
#define IDC_EDITCOLS
Definition: resource.h:45
BOOL WINAPI EndDialog(HWND hwnd, INT_PTR retval)
Definition: dialog.c:2015
#define IDCANCEL
Definition: winuser.h:825
#define IDC_EDITMINES
Definition: resource.h:47
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82

◆ TimesDlgProc()

INT_PTR CALLBACK TimesDlgProc ( HWND  hDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 83 of file dialog.c.

Referenced by MainProc(), and TestBoard().

84 {
85  static BOARD *p_board;
86  unsigned i;
87 
88  switch( uMsg ) {
89  case WM_INITDIALOG:
90  p_board = (BOARD*) lParam;
91 
92  /* set best names */
93  for( i = 0; i < 3; i++ )
94  SetDlgItemTextW( hDlg, (IDC_NAME1) + i, p_board->best_name[i] );
95 
96  /* set best times */
97  for( i = 0; i < 3; i++ )
98  SetDlgItemInt( hDlg, (IDC_TIME1) + i, p_board->best_time[i], FALSE );
99  return TRUE;
100 
101  case WM_COMMAND:
102  switch( LOWORD( wParam ) ) {
103  case IDOK:
104  case IDCANCEL:
105  EndDialog( hDlg, 0 );
106  return TRUE;
107  }
108  break;
109  }
110  return FALSE;
111 }
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
BOOL WINAPI SetDlgItemInt(HWND hDlg, int nIDDlgItem, UINT uValue, BOOL bSigned)
Definition: dialog.c:2712
#define IDC_TIME1
Definition: resource.h:36
WCHAR best_name[3][MAX_PLAYER_NAME_SIZE+1]
Definition: main.h:98
WPARAM wParam
Definition: combotst.c:138
GLenum GLclampf GLint i
Definition: glfuncs.h:14
Definition: main.h:71
DWORD best_time[3]
Definition: main.h:99
BOOL WINAPI SetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPCWSTR lpString)
Definition: dialog.c:2748
#define WM_COMMAND
Definition: winuser.h:1716
BOOL WINAPI EndDialog(HWND hwnd, INT_PTR retval)
Definition: dialog.c:2015
#define IDCANCEL
Definition: winuser.h:825
#define IDC_NAME1
Definition: resource.h:39
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82