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

📄 createboxdialog.cpp

📁 3D游戏场景编辑器
💻 CPP
📖 第 1 页 / 共 2 页
字号:
}



void	CCreateBoxDialog::dlgFieldsToTexels(void)
{
	m_Thickness	=Units_CentimetersToEngine(m_Thickness);
	m_XSizeTop	=Units_CentimetersToEngine(m_XSizeTop);
	m_XSizeBot	=Units_CentimetersToEngine(m_XSizeBot);
	m_YSize		=Units_CentimetersToEngine(m_YSize);
	m_ZSizeTop	=Units_CentimetersToEngine(m_ZSizeTop);
	m_ZSizeBot	=Units_CentimetersToEngine(m_ZSizeBot);
}

void	CCreateBoxDialog::dlgFieldsToCentimeters(void)
{
	m_Thickness	=Units_FRound(Units_EngineToCentimeters(m_Thickness));
	m_XSizeTop	=Units_FRound(Units_EngineToCentimeters(m_XSizeTop));
	m_XSizeBot	=Units_FRound(Units_EngineToCentimeters(m_XSizeBot));
	m_YSize		=Units_FRound(Units_EngineToCentimeters(m_YSize));
	m_ZSizeTop	=Units_FRound(Units_EngineToCentimeters(m_ZSizeTop));
	m_ZSizeBot	=Units_FRound(Units_EngineToCentimeters(m_ZSizeBot));
}



void CCreateBoxDialog::OnSolid() 
{
	m_Picture.SetBitmap( mSolidBitmap );
	GetDlgItem (IDC_TSHEET)->EnableWindow (TRUE);
	OnOK();
}

void CCreateBoxDialog::OnHollow() 
{
	m_Picture.SetBitmap( mHollowBitmap );
	m_TSheet = FALSE;
	m_SheetBtn.EnableWindow (FALSE);
	m_SheetBtn.SetCheck (0);
	OnOK();
}

