/*=========================================================================== * * File: Dfto3ds.CPP * Author: Dave Humphrey (uesp@m0use.net) * Created On: Saturday, June 23, 2001 * * Implements the CDfto3dsApp class. * *=========================================================================*/ /* Include Files */ #include "stdafx.h" #include "dfto3ds.h" #include "aboutdlg.h" #include "MainFrm.h" #include "dfto3dsDoc.h" #include "dfto3dsView.h" #include "dfcommon.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif /*=========================================================================== * * Begin Local Variable Definitions * *=========================================================================*/ /* The one and only application object */ CDfto3dsApp theApp; /*=========================================================================== * End of Local Variable Definitions *=========================================================================*/ /*=========================================================================== * * Begin CDfto3dsApp Message Map * *=========================================================================*/ BEGIN_MESSAGE_MAP(CDfto3dsApp, CWinApp) //{{AFX_MSG_MAP(CDfto3dsApp) ON_COMMAND(ID_APP_ABOUT, OnAppAbout) ON_COMMAND(ID_CONTEXT_HELP, OnContextHelp) //}}AFX_MSG_MAP ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) ON_COMMAND(ID_FILE_OPEN, CDfto3dsApp::OnFileOpen) END_MESSAGE_MAP() /*=========================================================================== * End of CDfto3dsApp Message Map *=========================================================================*/ /*=========================================================================== * * Class CDfto3dsApp Constructor * *=========================================================================*/ CDfto3dsApp::CDfto3dsApp() { } /*=========================================================================== * End of Class CDfto3dsApp Constructor *=========================================================================*/ /*=========================================================================== * * Class CDfto3dsApp Method - BOOL InitInstance (); * * Description * *=========================================================================*/ BOOL CDfto3dsApp::InitInstance() { #if defined(_DEBUG) SystemLog.Open("dfto3ds.log"); #endif #ifdef _AFXDLL Enable3dControls(); #else Enable3dControlsStatic(); #endif /* Change the registry key under which our settings are stored. */ SetRegistryKey(_T("Abode")); /* Load standard INI file options (including MRU) */ LoadStdProfileSettings(); /* Register the application's document templates. Document templates * serve as the connection between documents, frame windows and views. */ CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate(IDR_MAINFRAME, RUNTIME_CLASS(CDfto3dsDoc), RUNTIME_CLASS(CMainFrame), RUNTIME_CLASS(CDfto3dsView)); AddDocTemplate(pDocTemplate); /* Parse command line for standard shell commands, DDE, file open */ CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); /* Dispatch commands specified on the command line */ if (!ProcessShellCommand(cmdInfo)) return FALSE; /* The one and only window has been initialized, so show and update it */ m_pMainWnd->ShowWindow(SW_SHOW); m_pMainWnd->UpdateWindow(); return TRUE; } /*=========================================================================== * End of Class Method CDfto3dsApp::InitInstance() *=========================================================================*/ /*=========================================================================== * * Class CDfto3dsApp Event - void OnAppAbout (); * *=========================================================================*/ void CDfto3dsApp::OnAppAbout() { CAboutDlg AboutDlg; AboutDlg.DoModal(); } /*=========================================================================== * End of Class Event CDfto3dsApp::OnAppAbout() *=========================================================================*/ /*=========================================================================== * * Class CDfto3dsApp Event - void OnFileOpen (); * *=========================================================================*/ void CDfto3dsApp::OnFileOpen() { CFileDialog FileDlg(TRUE, ".BSA", NULL, OFN_HIDEREADONLY | OFN_FILEMUSTEXIST, "Arch3D.BSA Files|Arch3D.BSA|BSA File (*.bsa)|*.bsa|All Files (*.*)|*.*||"); CString Filename; CString Pathname; int Result; /* Initialize the file dialog */ Pathname = GetOpenFilePath(); FileDlg.m_ofn.lpstrInitialDir = Pathname.GetBuffer(16); /* Display file open dialog */ Result = FileDlg.DoModal(); if (Result != IDOK) return; Filename = FileDlg.GetPathName(); SetOpenFilePath(Filename); ASSERT(m_pDocManager != NULL); m_pDocManager->OpenDocumentFile(Filename); } /*=========================================================================== * End of Class Event CDfto3dsApp::OnFileOpen() *=========================================================================*/ /*=========================================================================== * * Functions - CString GetExport3DSPath (void); * CString GetExportDXFPath (void); * CString GetOpenFilePath (void); * * Get paths from the registry. * *=========================================================================*/ CString GetExport3DSPath (void) { return theApp.GetProfileString("Paths", "Export3DS", NULL); } CString GetExportDXFPath (void) { return theApp.GetProfileString("Paths", "ExportDXF", NULL); } CString GetOpenFilePath (void) { return theApp.GetProfileString("Paths", "OpenFile", NULL); } /*=========================================================================== * End of Function Get...Path() *=========================================================================*/ /*=========================================================================== * * Functions - void SetExport3DSPath (Path); * void SetExportDXFPath (Path); * void SetOpenFilePath (Path); * * Set paths to the registry. The input filenames are parsed to remove * the filename and ensure the string is terminated. * *=========================================================================*/ void SetExport3DSPath (const CString& Path) { char Buffer[_MAX_PATH+1]; ExtractPath(Buffer, Path, _MAX_PATH); theApp.WriteProfileString("Paths", "Export3DS", Buffer); } void SetExportDXFPath (const CString& Path) { char Buffer[_MAX_PATH+1]; ExtractPath(Buffer, Path, _MAX_PATH); theApp.WriteProfileString("Paths", "ExportDXF", Buffer); } void SetOpenFilePath (const CString& Path) { char Buffer[_MAX_PATH+1]; ExtractPath(Buffer, Path, _MAX_PATH); theApp.WriteProfileString("Paths", "OpenFile", Buffer); //SetDFArena2Path(Buffer); } /*=========================================================================== * End of Function Set...Path() *=========================================================================*/ /*=========================================================================== * * Class CDfto3dsApp Event - void OnContextHelp (); * *=========================================================================*/ void CDfto3dsApp::OnContextHelp() { CWinApp::OnContextHelp(); } /*=========================================================================== * End of Class Event CDfto3dsApp::OnContextHelp() *=========================================================================*/