📄 minearea.h
字号:
#if !defined(AFX_MINEAREA_H__F4772965_7A00_4A06_8B17_BBCB1FA45B8B__INCLUDED_)
#define AFX_MINEAREA_H__F4772965_7A00_4A06_8B17_BBCB1FA45B8B__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// MineArea.h : header file
//
const int uWidth = 30;
const int uHeight = 16;
/////////////////////////////////////////////////////////////////////////////
// CMineArea window
// data struct
typedef struct
{
UINT uState;
UINT uDraw;
}MINE;
class CStock
{
public:
CStock()
{
for(int i=0;i<uWidth*uHeight;i++)
array[i][0]=array[i][1]=0;
top=0;
}
void Popup(int *idx, int *val)
{
if(top>0)
{
top--;
*idx=array[top][0];
*val=array[top][1];
}
}
void Push(int idx,int val)
{
if(top<uWidth*uHeight)
{
array[top][0]=idx;
array[top][1]=val;
top++;
}
}
void Empty()
{
top=0;
}
BOOL IsEmpty(){return top==0;}
private:
int array[uWidth*uHeight][2];
int top;
};
struct EQUATION
{
int vars[481];
int varnum;
struct {int x;int y;}org;
EQUATION *prev;
EQUATION *next;
};
typedef struct EQUATION* PEQUATION;
typedef struct EQUATION EQUAHEAD;
// constant
const COLORREF COLOR_WHITE = RGB(255,255,255);
const COLORREF COLOR_GRAY = RGB(192,192,192);
const COLORREF COLOR_DARK_GRAY = RGB(128,128,128);
const COLORREF COLOR_BLACK = RGB(0,0,0);
#define RECT_X_0 9
#define RECT_Y_0 9
#define RECT_HEIGHT_0 37
#define RECT_X_1 9
#define RECT_Y_1 52
#define MINE_AREA_X 12
#define MINE_AREA_Y 55
#define LINE_WIDTH_0 3
#define LINE_WIDTH_1 2
#define NEIGHBORS 8
static int neighbor[8][2]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
enum {WAIT,RUN,DEAD,VICTORY};
class CMineArea : public CStatic
{
// Construction
public:
CMineArea();
// Attributes
public:
void SetMineBox(int i, int j, int draw, int state);
void InferDoble();
private:
void MyDrawRectangle( CPaintDC& dc );
void MyDrawNumber( CPaintDC& dc );
void MyDrawButton( CPaintDC& dc );
void MyDrawMineArea( CPaintDC& dc );
void ProcessLeftButtonUp( int pos );
void SetMine(int pos );
void SetNumbers();
void GetEmptyAreas();
void GetAroundPos( UINT i, int around[9]);
void SetBitmap();
void ReAssign();
void GameInit();
void MyInvalidateRect( RECT &rectClick, int pos );
void ProcessLeftRightButtonUp( int pos );
void DrawEmptyArea( UINT areaFlag );
BOOL Victory();
void FlagAllMine();
void SetMineUpEx( int posArray[], int num );
void SetMineUp( int pos );
void ChangeFlag( int pos );
protected:
RECT rect;
CBitmap BMP_NUMBER;
CBitmap BMP_BUTTON;
CBitmap BMP_MINEAREA;
CBrush backGroundBrush;
UINT uNumPos[6];
UINT uRectPosX[10];
UINT uRectPosY[10];
UINT uButtonPos[3];
COLORREF darkColor;
MINE* pMines;
BOOL bRBUPOutMineArea;
BOOL bHitButton;
BOOL bInButtonRect;
UINT uGameState;
int nOldPos;
BOOL bDoubleClick;
BOOL bInMineArea;
CStock stock;
UINT uButtonState;
UINT uTotle;
PEQUATION pequahead;
BOOL bFirstClick;
UINT ClickNumber;
int nNewPos;
CPoint pt; //current minebox based on 1
int change;
int closed[uWidth*uHeight];
private:
void InferSimple();
PEQUATION DelEqua(PEQUATION equa);
void DelEqua();
void LinkNewEqua(CArray<int,int> &row, CArray<int,int> &col,int result,int i,int j);
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMineArea)
//}}AFX_VIRTUAL
// Implementation
public:
void RButtonUp(UINT nFlags, CPoint point);
void RButtonDown(UINT nFlags, CPoint point);
void MouseMove(UINT nFlags, CPoint point);
void LButtonUp(UINT nFlags, CPoint point);
void LButtonDown(UINT nFlags, CPoint point);
CString GetEquaTxt();
void SetCursorPos(int i,int j);
void AddEquations(int i,int j);
void Infer();
void AlertEquas(int i,int j);
virtual ~CMineArea();
int GetStation(int x,int y);
void SetMineDown( int pos );
void SetMineDownEx( int posArray[], int num );
// Generated message map functions
protected:
//{{AFX_MSG(CMineArea)
afx_msg void OnPaint();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MINEAREA_H__F4772965_7A00_4A06_8B17_BBCB1FA45B8B__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -