⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 genedit.cpp

📁 3D游戏场景编辑器
💻 CPP
📖 第 1 页 / 共 2 页
字号:

	if( !ProcessCommandLine() )
	{
		return FALSE;
	}

	//	Setup user preferences...
	InitUserPreferences(pMainFrame);

	pMainFrame->UpdateMainControls();	// updates command panel - G3D-Classic

	// ROB: This is the timeout function, not needed for "release"
#ifdef TIME_OUT
	// stick in a nice date check here.  This
	// copy will expire on september 1st
	CTime t = CTime::GetCurrentTime();
	// close the application.....
	if( (t.GetMonth() >= 11) || (t.GetYear() != 1996) ) {
		return FALSE;
	}
#endif

	pMainFrame->IsStartingApp = 0;
						

	// CG: This line inserted by 'Tip of the Day' component.
	ShowTipAtStartup();

	return TRUE;
}

/////////////////////////////////////////////////////////////////////////////
// CGenEditApp commands

BOOL CGenEditApp::PreTranslateMessage(MSG* pMsg)
{
	// CG: The following line was added by the Splash Screen component.	CSplashWnd::PreTranslateAppMessage(pMsg);
	return CWinApp::PreTranslateMessage(pMsg);
}

// App command to run the dialog
void CGenEditApp::OnAppAbout()
{
	CAboutDlg aboutDlg;

	aboutDlg.DoModal() ;
}

//	CHANGE!	03/29/97	John Moore
void CGenEditApp::InitUserPreferences(CMainFrame* pMainFrame)
{
	//	Get rid of the previous default view that is created...
//	pMainFrame->HideAllViews();

	// Let's show the window as maximized...
	m_nCmdShow = SW_MAXIMIZE;
	pMainFrame->ShowWindow(m_nCmdShow);
	pMainFrame->UpdateWindow();

	//	Setup 4 views from the get-go...
//	pMainFrame->View4views();
}
//	End of CHANGE

BOOL CGenEditApp::OnIdle(LONG lCount) 
{
	//	Let's grab the active document and save it...
	CChildFrame* pActiveChild =(CChildFrame *)pMainFrame->MDIGetActive();
	CGenEditDoc* pDoc;
	if (pActiveChild == NULL ||
		(pDoc = (CGenEditDoc*) pActiveChild->GetActiveDocument()) == NULL)
	{
		//TRACE0("Warning: No active document for tab update command.\n");
		//AfxMessageBox(AFX_IDP_COMMAND_FAILURE);
		//return FALSE;     // command failed

		//	We need to hide all tabs from display...
		if( pGenEditDoc != NULL )
		{
//			pMainFrame->m_wndTabControls->DisableAllTabDialogs(); //old GEdit
			pMainFrame->UpdateMainControls();			//GenEdit-Classic
			pGenEditDoc = NULL;

		}
	}
	else if( pGenEditDoc != pDoc )
	{
		pGenEditDoc = pDoc;
//		pMainFrame->m_wndTabControls->UpdateTabs();		//	Old GEdit
		pMainFrame->UpdateMainControls();						//	GenEdit-Classic
//		pMainFrame->LoadGroupComboBox() ;
//		pMainFrame->FillTextureListbox();
	}
	return CWinApp::OnIdle(lCount);
}

BOOL CGenEditApp::IsFirstInstance()
{
	pNewInstanceEvent = new CEvent( FALSE, FALSE, AfxGetAppName() );
	
	if( ::GetLastError() == ERROR_ALREADY_EXISTS )
	{
		pNewInstanceEvent->SetEvent();
		return FALSE;
	}

	pShutdownEvent = new CEvent;
	pWatcher = ( CActivationWatch* ) AfxBeginThread( RUNTIME_CLASS( CActivationWatch ) );

	return TRUE;
}

BOOL CGenEditApp::ProcessCommandLine()
{
	CString CmdLine = m_lpCmdLine;
	CString Argument;
	CString Parameter;
	BOOL done = CmdLine.IsEmpty();
	int index = 0;
	int length = 0;

	while( !done )
	{
		if( ( index = CmdLine.Find( ' ' )) != -1 )
		{
			Argument = CmdLine.Left( index );
			length = CmdLine.GetLength() - index - 1;
			CmdLine = CmdLine.Right( length );
		}
		else
		{
			Argument = CmdLine;
			done = TRUE;
		}

		//	Is this a command?  If so, process it and its argument(s)...
		if( Argument.GetAt( 0 ) == '-' )
		{
			//	If there's a parameter, grab it...
			if( ( index = CmdLine.Find( ' ' )) != -1 )
			{
				Parameter = CmdLine.Left( index );
				length = CmdLine.GetLength() - index - 1;
				CmdLine = CmdLine.Right( length );
			}
			else
			{
				//	Is CmdLine empty?  If not, our last argument is the parameter...
				Parameter = CmdLine;
				done = TRUE;
			}

			if( Parameter == Argument )
				Parameter.Empty();

			//	Which command?
			Argument.MakeLower();

			if( Argument == "-export" )
			{
				// MAP file export.  Parameter indicates the file name...
				CommandLineExport( &Parameter );

				//	Request satisfied, exit the application...
				return FALSE;
			}
		}
	}

	return TRUE;
}

