📄 mainfrm.cpp
字号:
/****************************************************************************************/
/* MainFrm.cpp */
/* */
/* Author: Tom Morris */
/* Description: MFC frame stuff with a bit of other misc ui stuff */
/* */
/* The contents of this file are subject to the Genesis3D Public License */
/* Version 1.01 (the "License"); you may not use this file except in */
/* compliance with the License. You may obtain a copy of the License at */
/* http://www.genesis3d.com */
/* */
/* Software distributed under the License is distributed on an "AS IS" */
/* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See */
/* the License for the specific language governing rights and limitations */
/* under the License. */
/* */
/* The Original Code is Genesis3D, released March 25, 1999. */
/* Genesis3D Version 1.1 released November 15, 1999 */
/* Copyright (C) 1999 Eclipse, Inc. All Rights Reserved */
/* */
/* Modified by Tom Morris for GenEdit-Classic ver. 0.58, April 23, 2001 */
/****************************************************************************************/
#include "stdafx.h"
#include "Globals.h"
#include "GenEditView.h"
#include "units.h"
#include <assert.h>
#include "GenEdit.h"
#include "ChildFrm.h"
#include "TextureDlg.h"
#include "EntityTable.h"
#include "TemplatesDlg.h"
#include "FilePath.h"
#include "Splash.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define MAX_TAB_NAME_LENGTH (32)
#define TOOLBAR_HEIGHT 33
#define TOOLBAR_HEIGHT_NOLABELS 28
#define TEXT_HEIGHT 16 // for toolbar button labels
#define TEXT_HEIGHT_NOLABELS 16
const static UINT tabNames[] =
{
IDS_TAB_TEMPLATES,
IDS_TAB_GROUP,
IDS_TAB_TEXTURES,
IDS_TAB_MODELS //,
// IDS_TAB_OBJECTS,
// IDS_TAB_LISTS
} ;
const CString strBarState = _T("MainFrameBarState");
static UINT indicators[] =
{
ID_SEPARATOR, // Text Area. Also holds progress control
ID_INDICATOR_SLOCK, // Lock pane
ID_INDICATOR_SELINFO, // Selection Info pane
ID_INDICATOR_WORLDPOS, // World Coordinates of cursor
ID_INDICATOR_CURSORINFO, // Cursor Info (What would select if you click)
ID_INDICATOR_GRID, // Grid Info
ID_INDICATOR_SNAP // Snap Info
};
typedef enum eINDICATORS
{
ID_SEPARATOR_PANE = 1,
ID_SLOCK_PANE,
ID_SELINFO_PANE,
ID_WORLDPOS_PANE,
ID_CURSORINFO_PANE,
ID_GRIDINFO_PANE,
ID_SNAPINFO_PANE
} ;
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
ON_WM_INITMENU()
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
ON_COMMAND(ID_WINDOW_NEW, OnWindowNew)
ON_UPDATE_COMMAND_UI(ID_INDICATOR_SLOCK, OnUpdateSLock)
ON_UPDATE_COMMAND_UI(ID_INDICATOR_SELINFO, OnUpdateSelInfo)
ON_UPDATE_COMMAND_UI(ID_INDICATOR_WORLDPOS, OnUpdateWorldPos)
ON_UPDATE_COMMAND_UI(ID_INDICATOR_CURSORINFO, OnUpdateCursorInfo)
ON_UPDATE_COMMAND_UI(ID_INDICATOR_GRID, OnUpdateGridInfo)
ON_UPDATE_COMMAND_UI(ID_INDICATOR_SNAP, OnUpdateSnapInfo)
ON_COMMAND(ID_GROUPS_MAKENEWGROUP, OnBrushGroupsMakenewgroup)
ON_COMMAND(IDM_MODEBAR, OnModebar)
ON_UPDATE_COMMAND_UI(IDM_MODEBAR, OnUpdateModebar)
ON_COMMAND(IDM_GROUPBAR, OnGroupbar)
ON_UPDATE_COMMAND_UI(IDM_GROUPBAR, OnUpdateGroupbar)
ON_COMMAND(IDM_COMMAND_PANEL, OnCommandPanel)
ON_UPDATE_COMMAND_UI(IDM_COMMAND_PANEL, OnUpdateCommandPanel)
ON_WM_CLOSE()
ON_COMMAND(ID_VIEWLEAKFINDER, OnViewLeakFinder)
ON_UPDATE_COMMAND_UI(ID_VIEWLEAKFINDER, OnUpdateViewLeakFinder)
ON_CBN_SELCHANGE(IDC_GROUPBAR_COMBO, OnSelchangeGroupList)
ON_COMMAND(IDM_PROPERTIES_PANEL, OnPropertiesPanel)
ON_UPDATE_COMMAND_UI(IDM_PROPERTIES_PANEL, OnUpdatePropertiesPanel)
ON_COMMAND(IDM_CONSOLE, OnConsole)
ON_BN_CLICKED(IDC_CONSOLE_COPY_BTN, OnConsoleCopyBtn)
ON_UPDATE_COMMAND_UI(IDM_CONSOLE, OnUpdateConsole)
ON_WM_ACTIVATE()
ON_BN_CLICKED(IDC_CLOSE_CONSOLEBTN, OnCloseConsolebtn)
ON_COMMAND(IDM_PLUGIN_1, OnPlugin1)
ON_COMMAND(IDM_PREVIEW, OnPreview)
ON_UPDATE_COMMAND_UI(IDM_PREVIEW, OnUpdatePreview)
ON_BN_CLICKED(IDC_CONSOLE_QUICKVIEW_BTN, OnConsoleQuickviewBtn)
// ON_WM_MENUSELECT()
//}}AFX_MSG_MAP
// Global help commands
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame(void) : IsStartingApp(1), IsDestroyingApp(0)
{
pDoc = NULL;
m_dPropBrushAttributesDialog = NULL;
m_dPropFaceAttributesDialog = NULL;
m_dPropEntitiesDialog = NULL;
m_pCurrentBrush = NULL;
m_pPreviousBrush = NULL;
m_pCurrentFace = NULL;
m_pPreviousFace = NULL;
m_CommandTabControl = NULL;
m_ConsoleDialogBar = NULL;
m_consoleEdit = NULL;
m_consoleCopyButton = NULL;
}
CMainFrame::~CMainFrame()
{
}
//==========================================================================================
// CMainFrame::OnCreate
// Called by:
// Calls:
// Parameters:LPCREATESTRUCT lpCreateStruct
// Returns: int
// Purpose: Main window builder. instructs for the construction of toolbars
//==========================================================================================
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
// Set the titlebar title
CFrameWnd::SetTitle("GenEdit - Classic");
// enable docking toolbars in the main frame client area
EnableDocking(CBRS_ALIGN_ANY | CBRS_FLOAT_MULTI);
if (!SetControlBarFont())
{TRACE0("Failed to create ControlBarFont\n");return -1;}
if (!CreateMainToolBar())
{TRACE0("Failed to create Main toolbar\n");return -1;}
if( !CreateBrushToolBar() )
{TRACE0("Failed to create brush toolbar\n");return -1;}
if( !CreateGroupBar() )
{TRACE0("Failed to create group toolbar\n");return -1;}
if (!InitCommandDialogBar()) // new for G3DC, replaces tab bar
{TRACE0("Failed to InitCommandDialogBar() \n");return -1;}
if (!CreatePropertiesPanel())
{TRACE0("Failed to CreatePropertiesPanel() \n");return -1;}
if (!CreateConsoleDialogBar())
{TRACE0("Failed to CreateConsoleDialogBar() \n");return -1;}
if (!CreateStatusBar())
{TRACE0("Failed to create status bar\n");return -1;}
DockControlBarLeftOf(&m_wndToolBar, &m_wndBrushToolBar); // post 0.57
DockControlBarLeftOf(&m_wndBrushToolBar, &m_wndGroupBar);
m_CB_GenEdit_BRUSH_FORMAT = RegisterClipboardFormat( "GENEDITBRUSHDATA" );
m_CB_GenEdit_ENTITY_FORMAT = RegisterClipboardFormat( "GENEDITENTITYDATA" );
// LoadBarState( "DESKTOP" ) ; //THIS DON'T WORK
// zero out pointers for these dynamic dialog boxes
m_dPropEntitiesDialog = NULL;
m_pCurrentEntity = -1;
m_pPreviousEntity = -1;
m_dPropBrushAttributesDialog = NULL;
m_pCurrentBrush = NULL;
m_pPreviousBrush = NULL;
m_dPropFaceAttributesDialog = NULL;
m_pCurrentFace = NULL;
m_pPreviousFace = NULL;
// CG: The following line was added by the Splash Screen component. CSplashWnd::ShowSplashScreen(this);
return 0;
}
//==========================================================================================
// CMainFrame::
// Called by:
// Calls:
// Parameters:
// Returns:
// Purpose:
//==========================================================================================
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
return CMDIFrameWnd::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
//==========================================================================================
// CMainFrame::
// Called by:
// Calls:
// Parameters:
// Returns:
// Purpose:
//==========================================================================================
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CMDIFrameWnd::AssertValid();
}
//==========================================================================================
// CMainFrame::
// Called by:
// Calls:
// Parameters:
// Returns:
// Purpose:
//==========================================================================================
void CMainFrame::Dump(CDumpContext& dc) const
{
CMDIFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
// ***********************************************************************************************
// BEGIN TOOL BAR CODE
//=====================================================================================================================
// CMainFrame::SetControlBarFont
// Called by: OnCreate()
// Calls:
// Parameters: void
// Returns: BOOL
// Purpose: creates a font. makes it available for controlbars and status bar
// Sets it as a static global variable
//=====================================================================================================================
BOOL CMainFrame::SetControlBarFont()
{
// Prepare LOGFONT structure
CClientDC dc( this ); // need a DC for GetDeviceCaps() below
LOGFONT lf; // logical font structure
::ZeroMemory( &lf, sizeof( lf ) );
// designate desired font by name
TCHAR myfont[LF_FACESIZE] = "Tahoma";
// 8 point Tahoma
lf.lfHeight = - MulDiv( 8, dc.GetDeviceCaps( LOGPIXELSX ), 72 );
lf.lfWidth = 0;
lf.lfEscapement = 0;
lf.lfOrientation = 0;
lf.lfWeight = FW_NORMAL;
lf.lfItalic = FALSE;
lf.lfUnderline = FALSE;
lf.lfStrikeOut = FALSE;
lf.lfCharSet = DEFAULT_CHARSET;
lf.lfOutPrecision = OUT_TT_PRECIS;
lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
lf.lfQuality = DEFAULT_QUALITY;
lf.lfPitchAndFamily = VARIABLE_PITCH | TMPF_TRUETYPE;
strcpy(lf.lfFaceName, myfont);
// Create font and assign it to our CFont static Global var
if( !CGlobals::m_ControlBarFont.CreateFontIndirect( &lf ) )
{
return FALSE;
}
return TRUE;
}
//=====================================================================================================================
// CMainFrame::CreateMainToolBar
// Called by: OnCreate()
// Calls:
// Parameters: void
// Returns: BOOL
// Purpose:
//=====================================================================================================================
BOOL CMainFrame::CreateMainToolBar()
{
char szBuffer[MAX_TAB_NAME_LENGTH] ;
HINSTANCE hResources ;
hResources = AfxGetResourceHandle() ;
// Create the main toolbar
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return FALSE;
}
// set the font using global font var
m_wndToolBar.SetFont(&CGlobals::m_ControlBarFont);
// Assign a title to bar
::LoadString( hResources, IDS_TOOLBAR_GENERAL, szBuffer, sizeof szBuffer ) ;
m_wndToolBar.SetWindowText( szBuffer ) ;
/* // set button text for main toolbar
m_wndToolBar.SetButtonText(0, _T ("New"));
m_wndToolBar.SetButtonText(1, _T ("Open"));
m_wndToolBar.SetButtonText(2, _T ("Save"));
m_wndToolBar.SetButtonText(4, _T ("Lock X"));
m_wndToolBar.SetButtonText(5, _T ("Lock Y"));
m_wndToolBar.SetButtonText(6, _T ("Lock Z"));
m_wndToolBar.SetButtonText(7, _T ("Snap"));
m_wndToolBar.SetButtonText(8, _T ("Grid"));
m_wndToolBar.SetButtonText(10, _T ("Show/Hide"));
m_wndToolBar.SetButtonText(12, _T ("Rebuild"));
m_wndToolBar.SetButtonText(13, _T ("Compile"));
m_wndToolBar.SetSizes(CSize(58,TOOLBAR_HEIGHT), CSize(16,TEXT_HEIGHT));
*/
// make it dockabale
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
return TRUE;
}
//==========================================================================================
// CMainFrame::CreateBrushToolBar
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -