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

📄 geneditview.cpp

📁 3D游戏场景编辑器
💻 CPP
📖 第 1 页 / 共 5 页
字号:
//		SelBrush.CreateSolidBrush(CYAN);
		SelBrush.CreateHatchBrush(HS_BDIAGONAL, CYAN);
		CRect NewRect(mDragStartPoint, mDragCurrentPoint );
		NewRect.NormalizeRect();
		c->FrameRect( &NewRect, &SelBrush ) ;
	}
}

void CGenEditView::OnInitialUpdate() 
{
	RECT r;
	CGenEditDoc*	pDoc = (CGenEditDoc*) GetDocument();
	SizeInfo *WadSizeInfos = Level_GetWadSizeInfos (pDoc->pLevel);
	int iView;

	CView::OnInitialUpdate();
	GetClientRect(&r);

	if(WadSizeInfos)
	{
		Render_SetWadSizes(VCam, WadSizeInfos);
		Render_ResetSettings(VCam, r.right, r.bottom);
	}

			//	post 0.57	give user option to rebuild
			//	specs for Rebuild button on the view
	CRect btnRect(2,25,55,45);
	DWORD BUTTON_STYLE = WS_CHILD|WS_VISIBLE|BS_PUSHLIKE|BS_PUSHBUTTON|BS_TOP|BS_FLAT;

	switch(mViewType)
	{
	case ID_VIEW_TEXTUREVIEW:
		Render_SetViewType(VCam, VIEWTEXTURE);
		iView = 0;
		//	post 0.57	give user option to rebuild
		//	create  Rebuild button on the view
		m_btnRebuild.Create("Rebuild?",BUTTON_STYLE, btnRect, this, IDC_BTN_VIEW_REBUILD);
		m_btnRebuild.SetFont(&CGlobals::m_ControlBarFont);
		m_btnRebuild.ShowWindow(SW_HIDE);
		//	post 0.57

		break;
	case ID_VIEW_3DWIREFRAME:
		Render_SetViewType(VCam, VIEWWIRE);
		iView = 0;
		break;
	case ID_VIEW_TOPVIEW:
		Render_SetViewType(VCam, VIEWTOP);
		iView = 1;
		break;
	case ID_VIEW_SIDEVIEW:
		Render_SetViewType(VCam, VIEWSIDE);
		iView = 3;
		break;
	case ID_VIEW_FRONTVIEW:
		Render_SetViewType(VCam, VIEWFRONT);
		iView = 2;
		break;
	default :
		iView = -1;
		break;
	}

	GetParentFrame()->SetWindowText(pDoc->GetTitle());

	if (iView != -1)
	{
		// Update view state information that was saved in level
		ViewStateInfo *pViewStateInfo;

		pViewStateInfo = Level_GetViewStateInfo (pDoc->pLevel, iView);
		if (pViewStateInfo->IsValid)
		{
			Render_SetZoom (VCam, pViewStateInfo->ZoomFactor);
			Render_SetPitchRollYaw (VCam, &pViewStateInfo->PitchRollYaw);
			Render_SetCameraPos (VCam, &pViewStateInfo->CameraPos);
		}
	}

	pDoc->UpdateGridInformation ();
	//	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 );
}

/////////////////////////////////////////////////////////////////////////////
// CGenEditView construction/destruction
CGenEditView::CGenEditView()
{
	VCam	=Render_AllocViewVars();
	Render_SetWadSizes(VCam, NULL);

	mStartPoint.x=mStartPoint.y=0;

	mViewType = ID_VIEW_NEW;

	IsDragging = IsCopying = IsPanning = FALSE;
	LMouseButtonDown = GE_FALSE;
	RMouseButtonDown = GE_FALSE;

	mCY_DRAG = ::GetSystemMetrics( SM_CYDRAG ) ;
	mCX_DRAG = ::GetSystemMetrics( SM_CXDRAG ) ;

	m_pContextMenu = NULL;
	m_bActive = FALSE;				//	view does not have focus 
}

CGenEditView::~CGenEditView()
{
	Render_FreeViewVars(VCam);
	if (VCam != NULL)
	{
		geRam_Free (VCam);
	}
}

BOOL CGenEditView::PreCreateWindow(CREATESTRUCT& cs)
{
	//get rid of default cursor
	cs.lpszClass = AfxRegisterWndClass( CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW,
		NULL, (HBRUSH)GetStockObject(GRAY_BRUSH));
	
	return CView::PreCreateWindow(cs);
}

