代码拉取完成,页面将自动刷新
同步操作将从 Seconight/MFC_连连看游戏 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
// CGameDlg.cpp: 实现文件
//
//#include "pch.h"
#include <afxcontrolbars.h>
#include "Lianliankan.h"
#include "CGameDlg.h"
#include "afxdialogex.h"
#include "CGameLogic.h"
#include "CHelpDialog.h"
#include "CGameData.h"
#include "global.h"
#include "CSettingDlg.h"
#include<stack>
using namespace std;
extern int gameSound; //1,2
extern int gameHard; //1,2,3
extern CString userName;
extern CString gameBackground;
extern CString itemPath;
extern CString itemMask;
extern void GetIt();
// CGameDlg 对话框
IMPLEMENT_DYNAMIC(CGameDlg, CDialogEx)
CGameDlg::CGameDlg(CWnd* pParent /*=nullptr*/)
: CDialogEx(IDD_GAME_DIALOG, pParent)
{
icon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_ptGameTop.x = 50;
m_ptGameTop.y = 50;
//单个元素图片大小
m_sizeElem.cx = 40;
m_sizeElem.cy = 40;
m_bFirstPoint = true;
isPlaying = false;
isPause = false;
//初始化游戏地图更新区域
m_rtGameRect.top = m_ptGameTop.y;
m_rtGameRect.left = m_ptGameTop.x;
//个数加2
m_rtGameRect.right = m_rtGameRect.left+ 14* m_sizeElem.cx;
m_rtGameRect.bottom = m_rtGameRect.top + 10* m_sizeElem.cy;
//TODO:初始化control变量
}
CGameDlg::~CGameDlg()
{
delete m_GameC;
}
void CGameDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_GAME_TIME, m_GameProgress);
}
BEGIN_MESSAGE_MAP(CGameDlg, CDialogEx)
ON_WM_PAINT()
ON_BN_CLICKED(IDC_BTN_B_BIGIN, &CGameDlg::OnClickedBtnBBigin)
ON_WM_LBUTTONUP()
ON_BN_CLICKED(IDC_BTN_B_SIGN, &CGameDlg::OnClickedBtnBSign)
ON_BN_CLICKED(IDC_BTN_B_RERANK, &CGameDlg::OnClickedBtnBRerank)
ON_WM_TIMER()
ON_BN_CLICKED(IDC_BTN_B_PAUSE, &CGameDlg::OnClickedBtnBPause)
ON_BN_CLICKED(IDC_BTN_B_HELP, &CGameDlg::OnClickedBtnBHelp)
ON_BN_CLICKED(IDC_BTN_B_PROP, &CGameDlg::OnClickedBtnBProp)
ON_BN_CLICKED(IDC_BTN_B_SETTINGS, &CGameDlg::OnBnClickedBtnBSettings)
END_MESSAGE_MAP()
// CGameDlg 消息处理程序
void CGameDlg::InitBackground()
{
CClientDC dc(this);
HANDLE bmp = ::LoadImage(NULL, _T("theme\\picture\\b_bg.bmp"),
IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
m_dcBG.CreateCompatibleDC(&dc);
m_dcBG.SelectObject(bmp);
//初始化内存dc
m_dcMem.CreateCompatibleDC(&dc);
CBitmap bitmap;
bitmap.CreateCompatibleBitmap(&dc, 1920, 1080);
m_dcMem.SelectObject(&bitmap);
//绘制背景到内存dc中
m_dcMem.BitBlt(0, 0, 1920, 1080, &m_dcBG, 0, 0, SRCCOPY);
}
BOOL CGameDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
SetIcon(icon, TRUE); // 设置大图标
SetIcon(icon, FALSE); // 设置小图标
SetWindowText(m_GameC->GetGameFlag().sign);
//获取config
GetIt();
m_GameC->currentHard = gameHard;
if (gameSound == 1) {
haveSound = true;
}
else {
haveSound = false;
}
this->GetDlgItem(IDC_NAME)->SetWindowTextW(userName);
//CFont font;
////在OnInitDialog()中:
//font.CreatePointFont(700, _T("Fira Code"));
//GetDlgItem(IDC_STATIC)->SetFont(&font);
/*InitBackground();
InitElement();*/
UpdateTheme();
if (this->m_GameC->GetGameFlag().timer == false) {
this->GetDlgItem(IDC_GAME_TIME)->ShowWindow(SW_HIDE);
this->GetDlgItem(IDC_STATIC)->ShowWindow(SW_HIDE);
}
if (this->m_GameC->GetGameFlag().prop == false) {
this->GetDlgItem(IDC_BTN_B_PROP)->ShowWindow(SW_HIDE);
}
if (this->m_GameC->GetGameFlag().score == false) {
this->GetDlgItem(IDC_ST_PROP)->ShowWindow(SW_HIDE);
}
return TRUE;
}
void CGameDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: 在此处添加消息处理程序代码
// 不为绘图消息调用 CDialogEx::OnPaint()
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// 使图标在工作区矩形中居中
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// 绘制图标
dc.DrawIcon(x, y, icon);
dc.BitBlt(0, 0, 1920, 1080, &m_dcMem, 0, 0, SRCCOPY);
}
void CGameDlg::InitElement()
{
CClientDC dc(this);
HANDLE bmp = ::LoadImage(NULL, _T("theme\\picture\\fe.bmp"),
IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
m_dcElement.CreateCompatibleDC(&dc);
m_dcElement.SelectObject(bmp);
HANDLE mask = ::LoadImage(NULL, _T("theme\\picture\\final.bmp"),
IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
m_dcMask.CreateCompatibleDC(&dc);
m_dcMask.SelectObject(mask);
HANDLE bmp1 = ::LoadImage(NULL, _T("theme\\picture\\pause.bmp"),
IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
m_pause.CreateCompatibleDC(&dc);
m_pause.SelectObject(bmp1);
}
//void Test(CGameControl gameControl)
//{
// CStdioFile file(_T("log.txt"), CFile::modeCreate | CFile::modeReadWrite);
// for (int i = 0; i < gameControl.getGraph().vex_num; i++)
// {
// CString str;
// str.Format(_T("%d\t"), gameControl.getGraph().getVex(i));
// file.WriteString(str);
// }
// CString str;
// str.Format(_T("\n\n"));
// file.WriteString(str);
// for (int i = 0; i < 140; i++)
// {
// for (int j = 0; j < 140; j++)
// {
// CString str;
// str.Format(_T("%d\t"), gameControl.getGraph().edge[i][j]);
// file.WriteString(str);
// }
// CString str;
// str.Format(_T("\n"));
// file.WriteString(str);
// }
// file.Close();
//}
void CGameDlg::OnClickedBtnBBigin()
{
//初始化游戏
int a = m_GameC->gameMode;
if (m_GameC->gameMode != 3) {
if (gameHard == 1) {
m_GameC->StartGame();
}
if (gameHard == 2) {
m_GameC->StartGame2();
}
if (gameHard == 3) {
m_GameC->StartGame3();
}
}
else {
m_GameC->StartGame();
}
//提示正在游戏中
isPlaying = true;
//将开始游戏设置为false
this->GetDlgItem(IDC_BTN_B_BIGIN)->EnableWindow(false);
//初始进度条
m_GameProgress.SetRange(0, 200);
m_GameProgress.SetStep(-1);
m_GameProgress.SetPos(200);
//计时器
this->SetTimer(PLAY_TIMER_ID, 1000, NULL);
int i = 200;
CString str;
str.Format(_T("%d"), i);
LPCTSTR pStr = LPCTSTR(str);
GetDlgItem(IDC_STATIC)->SetWindowText(pStr);
//Test(&m_GameC); //输出生成图日志
UpdateMap();
Invalidate(FALSE);
//RedrawWindow();
}
void CGameDlg::UpdateMap()
{
int nLeft = m_ptGameTop.x;
int nTop = m_ptGameTop.y;
int nElmW = m_sizeElem.cx;
int nElmH = m_sizeElem.cy;
m_dcMem.BitBlt(m_rtGameRect.left, m_rtGameRect.top, m_rtGameRect.Width(),
m_rtGameRect.Height(), &m_dcBG, m_rtGameRect.left, m_rtGameRect.top, SRCCOPY);
//TODO:数组双边增加~
if (m_GameC->gameMode != 3) {
if (gameHard == 1) {
for (int i = 0; i < ROW_EASY; i++) {
for (int j = 0; j < COL_EASY; j++)
{
//利用getElement函数进行元素替换。
int element = m_GameC->GetElement(i, j);
m_dcMem.BitBlt(nLeft + nElmW * j, nTop + i * nElmH, nElmW,
nElmH, &m_dcMask, 0, element * nElmH, SRCPAINT);
//背景与原图相与
m_dcMem.BitBlt(nLeft + nElmW * j, nTop + i * nElmH, nElmW,
nElmH, &m_dcElement, 0, element * nElmH, SRCAND);
}
}
}
if (gameHard == 2) {
for (int i = 0; i < ROW_MIDDLE; i++) {
for (int j = 0; j < COL_MIDDLE; j++)
{
//利用getElement函数进行元素替换。
int element = m_GameC->GetElement(i, j);
m_dcMem.BitBlt(nLeft + nElmW * j, nTop + i * nElmH, nElmW,
nElmH, &m_dcMask, 0, element * nElmH, SRCPAINT);
//背景与原图相与
m_dcMem.BitBlt(nLeft + nElmW * j, nTop + i * nElmH, nElmW,
nElmH, &m_dcElement, 0, element * nElmH, SRCAND);
}
}
}
if (gameHard == 3) {
for (int i = 0; i < ROW_MAX; i++) {
for (int j = 0; j < COL_MAX; j++)
{
//利用getElement函数进行元素替换。
int element = m_GameC->GetElement(i, j);
m_dcMem.BitBlt(nLeft + nElmW * j, nTop + i * nElmH, nElmW,
nElmH, &m_dcMask, 0, element * nElmH, SRCPAINT);
//背景与原图相与
m_dcMem.BitBlt(nLeft + nElmW * j, nTop + i * nElmH, nElmW,
nElmH, &m_dcElement, 0, element * nElmH, SRCAND);
}
}
}
}
else {
if (m_GameC->currentLevel == 1) {
for (int i = 0; i < ROW_EASY; i++) {
for (int j = 0; j < COL_EASY; j++)
{
//利用getElement函数进行元素替换。
int element = m_GameC->GetElement(i, j);
m_dcMem.BitBlt(nLeft + nElmW * j, nTop + i * nElmH, nElmW,
nElmH, &m_dcMask, 0, element * nElmH, SRCPAINT);
//背景与原图相与
m_dcMem.BitBlt(nLeft + nElmW * j, nTop + i * nElmH, nElmW,
nElmH, &m_dcElement, 0, element * nElmH, SRCAND);
}
}
}
if (m_GameC->currentLevel == 2) {
for (int i = 0; i < ROW_MIDDLE; i++) {
for (int j = 0; j < COL_MIDDLE; j++)
{
//利用getElement函数进行元素替换。
int element = m_GameC->GetElement(i, j);
m_dcMem.BitBlt(nLeft + nElmW * j, nTop + i * nElmH, nElmW,
nElmH, &m_dcMask, 0, element * nElmH, SRCPAINT);
//背景与原图相与
m_dcMem.BitBlt(nLeft + nElmW * j, nTop + i * nElmH, nElmW,
nElmH, &m_dcElement, 0, element * nElmH, SRCAND);
}
}
}
if (m_GameC->currentLevel == 3) {
for (int i = 0; i < ROW_MAX; i++) {
for (int j = 0; j < COL_MAX; j++)
{
//利用getElement函数进行元素替换。
int element = m_GameC->GetElement(i, j);
m_dcMem.BitBlt(nLeft + nElmW * j, nTop + i * nElmH, nElmW,
nElmH, &m_dcMask, 0, element * nElmH, SRCPAINT);
//背景与原图相与
m_dcMem.BitBlt(nLeft + nElmW * j, nTop + i * nElmH, nElmW,
nElmH, &m_dcElement, 0, element * nElmH, SRCAND);
}
}
}
}
}
void CGameDlg::OnLButtonUp(UINT nFlags, CPoint point)
{
if (point.x < m_ptGameTop.x || point.y < m_ptGameTop.y)
{
return CDialogEx::OnLButtonUp(nFlags, point);
}
int nRow = (point.y - m_ptGameTop.y) / m_sizeElem.cy;
int nCol = (point.x - m_ptGameTop.x) / m_sizeElem.cx;
//TODO:修改常量
if (nRow > 13 || nCol > 13)
return CDialogEx::OnLButtonUp(nFlags, point);
if (m_bFirstPoint) {
DrawTipFrame(nRow, nCol);
m_GameC->SetFirstPoint(nRow, nCol);
}
else {
DrawTipFrame(nRow, nCol);
m_GameC->SetSecondPoint(nRow, nCol);
//检查是否相同
stack<Vertex> pp;
if (m_GameC->Link(pp))
{
DrawTipLine(pp);
UpdateMap();
if(haveSound)
MessageBeep(MB_OK);
//MessageBeep(MB_OK);
if (m_GameC->GetGameFlag().score == true) {
CString str;
str.Format(_T("当前积分:%d"), m_GameC->gameScore);
LPCTSTR pStr = LPCTSTR(str);
GetDlgItem(IDC_ST_PROP)->SetWindowText(pStr);
if (m_GameC->getProp) {
this->MessageBox(_T("获得一个道具!"));
CString str;
str.Format(_T("当前道具:%d"), m_GameC->gameProp);
LPCTSTR pStr = LPCTSTR(str);
this->GetDlgItem(IDC_BTN_B_PROP)->SetWindowTextW(pStr);
m_GameC->getProp = false;
}
}
}
Sleep(200);
InvalidateRect(m_rtGameRect, FALSE);
JudgeWin();
/*if (m_GameC.isWin(m_GameProgress.GetPos()))
{
MessageBox(_T("获胜!"));
isPlaying = false;
this->GetDlgItem(IDC_BTN_B_BIGIN)->EnableWindow(true);
}*/
}
m_bFirstPoint = !m_bFirstPoint;
}
void CGameDlg::DrawTipFrame(int nRow,int nCol)
{
CClientDC dc(this);
CBrush brush(RGB(233, 43, 43));
CRect rtTipFrame;
rtTipFrame.left = m_ptGameTop.x + nCol * m_sizeElem.cx;
rtTipFrame.top = m_ptGameTop.y + nRow * m_sizeElem.cy;
rtTipFrame.right = rtTipFrame.left + m_sizeElem.cx;
rtTipFrame.bottom = rtTipFrame.top + m_sizeElem.cy;
dc.FrameRect(rtTipFrame, &brush);
}
void CGameDlg::DrawTipLine(stack<Vertex> &path)
{
CClientDC dc(this);
//set the pen
CPen penline(PS_SOLID, 2, RGB(0, 255, 0));
CPen* pOldPen = dc.SelectObject(&penline);
while(path.size()!=1)
{
Vertex v1 = path.top(); path.pop();
Vertex v2 = path.top();
dc.MoveTo(m_ptGameTop.x + v1.col * m_sizeElem.cx + m_sizeElem.cx / 2,
m_ptGameTop.y + v1.row * m_sizeElem.cy + m_sizeElem.cy / 2);
dc.LineTo(m_ptGameTop.x + v2.col * m_sizeElem.cx + m_sizeElem.cx / 2,
m_ptGameTop.y + v2.row * m_sizeElem.cy + m_sizeElem.cy / 2);
}
dc.SelectObject(pOldPen);
path.pop();
}
void CGameDlg::OnClickedBtnBSign()
{
// TODO: 在此添加控件通知处理程序代码
stack<Vertex> pp;
int row1, row2, col1, col2;
if (m_GameC->GetGameFlag().score == false) {
if (m_GameC->Help(pp, row1, col1, row2, col2))
{
DrawTipLine(pp);
//UpdateMap();
DrawTipFrame(row1, col1);
DrawTipFrame(row2, col2);
}
else
{
this->MessageBox(_T("当前没有可连点!建议重排"));
}
}
else
{
if (m_GameC->gameScore < 20) {
this->MessageBox(_T("当前积分不足!最少20分"));
}
else
{
if (m_GameC->Help(pp, row1, col1, row2, col2))
{
DrawTipLine(pp);
//UpdateMap();
DrawTipFrame(row1, col1);
DrawTipFrame(row2, col2);
m_GameC->gameScore -= 20;
CString str;
str.Format(_T("当前积分:%d"), m_GameC->gameScore);
LPCTSTR pStr = LPCTSTR(str);
GetDlgItem(IDC_ST_PROP)->SetWindowText(pStr);
}
else
{
this->MessageBox(_T("当前没有可连点!建议重排"));
}
}
}
Sleep(300);
InvalidateRect(m_rtGameRect, FALSE);
}
void CGameDlg::OnClickedBtnBRerank()
{
// TODO: 在此添加控件通知处理程序代码
m_GameC->Reset(gameHard);
UpdateMap();
InvalidateRect(m_rtGameRect, FALSE);
}
void CGameDlg::OnTimer(UINT_PTR nIDEvent)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
if (m_GameC->GetGameFlag().timer == true) {
if (nIDEvent == PLAY_TIMER_ID && isPlaying)
{
m_GameProgress.StepIt();
int i = m_GameProgress.GetPos();
CString str;
str.Format(_T("%d"), i);
LPCTSTR pStr = LPCTSTR(str);
GetDlgItem(IDC_STATIC)->SetWindowText(pStr);
JudgeWin();
}
if (this->isPause == false) {
}
else {
this->KillTimer(nIDEvent);
}
}
CDialogEx::OnTimer(nIDEvent);
}
void CGameDlg::DrawGameTime()
{
// TODO: 在此处添加实现代码.
CFont font;
font.CreatePointFont(300, _T("Impact"));
}
void CGameDlg::JudgeWin()
{
// TODO: 在此处添加实现代码.
if (m_GameC->GetGameFlag().timer == true) {
int gameStatus = m_GameC->isWin(m_GameProgress.GetPos());
if (gameStatus == GAME_PLAY)
{
return;
}
else
{
isPlaying = false;
KillTimer(PLAY_TIMER_ID);
if (gameStatus == GAME_LOSE)
{
MessageBox(_T("YOU LOSE!"));
m_GameC->ClearMap();
UpdateMap();
}
if (gameStatus == GAME_WIN)
{
MessageBox(_T("YOU WIN!"));
m_GameC->ClearMap();
UpdateMap();
}
this->GetDlgItem(IDC_BTN_B_BIGIN)->EnableWindow(true);
InvalidateRect(m_rtGameRect, FALSE);
}
}
else
{
if (m_GameC->gameMode == 2) {
int gameStatus = m_GameC->isWin(100);
if (gameStatus == GAME_PLAY)
{
return;
}
if (gameStatus == GAME_WIN)
{
//写入数据到文件中
RankInfo current;
CString scoreStr;
scoreStr.Format(_T("%d"), m_GameC->gameScore);
CTime time = CTime::GetCurrentTime();
CString timeStr = time.Format(_T("%m%d%H%M"));
current.score = m_GameC->gameScore;
current.scoreStr = scoreStr;
current.userName = timeStr;
CGameData dataInput;
dataInput.addEasyRank(current);
//游戏停止
isPlaying = false;
MessageBox(_T("YOU WIN!"));
m_GameC->ClearMap();
UpdateMap();
this->GetDlgItem(IDC_BTN_B_BIGIN)->EnableWindow(true);
InvalidateRect(m_rtGameRect, FALSE);
}
}
else {
int gameStatus = m_GameC->isWin(100);
if (gameStatus == GAME_PLAY)
{
return;
}
if (gameStatus == GAME_WIN)
{
//写入数据到文件中
RankInfo current;
CString scoreStr;
scoreStr.Format(_T("%d"), m_GameC->gameScore);
CTime time = CTime::GetCurrentTime();
CString timeStr = time.Format(_T("%m%d%H%M"));
current.score = m_GameC->gameScore;
current.scoreStr = scoreStr;
current.userName = timeStr;
CGameData dataInput;
dataInput.addLevelRank(current);
isPlaying = false;
MessageBox(_T("YOU WIN!"));
m_GameC->ClearMap();
UpdateMap();
this->GetDlgItem(IDC_BTN_B_BIGIN)->EnableWindow(true);
InvalidateRect(m_rtGameRect, FALSE);
}
if (gameStatus == NEXT_LEVEL) {
MessageBox(_T("NEXT LEVEL!"));
if (m_GameC->currentLevel == 2) {
isPlaying = true;
int currentScore = m_GameC->gameScore;
int currentProp = m_GameC->gameProp;
m_GameC->StartGame2();
m_GameC->gameScore = currentScore;
m_GameC->gameProp = currentProp;
}
if (m_GameC->currentLevel == 3) {
int currentScore = m_GameC->gameScore;
int currentProp = m_GameC->gameProp;
isPlaying = true;
m_GameC->StartGame3();
m_GameC->gameScore = currentScore;
m_GameC->gameProp = currentProp;
}
UpdateMap();
InvalidateRect(m_rtGameRect, FALSE);
}
}
}
}
void CGameDlg::OnClickedBtnBPause()
{
// TODO: 在此添加控件通知处理程序代码
if (!isPlaying)
{
return;
}
else
{
if (isPause == false)
{
m_dcMem.BitBlt(m_rtGameRect.left, m_rtGameRect.top, m_rtGameRect.Width(),
m_rtGameRect.Height(), &m_pause, 700, 200, SRCCOPY);
this->GetDlgItem(IDC_BTN_B_PAUSE)->SetWindowTextW(_T("继续游戏"));
this->GetDlgItem(IDC_BTN_B_SIGN)->EnableWindow(false);
this->GetDlgItem(IDC_BTN_B_RERANK)->EnableWindow(false);
isPause = true;
InvalidateRect(m_rtGameRect, FALSE);
}
else if(isPause==true){
this->SetTimer(PLAY_TIMER_ID, 1000, NULL);
UpdateMap();
this->GetDlgItem(IDC_BTN_B_SIGN)->EnableWindow(true);
this->GetDlgItem(IDC_BTN_B_RERANK)->EnableWindow(true);
this->GetDlgItem(IDC_BTN_B_PAUSE)->SetWindowTextW(_T("暂停游戏"));
InvalidateRect(m_rtGameRect, FALSE);
isPause = false;
}
}
}
void CGameDlg::OnClickedBtnBHelp()
{
// TODO: 在此添加控件通知处理程序代码
CHelpDialog helpDialog;
helpDialog.DoModal();
//m_dcBG.DeleteDC();
//m_dcMem.DeleteDC();
//m_dcElement.DeleteDC();
//m_dcMask.DeleteDC();
//m_pause.DeleteDC();
//CClientDC dc(this);
//HANDLE bmpb = ::LoadImage(NULL, _T("theme\\picture\\b2.bmp"),
// IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
//m_dcBG.CreateCompatibleDC(&dc);
//m_dcBG.SelectObject(bmpb);
////初始化内存dc
//m_dcMem.CreateCompatibleDC(&dc);
//CBitmap bitmap;
//bitmap.CreateCompatibleBitmap(&dc, 1920, 1080);
//m_dcMem.SelectObject(&bitmap);
////绘制背景到内存dc中
//m_dcMem.BitBlt(0, 0, 1920, 1080, &m_dcBG, 0, 0, SRCCOPY);
//dc.BitBlt(0, 0, 1920, 1080, &m_dcBG, 0, 0, SRCCOPY);
////CClientDC dc(this);
//HANDLE bmp = ::LoadImage(NULL, _T("theme\\picture\\theme2.bmp"),
// IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
//m_dcElement.CreateCompatibleDC(&dc);
//m_dcElement.SelectObject(bmp);
//HANDLE mask = ::LoadImage(NULL, _T("theme\\picture\\th.bmp"),
// IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
//m_dcMask.CreateCompatibleDC(&dc);
//m_dcMask.SelectObject(mask);
//HANDLE bmp1 = ::LoadImage(NULL, _T("theme\\picture\\pause.bmp"),
// IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
//m_pause.CreateCompatibleDC(&dc);
//m_pause.SelectObject(bmp1);
////this->GetDlgItem(IDC_BTN_B_BIGIN)->ShowWindow(SW_SHOW);
////UpdateMap();
////InvalidateRect(m_rtGameRect, FALSE);
//////背景覆盖问题
//if (isPlaying == true) {
// UpdateMap();
// InvalidateRect(m_rtGameRect, FALSE);
//}
}
void CGameDlg::OnClickedBtnBProp()
{
// TODO: 在此添加控件通知处理程序代码
if (m_GameC->GetGameFlag().score == true)
{
if (m_GameC->gameProp == 0) {
MessageBox(_T("当前无道具可用!"));
}
else if (m_GameC->gameProp > 0) {
stack<Vertex> pp;
int row1, row2, col1, col2;
if (m_GameC->Help(pp, row1, col1, row2, col2))
{
DrawTipLine(pp);
//UpdateMap();
DrawTipFrame(row1, col1);
DrawTipFrame(row2, col2);
m_GameC->UseProp(row1, col1, row2, col2);
UpdateMap();
this->MessageBox(_T("使用道具!积分加10"));
CString str;
str.Format(_T("当前积分:%d"), m_GameC->gameScore);
LPCTSTR pStr = LPCTSTR(str);
GetDlgItem(IDC_ST_PROP)->SetWindowText(pStr);
CString str1;
str1.Format(_T("当前道具:%d"), m_GameC->gameProp);
LPCTSTR pStr1 = LPCTSTR(str1);
this->GetDlgItem(IDC_BTN_B_PROP)->SetWindowTextW(pStr1);
}
else
{
this->MessageBox(_T("当前没有可连点!建议重排"));
}
Sleep(200);
InvalidateRect(m_rtGameRect, FALSE);
}
}
}
void CGameDlg::UpdateTheme()
{
// TODO: 在此处添加实现代码.
m_dcBG.DeleteDC();
m_dcMem.DeleteDC();
m_dcElement.DeleteDC();
m_dcMask.DeleteDC();
m_pause.DeleteDC();
CClientDC dc(this);
//TODO
/*HANDLE bmpb = ::LoadImage(NULL, _T("theme/picture/b2.bmp"),
IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);*/
HANDLE bmpb = ::LoadImage(NULL, gameBackground,
IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
m_dcBG.CreateCompatibleDC(&dc);
m_dcBG.SelectObject(bmpb);
//初始化内存dc
m_dcMem.CreateCompatibleDC(&dc);
CBitmap bitmap;
bitmap.CreateCompatibleBitmap(&dc, 1920, 1080);
m_dcMem.SelectObject(&bitmap);
//绘制背景到内存dc中
m_dcMem.BitBlt(0, 0, 1920, 1080, &m_dcBG, 0, 0, SRCCOPY);
dc.BitBlt(0, 0, 1920, 1080, &m_dcBG, 0, 0, SRCCOPY);
//CClientDC dc(this);
/*HANDLE bmp = ::LoadImage(NULL, _T("theme\\picture\\theme2.bmp"),
IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);*/
HANDLE bmp = ::LoadImage(NULL, itemPath,
IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
m_dcElement.CreateCompatibleDC(&dc);
m_dcElement.SelectObject(bmp);
/*HANDLE mask = ::LoadImage(NULL, _T("theme\\picture\\th.bmp"),
IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);*/
HANDLE mask = ::LoadImage(NULL, itemMask,
IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
m_dcMask.CreateCompatibleDC(&dc);
m_dcMask.SelectObject(mask);
/*HANDLE bmp1 = ::LoadImage(NULL, _T("theme\\picture\\pause.bmp"),
IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);*/
HANDLE bmp1 = ::LoadImage(NULL, _T("theme/picture/pause.bmp"),
IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
m_pause.CreateCompatibleDC(&dc);
m_pause.SelectObject(bmp1);
this->GetDlgItem(IDC_BTN_B_BIGIN)->ShowWindow(SW_SHOW);
if (isPlaying == true) {
UpdateMap();
InvalidateRect(m_rtGameRect, FALSE);
}
//背景覆盖问题
}
void CGameDlg::OnBnClickedBtnBSettings()
{
// TODO: 在此添加控件通知处理程序代码
CSettingDlg setDlg;
setDlg.DoModal();
GetIt();
m_GameC->currentHard = gameHard;
this->GetDlgItem(IDC_NAME)->SetWindowTextW(userName);
if(m_GameC->gameMode!=3) OnClickedBtnBBigin();
UpdateTheme();
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。