BOOL CCreateBoxDialog::OnInitDialog() 
{
	CDialog::OnInitDialog();

//	pCube = NULL;		//	post 0.55 commented out 

	if( m_Solid == 0 )
		m_Picture.SetBitmap( mSolidBitmap );
	else
		m_Picture.SetBitmap( mHollowBitmap );

	this->GetDlgItem(IDC_CUSTOM_TEMPLATE_BTN)->SetFocus();
	
	return FALSE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CCreateBoxDialog::Serialize(CArchive& ar) 
{
	if (ar.IsStoring())
	{	
	}
	else
	{	// loading code
	}
}

void CCreateBoxDialog::OnDefaults() 
{
	m_Picture.SetBitmap( mHollowBitmap );
	m_XSizeTop = 512.0;
	m_ZSizeTop = 512.0;
	m_XSizeBot = 512.0;
	m_ZSizeBot = 512.0;
	m_YSize = 512.0;
	m_Solid = 1;
	m_Thickness = 16.0;
	m_TCut = FALSE;
	m_TSheet = FALSE;
	UpdateData(FALSE);
	OnOK();
}

void CCreateBoxDialog::OnTcut() 
{
	if (m_CutBtn.GetCheck ())
	{
		m_SheetBtn.SetCheck (0);
			OnOK();	
	}
}

void CCreateBoxDialog::OnTsheet() 
{
	if (m_SheetBtn.GetCheck () == 0)
	{
		m_CutBtn.SetCheck (0);

		OnOK();	
	}
}

/* EOF: CreateBoxDialog.cpp */
void CCreateBoxDialog::OnOK() // old gedit
{
	
	UpdateData(TRUE);		//	old gedit
	if(m_ConvertToMetric)
	{
		dlgFieldsToTexels();
	}
	
	if (!m_customTemplate)	//	if the Custom Template button is NOT pushed
	{
		if (m_pDoc->CurBrush)
		{
			pCube = m_pDoc->CurBrush;
		}
	}	
	else if (m_customTemplate)	//	if the Custom Template button is pushed
	{
		
		m_pBoxTemplate->Solid		= m_Solid;
		m_pBoxTemplate->TCut		= m_TCut;
		m_pBoxTemplate->TSheet		= m_TSheet;
		m_pBoxTemplate->Thickness	= m_Thickness;
		m_pBoxTemplate->XSizeTop	= m_XSizeTop;
		m_pBoxTemplate->XSizeBot	= m_XSizeBot;
		m_pBoxTemplate->YSize		= m_YSize;
		m_pBoxTemplate->ZSizeTop	= m_ZSizeTop;
		m_pBoxTemplate->ZSizeBot	= m_ZSizeBot;
		
		pCube = ::BrushTemplate_CreateBox (m_pBoxTemplate);
		if (pCube != NULL)
			m_pDoc->CreateNewTemplateBrush ((Brush*)pCube);
			m_pDoc->m_recentCube = Brush_Clone(pCube);	//	post 0.55
			Brush_SetName(m_pDoc->CurBrush, "Cube");	//	post 0.55
	}
}
	



void CCreateBoxDialog::OnKillfocusXsizetop() 
{
	float	lastValue = m_XSizeTop;

	if (GetDlgItemInt(IDC_XSIZETOP) == NULL)
	{
		this->SetDlgItemInt(IDC_XSIZETOP, lastValue);
		return;
	}

	UpdateData(TRUE);
	

	if ((m_XSizeTop >= BRUSH_MIN) && (m_XSizeTop <= BRUSH_MAX)) 
		OnOK();
	else
	{
		m_XSizeTop = lastValue;
		UpdateData(FALSE);
		AfxMessageBox(m_minMaxErrorString);
	}
}

void CCreateBoxDialog::OnKillfocusXsizebot() 
{
	float	lastValue = m_XSizeBot;

		if (GetDlgItemInt(IDC_XSIZEBOT) == NULL)
	{
		this->SetDlgItemInt(IDC_XSIZEBOT, lastValue);
		return;
	}

	UpdateData(TRUE);

	if ((m_XSizeBot >= BRUSH_MIN) && (m_XSizeBot <= BRUSH_MAX)) 
		OnOK();
	else
	{
		m_XSizeBot = lastValue;
		UpdateData(FALSE);
		AfxMessageBox(m_minMaxErrorString);
	}
}


void CCreateBoxDialog::OnKillfocusZsizetop() 
{
	float	lastValue = m_ZSizeTop;

		if (GetDlgItemInt(IDC_ZSIZETOP) == NULL)
	{
		this->SetDlgItemInt(IDC_ZSIZETOP, lastValue);
		return;
	}

	UpdateData(TRUE);

	if ((m_ZSizeTop >= BRUSH_MIN) && (m_ZSizeTop <= BRUSH_MAX)) 
		OnOK();
	else
	{
		m_ZSizeTop = lastValue;
		UpdateData(FALSE);
		AfxMessageBox(m_minMaxErrorString);
	}
}


void CCreateBoxDialog::OnKillfocusZsizebot() 
{
	float	lastValue = m_ZSizeBot;

		if (GetDlgItemInt(IDC_ZSIZEBOT) == NULL)
	{
		this->SetDlgItemInt(IDC_ZSIZEBOT, lastValue);
		return;
	}

	UpdateData(TRUE);

	if ((m_ZSizeBot >= BRUSH_MIN) && (m_ZSizeBot <= BRUSH_MAX)) 
		OnOK();
	else
	{
		m_ZSizeBot = lastValue;
		UpdateData(FALSE);
		AfxMessageBox(m_minMaxErrorString);
	}
}

void CCreateBoxDialog::OnKillfocusYsize() 
{
	float	lastValue = m_YSize;

		if (GetDlgItemInt(IDC_YSIZE) == NULL)
	{
		this->SetDlgItemInt(IDC_YSIZE, lastValue);
		return;
	}

	UpdateData(TRUE);

	if ((m_YSize >= BRUSH_MIN) && (m_YSize <= BRUSH_MAX)) 
		OnOK();
	else
	{
		m_YSize = lastValue;
		UpdateData(FALSE);
		AfxMessageBox(m_minMaxErrorString);
	}
}

void CCreateBoxDialog::OnKillfocusThickness() 
{
	float	lastValue = m_Thickness;

		if (GetDlgItemInt(IDC_THICKNESS) == NULL)
	{
		this->SetDlgItemInt(IDC_THICKNESS, lastValue);
		return;
	}

	UpdateData(TRUE);

	if ((m_Thickness >= WALL_THICK_MIN) && (m_Thickness <= WALL_THICK_MAX)) 
		OnOK();
	else
	{
		m_Thickness = lastValue;
		UpdateData(FALSE);
		AfxMessageBox(m_wallThicknessErrorString);
	}
}

void CCreateBoxDialog::OnApplyBoxBtn() 
{
	OnOK();	
	m_pDoc->AddBrushToWorld();	
	m_pDoc->mpMainFrame->UpdateMainControls();	
}



void CCreateBoxDialog::OnCustomTemplateBtn() 
{
	static bool toggle;
	toggle = !m_customTemplate;
	m_customTemplate = toggle;

	m_pDoc->mpMainFrame->UpdateMainControls();
}


void CCreateBoxDialog::OnCancel()
{
	return;
}

⌨️ 快捷键说明

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