Added WineMine

svn path=/trunk/; revision=4253
This commit is contained in:
Richard Campbell 2003-03-06 21:13:17 +00:00
parent c8c6395488
commit d2f53a79d8
13 changed files with 1611 additions and 0 deletions

View file

@ -0,0 +1,5 @@
*.o
*.d
*.exe
*.coff
*.sym

View file

@ -0,0 +1,19 @@
# $Id: Makefile,v 1.1 2003/03/06 21:13:17 rcampbell Exp $
PATH_TO_TOP = ../../..
TARGET_TYPE = program
TARGET_APPTYPE = windows
TARGET_NAME = winemine
TARGET_SDKLIBS = kernel32.a gdi32.a
TARGET_OBJECTS = main.o dialog.o
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View file

@ -0,0 +1,21 @@
WineMine README
WineMine, copyright March 2000, Joshua Thielen
WineMine is to be distributed under the Wine License
See the Wine License for further information.
This is minesweeper for wine...
Enjoy. I wrote it because it rhymes ;).
KNOWN BUGS:
Chokes on fastest times names greater than 16 characters long, must have
something to do with GetDlgItemText.
No help file.
Starting a new game causes the window to drop one pixel (Peter Hunnisett)
I don't know if it's a window manager problem (KDE)
UNKNOWN BUGS:
???

View file

@ -0,0 +1,132 @@
/*
* WineMine (dialog.c)
*
* Copyright 2000 Joshua Thielen <jt85296@ltu.edu>
*
* 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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <windows.h>
#include "main.h"
#include "dialog.h"
#include "resource.h"
BOOL CALLBACK CustomDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
BOOL IsRet;
static BOARD *p_board;
switch( uMsg ) {
case WM_INITDIALOG:
p_board = (BOARD*) lParam;
SetDlgItemInt( hDlg, IDC_EDITROWS, p_board->rows, FALSE );
SetDlgItemInt( hDlg, IDC_EDITCOLS, p_board->cols, FALSE );
SetDlgItemInt( hDlg, IDC_EDITMINES, p_board->mines, FALSE );
return TRUE;
case WM_COMMAND:
switch( LOWORD( wParam ) ) {
case IDOK:
p_board->rows = GetDlgItemInt( hDlg, IDC_EDITROWS, &IsRet, FALSE );
p_board->cols = GetDlgItemInt( hDlg, IDC_EDITCOLS, &IsRet, FALSE );
p_board->mines = GetDlgItemInt( hDlg, IDC_EDITMINES, &IsRet, FALSE );
CheckLevel( p_board );
EndDialog( hDlg, 0 );
return TRUE;
case IDCANCEL:
EndDialog( hDlg, 0 );
return TRUE;
}
break;
}
return FALSE;
}
BOOL CALLBACK CongratsDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
static BOARD *p_board;
switch( uMsg ) {
case WM_INITDIALOG:
p_board = (BOARD*) lParam;
SetDlgItemText( hDlg, IDC_EDITNAME,
p_board->best_name[p_board->difficulty] );
return TRUE;
case WM_COMMAND:
switch( LOWORD( wParam ) ) {
case IDOK:
GetDlgItemText( hDlg, IDC_EDITNAME,
p_board->best_name[p_board->difficulty],
sizeof( p_board->best_name[p_board->difficulty] ) );
EndDialog( hDlg, 0 );
return TRUE;
case IDCANCEL:
EndDialog( hDlg, 0 );
return TRUE;
}
break;
}
return FALSE;
}
BOOL CALLBACK TimesDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
static BOARD *p_board;
unsigned i;
switch( uMsg ) {
case WM_INITDIALOG:
p_board = (BOARD*) lParam;
/* set best names */
for( i = 0; i < 3; i++ )
SetDlgItemText( hDlg, (IDC_NAME1) + i, p_board->best_name[i] );
/* set best times */
for( i = 0; i < 3; i++ )
SetDlgItemInt( hDlg, (IDC_TIME1) + i, p_board->best_time[i], FALSE );
return TRUE;
case WM_COMMAND:
switch( LOWORD( wParam ) ) {
case IDOK:
EndDialog( hDlg, 0 );
return TRUE;
}
break;
}
return FALSE;
}
BOOL CALLBACK AboutDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
switch( uMsg ) {
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
switch( LOWORD( wParam ) ) {
case IDOK:
EndDialog( hDlg, 0 );
return TRUE;
}
break;
}
return FALSE;
}

