// EBFPanel.cpp : implementation file
//

#include "stdafx.h"
#include "pixelwhippro.h"
#include "EBFPanel.h"
#include <GosFx\EffectLibrary.hpp>
#include <MLR\MLRTexturePool.hpp>

extern CPixelWhipProApp theApp;


/////////////////////////////////////////////////////////////////////////////
// CEBFPanel dialog

#include <GosFx\GosFx.hpp>

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


void CEBFPanel::DoDataExchange(CDataExchange* pDX)
{
	CDynaPanel::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CEBFPanel)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CEBFPanel, CDynaPanel)
	//{{AFX_MSG_MAP(CEBFPanel)
	ON_BN_CLICKED(IDC_BROWSE, OnBrowse)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CEBFPanel message handlers

void CEBFPanel::Set(void *dat)
{

	ShapeSpec=(gosFX::DebrisCloud__Specification *)dat;
}

void CEBFPanel::OnBrowse() 
{
	CString doc_path=theApp.DocPath.Left(theApp.DocPath.ReverseFind('\\')),shape_path;
//	if(doc_path.GetLength()==0) 	GetCurrentDirectory(doc_path);
	SetCurrentDirectory(doc_path);
	
	CFileDialog dlg1(TRUE,"ebf",NULL,OFN_NOCHANGEDIR,"EBF Geometry(*.ebf)|*.ebf||",this);
	if(dlg1.DoModal()==IDOK)
	{
	shape_path=dlg1.GetPathName();
		if(doc_path.GetLength()>shape_path.GetLength() ||
			shape_path.Left(doc_path.GetLength()).CompareNoCase(doc_path)
			)
		{	
			MessageBox("Shape Path Error");
		}
		else
		{
			shape_path=shape_path.Mid(doc_path.GetLength()+1);
			MString mstr;
			mstr=(char *)(LPCSTR)shape_path;
			gosFX::EffectLibrary::Instance->LoadDebrisArray(ShapeSpec,mstr);
			ShapeSpec->m_shapeFile=shape_path;
			MidLevelRenderer::MLRTexturePool::Instance->LoadImages();
		}
		
	theApp.StopEffects();
	theApp.StartEffects();
	}

		
}
