// DlgLightmapInfo.cpp : implementation file // #include "stdafx.h" #include "worldcreator.h" #include "DlgLightmapInfo.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CDlgLightmapInfo dialog CDlgLightmapInfo::CDlgLightmapInfo(CWnd* pParent /*=NULL*/) : CDialog(CDlgLightmapInfo::IDD, pParent) { //{{AFX_DATA_INIT(CDlgLightmapInfo) m_bDirectionLight = TRUE; m_bGlobalShadow = FALSE; m_bPointLight = TRUE; m_bSkyLight = TRUE; m_fDirectionLightRandValue = 0.1f; m_iDirectionSampleCount = 10; m_iSkySampleCount = 50; m_fExposeValue = 0.0f; m_fGlobalRandValue = 4.0f; m_iGlobalSampleCount = 30; m_fPointRandValue = 4.0f; m_iPointSampleCount = 4; m_bStart = false; m_cSkyLightColor = 0xffFBD1BD; m_cDirectionColor = 0xffffffff; m_cAmbientColor = 0xff505050; //}}AFX_DATA_INIT m_iSelectedState = 0; } void CDlgLightmapInfo::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CDlgLightmapInfo) DDX_Control(pDX, IDC_LIST1, m_CtlListBox); DDX_Control(pDX, IDC_BUTTON_SKYLIGHTCOLOR, m_SkyLightColor); DDX_Control(pDX, IDC_BUTTON_DIRECTIONCOLOR, m_DirectionColor); DDX_Control(pDX, IDC_BUTTON_AMBIENTCOLOR, m_AmbientColor); DDX_ColourPicker(pDX, IDC_BUTTON_SKYLIGHTCOLOR, m_cSkyLightColor); DDX_ColourPicker(pDX, IDC_BUTTON_DIRECTIONCOLOR, m_cDirectionColor); DDX_ColourPicker(pDX, IDC_BUTTON_AMBIENTCOLOR, m_cAmbientColor); DDX_Check(pDX, IDC_CHECK_DIRECTION, m_bDirectionLight); DDX_Check(pDX, IDC_CHECK_GLOBALSHADOW, m_bGlobalShadow); DDX_Check(pDX, IDC_CHECK_POINTLIGHT, m_bPointLight); DDX_Check(pDX, IDC_CHECK_SKYLIGHT, m_bSkyLight); DDX_Text(pDX, IDC_DIRECTIONRANDVALUE, m_fDirectionLightRandValue); DDX_Text(pDX, IDC_DIRECTIONSAMPLECOUNT, m_iDirectionSampleCount); DDX_Text(pDX, IDC_SKYSAMPLECOUNT, m_iSkySampleCount); DDX_Text(pDX, IDC_EXPOSEVALUE, m_fExposeValue); DDX_Text(pDX, IDC_GLOBALRANDVALUE, m_fGlobalRandValue); DDX_Text(pDX, IDC_GLOBALSAMPLECOUNT, m_iGlobalSampleCount); DDX_Text(pDX, IDC_POINTRANDVALUE, m_fPointRandValue); DDX_Text(pDX, IDC_POINTSAMPLECOUNT, m_iPointSampleCount); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CDlgLightmapInfo, CDialog) //{{AFX_MSG_MAP(CDlgLightmapInfo) ON_LBN_SELCHANGE(IDC_LIST1, OnSelchangeList1) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CDlgLightmapInfo message handlers void CDlgLightmapInfo::OnOK() { // TODO: Add extra validation here UpdateData(); BackupState(m_iSelectedState); char strPath[256]; GetCurrentDirectory(256,strPath); sprintf(strPath,"%s\\WorldCreatorLightmapInfo.dat",strPath); FILE *fp = fopen(strPath,"wb+"); if(fp) { fwrite(m_State,sizeof(CLightmapInfoState)*10,1,fp); fclose(fp); } m_bStart = true; CDialog::OnOK(); } void CDlgLightmapInfo::OnCancel() { // TODO: Add extra cleanup here m_bStart = false; char strPath[256]; GetCurrentDirectory(256,strPath); sprintf(strPath,"%s\\WorldCreatorLightmapInfo.dat",strPath); BackupState(m_iSelectedState); FILE *fp = fopen(strPath,"wb+"); if(fp) { fwrite(m_State,sizeof(CLightmapInfoState)*10,1,fp); fclose(fp); } CDialog::OnCancel(); } /* int CDlgLightmapInfo::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CDialog::OnCreate(lpCreateStruct) == -1) return -1; // TODO: Add your specialized creation code here return 0; } BOOL CDlgLightmapInfo::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext) { // TODO: Add your specialized code here and/or call the base class return CDialog::Create(IDD, pParentWnd); } */ void CDlgLightmapInfo::BackupState(int iState) { m_State[iState].m_bDirectionLight = m_bDirectionLight; m_State[iState].m_bGlobalShadow = m_bGlobalShadow; m_State[iState].m_bPointLight = m_bPointLight; m_State[iState].m_bSkyLight = m_bSkyLight; m_State[iState].m_cAmbientColor = m_cAmbientColor; m_State[iState].m_cDirectionColor = m_cDirectionColor; m_State[iState].m_cSkyLightColor = m_cSkyLightColor; m_State[iState].m_fDirectionLightRandValue = m_fDirectionLightRandValue; m_State[iState].m_fExposeValue = m_fExposeValue; m_State[iState].m_fGlobalRandValue = m_fGlobalRandValue; m_State[iState].m_fPointRandValue = m_fPointRandValue; m_State[iState].m_iDirectionSampleCount = m_iDirectionSampleCount; m_State[iState].m_iGlobalSampleCount = m_iGlobalSampleCount; m_State[iState].m_iPointSampleCount = m_iPointSampleCount; m_State[iState].m_iSkySampleCount = m_iSkySampleCount; } void CDlgLightmapInfo::SetState() { m_bDirectionLight = m_State[m_iSelectedState].m_bDirectionLight; m_bGlobalShadow = m_State[m_iSelectedState].m_bGlobalShadow; m_bPointLight = m_State[m_iSelectedState].m_bPointLight; m_bSkyLight = m_State[m_iSelectedState].m_bSkyLight; m_fDirectionLightRandValue = m_State[m_iSelectedState].m_fDirectionLightRandValue; m_iDirectionSampleCount = m_State[m_iSelectedState].m_iDirectionSampleCount; m_iSkySampleCount = m_State[m_iSelectedState].m_iSkySampleCount; m_fExposeValue = m_State[m_iSelectedState].m_fExposeValue; m_fGlobalRandValue = m_State[m_iSelectedState].m_fGlobalRandValue; m_iGlobalSampleCount = m_State[m_iSelectedState].m_iGlobalSampleCount; m_fPointRandValue = m_State[m_iSelectedState].m_fPointRandValue; m_iPointSampleCount = m_State[m_iSelectedState].m_iPointSampleCount; m_cSkyLightColor = m_State[m_iSelectedState].m_cSkyLightColor; m_cDirectionColor = m_State[m_iSelectedState].m_cDirectionColor; m_cAmbientColor = m_State[m_iSelectedState].m_cAmbientColor; UpdateData(FALSE); } BOOL CDlgLightmapInfo::OnInitDialog() { CDialog::OnInitDialog(); char strPath[256]; GetCurrentDirectory(256,strPath); sprintf(strPath,"%s\\WorldCreatorLightmapInfo.dat",strPath); FILE *fp = fopen(strPath,"rb"); if(fp) { fread(m_State,sizeof(CLightmapInfoState)*10,1,fp); fclose(fp); } // TODO: Add extra initialization here char strList[256]; for(int i = 0; i < MAXLIST; i++ ) { sprintf(strList,"State %d",i); m_CtlListBox.AddString(strList); } m_iSelectedState = 0; m_CtlListBox.SetCurSel(m_iSelectedState); SetState(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CDlgLightmapInfo::OnSelchangeList1() { // TODO: Add your control notification handler code here UpdateData(); BackupState(m_iSelectedState); m_iSelectedState = m_CtlListBox.GetCurSel(); SetState(); }