Пример #1
0
void CTabItem_MainTabBn::OnLButtonDown(UINT /*nFlags*/, CPoint /*point*/)
{
	CRect	rtItem(GetRectInScreen());

	CCmdMainTabOp	cmdMainTabOp;

	/*CMenu	file;
	file.CreateMenu();
	file.AppendMenu(MF_STRING, 8, GetResString(IDS_NEWTASK));
	file.AppendMenu(MF_SEPARATOR);
	file.AppendMenu(MF_STRING, 3, GetResString(IDS_IMPORT_UNFINISHED));*/

	CMenu tool;
	tool.CreateMenu();
	tool.AppendMenu(MF_STRING, 8, GetResString(IDS_NEWTASK));
	tool.AppendMenu(MF_STRING, 3, GetResString(IDS_IMPORT_UNFINISHED));
	

	CMenu   help;
	help.CreateMenu();
	help.AppendMenu(MF_STRING, 2, GetResString(IDS_HELP_));
	help.AppendMenu(MF_STRING, 5, GetResString(IDS_BUGREPORT));
	help.AppendMenu(MF_STRING, 6, GetResString(IDS_NEWVERSIONREPORT));
	help.AppendMenu(MF_SEPARATOR);
	help.AppendMenu(MF_STRING, 4, GetResString(IDS_VERSIONCHECK));
	help.AppendMenu(MF_SEPARATOR);
	help.AppendMenu(MF_STRING, 9, GetResString(IDS_ABOUTBOX));

	CMenu	menu;
	menu.CreatePopupMenu();
	/*menu.AppendMenu(MF_STRING|MF_POPUP,(UINT_PTR)file.m_hMenu, GetResString(IDS_FILE));*/
	menu.AppendMenu(MF_STRING, 1, GetResString(IDS_EM_PREFS));
	menu.AppendMenu(MF_SEPARATOR);
	menu.AppendMenu(MF_STRING|MF_POPUP,(UINT_PTR)tool.m_hMenu, GetResString(IDS_TOOLS));
	menu.AppendMenu(MF_STRING|MF_POPUP,(UINT_PTR)help.m_hMenu, GetResString(IDS_HELP));
	menu.AppendMenu(MF_SEPARATOR);

	const static int SHOW_TAB_CMD_START = 7;

	if (cmdMainTabOp.IsTabShowed(CMainTabWnd::TI_ADVANCE))
		menu.AppendMenu(MF_STRING | MF_CHECKED, SHOW_TAB_CMD_START, GetResString(IDS_ADVANCE_));
	else
		menu.AppendMenu(MF_STRING, SHOW_TAB_CMD_START, GetResString(IDS_ADVANCE_));


	int iRet = menu.TrackPopupMenu(TPM_RETURNCMD, rtItem.left, rtItem.bottom, ::AfxGetMainWnd());

	menu.DestroyMenu();

	switch(iRet)
	{
	case 1:
		CmdFuncs::OpenPreferencesWnd();
		break;
	case 2:
		CmdFuncs::GotoGuide();
		break;
	case 3:
		CmdFuncs::ImportUnfinishedTasks();
		break;
	case 4:
		theApp.emuledlg->DoVersioncheck(true);
		break;
	case 5:
		CmdFuncs::OpenNewUrl(_T("http://beta.verycd.com/groups/eMuleBug"), GetResString(IDS_BUGREPORT));
		break;
	case 6:
		CmdFuncs::OpenNewUrl(_T("http://beta.verycd.com/groups/eMuleBeta/"), GetResString(IDS_NEWVERSIONREPORT));
		break;
	case SHOW_TAB_CMD_START:
		if (cmdMainTabOp.IsTabShowed(CMainTabWnd::TI_ADVANCE))
		{
			cmdMainTabOp.RemoveTabById(CMainTabWnd::TI_ADVANCE);
		}
		else
		{
			cmdMainTabOp.AddTabById(CMainTabWnd::TI_ADVANCE);
		}
		break;
	case 8:
		CmdFuncs::PopupNewTaskDlg();
		break;
	case 9:
		{
			CCreditsDlg dlgAbout;
			dlgAbout.DoModal();
			break;
		}
	default:
		break;
	}

}
void FEditorLiveStreaming::BroadcastStatusCallback( const FLiveStreamingStatus& Status )
{
	TSharedPtr< SNotificationItem > Notification( NotificationWeakPtr.Pin() );
	if( Notification.IsValid() )
	{
		// Don't bother clobbering existing message with text about web cam starting/stopping, unless we're already broadcasting.
		// We want to make sure people see the persistent text about login state.
		if( SubmittedVideoFrameCount > 0 ||
			( Status.StatusType != FLiveStreamingStatus::EStatusType::WebCamStarted &&
			  Status.StatusType != FLiveStreamingStatus::EStatusType::WebCamStopped &&
			  Status.StatusType != FLiveStreamingStatus::EStatusType::WebCamTextureNotReady &&
			  Status.StatusType != FLiveStreamingStatus::EStatusType::WebCamTextureReady &&
			  Status.StatusType != FLiveStreamingStatus::EStatusType::ChatConnected &&
			  Status.StatusType != FLiveStreamingStatus::EStatusType::ChatDisconnected ) )
		{
			Notification->SetText( Status.CustomStatusDescription );
		}
	}
	else
	{
		// Only spawn a notification if we're actually still trying to broadcast, not if we're stopping broadcasting.  We don't want
		// to revive our notification that we intentionally expired.
		if( bIsBroadcasting )
		{
			FNotificationInfo Info( Status.CustomStatusDescription );
			Info.FadeInDuration = 0.1f;
			Info.FadeOutDuration = 0.5f;
			Info.ExpireDuration = 1.5f;
			Info.bUseThrobber = false;
			Info.bUseSuccessFailIcons = true;
			Info.bUseLargeFont = true;
			Info.bFireAndForget = false;
			Info.bAllowThrottleWhenFrameRateIsLow = false;
			NotificationWeakPtr = FSlateNotificationManager::Get().AddNotification( Info );
		}
	}

	Notification = NotificationWeakPtr.Pin();
	if( Notification.IsValid() )
	{
		SNotificationItem::ECompletionState State = SNotificationItem::CS_Pending;
		if( Status.StatusType == FLiveStreamingStatus::EStatusType::Failure )
		{
			State = SNotificationItem::CS_Fail;
		}
		else if( Status.StatusType == FLiveStreamingStatus::EStatusType::BroadcastStarted ||
				 Status.StatusType == FLiveStreamingStatus::EStatusType::WebCamStarted ||
				 Status.StatusType == FLiveStreamingStatus::EStatusType::ChatConnected )
		{
			State = SNotificationItem::CS_Success;
		}

		Notification->SetCompletionState( State );
	}

	// If the web cam just turned on, then we'll go ahead and show it
	if( Status.StatusType == FLiveStreamingStatus::EStatusType::WebCamTextureReady )
	{	
		bool bIsImageFlippedHorizontally = false;
		bool bIsImageFlippedVertically = false;
		UTexture2D* WebCamTexture = LiveStreamer->GetWebCamTexture( bIsImageFlippedHorizontally, bIsImageFlippedVertically );
		if( ensure( WebCamTexture != nullptr ) )
		{
			IMainFrameModule& MainFrameModule = FModuleManager::LoadModuleChecked<IMainFrameModule>( TEXT( "MainFrame" ) );
			check( MainFrameModule.IsWindowInitialized() );
			auto RootWindow = MainFrameModule.GetParentWindow();
			check( RootWindow.IsValid() );

			// Allow the user to customize the image mirroring, too!
			const auto& Settings = *GetDefault< UEditorLiveStreamingSettings >();
			if( Settings.bMirrorWebCamImage )
			{
				bIsImageFlippedHorizontally = !bIsImageFlippedHorizontally;
			}

			// How many pixels from the edge of the main frame window to where the broadcast status window appears
			const int WindowBorderPadding = 50;

			// @todo livestream: Currently this window is not created as "topmost".  We don't really want it to be OS-topmost, but we do want it to be the most
			// topmost "regular" window in our application (not on top of tooltips, etc.)

			// Create a window that will show the web cam video feed
			BroadcastStatusWindow = SNew( SWindow )
				.Title( LOCTEXT( "StreamingWindowTitle", "Web Camera" ) )
				.ClientSize( FVector2D( WebCamTexture->GetSizeX(), WebCamTexture->GetSizeY() ) )
				.ScreenPosition( FVector2D( 
					RootWindow->GetRectInScreen().Right - WebCamTexture->GetSizeX() - WindowBorderPadding, 
					RootWindow->GetRectInScreen().Top +  WindowBorderPadding ) )

				// @todo livestream: Ideally the user could freely resize the window, but it gets a bit tricky to preserve the web cam aspect.  Plus, we don't really like how letterboxing/columnboxing looks with this.
				.SizingRule( ESizingRule::FixedSize )

				.AutoCenter( EAutoCenter::None )
				.bDragAnywhere( true )
				.SupportsMaximize( true )
				.SupportsMinimize( true )
				.FocusWhenFirstShown( false )
				.ActivateWhenFirstShown( false )
				.SaneWindowPlacement( false );

			WebCamDynamicImageBrush = MakeShareable( new FSlateDynamicImageBrush( 
				WebCamTexture,
				FVector2D( WebCamTexture->GetSizeX(), WebCamTexture->GetSizeY() ),
				WebCamTexture->GetFName() ) );

			// If the web cam image is coming in flipped, we'll apply mirroring to the Slate brush
			if( bIsImageFlippedHorizontally && bIsImageFlippedVertically )
			{
				WebCamDynamicImageBrush->Mirroring = ESlateBrushMirrorType::Both;
			}
			else if( bIsImageFlippedHorizontally )
			{ 
				WebCamDynamicImageBrush->Mirroring = ESlateBrushMirrorType::Horizontal;
			}
			else if( bIsImageFlippedVertically )
			{ 
				WebCamDynamicImageBrush->Mirroring = ESlateBrushMirrorType::Vertical;
			}

			// @todo livestream: Currently if the user closes the window, the camera is deactivated and it doesn't turn back on unless the broadcast is restarted.  We could allow the camera to be reactivated though.
			BroadcastStatusWindow->SetOnWindowClosed( 
				FOnWindowClosed::CreateStatic( []( const TSharedRef<SWindow>& Window, FEditorLiveStreaming* This ) 
				{
					// User closed the broadcast status window, so go ahead and shut down the web cam
					This->LiveStreamer->StopWebCam();
					This->BroadcastStatusWindow.Reset();
					This->WebCamDynamicImageBrush.Reset();
				}, 
				this ) );

			BroadcastStatusWindow->SetContent( 
				SNew( SImage )
					.Image( WebCamDynamicImageBrush.Get() )
			);

			FSlateApplication::Get().AddWindowAsNativeChild(
				BroadcastStatusWindow.ToSharedRef(), 
				RootWindow.ToSharedRef() );
		}

	}
	else if( Status.StatusType == FLiveStreamingStatus::EStatusType::WebCamTextureNotReady )
	{
		CloseBroadcastStatusWindow();
	}
}