Removed old style enums in favor of strongly typed enums

Former-commit-id: 0a33d916dbc0e318c63472c0768a0f934af31857
This commit is contained in:
mordentral
2016-10-21 11:04:27 -04:00
parent 5cddc4b1c5
commit d234ef1735
14 changed files with 157 additions and 175 deletions

View File

@@ -31,19 +31,19 @@ public:
// Show the UI that handles the Friends list
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedExternalUI", meta = (ExpandEnumAsExecs = "Result"))
static void ShowFriendsUI(APlayerController *PlayerController, TEnumAsByte<EBlueprintResultSwitch::Type> &Result);
static void ShowFriendsUI(APlayerController *PlayerController, EBlueprintResultSwitch &Result);
// Show the UI that handles inviting people to your game
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedExternalUI", meta = (ExpandEnumAsExecs = "Result"))
static void ShowInviteUI(APlayerController *PlayerController, TEnumAsByte<EBlueprintResultSwitch::Type> &Result);
static void ShowInviteUI(APlayerController *PlayerController, EBlueprintResultSwitch &Result);
// Show the UI that shows the leaderboard (doesn't work with steam)
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedExternalUI", meta = (ExpandEnumAsExecs = "Result"))
static void ShowLeaderBoardUI(FString LeaderboardName, TEnumAsByte<EBlueprintResultSwitch::Type> &Result);
static void ShowLeaderBoardUI(FString LeaderboardName, EBlueprintResultSwitch &Result);
// Show the UI that shows a web URL
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedExternalUI", meta = (ExpandEnumAsExecs = "Result", AutoCreateRefTerm = "AllowedDomains"))
static void ShowWebURLUI(FString URLToShow, TEnumAsByte<EBlueprintResultSwitch::Type> &Result, TArray<FString>& AllowedDomains, bool bEmbedded = false , bool bShowBackground = false, bool bShowCloseButton = false, int32 OffsetX = 0, int32 OffsetY = 0, int32 SizeX = 0, int32 SizeY = 0);
static void ShowWebURLUI(FString URLToShow, EBlueprintResultSwitch &Result, TArray<FString>& AllowedDomains, bool bEmbedded = false , bool bShowBackground = false, bool bShowCloseButton = false, int32 OffsetX = 0, int32 OffsetY = 0, int32 SizeX = 0, int32 SizeY = 0);
// Show the UI that shows a web URL
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedExternalUI")
@@ -52,10 +52,10 @@ public:
// Show the UI that shows the profile of a uniquenetid
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedExternalUI", meta = (ExpandEnumAsExecs = "Result"))
static void ShowProfileUI(const FBPUniqueNetId PlayerViewingProfile, const FBPUniqueNetId PlayerToViewProfileOf, TEnumAsByte<EBlueprintResultSwitch::Type> &Result);
static void ShowProfileUI(const FBPUniqueNetId PlayerViewingProfile, const FBPUniqueNetId PlayerToViewProfileOf, EBlueprintResultSwitch &Result);
// Show the UI that shows the account upgrade UI (doesn't work with steam)
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedExternalUI", meta = (ExpandEnumAsExecs = "Result"))
static void ShowAccountUpgradeUI(const FBPUniqueNetId PlayerRequestingAccountUpgradeUI, TEnumAsByte<EBlueprintResultSwitch::Type> &Result);
static void ShowAccountUpgradeUI(const FBPUniqueNetId PlayerRequestingAccountUpgradeUI, EBlueprintResultSwitch &Result);
};

View File

