📄 geneditview.cpp
字号:
case ID_TOOLS_BRUSH_SCALEBRUSH :
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
pDoc->SnapScaleNearest(sides, Render_GetInidx(VCam), VCam);
if(pDoc->mLastOp == BRUSH_SCALE)
{
pDoc->DoneResize(sides, Render_GetInidx(VCam)); // calls UpdateSelected()
}
pDoc->UpdateSelected(); // calls UpdateMainControls()
if((ModeTool == ID_TOOLS_TEMPLATE) ||
((pDoc->GetSelState() & ANYENTITY) && (!(pDoc->GetSelState() & ANYBRUSH))) )
{
// 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 );
}
else
{
// Be very careful when speccing flags for UpdateAllViews()
// The wrong flags at the wrong time will totally screw things up
// Make sure REBUILD_QUICK is absolutely necessary.
pDoc->UpdateAllViews( UAV_ALL3DVIEWS | REBUILD_QUICK, NULL );
}
break;
case ID_TOOLS_BRUSH_SHEARBRUSH :
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
if(pDoc->mLastOp==BRUSH_SHEAR)
pDoc->DoneShear(sides, Render_GetInidx(VCam));
pDoc->UpdateSelected(); // calls UpdateMainControls()
if((ModeTool == ID_TOOLS_TEMPLATE) ||
((pDoc->GetSelState() & ANYENTITY) && (!(pDoc->GetSelState() & ANYBRUSH))) )
{
// 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 );
}
else
{
// Be very careful when speccing flags for UpdateAllViews()
// The wrong flags at the wrong time will totally screw things up
// Make sure REBUILD_QUICK is absolutely necessary.
pDoc->UpdateAllViews( UAV_ALL3DVIEWS | REBUILD_QUICK, NULL );
}
break;
default :
break;
}
// new g3dc. pick the right UpdateAllViews flags so the Face Attributes
// controls work.
switch (AdjustMode)
{
case ADJUST_MODE_BRUSH :
case ADJUST_MODE_FACE :
// new g3dc
// critical for selecting brushes in textured view and
// and for getting the correct face information
// If a face is selected and a brush is not selected...
if ((!pDoc->GetSelState() & ANYBRUSH) || (pDoc->GetSelState() & ANYFACE))
{ // if face is selected and brush is not
// absolutely necessary in order to conserve brush and
// face dialog information
// 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 );
}
// g3dc tuning else
// { // if brush is selected but face is not
// Be very careful when speccing flags for UpdateAllViews()
// The wrong flags at the wrong time will totally screw things up
// Make sure REBUILD_QUICK is absolurelty necessary.
// pDoc->UpdateAllViews( UAV_ALL3DVIEWS | REBUILD_QUICK, NULL );
// }
// end add for g3dc
break;
default :
break;
}
}
if( bWasCaptured )
{
ClientToScreen( &mStartPoint ) ;
SetCursorPos( mStartPoint.x, mStartPoint.y ) ;
}
ShowTheCursor ();
}
assert( IsCopying == FALSE ) ;
}
#pragma warning (default:4100)
#pragma warning (default:4806)
#pragma warning (disable:4100)
void CGenEditView::OnLButtonDown(UINT nFlags, CPoint point)
{
/*
These tables convert the index values returned by GetCursorBoxPos
into the bitmapped values expected by the brush routines (the "sides" values).
These sides values are encode the cursor's position in relation to the box
using this:
4
----------
| |
1 | | 2
| |
| |
----------
8
So the cursor in the top-left corner of the box will be 5 (left+top = 1+4 = 5).
*/
static const int SideLookup[25] =
{
5, 5, 4, 6, 6,
5, 5, 4, 6, 6,
1, 1, 0, 2, 2,
9, 9, 8, 10, 10,
9, 9, 8, 10, 10
};
static const int SideLookupShear[25] =
{
0, 4, 4, 4, 0,
1, 0, 4, 0, 2,
1, 1, 0, 2, 2,
1, 0, 8, 0, 2,
0, 8, 8, 8, 0
};
int Tool = GetTool ();
int ModeTool = GetModeTool ();
int AdjustMode = GetAdjustMode ();
CGenEditDoc* pDoc = GetDocument();
LMouseButtonDown = GE_TRUE;
geBoolean SpaceIsDown = IsKeyDown (VK_SPACE);
assert( IsCopying == FALSE ) ;
if (!RMouseButtonDown)
{
/* if ((mViewIs3d == FALSE) && (AdjustMode == ADJUST_MODE_FACE))
{
::MessageBeep( (uint32)-1 ) ;
return ;
}
*/
SetCapture();
HideTheCursor ();
mStartPoint = point;
if (mViewIs3d || IsPanning || SpaceIsDown)
return ;
if ((Tool == CURTOOL_NONE))// && (ModeTool == ID_GENERALSELECT) && (AdjustMode == ADJUST_MODE_BRUSH))
{
mDragStartPoint = point ; // Drag mode is initiated in MouseMove
mDragCurrentPoint = point ;
}// Drag Select
else if (mViewIs3d == FALSE)
{
int CursorSide;
CursorSide = GetCursorBoxPos (&point);
if (Tool == ID_TOOLS_BRUSH_SHEARBRUSH)
{
sides = SideLookupShear[CursorSide];
}
else
{
sides = SideLookup[CursorSide];
}
if(Tool == ID_TOOLS_BRUSH_SCALEBRUSH)
{
pDoc->ScaleNum =0;
geVec3d_Set (&pDoc->FinalScale, 1.0f, 1.0f, 1.0f);
pDoc->TempCopySelectedBrushes();
}
else if(Tool == ID_TOOLS_BRUSH_SHEARBRUSH)
{
pDoc->ScaleNum =0;
geVec3d_Clear (&pDoc->FinalScale);
if (ModeTool == ID_TOOLS_TEMPLATE)
{
pDoc->TempShearTemplate =Brush_Clone(pDoc->CurBrush);
}
else
{
pDoc->TempCopySelectedBrushes();
}
}
else if ((Tool == ID_TOOLS_BRUSH_MOVEROTATEBRUSH) || (Tool == ID_TOOLS_BRUSH_MOVESELECTEDBRUSHES))
{
geVec3d_Clear (&pDoc->FinalPos);
pDoc->TempCopySelectedBrushes();
}
// new g3dc
else if ((Tool == ID_TOOLS_BRUSH_ROTATEBRUSH) /*|| (Tool == ID_TOOLS_BRUSH_MOVESELECTEDBRUSHES)*/)
{
if (mViewIs3d || IsPanning || SpaceIsDown)
return ;
geVec3d_Set (&(pDoc->FinalRot), 0.0f, 0.0f, 0.0f);
pDoc->TempCopySelectedBrushes();
}
// post 0.57
if ((ModeTool == ID_GENERALSELECT) && (AdjustMode == ADJUST_MODE_BRUSH))
{
if(!Level_RebuildBspAlways(pDoc->pLevel))
{
pDoc->mpMainFrame->SendMessageToDescendants(WM_COMMAND, IDC_BTN_REBUILD_COMMAND);
CGlobals::g_iRebuildClickCount = 0;
}
}
}// Not Drag-select
}// LButtonDown only
}
#pragma warning (default:4100)
#pragma warning (disable:4100)
void CGenEditView::OnRButtonDown(UINT nFlags, CPoint point)
{
// CGenEditDoc* pDoc = GetDocument();
geBoolean SpaceIsDown = IsKeyDown (VK_SPACE);
RMouseButtonDown = GE_TRUE;
if (!LMouseButtonDown)
{
// int Tool;
SetCapture();
HideTheCursor ();
mStartPoint = point;
if (mViewIs3d || IsPanning || SpaceIsDown)
return ;
/*
Tool = GetTool ();
if ((Tool == ID_TOOLS_BRUSH_MOVEROTATEBRUSH) || (Tool == ID_TOOLS_BRUSH_MOVESELECTEDBRUSHES))
{
geVec3d_Set (&(pDoc->FinalRot), 0.0f, 0.0f, 0.0f);
pDoc->TempCopySelectedBrushes();
}
*/
}
}
#pragma warning (default:4100)
#pragma warning (disable:4100)
void CGenEditView::OnRButtonUp(UINT nFlags, CPoint point)
{
ClientToScreen(&point);
// int Tool = GetTool ();
RMouseButtonDown = GE_FALSE;
if (!LMouseButtonDown)
{
CGenEditDoc* pDoc = GetDocument();
if(this==GetCapture())
{
ReleaseCapture();
}
// disable context menu while working with the camera in the
// textured view
/* if (IsPanning == FALSE && GetModeTool()==ID_TOOLS_CAMERA && !mViewIs3d)
{
// OnContextMenu(this, point); // new g3dc
}
// enable context menu in all views while working with tools
// other than the camera
else if (IsPanning == FALSE && GetModeTool()!=ID_TOOLS_CAMERA)
{
// OnContextMenu(this, point); // new g3dc
}
// new g3dc
// update the window after using the camera tool.
*/ if((IsKeyDown (VK_SPACE)) || IsPanning || GetModeTool()==ID_TOOLS_CAMERA)
{
pDoc->TempDeleteSelected();
IsPanning =FALSE;
OnContextMenu(this, point); // new g3dc
ShowTheCursor ();
RedrawWindow();
return;
}
ShowTheCursor ();
OnContextMenu(this, point); // new g3dc
/* if (!mViewIs3d)
{
if ((Tool == ID_TOOLS_BRUSH_MOVEROTATEBRUSH) || (Tool == ID_TOOLS_BRUSH_MOVESELECTEDBRUSHES))
{
pDoc->UpdateSelected();
if (GetModeTool () == ID_GENERALSELECT)
{
pDoc->DoneRotate ();
}
}
if (SelBrushList_GetSize (pDoc->pSelBrushes) != 0)
// Be very careful when speccing flags for UpdateAllViews()
// The wrong flags at the wrong time will totally screw things up
pDoc->UpdateAllViews(UAV_ALL3DVIEWS | REBUILD_QUICK, NULL);
} // if (!mViewIs3d)
*/
// ShowTheCursor ();
// OnContextMenu(this, point);
// AfxMessageBox("Finished processing context menu");
// 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); // old gedit. DON'T REBUILD HERE
}
assert( IsCopying == FALSE ) ;
}
#pragma warning (disable:4100)
// new g3dc
void CGenEditView::OnContextMenu(CWnd* pWnd, CPoint point)
{
// setup test for Control key held down
geBoolean ControlHeld, SpaceHeld;
ControlHeld = IsKeyDown (VK_CONTROL);
SpaceHeld = IsKeyDown (VK_SPACE);
CGenEditDoc* pDoc = GetDocument();
// if the left mouse button is held down (in addition to the
// rigiht mouse button), or if the active view is the textured
// view and the Control key is NOT being held down,
// or if the spacebar is being held down,
// or if we are in Camera Mode and NOT holding down the Ctrl key,
// then don't show the context menu
if (LMouseButtonDown || (mViewIs3d && !ControlHeld)
|| SpaceHeld
|| (pDoc->mModeTool == ID_TOOLS_CAMERA && !ControlHeld))
return;
ShowTheCursor();
// Adjust point if needed (for keyboard context menu)
if( point.x == -1 && point.y == -1 )
{
CRect rect;
GetClientRect( &rect );
point = rect.TopLeft();
point.Offset( 5, 5 );
ClientToScreen( &point );
}
// Load top-level menu from resource
CMenu mnuTop;
mnuTop.LoadMenu( IDR_POPUP_MENU );
// Get popup menu from first sub-menu
m_pContextMenu = mnuTop.GetSubMenu( 0 );
ASSERT_VALID( m_pContextMenu );
// Checked state for popup menu items is automatically
// managed by standard MFC UPDATE_COMMAND_UI mechanism!
// Display popup menu
m_pContextMenu->TrackPopupMenu( TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RIGHTBUTTON,
point.x, point.y, AfxGetMainWnd(), NULL );
// Popup menu commands are automatically handled
// by standard MFC command-routing mechanism!
}
void CGenEditView::OnDraw(CDC *c)
{
CGenEditDoc* pDoc = GetDocument();
switch(mViewType)
{
case ID_VIEW_TEXTUREVIEW:
case ID_VIEW_3DWIREFRAME:
//don't draw before texinfos are valid
if(Render_GetWadSizes(VCam))
{
pDoc->RenderWorld(VCam, c);
}
if(pDoc->IsLeakFileLoaded() && pDoc->bShowLeakFinder())
{
DrawLeakPoints3D(c->m_hDC, pDoc->GetLeakPoints(), pDoc->GetNumLeakPoints());
}
break;
case ID_VIEW_TOPVIEW:
case ID_VIEW_SIDEVIEW:
case ID_VIEW_FRONTVIEW:
pDoc->RenderOrthoView(VCam, c);
if(pDoc->IsLeakFileLoaded() && pDoc->bShowLeakFinder())
{
DrawLeakPoints(c->m_hDC, pDoc->GetLeakPoints(), pDoc->GetNumLeakPoints());
}
break;
}
int bkMode=c->GetBkMode();
int oldColor;
c->SetBkMode(TRANSPARENT);
if(this==GetParentFrame()->GetActiveView())
{
RECT r ;
GetClientRect( &r ) ; // This seemed to be more accurate, it shouldn't be...
CBrush RedBrush(RED); // new g3dc see globals.h for color constants
CBrush YellowBrush(YELLOW);
// c->FrameRect( &r, &RedBrush ); // old gedit
c->FrameRect( &r, &YellowBrush ); // new g3dc
oldColor=c->SetTextColor(WHITE); // new g3dc
}
else
{
oldColor=c->SetTextColor(LTGRAY); // new g3dc
}
switch( mViewType ) {
case ID_VIEW_TEXTUREVIEW:
c->TextOut(4,4,"Textured",8);
break;
case ID_VIEW_3DWIREFRAME:
c->TextOut(4,4,"Wireframe",9);
break;
case ID_VIEW_TOPVIEW:
c->TextOut(4,4,"Top",3);
break;
case ID_VIEW_SIDEVIEW:
c->TextOut(4,4,"Side",4);
break;
case ID_VIEW_FRONTVIEW:
c->TextOut(4,4,"Front",5);
break;
}
c->SetBkMode(bkMode);
c->SetTextColor(oldColor);
if( IsDragging && this==GetCapture() )
{
// DrawDragRect here just didn't show up against our grid...
CBrush SelBrush ;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -