D:/Zythum/DinoKod/MapEditor/MapEditor.cpp

00001 // MapEditor.cpp : Defines the class behaviors for the application.
00002 //
00003 
00004 #include "stdafx.h"
00005 #include "MapEditor.h"
00006 #include "MapEditorMainFrm.h"
00007 #include "Common/Console.h"
00008 
00009 #include "MapEditorChildFrm.h"
00010 #include "MapEditorDoc.h"
00011 #include "MapEditorView.h"
00012 #include "LandscapeView.h"
00013 #include "NewWorldDialog.h"
00014 
00015 #ifdef _DEBUG
00016 #define new DEBUG_NEW
00017 #endif
00018 
00019 
00020 // CMapEditorApp
00021 
00022 BEGIN_MESSAGE_MAP(CMapEditorApp, CWinApp)
00023         ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
00024         // Standard file based document commands
00025         ON_COMMAND(ID_FILE_NEW, OnFileNew)
00026         ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
00027         // Standard print setup command
00028         ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
00029 END_MESSAGE_MAP()
00030 
00031 
00032 // CMapEditorApp construction
00033 
00034 CMapEditorApp::CMapEditorApp()
00035 {
00036         EnableHtmlHelp();
00037 
00038         // TODO: add construction code here,
00039         // Place all significant initialization in InitInstance
00040 }
00041 
00042 
00043 // The one and only CMapEditorApp object
00044 
00045 CMapEditorApp theApp;
00046 
00047 // CMapEditorApp initialization
00048 
00049 BOOL CMapEditorApp::InitInstance()
00050 {
00051         GetCurrentDirectory( sizeof( m_pCurrentDirectory ), m_pCurrentDirectory );
00052 
00053         // InitCommonControls() is required on Windows XP if an application
00054         // manifest specifies use of ComCtl32.dll version 6 or later to enable
00055         // visual styles.  Otherwise, any window creation will fail.
00056         InitCommonControls();
00057 
00058         CWinApp::InitInstance();
00059 
00060         // Initialize OLE libraries
00061         if (!AfxOleInit())
00062         {
00063                 AfxMessageBox(IDP_OLE_INIT_FAILED);
00064                 return FALSE;
00065         }
00066         AfxEnableControlContainer();
00067 
00068 
00069         // Standard initialization
00070         // If you are not using these features and wish to reduce the size
00071         // of your final executable, you should remove from the following
00072         // the specific initialization routines you do not need
00073         // Change the registry key under which our settings are stored
00074         // TODO: You should modify this string to be something appropriate
00075         // such as the name of your company or organization
00076         SetRegistryKey(_T("Local AppWizard-Generated Applications"));
00077         LoadStdProfileSettings(4);  // Load standard INI file options (including MRU)
00078         // Register the application's document templates.  Document templates
00079         //  serve as the connection between documents, frame windows and views
00080         CMultiDocTemplate* pDocTemplate;
00081         pDocTemplate = new CMultiDocTemplate(IDR_MapTYPE,
00082                 RUNTIME_CLASS(CMapEditorDoc),
00083                 RUNTIME_CLASS(CMEChildFrame), // custom MDI child frame
00084                 RUNTIME_CLASS(CLandscapeView));
00085         AddDocTemplate(pDocTemplate);
00086         // create main MDI Frame window
00087         CMEMainFrame* pMainFrame = new CMEMainFrame;
00088         if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
00089                 return FALSE;
00090         m_pMainWnd = pMainFrame;
00091         // call DragAcceptFiles only if there's a suffix
00092         //  In an MDI app, this should occur immediately after setting m_pMainWnd
00093         // Enable drag/drop open
00094         m_pMainWnd->DragAcceptFiles();
00095         // Enable DDE Execute open
00096         EnableShellOpen();
00097         RegisterShellFileTypes(TRUE);
00098         // Parse command line for standard shell commands, DDE, file open
00099         CCommandLineInfo cmdInfo;
00100         cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
00101         ParseCommandLine(cmdInfo);
00102         // Dispatch commands specified on the command line.  Will return FALSE if
00103         // app was launched with /RegServer, /Register, /Unregserver or /Unregister.
00104         if (!ProcessShellCommand(cmdInfo))
00105                 return FALSE;
00106         // The main window has been initialized, so show and update it
00107         pMainFrame->ShowWindow(m_nCmdShow);
00108         pMainFrame->UpdateWindow();
00109 
00110         g_Console.Create( "MapEditor console", true, m_hInstance, pMainFrame->GetSafeHwnd() );
00111 
00112         return TRUE;
00113 }
00114 
00115 void CMapEditorApp::ResetCurrentDirectory()
00116 {
00117         SetCurrentDirectory( m_pCurrentDirectory );
00118 }
00119 
00120 
00121 
00122 // CAboutDlg dialog used for App About
00123 
00124 class CAboutDlg : public CDialog
00125 {
00126 public:
00127         CAboutDlg();
00128 
00129 // Dialog Data
00130         enum { IDD = IDD_ABOUTBOX };
00131 
00132 protected:
00133         virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
00134 
00135 // Implementation
00136 protected:
00137         DECLARE_MESSAGE_MAP()
00138 };
00139 
00140 CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
00141 {
00142 }
00143 
00144 void CAboutDlg::DoDataExchange(CDataExchange* pDX)
00145 {
00146         CDialog::DoDataExchange(pDX);
00147 }
00148 
00149 BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
00150 END_MESSAGE_MAP()
00151 
00152 // App command to run the dialog
00153 void CMapEditorApp::OnAppAbout()
00154 {
00155         CAboutDlg aboutDlg;
00156         aboutDlg.DoModal();
00157 }
00158 
00159 
00160 // CMapEditorApp message handlers
00161 
00162 
00163 int CMapEditorApp::ExitInstance()
00164 {
00165         g_Console.Close();
00166 
00167         return CWinApp::ExitInstance();
00168 }
00169 
00170 BOOL CMapEditorApp::OnIdle(LONG lCount)
00171 {
00172         if( !m_pMainWnd->IsIconic() )
00173         {
00174                 CMEChildFrame*  pChild = (CMEChildFrame*)((CMDIFrameWnd*)m_pMainWnd)->MDIGetActive();
00175                 if( pChild )
00176                         pChild->Manage();
00177         }
00178         else
00179                 Sleep( 100 );
00180 
00181         return TRUE;//CWinApp::OnIdle(lCount);
00182 }
00183 
00184 void CMapEditorApp::OnFileNew()
00185 {
00186         if( m_NewWorldDlg.DoModal() != IDOK )
00187                 return;
00188 
00189         CWinApp::OnFileNew();
00190 }

Generated on Sun Mar 25 20:02:13 2007 for Zythum Project by  doxygen 1.5.1-p1