//	Executes command line request to export a quake map file...
void CGenEditApp::CommandLineExport( CString* pMapFileName )
{
	if( !pMapFileName->IsEmpty() )
	{
		//	Does the file name have a .MAP extension?
		//  If not, provide one...
		CString Argument = *pMapFileName;
		Argument.MakeLower();
	
		if( Argument.Find( ".map" ) == -1 )
		{
			//	Extension not present, add it to the end of file name
			Argument = Argument + ".map";
			*pMapFileName = Argument;
		}

		//	Go ahead and export...
//		pGenEditDoc->ExportToQuakeMap( FALSE, pMapFileName );
	}
	else
	{
		//	Problem! no MAP file specified...
		AfxMessageBox( "Unable to export .3DT file.  No map file name specified.\n", MB_OK );
	}
}


// called when user creates a new file
void CGenEditApp::OnFileNew() 
{
	// first call down to CWinApp::FileNew()
	CWinApp::OnFileNew();
//	this->pMainFrame->UpdateActiveDoc ();  // old gedit
	this->pMainFrame->UpdateMainControls();	// new g3dc
}

void CGenEditApp::OnFileOpen() 
{
	// If the current document is unmodified and has no brushes, wipe it
	CGenEditDoc* pDoc = GetActiveGenEditDoc() ;
	if( pDoc && ( pDoc->IsModified() == FALSE ) && BrushList_Count( Level_GetBrushes (pDoc->pLevel), BRUSH_COUNT_ALL ) == 0 )
	{
		this->pMainFrame->SendMessage( WM_COMMAND, ID_FILE_CLOSE, 0 ) ;
	}
	CWinApp::OnFileOpen ();

//	this->pMainFrame->UpdateActiveDoc ();	//	old gedit
	this->pMainFrame->UpdateMainControls();	// new g3dc

}

BOOL CGenEditApp::OnOpenRecentFile (UINT nID)
{
	BOOL rslt;

	// If the current document is unmodified and has no brushes, wipe it
	CGenEditDoc* pDoc = GetActiveGenEditDoc() ;
	if( pDoc && ( pDoc->IsModified() == FALSE ) && BrushList_Count( Level_GetBrushes (pDoc->pLevel), BRUSH_COUNT_ALL ) == 0 )
	{
		this->pMainFrame->SendMessage( WM_COMMAND, ID_FILE_CLOSE, 0 ) ;
	}

	rslt = CWinApp::OnOpenRecentFile (nID);
	if (rslt != FALSE)
	{
//		this->pMainFrame->UpdateActiveDoc ();	// old gedit
		this->pMainFrame->UpdateMainControls();	// new g3dc

	}
	return rslt;
}



CGenEditDoc * CGenEditApp::GetActiveGenEditDoc( void ) const
{
	CGenEditDoc* pDoc;
	CChildFrame* pActiveChild =(CChildFrame *)pMainFrame->MDIGetActive();

	if(	pActiveChild == NULL ||
	  (	pDoc = (CGenEditDoc*) pActiveChild->GetActiveDocument()) == NULL )
	{
		return NULL ;
	}
	return  pDoc;
}

void CGenEditApp::OnPreferences() 
{
	CPreferencesDialog PrefsDlg;

	PrefsDlg.coBackground = Prefs_GetBackgroundColor (pPrefs);
	PrefsDlg.coGrid = Prefs_GetGridColor (pPrefs);
	PrefsDlg.coSnapGrid = Prefs_GetSnapGridColor (pPrefs);

	if(	PrefsDlg.DoModal() == IDOK )
	{
		Prefs_SetBackgroundColor (pPrefs, PrefsDlg.coBackground);
		Prefs_SetGridColor (pPrefs, PrefsDlg.coGrid);
		Prefs_SetSnapGridColor (pPrefs, PrefsDlg.coSnapGrid);
#if 1
		/*
		  Something in this program has the disturbing tendency to change 
		  the current directory.  Until I can track that down, I don't want
		  to resolve the paths but once...
		*/
		Prefs_SetBackgroundColor (pResolvedPrefs, PrefsDlg.coBackground);
		Prefs_SetGridColor (pResolvedPrefs, PrefsDlg.coGrid);
		Prefs_SetSnapGridColor (pResolvedPrefs, PrefsDlg.coSnapGrid);
#else	
		ResolvePreferencesPaths ();
#endif			
		CGenEditDoc* pDoc = GetActiveGenEditDoc() ;
		if( pDoc != NULL )
		{
			//	Be very careful when speccing flags for UpdateAllViews()
			//	The wrong flags at the wrong time will totally screw things up
			pDoc->UpdateAllViews( UAV_ALL3DVIEWS, NULL );
		}
	}
}

void CGenEditApp::OnUpdatePreferences(CCmdUI* pCmdUI) 
{
	pCmdUI->Enable() ;
}

afx_msg void CGenEditApp::OnHelp( )
{
	WinHelp (0, HELP_FINDER);
}

afx_msg void CGenEditApp::OnHelpIndex( )
{
	WinHelp ((LONG)"", HELP_PARTIALKEY);
}

void CGenEditApp::OnHelpHowdoi() 
{
	// TODO: Add your command handler code here
	
}


void CGenEditApp::ShowTipAtStartup(void)
{
	// CG: This function added by 'Tip of the Day' component.

	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);
	if (cmdInfo.m_bShowSplash)
	{
		CTipDlg dlg;
		if (dlg.m_bStartup)
			dlg.DoModal();
	}

}

void CGenEditApp::ShowTipOfTheDay(void)
{
	// CG: This function added by 'Tip of the Day' component.

	CTipDlg dlg;
	dlg.DoModal();

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -