⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 settingsdlg.cpp

📁 一个在Pocket PC上运行的贪食蛇游戏
💻 CPP
字号:
// SettingsDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Snake.h"
#include "SettingsDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

extern struct Setting_Parameters
{
	int mode;
	int level;
	int mazes;
}Settings;

/////////////////////////////////////////////////////////////////////////////
// CSettingsDlg dialog


CSettingsDlg::CSettingsDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CSettingsDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSettingsDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CSettingsDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSettingsDlg)
	DDX_Control(pDX, IDC_MODE, m_mode);
	DDX_Control(pDX, IDC_MAZES, m_mazes);
	DDX_Control(pDX, IDC_LEVEL, m_level);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSettingsDlg, CDialog)
	//{{AFX_MSG_MAP(CSettingsDlg)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSettingsDlg message handlers

void CSettingsDlg::OnOK() 
{
	// TODO: Add extra validation here
	CString str;

	GetDlgItemText(IDC_LEVEL,str);
	if(!str.IsEmpty())
	{
		if(str==_T("1"))
		{
			Settings.level=1;
		}
		else if(str==_T("2"))
		{
			Settings.level=2;
		}
		else if(str==_T("3"))
		{
			Settings.level=3;
		}
		else if(str==_T("4"))
		{
			Settings.level=4;
		}
		else if(str==_T("5"))
		{
			Settings.level=5;
		}
		else if(str==_T("6"))
		{
			Settings.level=6;
		}
		else if(str==_T("7"))
		{
			Settings.level=7;
		}
		else if(str==_T("8"))
		{
			Settings.level=8;
		}
		else if(str==_T("9"))
		{
			Settings.level=9;
		}
		else
		{
			AfxMessageBox(_T("set level error!"));
		}
	}

	GetDlgItemText(IDC_MODE,str);
	if(!str.IsEmpty())
	{	
		if(str==_T("Classic"))
		{
			Settings.mode=1;
		}
		else if(str==_T("Extreme"))
		{
			Settings.mode=2;
		}
		else
		{
			AfxMessageBox(_T("set mode error!"));
		}
	}

	GetDlgItemText(IDC_MAZES,str);
	if(!str.IsEmpty())
	{
		if(str==_T("No maze"))
		{
			Settings.mazes=1;
		}
		else if(str==_T("Box"))
		{
			Settings.mazes=2;
		}
		else if(str==_T("Tunnel"))
		{
			Settings.mazes=3;
		}
		else if(str==_T("Spiral"))
		{
			Settings.mazes=4;
		}
		else if(str==_T("Blockade"))
		{
			Settings.mazes=5;
		}
		else if(str==_T("Twisted"))
		{
			Settings.mazes=6;
		}
		else
		{
			AfxMessageBox(_T("set mazes error!"));
		}
	}

	UpdateData(true);
	CDialog::OnOK();
}
	
void CSettingsDlg::OnCancel() 
{
	// TODO: Add extra cleanup here
	UpdateData(true);
	CDialog::OnCancel();
}

BOOL CSettingsDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	m_level.SetCurSel(Settings.level-1);
	m_mode.SetCurSel(Settings.mode-1);
	m_mazes.SetCurSel(Settings.mazes-1);	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -