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

📄 mainfrm.cpp

📁 3D游戏场景编辑器
💻 CPP
📖 第 1 页 / 共 5 页
字号:
	if (pBar != NULL)
    {
		pCmdUI->SetCheck((pBar->GetStyle() & WS_VISIBLE) != 0);
	}
}



//	END PROPERTIES PANEL CODE
//	****************************************************************************************
//	BEGIN CONSOLE PANEL CODE



//=====================================================================================================================
// CMainFrame::CreateConsoleDialogBar
// Called by: OnCreate()
// Calls: 
// Parameters: 
// Returns:	
// Purpose: Creates console bar and places CEdit control on the Console bar
//=====================================================================================================================
BOOL	CMainFrame::CreateConsoleDialogBar()
{
	m_ConsoleDialogBar = NULL;				//	this is a pointer so set it to NULL
	m_ConsoleDialogBar = new CDialogBar;	//	new instance and point to it

											//	 create the console dialogbar
	if (!m_ConsoleDialogBar->Create(this, IDD_CONSOLE_DIALOG, CBRS_GRIPPER |
		CBRS_BOTTOM | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, IDD_CONSOLE_DIALOG))
	{
		TRACE0("Failed to create Console DialogBar\n");
		return FALSE;
	}
										//	assign a var to the template's CEdit control
	m_consoleEdit = (CEdit*)m_ConsoleDialogBar->GetDlgItem(IDC_CONSOLE_EDIT);
										//	set the font using global font var
	m_consoleEdit->SetFont(&CGlobals::m_ControlBarFont);
										//	put in a test string for fun
	m_consoleEdit->SetWindowText(_T("Test"));

	m_consoleCopyButton = (CButton*)m_ConsoleDialogBar->GetDlgItem(IDC_CONSOLE_COPY_BTN);
										//	 make it dockable
	m_ConsoleDialogBar->EnableDocking(CBRS_ALIGN_BOTTOM);
										//	hide it until we need it
	m_ConsoleDialogBar->ShowWindow(SW_HIDE);
	
 return TRUE;
}


//=====================================================================================================================
// CMainFrame::ShowConsoleBar
// Called by: CCompiler(3) and CGenEditDoc(1)
// Calls: 
// Parameters: 
// Returns:	
// Purpose: Bring Console bar outta hiding. Put it where it belongs
//=====================================================================================================================
void	CMainFrame::ShowConsoleBar()
{
//	DockControlBar(m_ConsoleDialogBar);
//	m_ConsoleDialogBar->ShowWindow(SW_SHOW);

//	CDialogBar* pBar = (CDialogBar*)m_ConsoleDialogBar ;

	if( m_ConsoleDialogBar )
	{
		DockControlBar(m_ConsoleDialogBar);
		ShowControlBar( m_ConsoleDialogBar, TRUE, FALSE ) ;
	}
}


//=====================================================================================================================
// CMainFrame::TranslateString
// Called by: ConPrintf (just below)
// Calls: 
// Parameters: 
// Returns:	
// Purpose: organize char buffer into comprehensible strings of chars - for Console output
//=====================================================================================================================
char *CMainFrame::TranslateString(char *buf)
{
	static	char	buf2[32768];
	char			*out;
	unsigned int	i;

	for(i=0, out=buf2;i < strlen(buf);i++)
	{
		if(buf[i]=='\n')
		{
			*out++	='\r';
			*out++	='\n';
		}
		else
		{
			*out++	=buf[i];
		}
	}
	*out++	=0;

	return	buf2;
}


//=====================================================================================================================
// CMainFrame::ConClear
// Called by: CGenEditDoc::OnCompile(), and OnMaxtextConedit(below)
// Calls: 
// Parameters: 
// Returns:	
// Purpose: clear out the console window and get it ready for new messages
//=====================================================================================================================
void CMainFrame::ConClear()
{
	char	text[4];
	text[0]	=0;

	m_consoleEdit = (CEdit*)m_ConsoleDialogBar->GetDlgItem(IDC_CONSOLE_EDIT);

	if (m_consoleEdit == NULL)
		{AfxMessageBox("Failed to get m_ConsoleEdit"); return;}

	m_consoleEdit->SetWindowText(text);

//	m_consoleEdit->SendMessage(WM_SETTEXT, 0, (LPARAM)text);
}