CGenEditDoc* CGenEditView::GetDocument()
{
	
	static CGenEditDoc	*oldDoc;	//	post 0.57 checking for doc switching
	CGenEditDoc *pDoc;
	CMainFrame *pMainFrame = (CMainFrame*)AfxGetApp()->GetMainWnd();	//	post 0.57
	
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CGenEditDoc)));
	pDoc = (CGenEditDoc *)m_pDocument;
	ASSERT_VALID (pDoc);
	
	
	//	post 0.57
	//	This little routine resets the correct template dialog box onto the Propeties 
	//	Panel after switching from one document to another.
	if (pDoc && pMainFrame && oldDoc)
	{
		if (pDoc != oldDoc)
		{
			if (pDoc == CGlobals::GetActiveDocument())
			{
				if (pDoc->mModeTool == ID_TOOLS_TEMPLATE)
				{
					if ((pDoc->m_currentTemplateName == "") ||  (pDoc->m_currentTemplateName == "Cube"))
						pDoc->CreateCube();
					if (pDoc->m_currentTemplateName == "Arch")
						pDoc->CreateArch();
					if (pDoc->m_currentTemplateName == "Cone")
						pDoc->CreateCone();
					if (pDoc->m_currentTemplateName == "Cylinder")
						pDoc->CreateCylinder();
					if (pDoc->m_currentTemplateName == "Sphere")
						pDoc->CreateSpheroid();
					if (pDoc->m_currentTemplateName == "Stairs")
						pDoc->CreateStaircase();
				}
			}
		}
	}
	
	oldDoc = pDoc;	//	post 0.57	checking for doc-switching
	
	return pDoc;
}

void CGenEditView::OnSize(UINT nType, int cx, int cy) 
{
	CGenEditDoc* pDoc = GetDocument();
	SizeInfo *WadSizeInfos = Level_GetWadSizeInfos (pDoc->pLevel);

	// call our oldself
	CView::OnSize(nType, cx, cy);
	
	// make sure that our camera knows our current size
	if(WadSizeInfos)
	{
		Render_SetWadSizes(VCam, WadSizeInfos);
		Render_ResizeView (VCam, cx, cy);
	}
}

void CGenEditView::OnToolsCamera() 
{
	CGenEditDoc* pDoc = GetDocument();

	SetModeTool(ID_TOOLS_CAMERA);

	pDoc->ConfigureCurrentTool();	//	calls UpdateAllViews()
//	pDoc->mpMainFrame->m_wndTabControls->m_pBrushEntityDialog->Update(pDoc); // old gedit
	pDoc->mpMainFrame->m_TemplatesTab.UpdateTemplates(pDoc);			//	new g3dc
}

void CGenEditView::OnUpdateToolsCamera(CCmdUI* pCmdUI) 
{
	if( GetModeTool() == ID_TOOLS_CAMERA )
		pCmdUI->SetCheck();
	else
		pCmdUI->SetCheck(0);
}


void CGenEditView::OnAxisX() 
{
	CGenEditDoc* pDoc = GetDocument();

	pDoc->SetLockAxis( pDoc->GetLockAxis() ^ AXIS_X ) ;
}


void CGenEditView::OnUpdateAxisX(CCmdUI* pCmdUI) 
{
	CGenEditDoc* pDoc = GetDocument();

	if( pDoc->GetLockAxis() & AXIS_X )
		pCmdUI->SetCheck();
	else
		pCmdUI->SetCheck(0);
}


void CGenEditView::OnAxisY() 
{
	CGenEditDoc* pDoc = GetDocument();

	pDoc->SetLockAxis( pDoc->GetLockAxis() ^ AXIS_Y ) ;
}


void CGenEditView::OnUpdateAxisY(CCmdUI* pCmdUI) 
{
	CGenEditDoc* pDoc = GetDocument();
	
	if( pDoc->GetLockAxis() & AXIS_Y )
		pCmdUI->SetCheck();
	else
		pCmdUI->SetCheck(0);
}


void CGenEditView::OnAxisZ() 
{
	CGenEditDoc* pDoc = GetDocument();

	pDoc->SetLockAxis( pDoc->GetLockAxis() ^ AXIS_Z ) ;
}


void CGenEditView::OnUpdateAxisZ(CCmdUI* pCmdUI) 
{
	CGenEditDoc* pDoc = GetDocument();
	
	if( pDoc->GetLockAxis() & AXIS_Z )
		pCmdUI->SetCheck();
	else
		pCmdUI->SetCheck(0);
}


void CGenEditView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView) 
{
	CGenEditDoc* pDoc = GetDocument();



	BOOL bStateChanged = (m_bActive != bActivate);
	m_bActive = bActivate;

	if (bStateChanged)
	{
		RedrawWindow();
	}
	// set our title
	GetParentFrame()->SetWindowText(pDoc->GetTitle());

	// make sure the bar is updated for our doc.
	CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd();

	//	If the application terminates after running a command line
	//	request, we don't want to update this combo box...
	if( pFrame->IsDestroyingApp )
//		pFrame->LoadGroupComboBox();
		pFrame->UpdateMainControls();
//		pFrame->FillTextureListbox();

	CView::OnActivateView(bActivate, pActivateView, pDeactiveView);


}


void CGenEditView::OnToolsBrushMoverotatebrush() 
{
	CGenEditDoc* pDoc = GetDocument();

	int mode=GetModeTool();

	if(mode==ID_TOOLS_TEMPLATE)
	{
		SetTool( ID_TOOLS_BRUSH_MOVEROTATEBRUSH );
		pDoc->ConfigureCurrentTool();	//	calls UpdateAllViews()
	} 
	else 
	{
		if(GetTool()==ID_TOOLS_BRUSH_MOVEROTATEBRUSH)
		{
			SetTool(CURTOOL_NONE);
			SetAdjustMode (ADJUST_MODE_BRUSH);
		} 
		else 
		{
			SetTool(ID_TOOLS_BRUSH_MOVEROTATEBRUSH);
		}
		pDoc->ConfigureCurrentTool();	//	calls UpdateAllViews()
	}
}