@@ -21,7 +21,7 @@
DECLARE_LOG_CATEGORY_EXTERN(AdvancedFriendsLog, Log, All);
UENUM(Blueprintable)
enum SteamAvatarSize
enum class SteamAvatarSize : uint8
{
SteamAvatar_Small = 1,
SteamAvatar_Medium = 2,
@@ -39,11 +39,11 @@ public:
// Sends an Invite to the current online session to a list of friends
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|FriendsList", meta = (ExpandEnumAsExecs = "Result"))
static void SendSessionInviteToFriends(APlayerController *PlayerController, const TArray<FBPUniqueNetId> &Friends, TEnumAsByte<EBlueprintResultSwitch::Type> &Result);
static void SendSessionInviteToFriends(APlayerController *PlayerController, const TArray<FBPUniqueNetId> &Friends, EBlueprintResultSwitch &Result);
// Sends an Invite to the current online session to a friend
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|FriendsList", meta = (ExpandEnumAsExecs = "Result"))
static void SendSessionInviteToFriend(APlayerController *PlayerController, const FBPUniqueNetId &FriendUniqueNetId, TEnumAsByte<EBlueprintResultSwitch::Type> &Result);
static void SendSessionInviteToFriend(APlayerController *PlayerController, const FBPUniqueNetId &FriendUniqueNetId, EBlueprintResultSwitch &Result);
// Get a friend from the previously read/saved friends list (Must Call GetFriends first for this to return anything)
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|FriendsList")

View File

@@ -38,11 +38,11 @@ public:
// Get the current session state
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo")
static void GetSessionState(TEnumAsByte<EBPOnlineSessionState::Type> &SessionState);
static void GetSessionState(EBPOnlineSessionState &SessionState);
// Get the current session settings
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (ExpandEnumAsExecs = "Result"))
static void GetSessionSettings(int32 &NumConnections, int32 &NumPrivateConnections, bool &bIsLAN, bool &bIsDedicated, bool &bAllowInvites, bool &bAllowJoinInProgress, bool &bIsAnticheatEnabled, int32 &BuildUniqueID, TArray<FSessionPropertyKeyPair> &ExtraSettings, TEnumAsByte<EBlueprintResultSwitch::Type> &Result);
static void GetSessionSettings(int32 &NumConnections, int32 &NumPrivateConnections, bool &bIsLAN, bool &bIsDedicated, bool &bAllowInvites, bool &bAllowJoinInProgress, bool &bIsAnticheatEnabled, int32 &BuildUniqueID, TArray<FSessionPropertyKeyPair> &ExtraSettings, EBlueprintResultSwitch &Result);
// Check if someone is in the current session
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo")
@@ -50,7 +50,7 @@ public:
// Make a literal session search parameter
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo|Literals")
static FSessionsSearchSetting MakeLiteralSessionSearchProperty(FSessionPropertyKeyPair SessionSearchProperty, EOnlineComparisonOpRedux::Type ComparisonOp);
static FSessionsSearchSetting MakeLiteralSessionSearchProperty(FSessionPropertyKeyPair SessionSearchProperty, EOnlineComparisonOpRedux ComparisonOp);
//********* Session Information Functions ***********//
@@ -69,23 +69,23 @@ public:
// Get session custom information key/value as Byte (For Enums)
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (ExpandEnumAsExecs = "SearchResult"))
static void GetSessionPropertyByte(const TArray<FSessionPropertyKeyPair> & ExtraSettings, FName SettingName, TEnumAsByte<ESessionSettingSearchResult::Type> &SearchResult, uint8 &SettingValue);
static void GetSessionPropertyByte(const TArray<FSessionPropertyKeyPair> & ExtraSettings, FName SettingName, ESessionSettingSearchResult &SearchResult, uint8 &SettingValue);
// Get session custom information key/value as Bool
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (ExpandEnumAsExecs = "SearchResult"))
static void GetSessionPropertyBool(const TArray<FSessionPropertyKeyPair> & ExtraSettings, FName SettingName, TEnumAsByte<ESessionSettingSearchResult::Type> &SearchResult, bool &SettingValue);
static void GetSessionPropertyBool(const TArray<FSessionPropertyKeyPair> & ExtraSettings, FName SettingName, ESessionSettingSearchResult &SearchResult, bool &SettingValue);
// Get session custom information key/value as String
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (ExpandEnumAsExecs = "SearchResult"))
static void GetSessionPropertyString(const TArray<FSessionPropertyKeyPair> & ExtraSettings, FName SettingName, TEnumAsByte<ESessionSettingSearchResult::Type> &SearchResult, FString &SettingValue);
static void GetSessionPropertyString(const TArray<FSessionPropertyKeyPair> & ExtraSettings, FName SettingName, ESessionSettingSearchResult &SearchResult, FString &SettingValue);
// Get session custom information key/value as Int
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (ExpandEnumAsExecs = "SearchResult"))
static void GetSessionPropertyInt(const TArray<FSessionPropertyKeyPair> & ExtraSettings, FName SettingName, TEnumAsByte<ESessionSettingSearchResult::Type> &SearchResult, int32 &SettingValue);
static void GetSessionPropertyInt(const TArray<FSessionPropertyKeyPair> & ExtraSettings, FName SettingName, ESessionSettingSearchResult &SearchResult, int32 &SettingValue);
// Get session custom information key/value as Float
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (ExpandEnumAsExecs = "SearchResult"))
static void GetSessionPropertyFloat(const TArray<FSessionPropertyKeyPair> & ExtraSettings, FName SettingName, TEnumAsByte<ESessionSettingSearchResult::Type> &SearchResult, float &SettingValue);
static void GetSessionPropertyFloat(const TArray<FSessionPropertyKeyPair> & ExtraSettings, FName SettingName, ESessionSettingSearchResult &SearchResult, float &SettingValue);
// Make a literal session custom information key/value pair from Byte (For Enums)

View File

@@ -15,85 +15,70 @@
UENUM()
namespace ESessionSettingSearchResult
enum class ESessionSettingSearchResult : uint8
{
enum Type
{
// Found the setting
Found,
// Found the setting
Found,
// Did not find the setting
NotFound,
// Did not find the setting
NotFound,
// Was not the correct ype
WrongType
};
}
// Was not the correct ype
WrongType
};
// This makes a lot of the blueprint functions cleaner
UENUM()
namespace EBlueprintResultSwitch
enum class EBlueprintResultSwitch : uint8
{
enum Type
{
// On Success
OnSuccess,
// On Success
OnSuccess,
// On Failure
OnFailure
};
}
// On Failure
OnFailure
};
// This is to define server type searches
UENUM(BlueprintType)
namespace EBPServerPresenceSearchType
enum class EBPServerPresenceSearchType : uint8
{
enum Type
{
ClientServersOnly,
DedicatedServersOnly,
AllServers
};
}
ClientServersOnly,
DedicatedServersOnly,
AllServers
};
// Wanted this to be switchable in the editor
UENUM(BlueprintType)
namespace EBPOnlinePresenceState
enum class EBPOnlinePresenceState : uint8
{
enum Type
{
Online,
Offline,
Away,
ExtendedAway,
DoNotDisturb,
Chat
};
}
Online,
Offline,
Away,
ExtendedAway,
DoNotDisturb,
Chat
};
UENUM(BlueprintType)
namespace EBPOnlineSessionState
enum class EBPOnlineSessionState : uint8
{
enum Type
{
/** An online session has not been created yet */
NoSession,
/** An online session is in the process of being created */
Creating,
/** Session has been created but the session hasn't started (pre match lobby) */
Pending,
/** Session has been asked to start (may take time due to communication with backend) */
Starting,
/** The current session has started. Sessions with join in progress disabled are no longer joinable */
InProgress,
/** The session is still valid, but the session is no longer being played (post match lobby) */
Ending,
/** The session is closed and any stats committed */
Ended,
/** The session is being destroyed */
Destroying
};
}
/** An online session has not been created yet */
NoSession,
/** An online session is in the process of being created */
Creating,
/** Session has been created but the session hasn't started (pre match lobby) */
Pending,
/** Session has been asked to start (may take time due to communication with backend) */
Starting,
/** The current session has started. Sessions with join in progress disabled are no longer joinable */
InProgress,
/** The session is still valid, but the session is no longer being played (post match lobby) */
Ending,
/** The session is closed and any stats committed */
Ended,
/** The session is being destroyed */
Destroying
};
// Boy oh boy is this a dirty hack, but I can't figure out a good way to do it otherwise at the moment
// The UniqueNetId is an abstract class so I can't exactly re-initialize it to make a shared pointer on some functions
@@ -205,7 +190,7 @@ public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
bool bHasVoiceSupport;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
TEnumAsByte<EBPOnlinePresenceState::Type> PresenceState;
EBPOnlinePresenceState PresenceState;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
FString StatusString;
};
@@ -224,7 +209,7 @@ public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
FString RealName;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
TEnumAsByte<EBPOnlinePresenceState::Type> OnlineState;
EBPOnlinePresenceState OnlineState;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
FBPUniqueNetId UniqueNetId;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
@@ -236,18 +221,15 @@ public:
/** The types of comparison operations for a given search query */
// Used to compare session properties
UENUM(BlueprintType)
namespace EOnlineComparisonOpRedux
enum class EOnlineComparisonOpRedux : uint8
{
enum Type
{
Equals,
NotEquals,
GreaterThan,
GreaterThanEquals,
LessThan,
LessThanEquals,
};
}
Equals,
NotEquals,
GreaterThan,
GreaterThanEquals,
LessThan,
LessThanEquals,
};
// Used to store session properties before converting to FVariantData
@@ -271,7 +253,7 @@ struct FSessionsSearchSetting
// Had to make a copy of this to account for the original not being exposed to blueprints
/** How is this session setting compared on the backend searches */
TEnumAsByte<EOnlineComparisonOpRedux::Type> ComparisonOp;
EOnlineComparisonOpRedux ComparisonOp;
// The key pair to search for
FSessionPropertyKeyPair PropertyKeyPair;
@@ -333,11 +315,11 @@ class FOnlineSearchSettingsEx : public FOnlineSearchSettings
*/
public:
void HardSet(FName Key, const FVariantData& Value, EOnlineComparisonOpRedux::Type CompOp)
void HardSet(FName Key, const FVariantData& Value, EOnlineComparisonOpRedux CompOp)
{
FOnlineSessionSearchParam* SearchParam = SearchParams.Find(Key);
EOnlineComparisonOp::Type op;
TEnumAsByte<EOnlineComparisonOp::Type> op;
switch (CompOp)
{

View File

@@ -21,9 +21,9 @@ class UFindSessionsCallbackProxyAdvanced : public UOnlineBlueprintCallProxyBase
// Searches for advertised sessions with the default online subsystem and includes an array of filters
UFUNCTION(BlueprintCallable, meta = (BlueprintInternalUseOnly = "true", WorldContext = "WorldContextObject", AutoCreateRefTerm="Filters"), Category = "Online|AdvancedSessions")
static UFindSessionsCallbackProxyAdvanced* FindSessionsAdvanced(UObject* WorldContextObject, class APlayerController* PlayerController, int32 MaxResults, bool bUseLAN, TEnumAsByte<EBPServerPresenceSearchType::Type> ServerTypeToSearch, const TArray<FSessionsSearchSetting> &Filters, bool bEmptyServersOnly = false, bool bNonEmptyServersOnly = false, bool bSecureServersOnly = false, int MinSlotsAvailable = 0);
static UFindSessionsCallbackProxyAdvanced* FindSessionsAdvanced(UObject* WorldContextObject, class APlayerController* PlayerController, int32 MaxResults, bool bUseLAN, EBPServerPresenceSearchType ServerTypeToSearch, const TArray<FSessionsSearchSetting> &Filters, bool bEmptyServersOnly = false, bool bNonEmptyServersOnly = false, bool bSecureServersOnly = false, int MinSlotsAvailable = 0);
static bool CompareVariants(const FVariantData &A, const FVariantData &B, EOnlineComparisonOpRedux::Type Comparator);
static bool CompareVariants(const FVariantData &A, const FVariantData &B, EOnlineComparisonOpRedux Comparator);
// Filters an array of session results by the given search parameters, returns a new array with the filtered results
UFUNCTION(BluePrintCallable, meta = (Category = "Online|AdvancedSessions"))
@@ -68,7 +68,7 @@ private:
bool bUseLAN;
// Whether or not to search for dedicated servers
EBPServerPresenceSearchType::Type ServerSearchType;
EBPServerPresenceSearchType ServerSearchType;
// Maximum number of results to return
int MaxResults;

View File

@@ -40,7 +40,7 @@ private:
// The Type of friends list to get
// Removed because all but the facebook interfaces don't even currently support anything but the default friends list.
//EBPFriendsLists::Type FriendListToGet;
//EBPFriendsLists FriendListToGet;
// The world context object in which this call is taking place
UObject* WorldContextObject;