Skip to content

Commit

Permalink
Merge branch 'development' into feat/documentation-link-checker
Browse files Browse the repository at this point in the history
  • Loading branch information
paulhazen authored Sep 23, 2024
2 parents f69caea + 27a8ca2 commit 82a9f63
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 1 deletion.
11 changes: 11 additions & 0 deletions Assets/Plugins/Source/Editor/EditorWindows/EOSSettingsWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@

namespace PlayEveryWare.EpicOnlineServices.Editor.Windows
{
using Epic.OnlineServices.UI;
using PlayEveryWare.EpicOnlineServices.Extensions;
using PlayEveryWare.EpicOnlineServices.Utility;
using System;
using System.Collections.Generic;
using System.IO;
Expand Down Expand Up @@ -347,6 +350,14 @@ private void OnDefaultGUI()
GUIEditorUtility.AssigningBoolField("Always send Input to Overlay",
ref mainEOSConfigFile.alwaysSendInputToOverlay, 190,
"If true, the plugin will always send input to the overlay from the C# side to native, and handle showing the overlay. This doesn't always mean input makes it to the EOS SDK.");

InputStateButtonFlags toggleFriendsButtonCombinationEnum = mainEOSConfigFile.GetToggleFriendsButtonCombinationFlags();
GUIEditorUtility.AssigningEnumField<InputStateButtonFlags>("Default Activate Overlay Button",
ref toggleFriendsButtonCombinationEnum, 190,
"Users can press the button(s) associated with this value to activate the Epic Social Overlay. Not all combinations are valid; the SDK will log an error at the start of runtime if an invalid combination is selected.");
mainEOSConfigFile.toggleFriendsButtonCombination = EnumUtility<InputStateButtonFlags>.GetEnumerator(toggleFriendsButtonCombinationEnum)
.Select(enumValue => enumValue.ToString())
.ToList();
}

protected override void RenderWindow()
Expand Down
14 changes: 14 additions & 0 deletions Assets/Plugins/Source/Editor/Utility/GUIEditorUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,20 @@ public static void AssigningFloatToStringField(string label, ref string value, f
EditorGUIUtility.labelWidth = originalLabelWidth;
}

public static void AssigningEnumField<T>(string label, ref T value, float labelWidth = -1, string tooltip = null) where T : Enum
{
float originalLabelWidth = EditorGUIUtility.labelWidth;
if (labelWidth >= 0)
{
EditorGUIUtility.labelWidth = labelWidth;
}

var newValue = (T)EditorGUILayout.EnumFlagsField(CreateGUIContent(label, tooltip), value, GUILayout.ExpandWidth(true));
value = newValue;

EditorGUIUtility.labelWidth = originalLabelWidth;
}

#region New methods for rendering input fields

private delegate T InputRenderDelegate<T>(string label, T value, float labelWidth, string tooltip);
Expand Down
24 changes: 24 additions & 0 deletions com.playeveryware.eos/Runtime/Core/Config/EOSConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ namespace PlayEveryWare.EpicOnlineServices
using UnityEngine;
using System.Text.RegularExpressions;
using Extensions;
using Epic.OnlineServices.UI;
using PlayEveryWare.EpicOnlineServices.Utility;

/// <summary>
/// Represents the default deployment ID to use when a given sandbox ID is
Expand Down Expand Up @@ -335,6 +337,15 @@ protected EOSConfig() : base("EpicOnlineServicesConfig.json")
"to the SDK.", 4)]
public bool hackForceSendInputDirectlyToSDK;

/// <summary>
/// When this combination of buttons is pressed on a controller, the
/// social overlay will toggle on.
/// Default to <see cref="InputStateButtonFlags.SpecialLeft"/>, and will
/// use that value if this configuration field is null, empty, or contains
/// only <see cref="InputStateButtonFlags.None"/>.
/// </summary>
public List<string> toggleFriendsButtonCombination = new List<string>() { InputStateButtonFlags.SpecialLeft.ToString() };

#endregion

public static Regex InvalidEncryptionKeyRegex;
Expand Down Expand Up @@ -441,6 +452,19 @@ public AuthScopeFlags GetAuthScopeFlags()
AuthScopeFlagsExtensions.TryParse);
}

/// <summary>
/// Returns a single InputStateButtonFlags enum value that results from a
/// bitwise OR operation of all the <seealso cref="toggleFriendsButtonCombination"/> flags on this
/// config.
/// </summary>
/// <returns>An InputStateButtonFlags enum value.</returns>
public InputStateButtonFlags GetToggleFriendsButtonCombinationFlags()
{
return StringsToEnum<InputStateButtonFlags>(
toggleFriendsButtonCombination,
(IList<string> stringFlags, out InputStateButtonFlags result) => EnumUtility<InputStateButtonFlags>.TryParse(stringFlags, null, out result));
}

/// <summary>
/// Given a reference to an InitializeThreadAffinity struct, set the
/// member fields contained within to match the values of this config.
Expand Down
4 changes: 3 additions & 1 deletion com.playeveryware.eos/Runtime/Core/EOSManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -533,10 +533,12 @@ private PlatformInterface CreatePlatformInterface()
//-------------------------------------------------------------------------
private void InitializeOverlay(IEOSCoroutineOwner coroutineOwner)
{
EOSConfig configData = Config.Get<EOSConfig>();

// Sets the button for the bringing up the overlay
var friendToggle = new SetToggleFriendsButtonOptions
{
ButtonCombination = InputStateButtonFlags.SpecialLeft
ButtonCombination = configData.GetToggleFriendsButtonCombinationFlags()
};
UIInterface uiInterface = Instance.GetEOSPlatformInterface().GetUIInterface();
uiInterface.SetToggleFriendsButton(ref friendToggle);
Expand Down

0 comments on commit 82a9f63

Please sign in to comment.