📄 llkdlg.cpp
字号:
CFont *pOldFont,*font;
font = new CFont;
font->CreateFont(19, 0, 0, 0, FW_NORMAL, FALSE, FALSE,0,0,0,0,0,0, _T("Arial"));
pOldFont = (CFont*)pDC->SelectObject(font);
if (m_nLanguage == 0)
{
pDC->DrawText(_T("RePlay"), CRect(145,85,272,106), DT_CENTER);
pDC->DrawText(_T("Record"), CRect(145,110,272,131), DT_CENTER);
pDC->DrawText(_T("Return"), CRect(145,135,272,156), DT_CENTER);
if (m_bEffect)
pDC->DrawText(_T("Sound(open)"), CRect(145, 160, 274, 181), DT_CENTER);
else
pDC->DrawText(_T("Sound(close)"), CRect(145, 160, 274, 181), DT_CENTER);
pDC->DrawText(_T("Exit"), CRect(145,185,272,206), DT_CENTER);
}
if (m_nLanguage == 1)
{
pDC->DrawText(_T("重新开始"), CRect(145,85,272,106), DT_CENTER);
pDC->DrawText(_T("最高记录"), CRect(145,110,272,131), DT_CENTER);
pDC->DrawText(_T("返回游戏"), CRect(145,135,272,156), DT_CENTER);
if (m_bEffect)
pDC->DrawText(_T("声音(开)"), CRect(145,160,272,181), DT_CENTER);
else
pDC->DrawText(_T("声音(关)"), CRect(145,160,272,181), DT_CENTER);
pDC->DrawText(_T("退出游戏"), CRect(145,185,272,206), DT_CENTER);
}
DrawSemiTransparentRect(pDC,CRect(147,m_nMenu_y+85,273,m_nMenu_y+109),RGB(255,255,255));
dc.DeleteDC();
menu.DeleteObject();
pOldFont->DeleteObject();
font->DeleteObject();
delete font;
}
}
void CLlkDlg::OnOptionPrompt() //提示
{
// TODO: Add your command handler code here
Prompt();
if (m_bTip_ok)
{
UpdatePrompt();
}
m_bTip_ok = false;
}
void CLlkDlg::OnOptionShuffle() //洗牌
{
// TODO: Add your command handler code here
Shuffle();
UpdateShuffle();
}
void CLlkDlg::NextLEVEL(CDC *pDC) //绘对话框
{
if (m_nPass)
{
CRect Rect(145,108,272,182);
pDC->FillSolidRect(&Rect, RGB(82,123,156));
CBitmap Button,ButtonDown;
CDC Mydc1,Mydc2;
Button.LoadBitmap(IDB_BUTTON);
ButtonDown.LoadBitmap(IDB_BUTTON_DOWN);
Mydc1.CreateCompatibleDC(pDC);
Mydc1.SelectObject(&Button);
Mydc2.CreateCompatibleDC(pDC);
Mydc2.SelectObject(&ButtonDown);
if (m_bBox)
{
pDC->BitBlt(182,148,48,25,&Mydc2,0,0,SRCCOPY);
}
else
{
pDC->BitBlt(182,148,48,25,&Mydc1,0,0,SRCCOPY);
}
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(RGB(255,255,255));
CFont *pOldFont,*font;
font = new CFont;
font->CreateFont(16, 0, 0, 0, FW_NORMAL, FALSE, FALSE,0,0,0,0,0,0, _T("Arial"));
pOldFont = (CFont*)pDC->SelectObject(font);
pDC->DrawText(_T("OK"),CRect(196,150,216,170),DT_CENTER);
pDC->DrawText(m_strBox,CRect(150,120,265,151),DT_CENTER);
CPen pen( PS_SOLID, 1, RGB(0,0,255));
CPen Spen(PS_SOLID, 2, RGB(167,241,243));
CPen *pOldPen = pDC->SelectObject(&pen);
pDC->MoveTo(144, 107);
pDC->LineTo(272, 107);
pDC->LineTo(272, 182);
pDC->LineTo(144, 182);
pDC->LineTo(144, 107);
CPen *sOldPen=pDC->SelectObject(&Spen);
pDC->MoveTo(182,148);
pDC->LineTo(230,148);
pDC->LineTo(230,173);
pDC->LineTo(182,173);
pDC->LineTo(182,148);
Mydc1.DeleteDC();
Mydc2.DeleteDC();
pOldFont->DeleteObject();
pOldPen->DeleteObject();
sOldPen->DeleteObject();
font->DeleteObject();
delete font;
Button.DeleteObject();
ButtonDown.DeleteObject();
}
}
void CLlkDlg::OnOK()
{
}
BOOL CLlkDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if((UINT)pMsg->message == WM_KEYDOWN)
{
switch ((UINT)pMsg->wParam)
{
case VK_TAB:
if (!m_bSele_ok && !m_nPass)
m_nButton = 1;
break;
case VK_F12:
GoToNextLevel();
break;
case VK_LEFT:
if (!m_bSele_ok && !m_nPass)
{
if(!m_nButton && GetInGame())
{
m_bMouse = false;
m_nPane_x = m_nPane_x - 26;
if (m_nPane_x < 0)
m_nPane_x = 338;
}
else
{
m_nButton--;
if (m_nButton < 1)
m_nButton = 3;
}
}
if (m_bSele_ok)
{
if (m_nMenu_y == 75)
m_bEffect = !m_bEffect;
}
break;
case VK_RIGHT:
if (!m_bSele_ok && !m_nPass)
{
if (!m_nButton && GetInGame())
{
m_bMouse = false;
m_nPane_x = m_nPane_x + 26;
if (m_nPane_x > 338)
m_nPane_x = 0;
}
else
{
m_nButton++;
if (m_nButton > 3)
m_nButton = 1;
}
}
if (m_bSele_ok)
{
if (m_nMenu_y == 75)
m_bEffect = !m_bEffect;
}
break;
case VK_UP:
if (m_bSele_ok && !m_nPass)
{
m_nMenu_y -= 25;
if (m_nMenu_y < 0)
m_nMenu_y = 100;
break;
}
if (!m_nButton && !m_nPass && GetInGame())
{
m_bMouse = false;
m_nPane_y = m_nPane_y - 32;
if (m_nPane_y < 0)
m_nPane_y = 160;
}
break;
case VK_DOWN:
if (m_bSele_ok && !m_nPass)
{
m_nMenu_y += 25;
if (m_nMenu_y > 100)
m_nMenu_y = 0;
break;
}
if (!m_nButton && !m_nPass && GetInGame())
{
m_bMouse = false;
m_nPane_y = m_nPane_y + 32;
if (m_nPane_y > 160)
m_nPane_y = 0;
}
break;
case VK_RETURN:
if (m_nPass)
{
if (m_nPass == 3)
{
m_nPass = 3;
break;
}
if (m_nPass ==4)
{
m_nPass = 4;
break;
}
if (m_nPass == 7)
{
m_nPass = 7;
break;
}
m_nPass += 2;
m_bBox = true;
CDC *pDC = GetDC();
NextLEVEL(pDC);
pDC->DeleteDC();
break;
}
if (m_bSele_ok)
{
if (m_nMenu_y == 0)
{
m_nButton = 0;
m_bSele_ok = false;
m_nMenu_y = 0;
if (m_nScore > m_lHighPoint)
WriteFile();
OnGameAbandon();
InitSysVar();
SetInGame();
SetLevel();
StartGame();
}
if (m_nMenu_y == 25)
{
m_nPass = 5;
ReadFile();
m_bSele_ok = false;
m_bMessage = true;
m_nButton = 0;
m_nMenu_y = 0;
}
if (m_nMenu_y == 50)
{
m_nButton = 0;
m_bSele_ok = false;
m_nMenu_y = 0;
m_bMessage = false;
if (GetInGame())
SetPause(false);
}
if (m_nMenu_y == 75)
{
m_nButton = 0;
m_bSele_ok = false;
m_nMenu_y = 0;
m_bMessage = false;
if (GetInGame())
SetPause(false);
}
if (m_nMenu_y == 100)
{
if (m_nScore > m_lHighPoint)
WriteFile();
PostQuitMessage(0);
}
break;
}
if (!m_nButton && GetInGame())
{
int iTop, iLeft, iRight, iBottom;
iTop = DRAW_TOP + BMP_HEIGHT + 57;
iBottom = iTop + BMP_HEIGHT * ROW_NUMBER;
iLeft = DRAW_LEFT + BMP_WIDTH +16;
iRight = iLeft + BMP_WIDTH * LINE_NUMBER;
int tempx, tempy;
int xtempindex, ytempindex;
tempy = (m_nPane_x+88) / BMP_WIDTH;
tempx = (m_nPane_y+65) / BMP_HEIGHT;
xtempindex = tempx - 1;
ytempindex = tempy - 2;
m_bMouse = false;
if (GetPicIndex(xtempindex, ytempindex) > 0)
{
if (m_bSecClk)
{
if((xtempindex == m_nXIndex) && (ytempindex == m_nYIndex))
{
UpdateClkState(m_nXIndex, m_nYIndex, LS_NOCLK);
}
else
{
if(GetPicIndex(xtempindex, ytempindex) ==
GetPicIndex(m_nXIndex, m_nYIndex))
{
if (CheckConn(m_nXIndex, m_nYIndex, xtempindex, ytempindex))
{
UpdateLeft(1);
UpdateScore(100);
m_nTpos = 1;
AddTime();
if (m_bEffect)
PlaySound (TEXT("\\NAND\\llk(sound)\\OK.wav"), NULL, SND_ASYNC | SND_NODEFAULT);
ReleasePicPlace(m_nXIndex, m_nYIndex);
ReleasePicPlace(xtempindex, ytempindex);
int nEvent1 = GetValue(xtempindex, ytempindex);
int nEvent2 = GetValue(m_nXIndex, m_nYIndex);
if ((nEvent1 & LS_PROMPT) == LS_PROMPT ||
(nEvent2 & LS_PROMPT) == LS_PROMPT)
{
UpdatePrompt(1);
if (m_nLanguage == 0)
m_strTop = _T("Award tip+1");
if(m_nLanguage == 1)
m_strTop = _T("奖励:提示1次");
if (m_bEffect)
{
PlaySound (TEXT("\\NAND\\llk(sound)\\AWARD.wav"), NULL, SND_ASYNC | SND_NODEFAULT);
}
}
else if ((nEvent1 & LS_SHUFFLE) == LS_SHUFFLE ||
(nEvent2 & LS_SHUFFLE) == LS_SHUFFLE)
{
UpdateShuffle(1);
if (m_nLanguage == 0)
m_strTop =_T("Award Shuffle+1");
if (m_nLanguage == 1)
m_strTop =_T("奖励:洗牌1次");
if (m_bEffect)
{
PlaySound (TEXT("\\NAND\\llk(sound)\\AWARD.wav"), NULL, SND_ASYNC | SND_NODEFAULT);
}
}
else if ((nEvent1 & LS_SCORE) == LS_SCORE ||
(nEvent2 & LS_SCORE) == LS_SCORE)
{
UpdateScore(100);
if (m_nLanguage == 0)
m_strTop =_T("Award 100 points");
if (m_nLanguage == 1)
m_strTop =_T("奖励:100 分");
if (m_bEffect)
{
PlaySound (TEXT("\\NAND\\llk(sound)\\AWARD.wav"), NULL, SND_ASYNC | SND_NODEFAULT);
}
}
SetValue(xtempindex, ytempindex, LS_NONE);
SetValue(m_nXIndex, m_nYIndex, LS_NONE);
MovePic(m_nXIndex, m_nYIndex, xtempindex, ytempindex);
}
else
{
UpdateClkState(m_nXIndex, m_nYIndex, LS_NOCLK);
}
}
else
{
UpdateClkState(m_nXIndex, m_nYIndex, LS_NOCLK);
}
}
m_nXIndex = -1;
m_nYIndex = -1;
}
else
{
UpdateClkState(xtempindex, ytempindex, LS_CLICK);
m_nXIndex = xtempindex;
m_nYIndex = ytempindex;
}
}
if (GetPicIndex(xtempindex, ytempindex) <= 0 && m_bSecClk)
{
UpdateClkState(m_nXIndex, m_nYIndex, LS_NOCLK);
}
if (IsPicEmpty())
{
if (m_bEffect)
PlaySound (TEXT("\\NAND\\llk(sound)\\PASS.wav"), NULL, SND_ASYNC | SND_NODEFAULT);
int nLevel = GetLevel();
int nLeftTime = (int)(GetUpper() - GetPos());
SetPause();
if (nLevel < 15)
{
UpdateScore((nLevel * (nLevel - 1) + 1) * 5 + nLeftTime);
if (m_nLanguage == 0)
m_strBox = _T("GO TO NEXT LEVEL!");
if (m_nLanguage == 1)
m_strBox = _T("进入下一关!");
if (m_nScore > m_lHighPoint)
WriteFile();
m_nPass = 1;
}
else
{
if (m_nLanguage == 0)
m_strBox = _T("PASS ALL LEVEL!");
if (m_nLanguage == 1)
m_strBox = _T("全部过关!");
if (m_nScore > m_lHighPoint)
WriteFile();
m_nPass = 2;
SetInGame(FALSE);
}
m_bMessage = true;
}
m_bSecClk = !m_bSecClk;
}
if(m_nButton==1)
{
m_nButton=0;
m_bMouse=true;
if(m_nPrompt>0)
{
m_bTip=true;
if(m_bEffect)
PlaySound (TEXT("\\NAND\\llk(sound)\\TIP.wav"), NULL, SND_ASYNC | SND_NODEFAULT);
OnOptionPrompt();
CDC *pDC = GetDC();
TipButton(pDC);
pDC->DeleteDC();
}
}
if (m_nButton == 2)
{
m_bMouse = true;
m_nButton = 0;
if (m_nShuffle > 0)
{
m_bWash = true;
CDC *pDC = GetDC();
WashButton(pDC);
pDC->DeleteDC();
if (m_bEffect)
PlaySound (TEXT("\\NAND\\llk(sound)\\SHUFF.wav"), NULL, SND_ASYNC | SND_NODEFAULT);
OnOptionShuffle();
}
}
if (m_nButton == 3)
{
SetPause();
m_bMouse = true;
m_bSel = true;
m_bSele_ok = true;
m_nButton = 0;
CDC *pDC = GetDC();
SelButton(pDC);
pDC->DeleteDC();
}
break;
}
}
if ((UINT)pMsg->message == WM_KEYUP)
{
switch ((UINT)pMsg->wParam)
{
case VK_RETURN:
m_bTip = false;
m_bWash = false;
m_bSel = false;
if (m_nPass == 3)
{
m_bBox = false;
GoToNextLevel();
m_bMessage = false;
m_nPass = 0;
}
if (m_nPass == 4)
{
m_bSele_ok = true;
m_bMessage = false;
m_nPass = 0;
m_bBox =false;
}
if (m_nPass == 7)
{
m_bMessage = false;
m_nPass = 0;
m_bBox = false;
if (GetInGame())
SetPause(false);
}
break;
default:
break;
}
}
return CDialog::PreTranslateMessage(pMsg);
}
BOOL CLlkDlg::DestroyWindow()
{
// TODO: Add your specialized code here and/or call the base class
return CDialog::DestroyWindow();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -