📄 mainfrm.cpp
字号:
// Called by: OnNotify(here), and CGenEditDoc::SelectTab()
// Calls:
// Parameters: MAINFRM_COMMANDPANEL_TAB nTab
// Returns: void
// Purpose:
//==========================================================================================
void CMainFrame::SetCommandPanelTab( MAINFRM_COMMANDPANEL_TAB nTab )
{
CDialog * pOldDialog ;
CDialog * pNewDialog ;
ASSERT( nTab < MAINFRM_COMMANDPANEL_LAST ) ;
pDoc = this->GetCurrentDoc ();
if (pDoc != NULL)
{
if( m_eCurrentTab != nTab )
{
m_ePreviousTab = m_eCurrentTab; // keep the previous tab for a test below
// Notify Tab closing
pOldDialog = DialogFromIndex( m_eCurrentTab ) ;
pOldDialog->ShowWindow( SW_HIDE ) ;
// Notify Tab opening
pNewDialog = DialogFromIndex( nTab ) ;
pNewDialog->ShowWindow( SW_SHOW ) ;
m_eCurrentTab = nTab ;
}
// Now set the appropriate Mode based on the tab that was just selected
// This sends the current tab info to the SetMode() in CGenEditDoc.
// If it's the Templates tab, then the Templates mode is set and
// the templates button is pushed.
// If the Textures tab is pushed while at the Templates tab, then the Templates mode will
// remain -- unless the Brush mode is active at the time. If the Textures tab is pushed
// while at any other tab, the Brush mode will be set, the Brush edit button is pushed.
if (m_eCurrentTab == MAINFRM_COMMANDPANEL_TEMPLATES)
{
// post 0.57 // added to eliminate brush AND template simultaneous
// selection upon hitting the Templates Tab
pDoc->ResetAllSelectedEntities(); // calls DoGeneralSelect which calls
// ConfigureCurrentTool(), which calls
// UpdateAllViews()
pDoc->ResetAllSelectedFaces();
pDoc->ResetAllSelectedBrushes();
// end post 0.57 add
pDoc->SetMode(m_eCurrentTab);
int nState = m_wndBrushToolBar.GetToolBarCtrl().GetState(ID_TOOLS_TEMPLATE);
m_wndBrushToolBar.GetToolBarCtrl().SetState(ID_TOOLS_TEMPLATE, nState | TBSTATE_CHECKED);
}
else if (m_eCurrentTab == MAINFRM_COMMANDPANEL_TEXTURES && m_ePreviousTab == MAINFRM_COMMANDPANEL_TEMPLATES)
{
if (pDoc->mModeTool == ID_GENERALSELECT)
{
pDoc->SetMode(m_eCurrentTab);
int nState = m_wndBrushToolBar.GetToolBarCtrl().GetState(ID_GENERALSELECT);
m_wndBrushToolBar.GetToolBarCtrl().SetState(ID_GENERALSELECT, nState | TBSTATE_CHECKED);
}
else
{
pDoc->SetMode(m_ePreviousTab);
int nState = m_wndBrushToolBar.GetToolBarCtrl().GetState(ID_TOOLS_TEMPLATE);
m_wndBrushToolBar.GetToolBarCtrl().SetState(ID_TOOLS_TEMPLATE, nState | TBSTATE_CHECKED);
}
}
else
{
pDoc->SetMode(m_eCurrentTab);
int nState = m_wndBrushToolBar.GetToolBarCtrl().GetState(ID_GENERALSELECT);
m_wndBrushToolBar.GetToolBarCtrl().SetState(ID_GENERALSELECT, nState | TBSTATE_CHECKED);
}
}
else
{
// still need to keep track of clicked tab -- even if no docs open
m_eCurrentTab = nTab ;
}
}// SetCommandPanelTab
//==========================================================================================
// CMainFrame::DialogFromIndex
// Called by: SetCommandPanelTab()
// Calls:
// Parameters: MAINFRM_COMMANDPANEL_TAB nTab
// Returns: CDialog
// Purpose:
//==========================================================================================
CDialog * CMainFrame::DialogFromIndex(MAINFRM_COMMANDPANEL_TAB nTab)
{
ASSERT( nTab < MAINFRM_COMMANDPANEL_LAST ) ;
switch( nTab )
{
case MAINFRM_COMMANDPANEL_TEXTURES: return &m_TexturesTab;
case MAINFRM_COMMANDPANEL_TEMPLATES: return &m_TemplatesTab;
case MAINFRM_COMMANDPANEL_MODELS : return &m_ModelsTab;
case MAINFRM_COMMANDPANEL_GROUPS : return &m_GroupsTab ;
// case MAINFRM_COMMANDPANEL_OBJECTS : return &m_ObjectsTab;
// case MAINFRM_COMMANDPANEL_LISTS : return &m_ListsTab ;
default :
ASSERT( 0 ) ;
break ;
}
return &m_GroupsTab;
}// DialogFromIndex
//==========================================================================================
// CMainFrame::HideAllTabsBut
// Called by: UpdateMainControls()
// Calls: all tabbed dialog boxes on the Command Panel
// Parameters:
// Returns:
// Purpose: Hides all dialogboxes associated with the CommandPanel BUT ONE
//==========================================================================================
void CMainFrame::HideAllTabsBut(int nTab)
{
if (m_TexturesTab)
{
if (nTab == MAINFRM_COMMANDPANEL_TEXTURES)
m_TexturesTab.ShowWindow(SW_SHOW);
else
m_TexturesTab.ShowWindow(SW_HIDE);
}
if (m_TemplatesTab)
{
if (nTab == MAINFRM_COMMANDPANEL_TEMPLATES)
{
m_TemplatesTab.ShowWindow(SW_SHOW);
}
else
m_TemplatesTab.ShowWindow(SW_HIDE);
}
if (m_ModelsTab)
{
if (nTab == MAINFRM_COMMANDPANEL_MODELS)
m_ModelsTab.ShowWindow(SW_SHOW);
else
m_ModelsTab.ShowWindow(SW_HIDE);
}
if (m_GroupsTab)
{
if (nTab == MAINFRM_COMMANDPANEL_GROUPS)
m_GroupsTab.ShowWindow(SW_SHOW);
else
m_GroupsTab.ShowWindow(SW_HIDE);
}
/* if (m_ObjectsTab)
{
if (nTab == MAINFRM_COMMANDPANEL_OBJECTS)
m_ObjectsTab.ShowWindow(SW_SHOW);
else
m_ObjectsTab.ShowWindow(SW_HIDE);
}
if (m_ListsTab)
{
if (nTab == MAINFRM_COMMANDPANEL_LISTS)
m_ListsTab.ShowWindow(SW_SHOW);
else
m_ListsTab.ShowWindow(SW_HIDE);
} */
}
//==========================================================================================
// CMainFrame::UpdateMainControls
// Called by: CBrushAttributes::OnApply(),
// CGenEditApp::InitInstance(), OnFileNew(), OnIdle(), OnOpenRecenFile()
// CGenEditDoc::CopySelectedBrushes(), DeleteSelectedBrushes(), DoGeneralSelect(),
// OnBrushAddToWorld(), OnLevelOptions(), OnNewLibObject(), SetMode(),
// UpdateSelected()
// CGenEditView::OnActivateView(), OnBrushGroupsAddtogroup(),
// OnBrushRemoveselectedfromgroup(), OnToolsTemplate()
// CGroupsDlg::OnCreateNewGroup()
// CMainFrame::OnBrushGroupsMakenewgroup(), OnNotify(), OnSelchangeGroupList,
// UpdateTextures()
// Calls:
// Parameters:
// Returns:
// Purpose: This handles main control updates. This is the main function that is called
// by several classes for the purpose of updating toolbar and tab bar controls.
// This has replaced the previous version's style of updating toolbar and dialog
// bar properties by calling those classes directly. Now, nearly every control
// update goes through here. SHOULD TO BE CALLED AFTER DOCUMENT CREATION!
//==========================================================================================
void CMainFrame::UpdateMainControls()
{
// int UpdateBrushEntity =1;
int UpdateTexture = 1;
// Clear the slate.
// still needed here even though
// CGenEditDoc::OnCloseDocument()
// does this before closing a document
pDoc = this->GetCurrentDoc ();
if ( pDoc == NULL )
{
int NO_TABS_DUDE = -1;
HideAllPropDialogsBut(this);
HideAllTabsBut(NO_TABS_DUDE);
// get the latest address for the tab control
m_CommandTabControl = (CTabCtrl*)m_CommandDialogBar.GetDlgItem( IDC_COMMAND_TAB ) ;
// Default to TemplatesTab
m_CommandTabControl->SetCurSel( MAINFRM_COMMANDPANEL_TEMPLATES ) ;
m_eCurrentTab = MAINFRM_COMMANDPANEL_TEMPLATES ;
m_wndGroupBar.m_comboBox.ResetContent(); // clear contents of GroupBar combo box
return;
}
// this asks that if any entities are selected by the mouse, then call the pDoc function
// to display the entitiy editor onto the properties panel -- showing this entity's
// attributes.
// if an entity is selected and if the Mode is the GENERALSELECT Mode
if ((pDoc->GetSelState() & ANYENTITY) && pDoc->mModeTool == ID_GENERALSELECT)
{
if (m_dPropEntitiesDialog)
{
// see if it still on the same old entity
m_pCurrentEntity = pDoc->mCurrentEntity;
// if not, then update the entity editor
if (m_pCurrentEntity != m_pPreviousEntity)
{
CEntityArray *Entities;
Entities = Level_GetEntities (pDoc->pLevel);
m_dPropEntitiesDialog->EditEntity(*Entities, m_pCurrentEntity, pDoc);
m_pPreviousEntity = m_pCurrentEntity;
}
}
// otherwise just make a new one
else if (!m_dPropEntitiesDialog)
{
m_dPropEntitiesDialog = new CEntitiesDialog(&m_PropertiesPanel);
}
// in any case, update
m_dPropEntitiesDialog->UpdateEntities(pDoc);
}
// if the current mode is the GENERALSELECT Mode and select mode is Brush
if ((pDoc->mModeTool == ID_GENERALSELECT) && (pDoc->mAdjustMode == ADJUST_MODE_BRUSH)
&& (SelBrushList_GetSize (pDoc->pSelBrushes) > 0))
{
// if at least one brush is selected, and select mode is GENERALSELECT, and
// brush attributes are null, then show the brush attributes dialog on the
// properties panel (this initializes the attributes for the brush)
// if there's already a brush attributes dialog box
if (m_dPropBrushAttributesDialog)
{
// see if it still on the same old brush
m_pCurrentBrush = SelBrushList_GetBrush(pDoc->pSelBrushes, 0);
// if not, then replace the dialog box with a new one
if (m_pCurrentBrush != m_pPreviousBrush)
{
m_dPropBrushAttributesDialog->DestroyWindow();
delete m_dPropBrushAttributesDialog;
m_dPropBrushAttributesDialog = NULL;
m_dPropBrushAttributesDialog = new CBrushAttributesDialog(&m_PropertiesPanel);
m_pPreviousBrush = m_pCurrentBrush;
}
}
// otherwise just make a new one
else if (!m_dPropBrushAttributesDialog)
{
m_dPropBrushAttributesDialog = new CBrushAttributesDialog(&m_PropertiesPanel);
m_pCurrentBrush = SelBrushList_GetBrush(pDoc->pSelBrushes, 0);
m_pPreviousBrush = m_pCurrentBrush;
}
// in either case, update
m_dPropBrushAttributesDialog->UpdateBrushAttributes(pDoc);
}
// if the current mode is the GENERALSELECT Mode and select mode is Brush
// AND NEITHER BRUSHES NOR ENTITIES ARE SELECTED
if ((pDoc->mModeTool == ID_GENERALSELECT) && (pDoc->mAdjustMode == ADJUST_MODE_BRUSH)
&& (SelBrushList_GetSize (pDoc->pSelBrushes) == 0) && (pDoc->GetSelState() & NOENTITIES))
{
HideAllPropDialogsBut(this); // clear the properties panel
}
// if the current mode is the GENERALSELECT Mode and select mode is Face
if ((pDoc->mModeTool == ID_GENERALSELECT) && (pDoc->mAdjustMode == ADJUST_MODE_FACE)
&& (SelFaceList_GetSize (pDoc->pSelFaces) > 0))
{
// if at least one Face is selected, and select mode is GENERALSELECT, and
// Face attributes are null, then show the Face attributes dialog on the
// properties panel (this initializes the attributes for the Face)
// if there's already a face attributes dialog box
if (m_dPropFaceAttributesDialog)
{ // see if it still on the same old face
m_pCurrentFace = SelFaceList_GetFace (pDoc->pSelFaces, 0);
// if not, then replace the dialog box with a new one
if (m_pCurrentFace != m_pPreviousFace)
{
m_dPropFaceAttributesDialog->DestroyWindow();
delete m_dPropFaceAttributesDialog; // post 0,57
m_dPropFaceAttributesDialog = NULL;
m_dPropFaceAttributesDialog = new CFaceAttributesDialog(&m_PropertiesPanel);
m_pPreviousFace = m_pCurrentFace;
}
}
// otherwise just make a new one
if (!m_dPropFaceAttributesDialog)
{
m_dPropFaceAttributesDialog = new CFaceAttributesDialog(&m_PropertiesPanel);
m_pCurrentFace = SelFaceList_GetFace (pDoc->pSelFaces, 0);
m_pPreviousFace = m_pCurrentFace;
}
// in either case, update
m_dPropFaceAttributesDialog->UpdateFaceAttributes(pDoc, m_pCurrentFace);
}
// post 0.5 release
// if no Faces are selected, and select mode is GENERALSELECT, and
// adjust mode is ADJUST_MODE_FACE and the
// Face attributes dialog box is showing, destroy the face attributes
// dialog on the properties panel.
if ((pDoc->mModeTool == ID_GENERALSELECT) && (pDoc->mAdjustMode == ADJUST_MODE_FACE)
&& (SelFaceList_GetSize (pDoc->pSelFaces) <= 0))
{
if (m_dPropFaceAttributesDialog)
{
m_dPropFaceAttributesDialog->DestroyWindow();
delete m_dPropFaceAttributesDialog; // post 0.57
m_dPropFaceAttributesDialog = NULL;
}
}
// end post 0.5 release
// update the Create Template dialogs
if (m_createArchDialog.m_hWnd !=NULL) // post 0.55 // added m_hWnd...
m_createArchDialog.UpdateCreateArchDlg(pDoc);
if (m_createBoxDialog.m_hWnd !=NULL)
m_createBoxDialog.UpdateCreateBoxDlg(pDoc);
if (m_createConeDialog.m_hWnd !=NULL)
m_createConeDialog.UpdateCreateConeDlg(pDoc);
if (m_createCylDialog.m_hWnd !=NULL)
m_createCylDialog.UpdateCreateCylDlg(pDoc);
if (m_createSpheroidDialog.m_hWnd !=NULL)
m_createSpheroidDialog.UpdateCreateSpheroidDlg(pDoc);
if (m_createStaircaseDialog.m_hWnd !=NULL)
m_createStaircaseDialog.UpdateCreateStaircaseDlg(pDoc);
// Update all tabs...
if (!m_ModelsTab.UpdateModels(pDoc, Level_GetModelInfo (pDoc->pLevel)))
AfxMessageBox("Failed to update Models tab");
if (!m_TemplatesTab.UpdateTemplates(pDoc))
AfxMessageBox("Failed to update templates tab");
// if (!m_ObjectsTab.UpdateObjects(pDoc))
// AfxMessageBox("Failed to update ObjectsTab");
if (!m_GroupsTab.UpdateGroups(pDoc))
AfxMessageBox("Failed to update GroupsTab");
// NOTE: UpdateTextures is also called independently from
// CTextureListBox:: in order to avoid loss-of-focus problems.
// CTextureListBox:: does NOT call UpdateMainControls()
if (!m_TexturesTab.UpdateTextures( pDoc ))
AfxMessageBox("Failed to update textures tab");
// Which tab do we show..?
switch( m_eCurrentTab )
{
case MAINFRM_COMMANDPANEL_TEXTURES:
{
if( UpdateTexture )
{
HideAllTabsBut(MAINFRM_COMMANDPANEL_TEXTURES);
}
}
break;
case MAINFRM_COMMANDPANEL_TEMPLATES:
{
HideAllTabsBut(MAINFRM_COMMANDPANEL_TEMPLATES);
}
break;
case MAINFRM_COMMANDPANEL_MODELS:
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -