main.h 3.34 KB
Newer Older
1
/*
2
 * Copyright 2000 Joshua Thielen
3 4 5 6 7 8 9 10 11 12 13 14 15
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * 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
 */

Joshua Thielen's avatar
Joshua Thielen committed
19 20 21
#include <windows.h>

#define BEGINNER_MINES        10
22 23
#define BEGINNER_COLS         9
#define BEGINNER_ROWS         9
Joshua Thielen's avatar
Joshua Thielen committed
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47

#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

/* mine defines */
#define MINE_WIDTH       16
#define MINE_HEIGHT      16
#define LED_WIDTH        12
#define LED_HEIGHT       23
#define FACE_WIDTH       24
#define FACE_HEIGHT      24

48 49
#define MAX_PLAYER_NAME_SIZE 31

Joshua Thielen's avatar
Joshua Thielen committed
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
typedef enum { SPRESS_BMP, COOL_BMP, DEAD_BMP, OOH_BMP, SMILE_BMP } FACE_BMP;

typedef enum { WAITING, PLAYING, GAMEOVER, WON } GAME_STATUS;

typedef enum {
     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
} MINEBMP_OFFSET;

typedef enum { BEGINNER, ADVANCED, EXPERT, CUSTOM } DIFFICULTY;

typedef struct tagBOARD
{
    BOOL IsMarkQ;
    HDC    hdc;
    HINSTANCE hInst;
    HWND    hWnd;
    HBITMAP hMinesBMP;
    HBITMAP hFacesBMP;
    HBITMAP hLedsBMP;
    RECT mines_rect;
    RECT face_rect;
    RECT timer_rect;
74
    RECT counter_rect;
Joshua Thielen's avatar
Joshua Thielen committed
75 76 77 78 79 80

    unsigned width;
    unsigned height;
    POINT pos;

    unsigned time;
81
    unsigned num_flags;
Joshua Thielen's avatar
Joshua Thielen committed
82 83 84 85 86 87 88
    unsigned boxes_left;
    unsigned num_mines;

    /* difficulty info */
    unsigned rows;
    unsigned cols;
    unsigned mines;
89
    WCHAR best_name [3][MAX_PLAYER_NAME_SIZE+1];
90
    DWORD best_time [3];
Joshua Thielen's avatar
Joshua Thielen committed
91 92 93
    DIFFICULTY difficulty;

    POINT press;
94

Joshua Thielen's avatar
Joshua Thielen committed
95
    /* defines for mb */
96 97 98 99 100 101 102
#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
Joshua Thielen's avatar
Joshua Thielen committed
103
    unsigned mb;
104

Joshua Thielen's avatar
Joshua Thielen committed
105 106 107 108 109 110 111 112 113 114 115
    FACE_BMP face_bmp;
    GAME_STATUS status;
    struct BOX_STRUCT
    {
        unsigned IsMine    : 1;
        unsigned IsPressed : 1;
        unsigned FlagType  : 2;
        unsigned NumMines  : 4;
    } box [MAX_COLS + 2] [MAX_ROWS + 2];

    /* defines for FlagType */
116 117 118 119
#define NORMAL 0
#define QUESTION 1
#define FLAG 2
#define COMPLETE 3
Joshua Thielen's avatar
Joshua Thielen committed
120 121 122 123

} BOARD;

void CheckLevel( BOARD *p_board );
124 125
void SaveBoard( BOARD *p_board );
void ResetResults( BOARD *p_board );
Joshua Thielen's avatar
Joshua Thielen committed
126

127
INT_PTR CALLBACK CustomDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
Joshua Thielen's avatar
Joshua Thielen committed
128

129
INT_PTR CALLBACK CongratsDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
Joshua Thielen's avatar
Joshua Thielen committed
130

131
INT_PTR CALLBACK TimesDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
Joshua Thielen's avatar
Joshua Thielen committed
132 133 134


/* end of header */