Пример #1
0
/**
 * Used to cycle widget modes
 */
void FEditorModeTools::CycleWidgetMode (void)
{
	//make sure we're not currently tracking mouse movement.  If we are, changing modes could cause a crash due to referencing an axis/plane that is incompatible with the widget
	for(int32 ViewportIndex = 0;ViewportIndex < GEditor->LevelViewportClients.Num();ViewportIndex++)
	{
		FEditorViewportClient* ViewportClient = GEditor->LevelViewportClients[ ViewportIndex ];
		if (ViewportClient->IsTracking())
		{
			return;
		}
	}

	//only cycle when the mode is requesting the drawing of a widget
	if( GetShowWidget() )
	{
		const int32 CurrentWk = GetWidgetMode();
		int32 Wk = CurrentWk;
		do
		{
			Wk++;
			if ((Wk == FWidget::WM_TranslateRotateZ) && (!GetDefault<ULevelEditorViewportSettings>()->bAllowTranslateRotateZWidget))
			{
				Wk++;
			}
			// Roll back to the start if we go past FWidget::WM_Scale
			if( Wk >= FWidget::WM_Max)
			{
				Wk -= FWidget::WM_Max;
			}
		}
		while (!UsesTransformWidget((FWidget::EWidgetMode)Wk) && Wk != CurrentWk);
		SetWidgetMode( (FWidget::EWidgetMode)Wk );
		FEditorSupportDelegates::RedrawAllViewports.Broadcast();
	}
}
	virtual void ProcessClick(FSceneView & InView, HHitProxy* HitProxy, FKey Key, EInputEvent Event, uint32 HitX, uint32 HitY)
	{
		if (!HitProxy)
		{
			GEditor->SelectNone(true, true, true);
			SelectedActor = nullptr;
			return;
		}

		if (HitProxy->IsA(HActor::StaticGetType()))
		{
			HActor *h_actor = (HActor *)HitProxy;
			GEditor->SelectNone(true, true, true);
			GEditor->SelectActor(h_actor->Actor, true, true);

			SelectedActor = h_actor->Actor;

			SetWidgetMode(FWidget::WM_Translate);
		}
		else if (HitProxy->IsA(HWidgetAxis::StaticGetType()))
		{
			// TODO do something ?
		}
		else
		{
			GEditor->SelectNone(true, true, true);
			SelectedActor = nullptr;
		}
	}