//=====================================================================================================================
// CMainFrame::ConPrintf
// Called by:	Brush_SealFaces(), Brush_SnapShearNewest()
//				CGenEditDoc::CopySelectedBrushes(), LoadLeakFile(), OnBrushSelectedCopytocurrent()
//				CGenEditView::OnCompileMessage()
//				Compiler_RunPreview(), Face_SetPlaneFromFace(), fdocValidateBrush,
//				fdocValidateEntity(), Render_AllocViewVars(), Render_BlitViewDIB()
// Calls: 
// Parameters: 
// Returns:	
// Purpose: blast console messages to the console edit window
//=====================================================================================================================
void CMainFrame::ConPrintf(char *text, ...)
{
	char	buf[32768];		//this is ... cautious
	char	*out;
	CString	Listing;
	va_list argptr;

	va_start(argptr, text);
	vsprintf(buf, text, argptr);
	va_end(argptr);

	out	=TranslateString(buf);

	m_consoleEdit = (CEdit*)m_ConsoleDialogBar->GetDlgItem(IDC_CONSOLE_EDIT);

	if (m_consoleEdit == NULL)
		{AfxMessageBox("Failed to get m_ConsoleEdit"); return;}

	m_consoleEdit->ReplaceSel(out);

//	m_consoleEdit->SendMessage(EM_REPLACESEL, 0, (LPARAM)out);
}



//=====================================================================================================================
// CMainFrame::ConError
// Called by: GenEditView::OnCompileError()
// Calls: 
// Parameters: 
// Returns:	
// Purpose: announces a compiler error -- puts message on console
//=====================================================================================================================
void CMainFrame::ConError(char *text, ...)
{
	char	buf[32768];		//this is ... cautious
	char	*out;
	va_list argptr;

	va_start(argptr, text);
	vsprintf(buf, text, argptr);
	va_end(argptr);

	out	=TranslateString(buf);

	m_consoleEdit = (CEdit*)m_ConsoleDialogBar->GetDlgItem(IDC_CONSOLE_EDIT);

	if (m_consoleEdit == NULL)
		{AfxMessageBox("Failed to get m_ConsoleEdit"); return;}

	m_consoleEdit->ReplaceSel(out);

//	m_consoleEdit->SendMessage(EM_REPLACESEL, 0, (LPARAM)out);
  }



/*
//=====================================================================================================================
// CMainFrame::OnMaxtextConedit		OBSOLETE
// Called by: 
// Calls: 
// Parameters: 
// Returns:	
// Purpose: 
//=====================================================================================================================
void CMainFrame::OnMaxtextConedit() 
{
	ConClear();
}
*/

//=====================================================================================================================
// CMainFrame::OnConsole
// Called by: Menu
// Calls: 
// Parameters: 
// Returns:	
// Purpose: Displays or hides console bar
//=====================================================================================================================
void CMainFrame::OnConsole() 
{
//	CDialogBar* pBar = (CDialogBar*)m_ConsoleDialogBar ;

	if( m_ConsoleDialogBar )
	{
		DockControlBar(m_ConsoleDialogBar);
		ShowControlBar( m_ConsoleDialogBar, (m_ConsoleDialogBar->GetStyle() & WS_VISIBLE) == 0, FALSE ) ;
	}
}


//=====================================================================================================================
// CMainFrame::OnUpdateConsole
// Called by: Messaging, keeps menu current
// Calls: 
// Parameters: 
// Returns:	
// Purpose: places or removes check mark beside Console spot on View menu
//=====================================================================================================================
void CMainFrame::OnUpdateConsole(CCmdUI* pCmdUI) 
{
//	CControlBar* pBar = (CControlBar*)m_ConsoleDialogBar ;
	if (m_ConsoleDialogBar != NULL)
    {
		pCmdUI->SetCheck((m_ConsoleDialogBar->GetStyle() & WS_VISIBLE) != 0);
	}	
}



//=====================================================================================================================
// CMainFrame::OnConsoleCopyBtn() 
// Called by: messaging framework - copy to notepad button
// Calls: 
// Parameters: 
// Returns:	
// Purpose: Selects and copies console contents to clipboard, opens up Notepad
//=====================================================================================================================
void CMainFrame::OnConsoleCopyBtn() 
{
									// make sure we have a legit edit box
	m_consoleEdit = (CEdit*)m_ConsoleDialogBar->GetDlgItem(IDC_CONSOLE_EDIT);
	if (m_consoleEdit == NULL)
		{AfxMessageBox("Failed to get m_ConsoleEdit"); return;}
	
	m_consoleEdit->SetSel(0, -1);	// select all text on the console
	m_consoleEdit->Copy();			// copy it to the clipboard as text

									//	prepare to fire up Notepad.exe
	STARTUPINFO			si;
	::ZeroMemory(&si, sizeof(STARTUPINFO));
	si.cb = sizeof(STARTUPINFO);
	PROCESS_INFORMATION pi;
									//	setup error string if can't find Notepad
	CString notepadError = _T("No NotePad on your system, sorry.\n\n");
			notepadError += _T("However, you now may paste console text\n");
			notepadError += _T("into an editor of your choice.");		
	
									// launch Notepad... if present
	if(!::CreateProcess(NULL, _T("Notepad"), NULL, NULL, 
						FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi))
	{								//	if not present, let 'em know they can
									//	paste into any text editor of their choice
		AfxMessageBox(notepadError);
	}
	else
	{								//	if Notepad successfull, sever relations
									//	it's on its own now.
		::CloseHandle(pi.hThread);
		::CloseHandle(pi.hProcess);
	}
}



