-
-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathChineseChessView.h
More file actions
153 lines (127 loc) · 4.13 KB
/
ChineseChessView.h
File metadata and controls
153 lines (127 loc) · 4.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#pragma once
#include "ChineseChess.h"
#ifdef CHINESE_CHESS_USE_PNG
#include<atlimage.h>
#endif
class AFX_EXT_CLASS CChineseChessHandler
{
public:
CChineseChessHandler() {}
~CChineseChessHandler() {}
/**
* Executes the go chess action
*
* @author KangLin(kl222@126.com)
* @date 2020/5/24
*
* @param int i:当前下棋的位置,横坐标[0-8]
* @param int j:当前下棋的位置,纵坐标[0-9]
* @param CPiece::ENUM_QiZi chess:棋子
*
* @returns An int.
*
* @see CPiece::ENUM_QiZi
*/
virtual int OnGoChess(int i, int j, CPiece::ENUM_QiZi chess) = 0;
};
class AFX_EXT_CLASS CChineseChessView : public CView, public CChineseChess
{
DECLARE_DYNAMIC(CChineseChessView)
public:
CChineseChessView();
virtual ~CChineseChessView();
void AboutBox();
int SetQiPangColor(COLORREF col);
COLORREF GetQiPangColor();
int SetTiShiBoxColor(COLORREF col);
COLORREF GetTiShiBoxColor();
virtual int SaveChessGame(LPCTSTR pszFile);
virtual int LoadChessGame(LPCTSTR pszFile);
virtual int SetRedName(LPCTSTR pszName);
virtual int SetBlackName(LPCTSTR pszName);
virtual int AddGameTag(LPCTSTR pszTag, LPCTSTR szVal);
CString GetGameTag(LPCTSTR szTag);
int SetChineseChessHandler(CChineseChessHandler* handler);
protected:
DECLARE_MESSAGE_MAP()
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnSize(UINT nType, int cx, int cy);
virtual void OnDraw(CDC* pDC);
protected:
virtual int onPromptSound(PROMPT_SOUND sound);
virtual int onPromptMessage(CGoRule::ENUM_ReturnValue val);
virtual int onCleanPrompt(int i, int j);
virtual int onDrawPrompt(int i, int j);
virtual int onGoChess(int i, int j, CPiece::ENUM_QiZi chess);
private:
LONG m_QiPangStartX; //棋盘的开始横坐标
LONG m_QiPangStartY; //棋盘的开始横坐标
LONG m_QiPangDistance; //棋盘格的距离
COLORREF m_QiPangColor;
COLORREF m_TiShiBoxColor;
//楚河汉界
CBitmap m_Chu;
CBitmap m_He;
CBitmap m_Han;
CBitmap m_Jie;
CBitmap m_Copyright;
#ifdef CHINESE_CHESS_USE_PNG
ATL::CImage m_QiPangPicture; //棋盘背景图片
//棋子图片
ATL::CImage m_RedShuai; //红帅
ATL::CImage m_RedShi; //红仕
ATL::CImage m_RedXiang; //红相
ATL::CImage m_RedMa; //红马
ATL::CImage m_RedChe; //红车
ATL::CImage m_RedBing; //红兵
ATL::CImage m_RedPao; //红炮
ATL::CImage m_BlackShuai; //黑帅
ATL::CImage m_BlackShi; //黑仕
ATL::CImage m_BlackXiang; //黑相
ATL::CImage m_BlackMa; //黑马
ATL::CImage m_BlackChe; //黑车
ATL::CImage m_BlackBing; //黑兵
ATL::CImage m_BlackPao; //黑炮
#else
CBitmap m_QiPangPicture; //棋盘背景图片
//棋子图片
CBitmap m_RedShuai; //红帅
CBitmap m_RedShi; //红仕
CBitmap m_RedXiang; //红相
CBitmap m_RedMa; //红马
CBitmap m_RedChe; //红车
CBitmap m_RedBing; //红兵
CBitmap m_RedPao; //红炮
CBitmap m_BlackShuai; //黑帅
CBitmap m_BlackShi; //黑仕
CBitmap m_BlackXiang; //黑相
CBitmap m_BlackMa; //黑马
CBitmap m_BlackChe; //黑车
CBitmap m_BlackBing; //黑兵
CBitmap m_BlackPao; //黑炮
#endif
#ifdef CHINESE_CHESS_USE_PNG
// 从资源中加载图片到 CImage
BOOL LoadImageFromResource(ATL::CImage *pImage, UINT ID, LPCTSTR pType = _T("PNG"));
BOOL LoadImageFromResource(ATL::CImage *pImage, LPCTSTR pID, LPCTSTR pType = _T("PNG"));
#endif
//坐标转换
enum ENUM_ConvertCoordinate { XYToIJ, IJToXY };
BOOL ConvertCoordinate(long *x, long *y, int *i, int *j, ENUM_ConvertCoordinate eCC = XYToIJ);
//棋盘星位
enum ENUM_XINWEI { XinWei, Left_XinWei, Right_XinWei };
void DrawXinWei(CDC *pdc, int i, int j, ENUM_XINWEI xinwei = XinWei);
BOOL DrawTiShiBox(CDC *pdc, int i, int j);
BOOL DrawQiZi(CDC *pdc, int i, int j, CPiece::ENUM_QiZi eQiZi);
void DrawQiPang(CDC *pdc, CRect rcBounds);
#ifdef CHINESE_CHESS_USE_PNG
BOOL DrawPicture(CDC *pdc, int i, int j, ATL::CImage* pImage);
#endif
BOOL DrawPicture(CDC *pdc, int i, int j, CBitmap* pbmp, BOOL CHHJKL = false);
void InvalidateRectage(int i, int j);
BOOL SetQiPang(int width, int height);
BOOL PromptSound(LPCTSTR ID = NULL);
CChineseChessHandler* m_pGoChessHandler;
};