?? datatype.h
字號:
#if !defined __DATATYPE_H__
#define __DATATYPE_H__
#define CARD(num,type) (num + type*13)
#define IS_CARD(card) (card<=52 && card>=1)
#define TYPE(card) ((card-1)/13)
#define NUM(card) ((card-1)%13+1)
#define COL_IN_CARD(c) (c<=8)
#define COL_IN_BUFF(c) (c>=9 && c<=12)
#define COL_IN_RECY(c) (c>=13)
const CPoint ptOrg(1,17);//牌局左上角
const CARD_HEI = 94; // 每張牌的高度height
const CARD_WID = 69; // 每張牌的寬度width
const CARD_INT = 8;
// 代表1-8列中每兩堆牌之間的間隔(interval)
// (第9,16兩列分別與窗口兩邊的間距也是這個值)
const PILE_VINT = 8; // 牌列與緩存列間垂直方向上的間隔
const PILE_HINT = 9*CARD_INT; //緩存列與回收列之間的水平間隔
const CARD_UNCOVER = 18; // 當被一張牌壓著的時候,此露出的部分的高度
//usage: clr[BIG/SML][HT/HX/MH/FK][UP/DN][X/Y]...
const UCHAR BIG=0, SML=1, big=16, sml=8;
const UCHAR clr[2][4][2][2] = {
{ { {0 *big,1 *big},//黑桃上
{1 *big,1 *big},//黑桃下
},{ {0 *big,2 *big},//紅桃上
{1 *big,2 *big},//紅桃下
},{ {0 *big,3 *big},//梅花上
{1 *big,3 *big},//梅花下
},{ {0 *big,4 *big},//方塊上
{1 *big,4 *big},//方塊下
}
},{ { {0 *sml,0 *sml},
{0 *sml,1 *sml}
},{ {1 *sml,0 *sml},
{1 *sml,1 *sml}
},{ {2 *sml,0 *sml},
{2 *sml,1 *sml}
},{ {3 *sml,0 *sml},
{3 *sml,1 *sml}
}
}
};
//牌A--牌10的圖像數據
const UCHAR x12 = CARD_WID / 2;
const UCHAR x13 = CARD_WID * 9 / 30;
const UCHAR x23 = CARD_WID * 21 / 30;
const UCHAR y12 = CARD_HEI / 2;
const UCHAR y15 = CARD_HEI / 5;
const UCHAR y25 = CARD_HEI * 2 / 5;
const UCHAR y35 = CARD_HEI * 3 / 5;
const UCHAR y45 = CARD_HEI * 4 / 5;
const UCHAR y310 = CARD_HEI * 3 / 10;
const UCHAR y710 = CARD_HEI * 7 / 10;
const UCHAR y720 = CARD_HEI * 7 / 20;
const UCHAR y1320 = CARD_HEI * 13 / 20;
const UCHAR cA[] = { x12 , y12 , 1, };
const UCHAR c2[] = { x12 , y15 , 1, x12 , y45 , 0, };
const UCHAR c3[] = { x12 , y15 , 1, x12 , y45 , 0, x12 , y12 , 1, };
const UCHAR c4[] = { x13 , y15 , 1, x23 , y15 , 1, x13 , y45 , 0, x23 , y45 , 0, };
const UCHAR c5[] = { x13 , y15 , 1, x23 , y15 , 1, x13 , y45 , 0, x23 , y45 , 0, x12 , y12 , 1, };
const UCHAR c6[] = { x13 , y15 , 1, x23 , y15 , 1, x13 , y45 , 0, x23 , y45 , 0, x13 , y12 , 1, x23 , y12 , 1, };
const UCHAR c7[] = { x13 , y15 , 1, x23 , y15 , 1, x13 , y45 , 0, x23 , y45 , 0, x13 , y12 , 1, x23 , y12 , 1, x12 , y720 , 1 , };
const UCHAR c8[] = { x13 , y15 , 1, x23 , y15 , 1, x13 , y25 , 1, x23 , y25 , 1, x13 , y35 , 0, x23 , y35 , 0, x13 , y45 , 0 , x23 , y45 , 0 };
const UCHAR c9[] = { x13 , y15 , 1, x23 , y15 , 1, x13 , y25 , 1, x23 , y25 , 1, x13 , y35 , 0, x23 , y35 , 0, x13 , y45 , 0 , x23 , y45 , 0 , x12 , y12 , 1 , };
const UCHAR c10[]= { x13 , y15 , 1, x23 , y15 , 1, x13 , y25 , 1, x23 , y25 , 1, x13 , y35 , 0, x23 , y35 , 0, x13 , y45 , 0 , x23 , y45 , 0 , x12 , y310 , 1 , x12 , y710 , 0 , };
const UCHAR c8FK[] = { x13 , y15 , 1, x23 , y15 , 1, x13 , y45 , 0, x23 , y45 , 0, x13 , y12 , 1, x23 , y12 , 1, x12 , y720 , 1 , x12 , y1320 , 0 , };
const UINT modeCrWr = CFile::modeWrite | CFile::modeCreate;
const UINT modeRead = CFile::modeRead;
const DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
static const char * filter = "接龍存檔文件(*.rep)|*.rep||";//文件名過濾器
//步驟計數的字體高度
const UINT stepFont = 22;
//解碼
void Decoding(CFile & desFile, CFile & srcFile);
//////////////////////////////////////////////////////////
class COperation : public CObject
{
DECLARE_SERIAL(COperation)
public:
UCHAR src,des,cnt;//記錄從第src列移動cnt張牌到第des列
COperation()
: des(0),src(0),cnt(0)
{ }
COperation(UINT d,UINT s,UINT n)
: des(d),src(s),cnt(n)
{ }
void Serialize(CArchive &ar) {
//CObject does not serialize anything by default
//CObject::Serialize(ar);
if(ar.IsStoring()) {
ar<<src<<des<<cnt;
} else {
ar>>src>>des>>cnt;
}
}
};
//////////////////////////////////////////////////////////
class COperations : public CObject
{
public:
COperations()
{
pOps = new CObList;
}
COperations(UINT des,UINT src,UINT n)
{
pOps = new CObList;
pOps->AddHead(new COperation(des,src,n));
}
void AddOperation(UINT des,UINT src,UINT n) {
pOps->AddHead(new COperation(des,src,n));
}
void ClrOps() {
POSITION p = pOps->GetHeadPosition();
while(p) {
COperation *pOp = (COperation *)pOps->GetNext(p);
delete pOp;
}
pOps->RemoveAll();
}
~COperations() {
ClrOps();
delete pOps;
}
void Serialize(CArchive &ar) {
//CObject does not serialize anything by default
//CObject::Serialize(ar);
pOps->Serialize(ar);
}
CObList *pOps;
DECLARE_SERIAL(COperations)
};
//////////////////////////////////////////////////////////
//記錄下一步的所有可能的移動步驟用于提示
class HINTS : public COperations
{
int curHint;
public:
HINTS() {
curHint = 0;
}
//
// before call NextHint, you must firstly
// call COperations::AddOperation to fill
// the operation list, for it should NOT be
// empty
//
const COperation* NextHint(void) {
ASSERT(!pOps->IsEmpty());
int cnt = pOps->GetCount();
if(curHint >= cnt) {
curHint = 0;
}
//最先提示鏈尾的動作
const COperation* pOp = (const COperation*)
pOps->GetAt(pOps->FindIndex(cnt - ++curHint));
return pOp;
}
void ClrHints(void) {
ClrOps();
curHint = 0;
}
BOOL IsEmpty() {
return pOps->IsEmpty();
}
};
///////////////////////////////////
struct CARD_POS { UINT col,idx; };
///////////////////////////////////
#define MIN_GAME_NUMBER 1
#define MAX_GAME_NUMBER 0x7FFFFFFF
#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -