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

📄 dialogeffect.cpp

📁 网络游戏魔域源代码 测试可以完整变异
💻 CPP
字号:
// DialogEffect.cpp : implementation file
//

#include "stdafx.h"
#include "Architect.h"
#include "DialogEffect.h"
#include "ArchitectDlg.h"
#include "3DGameMap.h"
#include "3DMapEffectNew.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDialogEffect dialog


CDialogEffect::CDialogEffect(CWnd* pParent /*=NULL*/)
	: CDialog(CDialogEffect::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDialogEffect)
	m_bShow = FALSE;
	m_dwWidth = 1;
	m_dwHeight = 1;
	m_fAngleX = 0.0f;
	m_fAngleY = 0.0f;
	m_fAngleZ = 0.0f;
	m_fScaleX = 1.0f;
	m_fScaleY = 1.0f;
	m_fScaleZ = 1.0f;
	//}}AFX_DATA_INIT
}


void CDialogEffect::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDialogEffect)
	DDX_Control(pDX, IDC_LIST, m_ctrlList);
	DDX_Check(pDX, IDC_CHECK_SHOW, m_bShow);
	DDX_Text(pDX, IDC_EDIT_WIDTH, m_dwWidth);
	DDV_MinMaxDWord(pDX, m_dwWidth, 1, 10);
	DDX_Text(pDX, IDC_EDIT_HEIGHT, m_dwHeight);
	DDV_MinMaxDWord(pDX, m_dwHeight, 1, 10);
	DDX_Text(pDX, IDC_EDIT_ANGLEX, m_fAngleX);
	DDV_MinMaxFloat(pDX, m_fAngleX, 0.0f, 360.0f);
	DDX_Text(pDX, IDC_EDIT_ANGLEY, m_fAngleY);
	DDV_MinMaxFloat(pDX, m_fAngleY, 0.0f, 360.0f);
	DDX_Text(pDX, IDC_EDIT_ANGLEZ, m_fAngleZ);
	DDV_MinMaxFloat(pDX, m_fAngleZ, 0.0f, 360.0f);
	DDX_Text(pDX, IDC_EDIT_SCALEX, m_fScaleX);
	DDV_MinMaxFloat(pDX, m_fScaleX, 0.0f, 10.0f);
	DDX_Text(pDX, IDC_EDIT_SCALEY, m_fScaleY);
	DDV_MinMaxFloat(pDX, m_fScaleY, 0.0f, 10.0f);
	DDX_Text(pDX, IDC_EDIT_SCALEZ, m_fScaleZ);
	DDV_MinMaxFloat(pDX, m_fScaleZ, 0.0f, 10.0f);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDialogEffect, CDialog)
	//{{AFX_MSG_MAP(CDialogEffect)
	ON_BN_CLICKED(IDC_BUTTON_FLASH, OnButtonFlash)
	ON_BN_CLICKED(IDC_BUTTON_ADD, OnButtonAdd)
	ON_BN_CLICKED(IDC_BUTTON_MODIFY, OnButtonModify)
	ON_BN_CLICKED(IDC_CHECK_SHOW, OnCheckShow)
	ON_BN_CLICKED(IDC_BUTTON_DEL, OnButtonDel)
	ON_EN_CHANGE(IDC_EDIT_ANGLEX, OnChangeEditAll)
	ON_EN_CHANGE(IDC_EDIT_ANGLEY, OnChangeEditAll)
	ON_EN_CHANGE(IDC_EDIT_ANGLEZ, OnChangeEditAll)
	ON_EN_CHANGE(IDC_EDIT_SCALEX, OnChangeEditAll)
	ON_EN_CHANGE(IDC_EDIT_SCALEY, OnChangeEditAll)
	ON_EN_CHANGE(IDC_EDIT_SCALEZ, OnChangeEditAll)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDialogEffect message handlers

void CDialogEffect::OnOK() 
{
	// TODO: Add extra validation here
	return;
	CDialog::OnOK();
}

void CDialogEffect::OnCancel() 
{
	// TODO: Add extra cleanup here
	return;
	CDialog::OnCancel();
}

void CDialogEffect::OnButtonFlash() 
{
	// TODO: Add your control notification handler code here
	this->Flash();	
}

void CDialogEffect::Flash()
{
	m_ctrlList.ResetContent();
	const char szFile[]="3DMapEffect.ini";
	FILE* fp = fopen(szFile, "r");
	if(!fp)
		return;
	char szLine[256];
	int nIndex = 0;
	while(true)
	{
		int nReturn = fscanf(fp, "%s\n", szLine);
		if(EOF == nReturn)
			break;
		m_ctrlList.InsertString(nIndex, szLine);
		nIndex ++;
	}
	fclose(fp);
}

BOOL CDialogEffect::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	this->Flash();
	this->UpdateData(false);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CDialogEffect::OnButtonAdd() 
{
	// TODO: Add your control notification handler code here
 	OnChangeEditAll();
	extern CArchitectDlg* g_pDialog;
	int nIndex = this->m_ctrlList.GetCurSel();
	if(nIndex < 0)
		return;
	
	g_pDialog->m_nMouseOperate = 14;
	CMyPos posWorld={0, 0};
	CString m_strIndex;
	m_ctrlList.GetText(nIndex, m_strIndex);

	g_pDialog->m_StringBuffer	= m_strIndex;

	g_pDialog->m_p3DMapEffect = C3DMapEffectNew::CreateNew(posWorld, 
		m_strIndex.GetBuffer(0), false, true);
	g_pDialog->m_p3DMapEffect->SetRotate(m_fAngleZ * D3DX_PI / 180, m_fAngleX * D3DX_PI / 180);
	((C3DMapEffectNew*)g_pDialog->m_p3DMapEffect)->SetScale(m_fScaleX, m_fScaleY, m_fScaleZ);
	g_objGameMap.AddInteractiveObj(g_pDialog->m_p3DMapEffect);
}

void CDialogEffect::OnButtonModify()
{
	extern CArchitectDlg* g_pDialog;
	g_pDialog->m_nMouseOperate = 23;
}

void CDialogEffect::OnCheckShow() 
{
	// TODO: Add your control notification handler code here
	this->UpdateData(true);
	C3DMapEffect::s_bStroke = this->m_bShow;
}

void CDialogEffect::OnButtonDel() 
{
	// TODO: Add your control notification handler code here
	extern CArchitectDlg* g_pDialog;
	g_pDialog->m_nMouseOperate = 15;
}

void CDialogEffect::OnChangeEditAll()
{
	UpdateData();
	if (m_fScaleX < 0.001) m_fScaleX = 0.001;
	if (m_fScaleY < 0.001) m_fScaleY = 0.001;
	if (m_fScaleZ < 0.001) m_fScaleZ = 0.001;
	extern CArchitectDlg* g_pDialog;

	// 将角度和缩放保存
	g_pDialog->m_fAngleX	= m_fAngleX;
	g_pDialog->m_fAngleY	= m_fAngleY;
	g_pDialog->m_fAngleZ	= m_fAngleZ;
	g_pDialog->m_fScaleX	= m_fScaleX;
	g_pDialog->m_fScaleY	= m_fScaleY;
	g_pDialog->m_fScaleZ	= m_fScaleZ;

	// 判断是否已选择添加
	if (14 == g_pDialog->m_nMouseOperate &&
		NULL != g_pDialog->m_p3DMapEffect &&
		MAP_3DEFFECTNEW == g_pDialog->m_p3DMapEffect->GetObjType())
	{
		g_pDialog->m_p3DMapEffect->SetRotate(m_fAngleZ * D3DX_PI / 180, m_fAngleX * D3DX_PI / 180);
		((C3DMapEffectNew*)g_pDialog->m_p3DMapEffect)->SetScale(m_fScaleX, m_fScaleY, m_fScaleZ);
	}
}

BOOL CDialogEffect::PreTranslateMessage(MSG* pMsg) 
{
	// TODO: Add your specialized code here and/or call the base class
	
	return CDialog::PreTranslateMessage(pMsg);
}

⌨️ 快捷键说明

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