View file

@ -0,0 +1,29 @@
/*
* WineMine (dialog.h)
*
* Copyright 2000 Joshua Thielen <jt85296@ltu.edu>
*
* 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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
BOOL CALLBACK CustomDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
BOOL CALLBACK CongratsDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
BOOL CALLBACK TimesDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
BOOL CALLBACK AboutDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,181 @@
/*
* Copyright 2000 Joshua Thielen <jt85296@ltu.edu>
*
* 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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <windows.h>
#define BEGINNER_MINES 10
#define BEGINNER_COLS 8
#define BEGINNER_ROWS 8
#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
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;
RECT counter_rect;
unsigned width;
unsigned height;
POINT pos;
unsigned time;
unsigned num_flags;
unsigned boxes_left;
unsigned num_mines;
/* difficulty info */
unsigned rows;
unsigned cols;
unsigned mines;
char best_name [3][16];
unsigned best_time [3];
DIFFICULTY difficulty;
POINT press;
/* defines for mb */
#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
unsigned mb;
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 */
#define NORMAL 0
#define QUESTION 1
#define FLAG 2
#define COMPLETE 3
} BOARD;
void ExitApp( int error );
void InitBoard( BOARD *p_board );
void LoadBoard( BOARD *p_board );
void SaveBoard( BOARD *p_board );
void DestroyBoard( BOARD *p_board );
void SetDifficulty( BOARD *p_board, DIFFICULTY difficulty );
void CheckLevel( BOARD *p_board );
void CreateBoard( BOARD *p_board );
void CreateBoxes( BOARD *p_board );
void TestBoard( HWND hWnd, BOARD *p_board, unsigned x, unsigned y, int msg );
void TestMines( BOARD *p_board, POINT pt, int msg );
void TestFace( BOARD *p_board, POINT pt, int msg );
void DrawBoard( HDC hdc, HDC hMemDC, PAINTSTRUCT *ps, BOARD *p_board );
void DrawMines( HDC hdc, HDC hMemDC, BOARD *p_board );
void DrawMine( HDC hdc, HDC hMemDC, BOARD *p_board, unsigned col, unsigned row, BOOL IsPressed );
void AddFlag( BOARD *p_board, unsigned col, unsigned row );
void CompleteBox( BOARD *p_board, unsigned col, unsigned row );
void CompleteBoxes( BOARD *p_board, unsigned col, unsigned row );
void PressBox( BOARD *p_board, unsigned col, unsigned row );
void PressBoxes( BOARD *p_board, unsigned col, unsigned row );
void UnpressBox( BOARD *p_board, unsigned col, unsigned row );
void UnpressBoxes( BOARD *p_board, unsigned col, unsigned row );
void UpdateTimer( BOARD *p_board );
void DrawLeds( HDC hdc, HDC hMemDC, BOARD *p_board, int number, int x, int y);
void DrawFace( HDC hdc, HDC hMemDC, BOARD *p_board );
LRESULT WINAPI MainProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
BOOL CALLBACK CustomDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
BOOL CALLBACK CongratsDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
BOOL CALLBACK TimesDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
BOOL CALLBACK AboutDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
/* end of header */

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

View file

@ -0,0 +1,54 @@
/*
* WineMine (resource.h)
*
* Copyright 2000 Joshua Thielen <jt85296@ltu.edu>
*
* 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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define ID_TIMER 1000
/* menu defines */
#define IDM_NEW 1001
#define IDM_EXIT 1002
#define IDM_TIMES 1003
#define IDM_ABOUT 1004
#define IDM_BEGINNER 1005
#define IDM_ADVANCED 1006
#define IDM_EXPERT 1007
#define IDM_CUSTOM 1008
#define IDM_MARKQ 1009
#define IDC_TIME1 1011
#define IDC_TIME2 1012
#define IDC_TIME3 1013
#define IDC_NAME1 1014
#define IDC_NAME2 1015
#define IDC_NAME3 1016
#define IDC_EDITNAME 1021
#define IDC_EDITCOLS 1031
#define IDC_EDITROWS 1032
#define IDC_EDITMINES 1033
#define IDS_APPNAME 1101
#define IDI_WINEMINE 1201
#define IDB_FACES 1301
#define IDB_LEDS 1302
#define IDB_MINES 1303

View file