void CGenEditView::OnUpdateToolsBrushMoverotatebrush(CCmdUI* pCmdUI) 
{
	CGenEditDoc* pDoc = GetDocument();

	//that's a pretty big if
	if(GetModeTool()==ID_TOOLS_TEMPLATE ||
		(GetModeTool()==ID_GENERALSELECT &&
		GetAdjustMode()==ADJUST_MODE_BRUSH &&
		pDoc->GetSelState()!=NOSELECTIONS)) 
	{
		pCmdUI->Enable();
		if(GetTool()==ID_TOOLS_BRUSH_MOVEROTATEBRUSH)
		{
			pCmdUI->SetCheck();
		}
		else 
		{
			pCmdUI->SetCheck(0);
		}
	} 
	else 
	{
		pCmdUI->Enable(0);
		pCmdUI->SetCheck(0);
	}
}




void CGenEditView::OnToolsBrushRotatebrush() 
{
	CGenEditDoc* pDoc = GetDocument();

	int mode=GetModeTool();

	if(mode==ID_TOOLS_TEMPLATE)
	{
		SetTool( ID_TOOLS_BRUSH_ROTATEBRUSH );
		pDoc->ConfigureCurrentTool();	//	calls UpdateAllViews()
	} 
	else 
	{
		if(GetTool()==ID_TOOLS_BRUSH_ROTATEBRUSH)
		{
			SetTool(CURTOOL_NONE);
			SetAdjustMode (ADJUST_MODE_BRUSH);
		} 
		else 
		{
			SetTool(ID_TOOLS_BRUSH_ROTATEBRUSH);
		}
		pDoc->ConfigureCurrentTool();	//	calls UpdateAllViews()
	}
	
}




void CGenEditView::OnUpdateToolsBrushRotatebrush(CCmdUI* pCmdUI) 
{
	CGenEditDoc* pDoc = GetDocument();

	//that's a pretty big if
	if(GetModeTool()==ID_TOOLS_TEMPLATE ||
		(GetModeTool()==ID_GENERALSELECT &&
		GetAdjustMode()==ADJUST_MODE_BRUSH &&
		pDoc->GetSelState()!=NOSELECTIONS)) 
	{
		pCmdUI->Enable();
		if(GetTool()==ID_TOOLS_BRUSH_ROTATEBRUSH)
		{
			pCmdUI->SetCheck();
		}
		else 
		{
			pCmdUI->SetCheck(0);
		}
	} 
	else 
	{
		pCmdUI->Enable(0);
		pCmdUI->SetCheck(0);
	}
	
}




void CGenEditView::OnToolsBrushScalebrush() 
{
	CGenEditDoc* pDoc = GetDocument();

	int mode=GetModeTool();

	if(mode==ID_TOOLS_TEMPLATE)
	{
		SetTool(ID_TOOLS_BRUSH_SCALEBRUSH);
		pDoc->ConfigureCurrentTool();	//	calls UpdateAllViews()
	} 
	else 
	{
		if(GetTool()==ID_TOOLS_BRUSH_SCALEBRUSH)
		{
			SetTool(CURTOOL_NONE);
			SetAdjustMode (ADJUST_MODE_BRUSH);
		} 
		else 
		{
			SetTool(ID_TOOLS_BRUSH_SCALEBRUSH);
		}
		pDoc->ConfigureCurrentTool();	//	calls UpdateAllViews()
	}
}

void CGenEditView::OnUpdateToolsBrushScalebrush(CCmdUI* pCmdUI) 
{
	CGenEditDoc* pDoc = GetDocument();

	//that's a very big if
	if((GetModeTool()==ID_TOOLS_TEMPLATE && !pDoc->TempEnt) ||
		(GetModeTool()==ID_GENERALSELECT &&
		GetAdjustMode ()==ADJUST_MODE_BRUSH &&
#pragma message ("Can't do multiple brush scaling due to Brush_Resize implementation.")
//		SelBrushList_GetSize (pDoc->pSelBrushes) > 0)) 
		SelBrushList_GetSize (pDoc->pSelBrushes) == 1))
	{
		pCmdUI->Enable();
		if(GetTool()==ID_TOOLS_BRUSH_SCALEBRUSH)
		{
			pCmdUI->SetCheck();
		}
		else 
		{
			pCmdUI->SetCheck(0);
		}
	} 
	else 
	{
		pCmdUI->Enable(0);
		pCmdUI->SetCheck(0);
	}
}

void CGenEditView::OnToolsBrushShowbrush() 
{

	CGenEditDoc* pDoc = GetDocument();

	// toggle brush
	pDoc->mShowBrush ^= 1;

	// redraw the screen
	//	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 CGenEditVie

⌨️ 快捷键说明

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