123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- //===========================================================================//
- // Copyright (C) Microsoft Corporation. All rights reserved. //
- //===========================================================================//
- // EditorMFC.cpp : Defines the class behaviors for the application.
- //
- #include "stdafx.h"
- #include "EditorMFC.h"
- #include "MainFrm.h"
- #include "MFCPlatform.hpp"
- /////////////////////////////////////////////////////////////////////////////
- // EditorMFCApp
- BEGIN_MESSAGE_MAP(EditorMFCApp, CWinApp)
- //{{AFX_MSG_MAP(EditorMFCApp)
- ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // EditorMFCApp construction
- EditorMFCApp::EditorMFCApp()
- {
- }
- /////////////////////////////////////////////////////////////////////////////
- // The one and only EditorMFCApp object
- EditorMFCApp theApp;
- /////////////////////////////////////////////////////////////////////////////
- // EditorMFCApp initialization
- BOOL EditorMFCApp::InitInstance()
- {
- // Standard initialization
- #ifdef _AFXDLL
- Enable3dControls(); // Call this when using MFC in a shared DLL
- #else
- Enable3dControlsStatic(); // Call this when linking to MFC statically
- #endif
- // Change the registry key under which our settings are stored.
- SetRegistryKey(_T("Local AppWizard-Generated Applications"));
- MainFrame* pFrame = new MainFrame;
- m_pMainWnd = pFrame;
- // create and load the frame with its resources
- pFrame->LoadFrame(IDR_EDITOR_MENU/*, WS_OVERLAPPED |WS_CAPTION | WS_SYSMENU | FWS_ADDTOTITLE*/ );
- HICON editorIco = LoadIcon(IDI_ICON1);
- pFrame->SetIcon(editorIco,true);
-
- pFrame->ShowWindow(SW_SHOW);
- pFrame->UpdateWindow();
-
- InitGameOS( m_hInstance, EditorInterface::instance()->m_hWnd, m_lpCmdLine );
- pFrame->SetFocus();
- return TRUE;
- }
- /////////////////////////////////////////////////////////////////////////////
- // EditorMFCApp message handlers
- /////////////////////////////////////////////////////////////////////////////
- // CAboutDlg dialog used for App About
- class CAboutDlg : public CDialog
- {
- public:
- CAboutDlg();
- // Dialog Data
- //{{AFX_DATA(CAboutDlg)
- enum { IDD = IDD_FOG };
- //}}AFX_DATA
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CAboutDlg)
- protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- //}}AFX_VIRTUAL
- // Implementation
- protected:
- //{{AFX_MSG(CAboutDlg)
- // No message handlers
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
- };
- CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
- {
- //{{AFX_DATA_INIT(CAboutDlg)
- //}}AFX_DATA_INIT
- }
- void CAboutDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CAboutDlg)
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
- //{{AFX_MSG_MAP(CAboutDlg)
- // No message handlers
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- // App command to run the dialog
- void EditorMFCApp::OnAppAbout()
- {
- CAboutDlg aboutDlg;
- aboutDlg.DoModal();
- }
- /////////////////////////////////////////////////////////////////////////////
- // EditorMFCApp message handlers
- BOOL EditorMFCApp::OnIdle(LONG lCount)
- {
- const CWnd *pW1 = this->GetMainWnd();
- const CWnd *pW2 = EditorInterface::instance();
- const CWnd *pW3 = CWnd::GetForegroundWindow();
- const CWnd *pW4 = CWnd::GetActiveWindow();
- const CWnd *pW5 = CWnd::GetFocus();
- if (pW1 == pW3)
- {
- EditorInterface::instance()->InvalidateRect(NULL, FALSE);
- }
- Sleep(2/*milliseconds*/); /* limits the framerate to 500fps */
-
- CWinApp::OnIdle(lCount);
- return 1;
- }
- int EditorMFCApp::ExitInstance()
- {
- {
- Environment.TerminateGameEngine();
- gos_PushCurrentHeap(0); // TerminateGameEngine() forgets to do this
- }
- if (false) {
- ExitGameOS();
- if (!EditorInterface::instance()->m_hWnd)
- {
- /* ExitGameOS() shuts down directX which has the side effect of killing the
- EditorInterface window, so we recreate the window here. The editor window
- may not be referenced after this function is executed, but this is not the correct
- place for the EditorInterface window to be destroyed. */
- EditorInterface::instance()->Create(NULL, NULL, AFX_WS_DEFAULT_VIEW | WS_VSCROLL | WS_HSCROLL,
- CRect(0, 0, 0, 0), m_pMainWnd, AFX_IDW_PANE_FIRST, NULL);
- }
- }
- delete m_pMainWnd;
- m_pMainWnd = 0;
- return CWinApp::ExitInstance();
- }
|