@ -0,0 +1,115 @@
/*
* WineMine (rsrc.rc)
*
* Copyright 2000 Joshua Thielen <jt85296@ltu.edu>
*
* 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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <windows.h>
#include "resource.h"
IDI_WINEMINE ICON MOVEABLE "rc/winemine.ico"
IDB_FACES BITMAP MOVEABLE "rc/faces.bmp"
IDB_LEDS BITMAP MOVEABLE "rc/leds.bmp"
IDB_MINES BITMAP MOVEABLE "rc/mines.bmp"
/* English-US Resources */
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
STRINGTABLE {
IDS_APPNAME, "WineMine"
}
MENU_WINEMINE MENU DISCARDABLE
{
POPUP "&Options" {
MENUITEM "&New", IDM_NEW
MENUITEM SEPARATOR
MENUITEM "&Mark Question", IDM_MARKQ
MENUITEM SEPARATOR
MENUITEM "&Beginner", IDM_BEGINNER
MENUITEM "&Advanced", IDM_ADVANCED
MENUITEM "&Expert", IDM_EXPERT
MENUITEM "&Custom", IDM_CUSTOM
MENUITEM SEPARATOR
MENUITEM "E&xit", IDM_EXIT
}
POPUP "&Info" {
MENUITEM "&Fastest Times", IDM_TIMES
MENUITEM "&About", IDM_ABOUT
}
}
DLG_TIMES DIALOG DISCARDABLE 0, 0, 160, 80
STYLE DS_MODALFRAME | DS_3DLOOK |
WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_POPUP
CAPTION "Fastest Times"
{
GROUPBOX "Fastest Times", IDIGNORE, 10, 10, 140, 45
LTEXT "Beginner", IDIGNORE, 20, 20, 40, 8
LTEXT "Advanced", IDIGNORE, 20, 30, 40, 8
LTEXT "Expert", IDIGNORE, 20, 40, 40, 8
LTEXT "999", IDC_TIME1, 70, 20, 15, 8
LTEXT "999", IDC_TIME2, 70, 30, 15, 8
LTEXT "999", IDC_TIME3, 70, 40, 15, 8
LTEXT "", IDC_NAME1, 90, 20, 55, 8
LTEXT "", IDC_NAME2, 90, 30, 55, 8
LTEXT "", IDC_NAME3, 90, 40, 55, 8
DEFPUSHBUTTON "OK", IDOK, 55, 60, 50, 15
}
DLG_CONGRATS DIALOG DISCARDABLE 0, 0, 160, 60
STYLE DS_MODALFRAME | DS_3DLOOK |
WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_POPUP
CAPTION "Congratulations!"
{
LTEXT "Please enter your name", IDIGNORE, 10, 10, 150, 10
EDITTEXT IDC_EDITNAME, 25, 20, 110, 12
DEFPUSHBUTTON "Ok", IDOK, 60, 40, 40, 15
}
DLG_CUSTOM DIALOG DISCARDABLE 0, 0, 100, 100
STYLE DS_MODALFRAME | DS_3DLOOK |
WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_POPUP
CAPTION "Custom Game"
{
LTEXT "Rows", IDIGNORE, 5, 5, 30, 10
LTEXT "Cols", IDIGNORE, 5, 35, 30, 10
LTEXT "Mines", IDIGNORE, 5, 65, 30, 10
EDITTEXT IDC_EDITROWS, 5, 15, 20, 12, ES_NUMBER
EDITTEXT IDC_EDITCOLS, 5, 45, 20, 12, ES_NUMBER
EDITTEXT IDC_EDITMINES, 5, 75, 20, 12, ES_NUMBER
DEFPUSHBUTTON "Ok", IDOK, 40, 30, 50, 15
PUSHBUTTON "Cancel", IDCANCEL, 40, 50, 50, 15
}
DLG_ABOUT DIALOG DISCARDABLE 0, 0, 145, 80
STYLE DS_MODALFRAME | DS_3DLOOK |
WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_POPUP
CAPTION "About"
{
LTEXT "Winemine", IDIGNORE, 10, 10, 35, 10
LTEXT "Copyright 2000, Joshua Thielen", IDIGNORE, 35, 25, 100, 10
LTEXT "under the Wine license", IDIGNORE, 35, 35, 100, 10
ICON "WINEMINE", IDIGNORE, 10, 25, 20, 20
DEFPUSHBUTTON "Ok", IDOK, 50, 60, 55, 15
}
/* End of English-US Resources */