This repository has been archived by the owner on Jul 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding UMG version of Mixer login pane
- Loading branch information
Showing
2 changed files
with
164 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
//********************************************************* | ||
// | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF | ||
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY | ||
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR | ||
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. | ||
// | ||
//********************************************************* | ||
|
||
#include "MixerLoginPane.h" | ||
#include "GameFramework/PlayerController.h" | ||
#include "GameFramework/PlayerState.h" | ||
#include "Engine/World.h" | ||
#include "STextBlock.h" | ||
#include "SBox.h" | ||
|
||
void UMixerLoginPane::SynchronizeProperties() | ||
{ | ||
Super::SynchronizeProperties(); | ||
} | ||
|
||
void UMixerLoginPane::ReleaseSlateResources(bool bReleaseChildren) | ||
{ | ||
Super::ReleaseSlateResources(bReleaseChildren); | ||
|
||
MyLoginPane.Reset(); | ||
} | ||
|
||
#if WITH_EDITOR | ||
const FText UMixerLoginPane::GetPaletteCategory() | ||
{ | ||
return NSLOCTEXT("MixerInteractivity", "Mixer", "Mixer"); | ||
} | ||
#endif | ||
|
||
TSharedRef<SWidget> UMixerLoginPane::RebuildWidget() | ||
{ | ||
if (!IsDesignTime()) | ||
{ | ||
MyLoginPane = SNew(SMixerLoginPane) | ||
.UserId_UObject(this, &UMixerLoginPane::SlateGetUserId) | ||
.OnAuthCodeReady_UObject(this, &UMixerLoginPane::SlateHandleAuthCodeReady) | ||
.OnUIFlowFinished_UObject(this, &UMixerLoginPane::SlateHandleUIFlowFinished) | ||
.AllowSilentLogin(AllowSilentLogin) | ||
.BackgroundColor(BackgroundColor); | ||
} | ||
else | ||
{ | ||
MyLoginPane = SNew(SBox) | ||
.WidthOverride(350.0f) | ||
.HeightOverride(500.0f) | ||
.HAlign(EHorizontalAlignment::HAlign_Center) | ||
.VAlign(EVerticalAlignment::VAlign_Center) | ||
[ | ||
SNew(STextBlock) | ||
.Text(NSLOCTEXT("MixerInteractivity", "Mixer_Login_Pane", "Mixer Login Pane")) | ||
]; | ||
} | ||
|
||
return MyLoginPane.ToSharedRef(); | ||
} | ||
|
||
FReply UMixerLoginPane::SlateHandleAuthCodeReady(const FString& AuthCode) | ||
{ | ||
OnAuthCodeReady.Broadcast(AuthCode); | ||
|
||
// Report unhandled so that Slate widget will continue with login process. | ||
return FReply::Unhandled(); | ||
} | ||
|
||
void UMixerLoginPane::SlateHandleUIFlowFinished(bool bSucceeded) | ||
{ | ||
OnUIFlowFinished.Broadcast(bSucceeded); | ||
} | ||
|
||
TSharedPtr<const FUniqueNetId> UMixerLoginPane::SlateGetUserId() const | ||
{ | ||
TSharedPtr<const FUniqueNetId> NetId = nullptr; | ||
APlayerController* OwningController = GetOwningPlayer(); | ||
if (OwningController != nullptr) | ||
{ | ||
APlayerState* PlayerState = OwningController->PlayerState; | ||
if (PlayerState) | ||
{ | ||
NetId = PlayerState->UniqueId.GetUniqueNetId(); | ||
} | ||
} | ||
return NetId; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
//********************************************************* | ||
// | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF | ||
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY | ||
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR | ||
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. | ||
// | ||
//********************************************************* | ||
|
||
#pragma once | ||
|
||
#include "SMixerLoginPane.h" | ||
#include "Components/Widget.h" | ||
#include "MixerLoginPane.generated.h" | ||
|
||
class APlayerController; | ||
|
||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnMixerAuthCodeReadyEvent, const FString&, AuthCode); | ||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnMixerLoginUIFlowFinishedEvent, bool, bSucceeded); | ||
|
||
/** | ||
* A widget that displays browser-based UI for signing into Mixer via OAuth | ||
*/ | ||
UCLASS() | ||
class MIXERINTERACTIVITY_API UMixerLoginPane : public UWidget | ||
{ | ||
GENERATED_BODY() | ||
|
||
public: | ||
/** Background color for web browser control when no document color is specified. */ | ||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Mixer", meta=(HideAlphaChannel)) | ||
FColor BackgroundColor; | ||
|
||
/** Whether to attempt automatic signin before displaying UI. */ | ||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Mixer") | ||
bool AllowSilentLogin; | ||
|
||
public: | ||
/** Called when an OAuth authorization code has been obtained (note: full login is not yet complete). */ | ||
UPROPERTY(BlueprintAssignable, Category = "Mixer|Event") | ||
FOnMixerAuthCodeReadyEvent OnAuthCodeReady; | ||
|
||
/** Called when the phase of login that requires UI is finished (note: full login is not yet complete). */ | ||
UPROPERTY(BlueprintAssignable, Category = "Mixer|Event") | ||
FOnMixerLoginUIFlowFinishedEvent OnUIFlowFinished; | ||
|
||
public: | ||
//~ Begin UWidget Interface | ||
virtual void SynchronizeProperties() override; | ||
//~ End UWidget Interface | ||
|
||
//~ Begin UVisual Interface | ||
virtual void ReleaseSlateResources(bool bReleaseChildren) override; | ||
//~ End UVisual Interface | ||
|
||
#if WITH_EDITOR | ||
virtual const FText GetPaletteCategory() override; | ||
#endif | ||
|
||
protected: | ||
//~ Begin UWidget Interface | ||
virtual TSharedRef<SWidget> RebuildWidget() override; | ||
//~ End UWidget Interface | ||
|
||
private: | ||
FReply SlateHandleAuthCodeReady(const FString& AuthCode); | ||
void SlateHandleUIFlowFinished(bool bSucceeded); | ||
|
||
TSharedPtr<const FUniqueNetId> SlateGetUserId() const; | ||
|
||
private: | ||
TSharedPtr<SWidget> MyLoginPane; | ||
}; |