void CMainFrame::OnConsoleQuickviewBtn() 
{
	OnPreview();	
}




//=====================================================================================================================
// CMainFrame::OnCloseConsolebtn() 
// Called by: messaging framework - Close console button
// Calls: 
// Parameters: 
// Returns:	
// Purpose: Manually closes the console dialog bar.
//=====================================================================================================================
void CMainFrame::OnCloseConsolebtn() 
{
	if( m_ConsoleDialogBar )
	{
		ShowControlBar( m_ConsoleDialogBar, FALSE, FALSE ) ;
	}
}







//	END CONSOLE PANEL CODE
//	****************************************************************************************
//	BEGIN COMMAND PANEL / TAB CODE

//==========================================================================================
// CMainFrame::InitCommandPanel
// Called by: OnCreate()
// Calls: 
// Parameters: void
// Returns:	bool
// Purpose: setup the main command panel. This sits on the left side of the view ports
//==========================================================================================
bool CMainFrame::InitCommandDialogBar()
{
	int			i ;
	TC_ITEM		TabItem ;
	char		szBuffer[MAX_TAB_NAME_LENGTH] ;
	HINSTANCE	hResources  = AfxGetResourceHandle() ;

					//	create the command dialog. This will hold
					//	the tab control and the tab control tabs will hold the
					//	individual control dialogs.
	if (!m_CommandDialogBar.Create(this, IDD_COMMANDDIALOG, CBRS_GRIPPER |
		CBRS_ALIGN_LEFT|CBRS_TOOLTIPS|CBRS_FLYBY | CBRS_SIZE_DYNAMIC, IDC_COMMAND_TAB))
	{
		TRACE0("Failed to create DlgBar\n");
		return FALSE;	
	}

	//	make it dockabale
	m_CommandDialogBar.EnableDocking(CBRS_ALIGN_LEFT | CBRS_ALIGN_RIGHT);
	DockControlBar(&m_CommandDialogBar);

							//	Create the tab control
	m_CommandTabControl = (CTabCtrl*)m_CommandDialogBar.GetDlgItem( IDC_COMMAND_TAB ) ;
	ASSERT( m_CommandTabControl != NULL ) ;

	CWnd	*pCommandTabControlWnd;
	pCommandTabControlWnd = m_CommandTabControl->GetParent();
	ASSERT( pCommandTabControlWnd != NULL ) ;

							//	set up the tab control labels by using 
							//	an array of Identifiers for strings
							//	tabNames is defined at the top of this file.
	TabItem.mask = TCIF_TEXT ;
	for( i=0; i< sizeof(tabNames)/sizeof(*tabNames); i++ )
	{
		::LoadString( hResources, tabNames[i], szBuffer, sizeof szBuffer ) ;
		TabItem.pszText = szBuffer ;
		TabItem.cchTextMax = strlen( szBuffer ) + sizeof szBuffer[0] ;
		m_CommandTabControl->InsertItem(i, &TabItem);
	}
							//	create the dialogs for the tab bar
	m_GroupsTab.Create( IDD_GROUPDIALOG, m_CommandTabControl ) ;
	m_TexturesTab.Create(IDD_TEXTURE_DLG, m_CommandTabControl);
	m_TemplatesTab.Create(IDD_TEMPLATES_DLG, m_CommandTabControl);
	m_ModelsTab.Create(IDD_MODELKEY, m_CommandTabControl);
//	m_ListsTab.Create(IDD_LISTS, m_CommandTabControl);
//	m_ObjectsTab.Create(IDD_OBJECTSDLG, m_CommandTabControl);
							// Default to TemplatesTab
	m_CommandTabControl->SetCurSel( MAINFRM_COMMANDPANEL_TEMPLATES ) ;
	m_eCurrentTab = MAINFRM_COMMANDPANEL_TEMPLATES ;	

	return TRUE;
}



//==========================================================================================
// CMainFrame::SetCommandPanelTab

⌨️ 快捷键说明

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