diff --git a/Assets/Plugins/Windows/x64/.gitignore b/Assets/Plugins/Windows/x64/.gitignore index 217482176..e36f681e0 100644 --- a/Assets/Plugins/Windows/x64/.gitignore +++ b/Assets/Plugins/Windows/x64/.gitignore @@ -11,3 +11,5 @@ DynamicLibraryLoaderHelper.ipdb DynamicLibraryLoaderHelper.ipdb.meta DynamicLibraryLoaderHelper.lib DynamicLibraryLoaderHelper.lib.meta + +ConsoleApplication* \ No newline at end of file diff --git a/Assets/Plugins/Windows/x64/DynamicLibraryLoaderHelper-x64.dll b/Assets/Plugins/Windows/x64/DynamicLibraryLoaderHelper-x64.dll index 771348cf6..350ad9b46 100644 --- a/Assets/Plugins/Windows/x64/DynamicLibraryLoaderHelper-x64.dll +++ b/Assets/Plugins/Windows/x64/DynamicLibraryLoaderHelper-x64.dll @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1e2f180704534a3216f83b0f53b2aeef471fdd1ff9837cad9e8f56753531a1ef -size 10752 +oid sha256:1172bc25ac4cac39887750eb40a3da76aaec09049544f4df5615b54ec5373302 +size 127488 diff --git a/Assets/Plugins/Windows/x64/GfxPluginNativeRender-x64.dll b/Assets/Plugins/Windows/x64/GfxPluginNativeRender-x64.dll index cc83dd117..2445b413f 100644 --- a/Assets/Plugins/Windows/x64/GfxPluginNativeRender-x64.dll +++ b/Assets/Plugins/Windows/x64/GfxPluginNativeRender-x64.dll @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0b20be58a39f0990f0b7b1abae17b70b930e59a4b573c89d18762e223a88e5f3 -size 129536 +oid sha256:0358255da1067f0c9f66d6a5920f3e2abbacea9d395a2eda07bb6f718a056c39 +size 561664 diff --git a/com.playeveryware.eos/Runtime/Core/EOSManager.cs b/com.playeveryware.eos/Runtime/Core/EOSManager.cs index 5dad427d4..8e4c135d3 100644 --- a/com.playeveryware.eos/Runtime/Core/EOSManager.cs +++ b/com.playeveryware.eos/Runtime/Core/EOSManager.cs @@ -86,6 +86,7 @@ namespace PlayEveryWare.EpicOnlineServices using LogoutCallbackInfo = Epic.OnlineServices.Auth.LogoutCallbackInfo; using LogoutOptions = Epic.OnlineServices.Auth.LogoutOptions; using OnLogoutCallback = Epic.OnlineServices.Auth.OnLogoutCallback; + using System.Threading.Tasks; #endif /// /// One of the responsibilities of this class is to manage the lifetime of @@ -106,10 +107,20 @@ public partial class EOSManager : MonoBehaviour, IEOSCoroutineOwner public delegate void OnConnectLoginCallback(Epic.OnlineServices.Connect.LoginCallbackInfo loginCallbackInfo); + public delegate Task GetUserLoginInfoDelegate(); + private static event OnAuthLoginCallback OnAuthLogin; private static event OnAuthLogoutCallback OnAuthLogout; private static event OnConnectLoginCallback OnConnectLogin; + /// + /// Some platforms require additional user information while performing + /// a connect login. This delegate can be provided to saturate a + /// UserLoginInfo during . + /// If this is not provided, no UserLoginInfo will be set. + /// + public static GetUserLoginInfoDelegate GetUserLoginInfo = null; + public delegate void OnCreateConnectUserCallback(CreateUserCallbackInfo createUserCallbackInfo); public delegate void OnConnectLinkExternalAccountCallback(LinkAccountCallbackInfo linkAccountCallbackInfo); @@ -1040,11 +1051,21 @@ public void ConnectLinkExternalAccountWithContinuanceToken(ContinuanceToken toke //------------------------------------------------------------------------- /// - /// + /// Starts a Connect Login using a provided EpicAccountId. + /// If is set, this will + /// use that delegate to determine the + /// . /// - /// - /// - public void StartConnectLoginWithEpicAccount(EpicAccountId epicAccountId, + /// + /// The Epic Account to login as. + /// This is provided by logging in through the Auth interface. + /// + /// + /// Callback to run with information about the results of the login. + /// Also contains the information needed to set ProductUserId. + /// + /// + public async void StartConnectLoginWithEpicAccount(EpicAccountId epicAccountId, OnConnectLoginCallback onConnectLoginCallback) { var EOSAuthInterface = GetEOSPlatformInterface().GetAuthInterface(); @@ -1079,6 +1100,13 @@ public void StartConnectLoginWithEpicAccount(EpicAccountId epicAccountId, return; } + // If the GetUserLoginInfo delegate is set, the UserLoginInfo can + // be provided here for platforms that require it in this scenario. + if (EOSManager.GetUserLoginInfo != null) + { + connectLoginOptions.UserLoginInfo = await EOSManager.GetUserLoginInfo(); + } + // If the authToken returned a value, and there is a RefreshToken, then try to login using that // Otherwise, try to use the AccessToken if that's available // One or the other should be provided, but if neither is available then fail to login diff --git a/com.playeveryware.eos/Runtime/EOS_SDK/Core/Config.cs b/com.playeveryware.eos/Runtime/EOS_SDK/Core/Config.cs index e79cba387..19903ef68 100644 --- a/com.playeveryware.eos/Runtime/EOS_SDK/Core/Config.cs +++ b/com.playeveryware.eos/Runtime/EOS_SDK/Core/Config.cs @@ -54,51 +54,57 @@ namespace Epic.OnlineServices // platform support. public static partial class Config { - // This conditional (added by PlayEveryWare) is here (in conjunction with - // the class it is contained within being marked as "partial") so that - // other platforms can be supported by adding to this code-base another - // part of the partial class that sets the LibraryName differently - // depending on the presence of other scripting defines that indicate - // available functionality on other platforms. - #if EOS_PLATFORM_WINDOWS_32 || EOS_PLATFORM_WINDOWS_64 || EOS_PLATFORM_OSX || EOS_PLATFORM_LINUX || EOS_PLATFORM_IOS || EOS_PLATFORM_ANDROID + // This conditional (added by PlayEveryWare) is here (in conjunction with + // the class it is contained within being marked as "partial") so that + // other platforms can be supported by adding to this code-base another + // part of the partial class that sets the LibraryName differently + // depending on the presence of other scripting defines that indicate + // available functionality on other platforms. +#if EOS_PLATFORM_WINDOWS_32 || EOS_PLATFORM_WINDOWS_64 || EOS_PLATFORM_OSX || EOS_PLATFORM_LINUX || EOS_PLATFORM_IOS || EOS_PLATFORM_ANDROID public const string LibraryName = - #if EOS_PLATFORM_WINDOWS_32 && EOS_UNITY +#if EOS_PLATFORM_WINDOWS_32 && EOS_UNITY "EOSSDK-Win32-Shipping" - #elif EOS_PLATFORM_WINDOWS_32 +#elif EOS_PLATFORM_WINDOWS_32 "EOSSDK-Win32-Shipping.dll" - #elif EOS_PLATFORM_WINDOWS_64 && EOS_UNITY +#elif EOS_PLATFORM_WINDOWS_64 && EOS_UNITY "EOSSDK-Win64-Shipping" - #elif EOS_PLATFORM_WINDOWS_64 +#elif EOS_PLATFORM_WINDOWS_64 "EOSSDK-Win64-Shipping.dll" - #elif EOS_PLATFORM_OSX && EOS_UNITY +#elif EOS_PLATFORM_OSX && EOS_UNITY "libEOSSDK-Mac-Shipping" - #elif EOS_PLATFORM_OSX +#elif EOS_PLATFORM_OSX "libEOSSDK-Mac-Shipping.dylib" - #elif EOS_PLATFORM_LINUX && EOS_UNITY +#elif EOS_PLATFORM_LINUX && EOS_UNITY "libEOSSDK-Linux-Shipping" - #elif EOS_PLATFORM_LINUX +#elif EOS_PLATFORM_LINUX "libEOSSDK-Linux-Shipping.so" - #elif EOS_PLATFORM_IOS && EOS_UNITY && EOS_EDITOR +#elif EOS_PLATFORM_IOS && EOS_UNITY && EOS_EDITOR "EOSSDK" - #elif EOS_PLATFORM_IOS +#elif EOS_PLATFORM_IOS "EOSSDK.framework/EOSSDK" - #elif EOS_PLATFORM_ANDROID +#elif EOS_PLATFORM_ANDROID "EOSSDK" - #else - #error Unable to determine the name of the EOSSDK library. Ensure you have set the correct EOS compilation symbol for the current platform, such as EOS_PLATFORM_WINDOWS_32 or EOS_PLATFORM_WINDOWS_64, so that the correct EOSSDK library can be targeted. +#else +#error Unable to determine the name of the EOSSDK library. Ensure you have set the correct EOS compilation symbol for the current platform, such as EOS_PLATFORM_WINDOWS_32 or EOS_PLATFORM_WINDOWS_64, so that the correct EOSSDK library can be targeted. "EOSSDK-UnknownPlatform-Shipping" - #endif +#endif ; - #endif - // PEW: End modify - public const CallingConvention LibraryCallingConvention = +#elif EXTERNAL_TO_UNITY +#if PLATFORM_64 + public const string LibraryName = "EOSSDK-Win64-Shipping.dll"; +#else + public const string LibraryName = "EOSSDK-Win32-Shipping.dll"; +#endif +#endif + // PEW: End modify + public const CallingConvention LibraryCallingConvention = #if EOS_PLATFORM_WINDOWS_32 CallingConvention.StdCall #else diff --git a/com.playeveryware.eos/Runtime/EOS_SDK/Core/Helper.cs b/com.playeveryware.eos/Runtime/EOS_SDK/Core/Helper.cs index 6c46ace37..0db0f84fb 100644 --- a/com.playeveryware.eos/Runtime/EOS_SDK/Core/Helper.cs +++ b/com.playeveryware.eos/Runtime/EOS_SDK/Core/Helper.cs @@ -630,6 +630,16 @@ private static IntPtr AddPinnedBuffer(Utf8String str) return AddPinnedBuffer(str.Bytes, 0); } + // PEW: Start Modify + // This function is added because this file is included in a class + // library with a lower supported version of C# that does not allow a + // byte array to be automatically converted into an ArraySegment + internal static IntPtr AddPinnedBuffer(byte[] array) + { + return array == null ? IntPtr.Zero : AddPinnedBuffer(new ArraySegment(array)); + } + // PEW: End Modify + internal static IntPtr AddPinnedBuffer(ArraySegment array) { if (array == null) diff --git a/lib/NativeCode/DynamicLibraryLoaderHelper/.gitignore b/lib/NativeCode/DynamicLibraryLoaderHelper/.gitignore new file mode 100644 index 000000000..faf48f0b9 --- /dev/null +++ b/lib/NativeCode/DynamicLibraryLoaderHelper/.gitignore @@ -0,0 +1,3 @@ +# Exclude nuget packages +packages/* +Build/* \ No newline at end of file diff --git a/lib/NativeCode/DynamicLibraryLoaderHelper/ConsoleApplication/.gitignore b/lib/NativeCode/DynamicLibraryLoaderHelper/ConsoleApplication/.gitignore new file mode 100644 index 000000000..338c2b020 --- /dev/null +++ b/lib/NativeCode/DynamicLibraryLoaderHelper/ConsoleApplication/.gitignore @@ -0,0 +1,2 @@ +x64/* +*.user \ No newline at end of file diff --git a/lib/NativeCode/DynamicLibraryLoaderHelper/ConsoleApplication/ConsoleApplication.cpp b/lib/NativeCode/DynamicLibraryLoaderHelper/ConsoleApplication/ConsoleApplication.cpp new file mode 100644 index 000000000..9668cea4e --- /dev/null +++ b/lib/NativeCode/DynamicLibraryLoaderHelper/ConsoleApplication/ConsoleApplication.cpp @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 PlayEveryWare + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include + +int main() +{ + pew::eos::config::EOSConfig eos_config; + if(try_get_eos_config(eos_config)) + { + std::cout << "EOSConfig was read successfully."; + } + else + { + std::cout << "Could not load EOSConfig."; + } +} + +// Run program: Ctrl + F5 or Debug > Start Without Debugging menu +// Debug program: F5 or Debug > Start Debugging menu + +// Tips for Getting Started: +// 1. Use the Solution Explorer window to add/manage files +// 2. Use the Team Explorer window to connect to source control +// 3. Use the Output window to see build output and other messages +// 4. Use the Error List window to view errors +// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project +// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file diff --git a/lib/NativeCode/DynamicLibraryLoaderHelper/ConsoleApplication/ConsoleApplication.vcxproj b/lib/NativeCode/DynamicLibraryLoaderHelper/ConsoleApplication/ConsoleApplication.vcxproj new file mode 100644 index 000000000..82fa07774 --- /dev/null +++ b/lib/NativeCode/DynamicLibraryLoaderHelper/ConsoleApplication/ConsoleApplication.vcxproj @@ -0,0 +1,179 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {d7462eaf-0024-4ea5-9d89-dbbbc7766333} + ConsoleApplication + 10.0 + + + + false + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + $(SolutionDir)Build\$(Configuration)\$(PlatformTarget)\ + $(SolutionDir)Build\Temp\$(ProjectName)\$(Configuration)\$(PlatformTarget)\ + $(SolutionDir)Build\$(Configuration)\$(Platform)\;$(LibraryPath) + $(ProjectName)-$(PlatformTarget) + + + $(SolutionDir)Build\$(Configuration)\$(PlatformTarget)\ + $(SolutionDir)Build\Temp\$(ProjectName)\$(Configuration)\$(PlatformTarget)\ + $(SolutionDir)Build\$(Configuration)\$(Platform)\;$(LibraryPath) + $(ProjectName)-$(PlatformTarget) + + + $(SolutionDir)Build\$(Configuration)\$(PlatformTarget)\ + $(SolutionDir)Build\Temp\$(ProjectName)\$(Configuration)\$(PlatformTarget)\ + $(SolutionDir)Build\$(Configuration)\$(Platform)\;$(LibraryPath) + $(ProjectName)-$(PlatformTarget) + + + $(SolutionDir)Build\$(Configuration)\$(PlatformTarget)\ + $(SolutionDir)Build\Temp\$(ProjectName)\$(Configuration)\$(PlatformTarget)\ + $(SolutionDir)Build\$(Configuration)\$(Platform)\;$(LibraryPath) + $(ProjectName)-$(PlatformTarget) + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpp17 + $(SolutionDir)NativeRender\;$(SolutionDir)..\third_party\eos_sdk\include\;$(SolutionDir)..\include\windows;$(ProjectDir);%(AdditionalIncludeDirectories) + + + Console + true + $(SolutionDir)Build\$(Configuration)\$(PlatformTarget)\GfxPluginNativeRender-$(PlatformTarget).lib;%(AdditionalDependencies) + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpp17 + $(SolutionDir)NativeRender\;$(SolutionDir)..\third_party\eos_sdk\include\;$(SolutionDir)..\include\windows;$(ProjectDir);%(AdditionalIncludeDirectories) + + + Console + true + true + true + $(SolutionDir)Build\$(Configuration)\$(PlatformTarget)\GfxPluginNativeRender-$(PlatformTarget).lib;%(AdditionalDependencies) + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpp17 + $(SolutionDir)NativeRender\;$(SolutionDir)..\third_party\eos_sdk\include\;$(SolutionDir)..\include\windows;$(ProjectDir);%(AdditionalIncludeDirectories) + + + Console + true + $(SolutionDir)Build\$(Configuration)\$(PlatformTarget)\GfxPluginNativeRender-$(PlatformTarget).lib;%(AdditionalDependencies) + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpp17 + $(SolutionDir)NativeRender\;$(SolutionDir)..\third_party\eos_sdk\include\;$(SolutionDir)..\include\windows;$(ProjectDir);%(AdditionalIncludeDirectories) + + + Console + true + true + true + $(SolutionDir)Build\$(Configuration)\$(PlatformTarget)\GfxPluginNativeRender-$(PlatformTarget).lib;%(AdditionalDependencies) + + + + + + + + {251d4477-4c90-4fe1-94a2-52377327d3b2} + + + + + + \ No newline at end of file diff --git a/lib/NativeCode/DynamicLibraryLoaderHelper/ConsoleApplication/ConsoleApplication.vcxproj.filters b/lib/NativeCode/DynamicLibraryLoaderHelper/ConsoleApplication/ConsoleApplication.vcxproj.filters new file mode 100644 index 000000000..ed610da4e --- /dev/null +++ b/lib/NativeCode/DynamicLibraryLoaderHelper/ConsoleApplication/ConsoleApplication.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + \ No newline at end of file diff --git a/lib/NativeCode/DynamicLibraryLoaderHelper/Directory.Build.props b/lib/NativeCode/DynamicLibraryLoaderHelper/Directory.Build.props new file mode 100644 index 000000000..f77726086 --- /dev/null +++ b/lib/NativeCode/DynamicLibraryLoaderHelper/Directory.Build.props @@ -0,0 +1,8 @@ + + + + $(SolutionDir.Replace('\', '/')) + $(SolutionDirForwardSlashes)../../../Assets/StreamingAssets/ + $(SolutionDirForwardSlashes)../../../Assets/Plugins/Windows/$(Platform)/ + + \ No newline at end of file diff --git a/lib/NativeCode/DynamicLibraryLoaderHelper/DynamicLibraryLoaderHelper.sln b/lib/NativeCode/DynamicLibraryLoaderHelper/DynamicLibraryLoaderHelper.sln index 9e145432e..73388a0cb 100644 --- a/lib/NativeCode/DynamicLibraryLoaderHelper/DynamicLibraryLoaderHelper.sln +++ b/lib/NativeCode/DynamicLibraryLoaderHelper/DynamicLibraryLoaderHelper.sln @@ -7,6 +7,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DynamicLibraryLoaderHelper" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GfxPluginNativeRender", "NativeRender\NativeRender.vcxproj", "{251D4477-4C90-4FE1-94A2-52377327D3B2}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EOSPluginConfig", "EOSPluginConfig\EOSPluginConfig.csproj", "{7C3CF875-0B42-493F-958B-9D068C8EF018}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ConsoleApplication", "ConsoleApplication\ConsoleApplication.vcxproj", "{D7462EAF-0024-4EA5-9D89-DBBBC7766333}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -31,6 +35,20 @@ Global {251D4477-4C90-4FE1-94A2-52377327D3B2}.Release|x64.Build.0 = Release|x64 {251D4477-4C90-4FE1-94A2-52377327D3B2}.Release|x86.ActiveCfg = Release|Win32 {251D4477-4C90-4FE1-94A2-52377327D3B2}.Release|x86.Build.0 = Release|Win32 + {7C3CF875-0B42-493F-958B-9D068C8EF018}.Debug|x64.ActiveCfg = Debug|x64 + {7C3CF875-0B42-493F-958B-9D068C8EF018}.Debug|x64.Build.0 = Debug|x64 + {7C3CF875-0B42-493F-958B-9D068C8EF018}.Debug|x86.ActiveCfg = Debug|Win32 + {7C3CF875-0B42-493F-958B-9D068C8EF018}.Debug|x86.Build.0 = Debug|Win32 + {7C3CF875-0B42-493F-958B-9D068C8EF018}.Release|x64.ActiveCfg = Release|x64 + {7C3CF875-0B42-493F-958B-9D068C8EF018}.Release|x64.Build.0 = Release|x64 + {7C3CF875-0B42-493F-958B-9D068C8EF018}.Release|x86.ActiveCfg = Release|Win32 + {7C3CF875-0B42-493F-958B-9D068C8EF018}.Release|x86.Build.0 = Release|Win32 + {D7462EAF-0024-4EA5-9D89-DBBBC7766333}.Debug|x64.ActiveCfg = Debug|x64 + {D7462EAF-0024-4EA5-9D89-DBBBC7766333}.Debug|x64.Build.0 = Debug|x64 + {D7462EAF-0024-4EA5-9D89-DBBBC7766333}.Debug|x86.ActiveCfg = Debug|Win32 + {D7462EAF-0024-4EA5-9D89-DBBBC7766333}.Debug|x86.Build.0 = Debug|Win32 + {D7462EAF-0024-4EA5-9D89-DBBBC7766333}.Release|x64.ActiveCfg = Release|x64 + {D7462EAF-0024-4EA5-9D89-DBBBC7766333}.Release|x86.ActiveCfg = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/lib/NativeCode/DynamicLibraryLoaderHelper/DynamicLibraryLoaderHelper/DynamicLibraryLoaderHelper.vcxproj b/lib/NativeCode/DynamicLibraryLoaderHelper/DynamicLibraryLoaderHelper/DynamicLibraryLoaderHelper.vcxproj index db1285804..8004becce 100644 --- a/lib/NativeCode/DynamicLibraryLoaderHelper/DynamicLibraryLoaderHelper/DynamicLibraryLoaderHelper.vcxproj +++ b/lib/NativeCode/DynamicLibraryLoaderHelper/DynamicLibraryLoaderHelper/DynamicLibraryLoaderHelper.vcxproj @@ -26,75 +26,42 @@ 10.0.17763.0 - + + StaticLibrary true v141 Unicode + true - + DynamicLibrary false v141 true Unicode + false - - StaticLibrary - true - v141 - Unicode - - - DynamicLibrary - false - v141 - true - Unicode + + + $(SolutionDir)Build\$(Configuration)\$(PlatformTarget)\ + $(SolutionDir)Build\Temp\$(ProjectName)\$(Configuration)\$(PlatformTarget)\ + $(ProjectName)-$(PlatformTarget) - - - - - - - - - - - - - - + + + + - - true - $(SolutionDir)..\..\..\Assets\Plugins\Windows\$(PlatformTarget)\ - - - true - $(SolutionDir)..\..\..\Assets\Plugins\Windows\$(PlatformTarget)\ - - - false - $(SolutionDir)..\..\..\Assets\Plugins\Windows\$(PlatformTarget)\ - $(ProjectName)-x86 - - - false - $(SolutionDir)..\..\..\Assets\Plugins\Windows\$(PlatformTarget)\ - $(ProjectName)-x64 - - + + Use Level3 - Disabled true - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) true pch.h $(SolutionDir)..\third_party\eos_sdk\include\;$(SolutionDir)..\include;$(SolutionDir)..\include\windows;$(ProjectDir);%(AdditionalIncludeDirectories) @@ -105,72 +72,31 @@ true - + + - Use - Level3 Disabled - true _DEBUG;_LIB;%(PreprocessorDefinitions) - true - pch.h - $(SolutionDir)..\third_party\eos_sdk\include\;$(SolutionDir)..\include;$(SolutionDir)..\include\windows;$(ProjectDir);%(AdditionalIncludeDirectories) - stdcpp17 - - Windows - true - - - - - Use - Level3 - MaxSpeed - true - true - true - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - true - pch.h - $(SolutionDir)..\third_party\eos_sdk\include\;$(SolutionDir)..\include;$(SolutionDir)..\include\windows;$(ProjectDir);%(AdditionalIncludeDirectories) - MultiThreaded - stdcpp17 - - - Windows - true - true - true - - - copy $(SolutionDir)$(ProjectName)-x86.dll.meta $(SolutionDir)..\..\..\Assets\Plugins\Windows\$(PlatformTarget)\ - - + - Use - Level3 MaxSpeed true true - true NDEBUG;_LIB;%(PreprocessorDefinitions) - true - pch.h - $(SolutionDir)..\third_party\eos_sdk\include\;$(SolutionDir)..\include;$(SolutionDir)..\include\windows;$(ProjectDir);%(AdditionalIncludeDirectories) - stdcpp17 + MultiThreaded - Windows true true - true - copy $(SolutionDir)$(ProjectName)-x64.dll.meta $(SolutionDir)..\..\..\Assets\Plugins\Windows\$(PlatformTarget)\ + copy $(SolutionDir)$(ProjectName)-$(Platform).dll.meta $(OutputUnityAssetsDirectory) + xcopy "$(TargetDir)*" "$(OutputUnityAssetsDirectory)" /E /I /Y + @@ -182,15 +108,11 @@ - Create - Create - Create - Create + Create - - + \ No newline at end of file diff --git a/lib/NativeCode/DynamicLibraryLoaderHelper/DynamicLibraryLoaderHelper/DynamicLibraryLoaderHelper.vcxproj.filters b/lib/NativeCode/DynamicLibraryLoaderHelper/DynamicLibraryLoaderHelper/DynamicLibraryLoaderHelper.vcxproj.filters index 934524dfe..8a309942b 100644 --- a/lib/NativeCode/DynamicLibraryLoaderHelper/DynamicLibraryLoaderHelper/DynamicLibraryLoaderHelper.vcxproj.filters +++ b/lib/NativeCode/DynamicLibraryLoaderHelper/DynamicLibraryLoaderHelper/DynamicLibraryLoaderHelper.vcxproj.filters @@ -32,9 +32,6 @@ - - Source Files - Source Files @@ -47,5 +44,8 @@ Source Files + + Source Files + \ No newline at end of file diff --git a/lib/NativeCode/DynamicLibraryLoaderHelper/EOSPluginConfig/.gitignore b/lib/NativeCode/DynamicLibraryLoaderHelper/EOSPluginConfig/.gitignore new file mode 100644 index 000000000..3e6758810 --- /dev/null +++ b/lib/NativeCode/DynamicLibraryLoaderHelper/EOSPluginConfig/.gitignore @@ -0,0 +1,9 @@ +Debug/* +Release/* +x64/* +x32/* +bin/ +obj/ +config.json +Newtonsoft.Json.dll +Newtonsoft.Json.xml \ No newline at end of file diff --git a/lib/NativeCode/DynamicLibraryLoaderHelper/EOSPluginConfig/EOSPluginConfig.csproj b/lib/NativeCode/DynamicLibraryLoaderHelper/EOSPluginConfig/EOSPluginConfig.csproj new file mode 100644 index 000000000..b9fb6d9c6 --- /dev/null +++ b/lib/NativeCode/DynamicLibraryLoaderHelper/EOSPluginConfig/EOSPluginConfig.csproj @@ -0,0 +1,241 @@ + + + + + Debug + AnyCPU + {7C3CF875-0B42-493F-958B-9D068C8EF018} + Library + Properties + EOSPluginConfig + EOSPluginConfig + v4.8 + 512 + true + + + EOSPluginConfig-x64 + + + EOSPluginConfig-x86 + + + true + $(SolutionDir)Build\$(Configuration)\$(Platform)\ + $(SolutionDir)Build\$(Configuration)\$(Platform)\ + TRACE;DEBUG;EXTERNAL_TO_UNITY;PLATFORM_64; + full + x64 + 9.0 + prompt + + + $(SolutionDir)Build\$(Configuration)\$(Platform)\ + $(SolutionDir)Build\$(Configuration)\$(Platform)\ + TRACE;EXTERNAL_TO_UNITY;PLATFORM_64; + true + pdbonly + x64 + 9.0 + prompt + + + true + $(SolutionDir)Build\$(Configuration)\x86\ + $(SolutionDir)Build\$(Configuration)\x86\ + TRACE;DEBUG;EXTERNAL_TO_UNITY;PLATFORM_32; + full + x86 + 9.0 + prompt + + + $(SolutionDir)Build\$(Configuration)\x86\ + $(SolutionDir)Build\$(Configuration)\x86\ + TRACE;EXTERNAL_TO_UNITY;PLATFORM_32; + true + pdbonly + x86 + 9.0 + prompt + + + + ..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll + + + + + + + + + + + + + Assets\Plugins\Windows\Core\WindowsConfig.cs + + + com.playeveryware.eos\Runtime\Core\Common\Extensions\FileInfoExtensions.cs + + + com.playeveryware.eos\Runtime\Core\Common\Extensions\ListExtensions.cs + + + com.playeveryware.eos\Runtime\Core\Common\Extensions\StringExtensions.cs + + + com.playeveryware.eos\Runtime\Core\Common\Named.cs + + + com.playeveryware.eos\Runtime\Core\Common\SetOfNamed.cs + + + com.playeveryware.eos\Runtime\Core\Config\Attributes\ButtonFieldAttribute.cs + + + com.playeveryware.eos\Runtime\Core\Config\Attributes\ConfigFieldAttribute.cs + + + com.playeveryware.eos\Runtime\Core\Config\Attributes\ConfigFieldType.cs + + + com.playeveryware.eos\Runtime\Core\Config\Attributes\ConfigGroupAttribute.cs + + + com.playeveryware.eos\Runtime\Core\Config\Attributes\DirectoryPathFieldAttribute.cs + + + com.playeveryware.eos\Runtime\Core\Config\Attributes\ExpandFieldAttribute.cs + + + com.playeveryware.eos\Runtime\Core\Config\Attributes\FieldValidator.cs + + + com.playeveryware.eos\Runtime\Core\Config\Attributes\FieldValidatorAttribute.cs + + + com.playeveryware.eos\Runtime\Core\Config\Attributes\FilePathFieldAttribute.cs + + + com.playeveryware.eos\Runtime\Core\Config\Attributes\GUIDFieldValidatorAttribute.cs + + + com.playeveryware.eos\Runtime\Core\Config\Attributes\NonEmptyStringFieldValidatorAttribute.cs + + + com.playeveryware.eos\Runtime\Core\Config\Attributes\PlatformDependentConfigFieldAttribute.cs + + + com.playeveryware.eos\Runtime\Core\Config\Attributes\SandboxIDFieldValidatorAttribute.cs + + + com.playeveryware.eos\Runtime\Core\Config\Config.cs + + + com.playeveryware.eos\Runtime\Core\Config\Deployment.cs + + + com.playeveryware.eos\Runtime\Core\Config\EOSConfig.cs + + + com.playeveryware.eos\Runtime\Core\Config\JsonConverter\ListOfStringsToEnumConverters.cs + + + com.playeveryware.eos\Runtime\Core\Config\JsonConverter\StringToTypeConverter.cs + + + com.playeveryware.eos\Runtime\Core\Config\LogLevelConfig.cs + + + com.playeveryware.eos\Runtime\Core\Config\PlatformConfig.cs + + + com.playeveryware.eos\Runtime\Core\Config\ProductConfig.cs + + + com.playeveryware.eos\Runtime\Core\Config\ProductionEnvironments.cs + + + com.playeveryware.eos\Runtime\Core\Config\RuntimeConfig.cs + + + com.playeveryware.eos\Runtime\Core\Config\SandboxId.cs + + + com.playeveryware.eos\Runtime\Core\EOS_SDK_Additions\EOSClientCredentials.cs + + + com.playeveryware.eos\Runtime\Core\EOS_SDK_Additions\EventHandlers.cs + + + com.playeveryware.eos\Runtime\Core\EOS_SDK_Additions\Extensions\AuthScopeFlagsExtensions.cs + + + com.playeveryware.eos\Runtime\Core\EOS_SDK_Additions\Extensions\IntegratedPlatformManagementFlagsExtensions.cs + + + com.playeveryware.eos\Runtime\Core\EOS_SDK_Additions\Extensions\PlatformFlagsExtensions.cs + + + com.playeveryware.eos\Runtime\Core\EOS_SDK_Additions\FileRequestTransferWrapper.cs + + + com.playeveryware.eos\Runtime\Core\EOS_SDK_Additions\IFileTransferRequest.cs + + + com.playeveryware.eos\Runtime\Core\EOS_SDK_Additions\PlayerDataStorageFileTransferRequestWrapper.cs + + + com.playeveryware.eos\Runtime\Core\EOS_SDK_Additions\TitleStorageFileTransferRequestWrapper.cs + + + com.playeveryware.eos\Runtime\Core\EOS_SDK_Additions\WrappedInitializeThreadAffinity.cs + + + com.playeveryware.eos\Runtime\Core\EOS_SDK_Additions\WrappedPlatformFlags.cs + + + com.playeveryware.eos\Runtime\Core\PlatformManager.cs + + + com.playeveryware.eos\Runtime\Core\Utility\EnumUtility.cs + + + com.playeveryware.eos\Runtime\Core\Utility\HashUtility.cs + + + com.playeveryware.eos\Runtime\Core\Utility\FileSystemUtility.cs + + + com.playeveryware.eos\Runtime\Core\Utility\JsonUtility.cs + + + com.playeveryware.eos\Runtime\Core\Utility\LogLevelUtility.cs + + + com.playeveryware.eos\Runtime\Core\Utility\SafeTranslatorUtility.cs + + + + + + com.playeveryware.eos\Runtime\EOS_SDK\%(RecursiveDir)%(Filename)%(Extension) + + + + PreserveNewest + + + + + + + + + + + + \ No newline at end of file diff --git a/lib/NativeCode/DynamicLibraryLoaderHelper/EOSPluginConfig/Properties/AssemblyInfo.cs b/lib/NativeCode/DynamicLibraryLoaderHelper/EOSPluginConfig/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..58d4553fc --- /dev/null +++ b/lib/NativeCode/DynamicLibraryLoaderHelper/EOSPluginConfig/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("EOSPluginConfig")] +[assembly: AssemblyDescription("Class Library to expose configuration functionality from within the EOS Plugin for Unity.")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("PlayEveryWare, Inc.")] +[assembly: AssemblyProduct("EOSPluginConfig")] +[assembly: AssemblyCopyright("Copyright © 2024")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("7c3cf875-0b42-493f-958b-9d068c8ef018")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/lib/NativeCode/DynamicLibraryLoaderHelper/EOSPluginConfig/ResourceUtility.cs b/lib/NativeCode/DynamicLibraryLoaderHelper/EOSPluginConfig/ResourceUtility.cs new file mode 100644 index 000000000..7a18e8a18 --- /dev/null +++ b/lib/NativeCode/DynamicLibraryLoaderHelper/EOSPluginConfig/ResourceUtility.cs @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2024 PlayEveryWare + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System.IO; +using System.Reflection; + +namespace PlayEveryWare.EpicOnlineServices +{ + using Newtonsoft.Json; + + /// + /// This class is used to read values from an embedded "config.json" file. + /// + public static class ResourceUtility + { + /// + /// Private readonly instance of the resource values. + /// + private static readonly EmbeddedResourceValues s_values; + + /// + /// Kept internal because there are a very limited set of circumstances + /// where these values need to be used. + /// + internal class EmbeddedResourceValues + { + public string StreamingAssetsPath { get; set; } + } + + /// + /// Static constructor so that the static values can be set properly. + /// + static ResourceUtility() + { + s_values = GetEmbeddedResourceValues(); + } + + /// + /// Reads an embedded resource file of the given name. + /// + /// + /// The name of the embedded file to read from. + /// + /// + /// The string contents of the indicated embedded resource file. + /// + /// + /// Thrown if the embedded file is not found. + /// + private static string ReadEmbeddedJsonFile(string resourceFileName) + { + var assembly = Assembly.GetExecutingAssembly(); + + // Automatically prepend the assembly name to the resource path + string fullResourceName = $"EOSPluginConfig.{resourceFileName}"; + + using Stream stream = assembly.GetManifestResourceStream(fullResourceName); + + // Deal with the circumstance where the file does not exist. + if (stream == null) + throw new FileNotFoundException($"Resource not found: {fullResourceName}"); + + using StreamReader reader = new(stream); + return reader.ReadToEnd(); + } + + /// + /// Gets the embedded resource values. + /// + /// + /// The embedded resources contained within config.json. + /// + private static EmbeddedResourceValues GetEmbeddedResourceValues() + { + string jsonContent = ReadEmbeddedJsonFile("config.json"); + return JsonConvert.DeserializeObject(jsonContent); + } + + /// + /// Gets the streaming assets path. + /// + /// + /// Fully-qualified path to the streaming assets path. + /// + public static string GetStreamingAssetsPath() + { + return s_values.StreamingAssetsPath; + } + } +} diff --git a/lib/NativeCode/DynamicLibraryLoaderHelper/EOSPluginConfig/com.playeveryware.eos/Runtime/Core/Application.cs b/lib/NativeCode/DynamicLibraryLoaderHelper/EOSPluginConfig/com.playeveryware.eos/Runtime/Core/Application.cs new file mode 100644 index 000000000..220c7e631 --- /dev/null +++ b/lib/NativeCode/DynamicLibraryLoaderHelper/EOSPluginConfig/com.playeveryware.eos/Runtime/Core/Application.cs @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 PlayEveryWare + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +namespace PlayEveryWare.EpicOnlineServices +{ + public static class Application + { + public static readonly string streamingAssetsPath = ResourceUtility.GetStreamingAssetsPath(); + } +} diff --git a/lib/NativeCode/DynamicLibraryLoaderHelper/EOSPluginConfig/com.playeveryware.eos/Runtime/Core/Debug.cs b/lib/NativeCode/DynamicLibraryLoaderHelper/EOSPluginConfig/com.playeveryware.eos/Runtime/Core/Debug.cs new file mode 100644 index 000000000..9cb298bb1 --- /dev/null +++ b/lib/NativeCode/DynamicLibraryLoaderHelper/EOSPluginConfig/com.playeveryware.eos/Runtime/Core/Debug.cs @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 PlayEveryWare + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +namespace PlayEveryWare.EpicOnlineServices +{ + using System; + + internal class Debug + { + public static void LogError(string message) + { + Log($"ERROR: {message}"); + } + public static void LogWarning(string message) + { + Log($"WARNING: {message}"); + } + + public static void Log(string message) + { + Console.WriteLine(message); + } + + public static void LogException(Exception e) + { + Console.WriteLine($"An exception was logged. Exception message: \"{e.Message}\"."); + } + } +} \ No newline at end of file diff --git a/lib/NativeCode/DynamicLibraryLoaderHelper/EOSPluginConfig/packages.config b/lib/NativeCode/DynamicLibraryLoaderHelper/EOSPluginConfig/packages.config new file mode 100644 index 000000000..0b14af3ad --- /dev/null +++ b/lib/NativeCode/DynamicLibraryLoaderHelper/EOSPluginConfig/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/ConfigPaths.props b/lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/ConfigPaths.props new file mode 100644 index 000000000..6f05e443a --- /dev/null +++ b/lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/ConfigPaths.props @@ -0,0 +1,22 @@ + + + + $([System.String]::Copy('$(MSBuildThisFileDirectory)').Replace('\', '/'))../../../../Assets/StreamingAssets/EOS/ + + + + $([System.String]::Copy('$(MSBuildThisFileDirectory)').Replace('\', '/'))../../StreamingAssets/EOS/ + + + + EOSSDK-Win64-Shipping.dll + EOSOVH-Win64-Shipping.dll + steam_api64.dll + + + + EOSSDK-Win32-Shipping.dll + EOSOVH-Win32-Shipping.dll + steam_api.dll + + diff --git a/lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/NativeRender.vcxproj b/lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/NativeRender.vcxproj index 84c149057..4faef71bb 100644 --- a/lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/NativeRender.vcxproj +++ b/lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/NativeRender.vcxproj @@ -27,77 +27,42 @@ GfxPluginNativeRender - + + DynamicLibrary true v141 Unicode + true - + DynamicLibrary false v141 - true - Unicode - - - DynamicLibrary - true - v141 Unicode - - - DynamicLibrary - false - v141 true - Unicode + false + + + + $(SolutionDir)Build\$(Configuration)\$(PlatformTarget)\ + $(ProjectName)-$(PlatformTarget) + $(SolutionDir)Build\Temp\$(ProjectName)\$(Configuration)\$(PlatformTarget)\ - - - - - - - - - - - - - - + + + + - - true - $(SolutionDir)..\..\..\Assets\Plugins\Windows\$(PlatformTarget)\ - $(ProjectName)-x64 - - - true - $(SolutionDir)..\..\..\Assets\Plugins\Windows\$(PlatformTarget)\ - $(ProjectName)-x86 - - - false - $(SolutionDir)..\..\..\Assets\Plugins\Windows\$(PlatformTarget)\ - $(ProjectName)-x86 - - - false - $(SolutionDir)..\..\..\Assets\Plugins\Windows\$(PlatformTarget)\ - $(ProjectName)-x64 - - + + Use Level3 - Disabled true - _DEBUG;NATIVERENDER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true pch.h stdcpp17 @@ -107,78 +72,33 @@ Windows true false - %(AdditionalDependencies) - + + - Use - Level3 Disabled - true - WIN32;_DEBUG;NATIVERENDER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - pch.h - stdcpp17 - $(SolutionDir)..\third_party\eos_sdk\include\;$(SolutionDir)..\include\windows;$(ProjectDir);%(AdditionalIncludeDirectories) + OVERLAY_DLL_NAME="$(OverlayDllName)";STEAM_API_DLL="$(SteamApiDll)";SDK_DLL_NAME="$(SdkDllName)";CONFIG_DIRECTORY="$(ConfigDirectory)";_DEBUG;NATIVERENDER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - - Windows - true - false - - + - Use - Level3 MaxSpeed true true - true - WIN32;NDEBUG;NATIVERENDER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - pch.h - stdcpp17 - $(SolutionDir)..\third_party\eos_sdk\include\;$(SolutionDir)..\include\windows;$(ProjectDir);%(AdditionalIncludeDirectories) + OVERLAY_DLL_NAME="$(OverlayDllName)";STEAM_API_DLL="$(SteamApiDll)";SDK_DLL_NAME="$(SdkDllName)";CONFIG_DIRECTORY="$(ConfigDirectory)";NDEBUG;NATIVERENDER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) MultiThreaded - Windows - true - true - true - false - - - copy $(SolutionDir)$(ProjectName)-x86.dll.meta $(SolutionDir)..\..\..\Assets\Plugins\Windows\$(PlatformTarget)\ - - - - - Use - Level3 - MaxSpeed - true - true - true - NDEBUG;NATIVERENDER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - pch.h - stdcpp17 - $(SolutionDir)..\third_party\eos_sdk\include\;$(SolutionDir)..\include\windows;$(ProjectDir);%(AdditionalIncludeDirectories) - - - Windows true true - true - false - copy $(SolutionDir)$(ProjectName)-x64.dll.meta $(SolutionDir)..\..\..\Assets\Plugins\Windows\$(PlatformTarget)\ + copy $(SolutionDir)$(ProjectName)-$(Platform).dll.meta $(OutputUnityAssetsDirectory) + xcopy "$(TargetDir)*" "$(OutputUnityAssetsDirectory)" /E /I /Y + @@ -200,14 +120,11 @@ - Create - Create - Create - Create + Create - - + + \ No newline at end of file diff --git a/lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/config.cpp b/lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/config.cpp index 25f3067ad..42a513ba6 100644 --- a/lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/config.cpp +++ b/lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/config.cpp @@ -27,6 +27,147 @@ #include "json_helpers.h" #include "logging.h" +using namespace pew::eos::config; +using namespace pew::eos::json_helpers; + + /** + * @brief Reads an EOS configuration file as a JSON value. + * + * Retrieves the specified configuration file, loads its contents, and parses it into a JSON structure. + * + * @param config_filename The name of the configuration file. + * @return A pointer to a `json_value_s` representing the configuration data, or `nullptr` if parsing fails. + */ +json_value_s* read_eos_config_as_json_value_from_file(std::string config_filename); + +EOSConfig eos_config_from_json_value(json_value_s* config_json) +{ + // Create platform instance + json_object_s* config_json_object = json_value_as_object(config_json); + json_object_element_s* iter = config_json_object->start; + EOSConfig eos_config; + + while (iter != nullptr) + { + if (!strcmp("productName", iter->name->string)) + { + eos_config.productName = json_value_as_string(iter->value)->string; + } + else if (!strcmp("productVersion", iter->name->string)) + { + eos_config.productVersion = json_value_as_string(iter->value)->string; + } + else if (!strcmp("productID", iter->name->string)) + { + eos_config.productID = json_value_as_string(iter->value)->string; + } + else if (!strcmp("sandboxID", iter->name->string)) + { + eos_config.sandboxID = json_value_as_string(iter->value)->string; + } + else if (!strcmp("deploymentID", iter->name->string)) + { + eos_config.deploymentID = json_value_as_string(iter->value)->string; + } + else if (!strcmp("sandboxDeploymentOverrides", iter->name->string)) + { + json_array_s* overrides = json_value_as_array(iter->value); + eos_config.sandboxDeploymentOverrides = std::vector(); + for (auto e = overrides->start; e != nullptr; e = e->next) + { + json_object_s* override_json_object = json_value_as_object(e->value); + json_object_element_s* ov_iter = override_json_object->start; + SandboxDeploymentOverride override_item = SandboxDeploymentOverride(); + while (ov_iter != nullptr) + { + if (!strcmp("sandboxID", ov_iter->name->string)) + { + override_item.sandboxID = json_value_as_string(ov_iter->value)->string; + } + else if (!strcmp("deploymentID", ov_iter->name->string)) + { + override_item.deploymentID = json_value_as_string(ov_iter->value)->string; + } + ov_iter = ov_iter->next; + } + eos_config.sandboxDeploymentOverrides.push_back(override_item); + } + } + else if (!strcmp("clientID", iter->name->string)) + { + eos_config.clientID = json_value_as_string(iter->value)->string; + } + else if (!strcmp("clientSecret", iter->name->string)) + { + eos_config.clientSecret = json_value_as_string(iter->value)->string; + } + if (!strcmp("encryptionKey", iter->name->string)) + { + eos_config.encryptionKey = json_value_as_string(iter->value)->string; + } + else if (!strcmp("overrideCountryCode ", iter->name->string)) + { + eos_config.overrideCountryCode = json_value_as_string(iter->value)->string; + } + else if (!strcmp("overrideLocaleCode", iter->name->string)) + { + eos_config.overrideLocaleCode = json_value_as_string(iter->value)->string; + } + else if (!strcmp("platformOptionsFlags", iter->name->string)) + { + eos_config.flags = static_cast(collect_flags(&PLATFORM_CREATION_FLAGS_STRINGS_TO_ENUM, 0, iter)); + } + else if (!strcmp("tickBudgetInMilliseconds", iter->name->string)) + { + eos_config.tickBudgetInMilliseconds = json_value_as_uint32(iter->value); + } + else if (!strcmp("taskNetworkTimeoutSeconds", iter->name->string)) + { + eos_config.taskNetworkTimeoutSeconds = json_value_as_double(iter->value); + } + else if (!strcmp("ThreadAffinity_networkWork", iter->name->string)) + { + eos_config.ThreadAffinity_networkWork = json_value_as_uint64(iter->value); + } + else if (!strcmp("ThreadAffinity_storageIO", iter->name->string)) + { + eos_config.ThreadAffinity_storageIO = json_value_as_uint64(iter->value); + } + else if (!strcmp("ThreadAffinity_webSocketIO", iter->name->string)) + { + eos_config.ThreadAffinity_webSocketIO = json_value_as_uint64(iter->value); + } + else if (!strcmp("ThreadAffinity_P2PIO", iter->name->string)) + { + eos_config.ThreadAffinity_P2PIO = json_value_as_uint64(iter->value); + } + else if (!strcmp("ThreadAffinity_HTTPRequestIO", iter->name->string)) + { + eos_config.ThreadAffinity_HTTPRequestIO = json_value_as_uint64(iter->value); + } + else if (!strcmp("ThreadAffinity_RTCIO", iter->name->string)) + { + eos_config.ThreadAffinity_RTCIO = json_value_as_uint64(iter->value); + } + else if (!strcmp("isServer", iter->name->string)) + { + // In this JSON library, true and false are _technically_ different types. + if (json_value_is_true(iter->value)) + { + eos_config.isServer = true; + } + else if (json_value_is_false(iter->value)) + { + eos_config.isServer = false; + } + } + + iter = iter->next; + } + + return eos_config; +} + namespace pew::eos::config { /** @@ -34,6 +175,29 @@ namespace pew::eos::config */ static GetConfigAsJSONString_t GetConfigAsJSONString; + CONFIG_API bool try_get_eos_config(EOSConfig& config) + { + auto path_to_config_json = get_path_for_eos_service_config(EOS_SERVICE_CONFIG_FILENAME); + json_value_s* eos_config_as_json = nullptr; + + eos_config_as_json = read_config_json_from_dll(); + + if (!eos_config_as_json && exists(path_to_config_json)) + { + eos_config_as_json = read_config_json_as_json_from_path(path_to_config_json); + } + + if (!eos_config_as_json) + { + logging::log_warn("Failed to load a valid json config for EOS"); + return false; + } + + config = eos_config_from_json_value(eos_config_as_json); + return true; + } + + bool EOSSteamConfig::is_managed_by_application() const { return static_cast>(flags & @@ -83,18 +247,7 @@ namespace pew::eos::config std::filesystem::path get_path_for_eos_service_config(std::string config_filename) { - auto twoDirsUp = std::filesystem::path("../.."); - std::filesystem::path packaged_data_path = io_helpers::get_path_relative_to_current_module(twoDirsUp); - std::error_code error_code; - - logging::log_inform("about to look with exists"); - if (!std::filesystem::exists(packaged_data_path, error_code)) - { - logging::log_warn("Didn't find the path twoDirsUp"); - packaged_data_path = io_helpers::get_path_relative_to_current_module(std::filesystem::path("./Data/")); - } - - return packaged_data_path / "StreamingAssets" / "EOS" / config_filename; + return std::filesystem::path(CONFIG_DIRECTORY) / config_filename; } json_value_s* read_config_json_from_dll() @@ -131,135 +284,6 @@ namespace pew::eos::config return config_json; } - //------------------------------------------------------------------------- - EOSConfig eos_config_from_json_value(json_value_s* config_json) - { - // Create platform instance - json_object_s* config_json_object = json_value_as_object(config_json); - json_object_element_s* iter = config_json_object->start; - EOSConfig eos_config; - - while (iter != nullptr) - { - if (!strcmp("productName", iter->name->string)) - { - eos_config.productName = json_value_as_string(iter->value)->string; - } - else if (!strcmp("productVersion", iter->name->string)) - { - eos_config.productVersion = json_value_as_string(iter->value)->string; - } - else if (!strcmp("productID", iter->name->string)) - { - eos_config.productID = json_value_as_string(iter->value)->string; - } - else if (!strcmp("sandboxID", iter->name->string)) - { - eos_config.sandboxID = json_value_as_string(iter->value)->string; - } - else if (!strcmp("deploymentID", iter->name->string)) - { - eos_config.deploymentID = json_value_as_string(iter->value)->string; - } - else if (!strcmp("sandboxDeploymentOverrides", iter->name->string)) - { - json_array_s* overrides = json_value_as_array(iter->value); - eos_config.sandboxDeploymentOverrides = std::vector(); - for (auto e = overrides->start; e != nullptr; e = e->next) - { - json_object_s* override_json_object = json_value_as_object(e->value); - json_object_element_s* ov_iter = override_json_object->start; - SandboxDeploymentOverride override_item = SandboxDeploymentOverride(); - while (ov_iter != nullptr) - { - if (!strcmp("sandboxID", ov_iter->name->string)) - { - override_item.sandboxID = json_value_as_string(ov_iter->value)->string; - } - else if (!strcmp("deploymentID", ov_iter->name->string)) - { - override_item.deploymentID = json_value_as_string(ov_iter->value)->string; - } - ov_iter = ov_iter->next; - } - eos_config.sandboxDeploymentOverrides.push_back(override_item); - } - } - else if (!strcmp("clientID", iter->name->string)) - { - eos_config.clientID = json_value_as_string(iter->value)->string; - } - else if (!strcmp("clientSecret", iter->name->string)) - { - eos_config.clientSecret = json_value_as_string(iter->value)->string; - } - if (!strcmp("encryptionKey", iter->name->string)) - { - eos_config.encryptionKey = json_value_as_string(iter->value)->string; - } - else if (!strcmp("overrideCountryCode ", iter->name->string)) - { - eos_config.overrideCountryCode = json_value_as_string(iter->value)->string; - } - else if (!strcmp("overrideLocaleCode", iter->name->string)) - { - eos_config.overrideLocaleCode = json_value_as_string(iter->value)->string; - } - else if (!strcmp("platformOptionsFlags", iter->name->string)) - { - eos_config.flags = static_cast(json_helpers::collect_flags(&PLATFORM_CREATION_FLAGS_STRINGS_TO_ENUM, 0, iter)); - } - else if (!strcmp("tickBudgetInMilliseconds", iter->name->string)) - { - eos_config.tickBudgetInMilliseconds = json_helpers::json_value_as_uint32(iter->value); - } - else if (!strcmp("taskNetworkTimeoutSeconds", iter->name->string)) - { - eos_config.taskNetworkTimeoutSeconds = json_helpers::json_value_as_double(iter->value); - } - else if (!strcmp("ThreadAffinity_networkWork", iter->name->string)) - { - eos_config.ThreadAffinity_networkWork = json_helpers::json_value_as_uint64(iter->value); - } - else if (!strcmp("ThreadAffinity_storageIO", iter->name->string)) - { - eos_config.ThreadAffinity_storageIO = json_helpers::json_value_as_uint64(iter->value); - } - else if (!strcmp("ThreadAffinity_webSocketIO", iter->name->string)) - { - eos_config.ThreadAffinity_webSocketIO = json_helpers::json_value_as_uint64(iter->value); - } - else if (!strcmp("ThreadAffinity_P2PIO", iter->name->string)) - { - eos_config.ThreadAffinity_P2PIO = json_helpers::json_value_as_uint64(iter->value); - } - else if (!strcmp("ThreadAffinity_HTTPRequestIO", iter->name->string)) - { - eos_config.ThreadAffinity_HTTPRequestIO = json_helpers::json_value_as_uint64(iter->value); - } - else if (!strcmp("ThreadAffinity_RTCIO", iter->name->string)) - { - eos_config.ThreadAffinity_RTCIO = json_helpers::json_value_as_uint64(iter->value); - } - else if (!strcmp("isServer", iter->name->string)) - { - // In this JSON library, true and false are _technically_ different types. - if (json_value_is_true(iter->value)) - { - eos_config.isServer = true; - } - else if (json_value_is_false(iter->value)) - { - eos_config.isServer = false; - } - } - - iter = iter->next; - } - - return eos_config; - } - EOS_EIntegratedPlatformManagementFlags eos_collect_integrated_platform_management_flags(json_object_element_s* iter) { return json_helpers::collect_flags( @@ -295,11 +319,11 @@ namespace pew::eos::config } else if (!strcmp("steamSDKMajorVersion", iter->name->string)) { - eos_config.steamSDKMajorVersion = json_helpers::json_value_as_uint32(iter->value); + eos_config.steamSDKMajorVersion = json_value_as_uint32(iter->value); } else if (!strcmp("steamSDKMinorVersion", iter->name->string)) { - eos_config.steamSDKMinorVersion = json_helpers::json_value_as_uint32(iter->value); + eos_config.steamSDKMinorVersion = json_value_as_uint32(iter->value); } else if (!strcmp("steamApiInterfaceVersionsArray", iter->name->string)) { @@ -321,6 +345,6 @@ namespace pew::eos::config { std::filesystem::path path_to_config_json = get_path_for_eos_service_config(config_filename); - return json_helpers::read_config_json_as_json_from_path(path_to_config_json); + return read_config_json_as_json_from_path(path_to_config_json); } } diff --git a/lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/config.h b/lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/config.h index 4033ca97c..2defbb8b5 100644 --- a/lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/config.h +++ b/lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/config.h @@ -31,9 +31,18 @@ #include #include "json.h" +#include "eos_sdk.h" struct json_value_s; +#define CONFIG_EXPORTS + +#ifdef CONFIG_EXPORTS +#define CONFIG_API __declspec(dllexport) +#else +#define CONFIG_API __declspec(dllimport) +#endif + namespace pew::eos::config { /** @@ -243,15 +252,10 @@ namespace pew::eos::config json_value_s* read_config_json_from_dll(); /** - * @brief Parses an EOS configuration object from a JSON structure. - * - * Reads EOS-related configuration details such as product name, version, IDs, client credentials, - * and thread affinities from the given JSON structure, populating an `EOSConfig` object. - * - * @param config_json The JSON value representing the configuration. - * @return An `EOSConfig` object populated with settings from the JSON structure. + * \brief Parses an EOS configuration object from a JSON structure. + * \return An `EOSConfig` object populated with settings from the JSON structure. */ - EOSConfig eos_config_from_json_value(json_value_s* config_json); + CONFIG_API bool try_get_eos_config(EOSConfig& config); /** * @brief Collects integrated platform management flags from a JSON element. @@ -273,16 +277,5 @@ namespace pew::eos::config * @return An `EOSSteamConfig` object populated with settings from the JSON structure. */ EOSSteamConfig eos_steam_config_from_json_value(json_value_s* config_json); - - /** - * @brief Reads an EOS configuration file as a JSON value. - * - * Retrieves the specified configuration file, loads its contents, and parses it into a JSON structure. - * - * @param config_filename The name of the configuration file. - * @return A pointer to a `json_value_s` representing the configuration data, or `nullptr` if parsing fails. - */ - json_value_s* read_eos_config_as_json_value_from_file(std::string config_filename); - } #endif diff --git a/lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/dllmain.cpp b/lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/dllmain.cpp index 0bfd7a0bf..d41533285 100644 --- a/lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/dllmain.cpp +++ b/lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/dllmain.cpp @@ -25,16 +25,19 @@ // This is apparently needed so that the Overlay can render properly #include "pch.h" +#include #include #include #include "config.h" -#include "json_helpers.h" #include "logging.h" #include #include #include "io_helpers.h" +using namespace pew::eos; +using namespace pew::eos::eos_library_helpers; + using FSig_ApplicationWillShutdown = void (__stdcall *)(void); FSig_ApplicationWillShutdown FuncApplicationWillShutdown = nullptr; @@ -44,161 +47,126 @@ extern "C" void __declspec(dllexport) __stdcall UnityPluginUnload(); } -// Called by unity on load. It kicks off the work to load the DLL for Overlay -#if PLATFORM_32BITS -#pragma comment(linker, "/export:UnityPluginLoad=_UnityPluginLoad@4") -#endif -DLL_EXPORT(void) UnityPluginLoad(void*) +void get_cli_arguments(config::EOSConfig eos_config) { -#if _DEBUG - pew::eos::logging::show_log_as_dialog("You may attach a debugger to the DLL"); -#endif - - auto path_to_config_json = pew::eos::config::get_path_for_eos_service_config(EOS_SERVICE_CONFIG_FILENAME); - json_value_s* eos_config_as_json = nullptr; - - eos_config_as_json = pew::eos::config::read_config_json_from_dll(); - - if (!eos_config_as_json && std::filesystem::exists(path_to_config_json)) - { - eos_config_as_json = pew::eos::json_helpers::read_config_json_as_json_from_path(path_to_config_json); - } - - if (!eos_config_as_json) - { - pew::eos::logging::log_warn("Failed to load a valid json config for EOS"); - return; - } - - pew::eos::config::EOSConfig eos_config = pew::eos::config::eos_config_from_json_value(eos_config_as_json); - free(eos_config_as_json); - -#if PLATFORM_WINDOWS //support sandbox and deployment id override via command line arguments - std::stringstream argStream = std::stringstream(GetCommandLineA()); - std::istream_iterator argsBegin(argStream); - std::istream_iterator argsEnd; - std::vector argStrings(argsBegin, argsEnd); + std::stringstream argument_stream = std::stringstream(GetCommandLineA()); + std::istream_iterator argument_stream_begin(argument_stream); + std::istream_iterator argument_stream_end; + std::vector argument_strings(argument_stream_begin, argument_stream_end); std::string egsArgName = "-epicsandboxid="; std::string sandboxArgName = "-eossandboxid="; - for (unsigned i = 0; i < argStrings.size(); ++i) + for (unsigned i = 0; i < argument_strings.size(); ++i) { std::string* match = nullptr; - if (argStrings[i]._Starts_with(sandboxArgName)) + if (argument_strings[i]._Starts_with(sandboxArgName)) { match = &sandboxArgName; } - else if(argStrings[i]._Starts_with(egsArgName)) + else if (argument_strings[i]._Starts_with(egsArgName)) { match = &egsArgName; } if (match != nullptr) { - std::string sandboxArg = argStrings[i].substr(match->length()); + std::string sandboxArg = argument_strings[i].substr(match->length()); if (!sandboxArg.empty()) { - pew::eos::logging::log_inform(("Sandbox ID override specified: " + sandboxArg).c_str()); + logging::log_inform(("Sandbox ID override specified: " + sandboxArg).c_str()); eos_config.sandboxID = sandboxArg; } } } -#endif //check if a deployment id override exists for sandbox id for (unsigned i = 0; i < eos_config.sandboxDeploymentOverrides.size(); ++i) { if (eos_config.sandboxID == eos_config.sandboxDeploymentOverrides[i].sandboxID) { - pew::eos::logging::log_inform(("Sandbox Deployment ID override specified: " + eos_config.sandboxDeploymentOverrides[i].deploymentID).c_str()); + logging::log_inform(("Sandbox Deployment ID override specified: " + eos_config.sandboxDeploymentOverrides[i].deploymentID).c_str()); eos_config.deploymentID = eos_config.sandboxDeploymentOverrides[i].deploymentID; } } -#if PLATFORM_WINDOWS std::string deploymentArgName = "-eosdeploymentid="; std::string egsDeploymentArgName = "-epicdeploymentid="; - for (unsigned i = 0; i < argStrings.size(); ++i) + for (unsigned i = 0; i < argument_strings.size(); ++i) { std::string* match = nullptr; - if (argStrings[i]._Starts_with(deploymentArgName)) + if (argument_strings[i]._Starts_with(deploymentArgName)) { match = &deploymentArgName; } - else if (argStrings[i]._Starts_with(egsDeploymentArgName)) + else if (argument_strings[i]._Starts_with(egsDeploymentArgName)) { match = &egsDeploymentArgName; } if (match != nullptr) { - std::string deploymentArg = argStrings[i].substr(match->length()); + std::string deploymentArg = argument_strings[i].substr(match->length()); if (!deploymentArg.empty()) { - pew::eos::logging::log_inform(("Deployment ID override specified: " + deploymentArg).c_str()); + logging::log_inform(("Deployment ID override specified: " + deploymentArg).c_str()); eos_config.deploymentID = deploymentArg; } } } +} + +// Called by unity on load. It kicks off the work to load the DLL for Overlay +#if PLATFORM_32BITS +#pragma comment(linker, "/export:UnityPluginLoad=_UnityPluginLoad@4") #endif +DLL_EXPORT(void) UnityPluginLoad(void*) +{ +#if _DEBUG + logging::show_log_as_dialog("You may attach a debugger to the DLL"); +#endif + + config::EOSConfig eos_config; + if (!config::try_get_eos_config(eos_config)) + { + return; + } + + get_cli_arguments(eos_config); #if _DEBUG - pew::eos::logging::global_log_open("gfx_log.txt"); + logging::global_log_open("gfx_log.txt"); #endif std::filesystem::path DllPath; - pew::eos::logging::log_inform("On UnityPluginLoad"); - //if (!get_overlay_dll_path(&DllPath)) - //{ - // show_log_as_dialog("Missing Overlay DLL!\n Overlay functionality will not work!"); - //} - - pew::eos::eos_library_helpers::s_eos_sdk_lib_handle = pew::eos::eos_library_helpers::load_library_at_path(pew::eos::io_helpers::get_path_relative_to_current_module(SDK_DLL_NAME)); - - //eos_sdk_overlay_lib_handle = load_library_at_path(DllPath); - //if (eos_sdk_overlay_lib_handle) - //{ - // log_warn("loaded eos overlay sdk"); - // FuncApplicationWillShutdown = load_function_with_name(eos_sdk_overlay_lib_handle, "EOS_Overlay_Initilize"); - // if(FuncApplicationWillShutdown == nullptr) - // { - // log_warn("Unable to find overlay function"); - // } - //} - - if (pew::eos::eos_library_helpers::s_eos_sdk_lib_handle) + logging::log_inform("On UnityPluginLoad"); + + s_eos_sdk_lib_handle = load_library_at_path(io_helpers::get_path_relative_to_current_module(SDK_DLL_NAME)); + + if (s_eos_sdk_lib_handle) { - pew::eos::eos_library_helpers::FetchEOSFunctionPointers(); + FetchEOSFunctionPointers(); - if (pew::eos::eos_library_helpers::EOS_Initialize_ptr) + if (EOS_Initialize_ptr) { - pew::eos::logging::log_inform("start eos init"); - - pew::eos::eos_init(eos_config); - - pew::eos::eos_set_loglevel_via_config(); - //log_warn("start eos create"); - pew::eos::eos_create(eos_config); - - // This code is commented out because the handle is now handed off to the C# code - //EOS_Platform_Release(eos_platform_handle); - //eos_platform_handle = NULL; - //log_warn("start eos shutdown"); - //EOS_Shutdown(); - //log_warn("unload eos sdk"); - //unload_library(s_eos_sdk_lib_handle); - - pew::eos::eos_library_helpers::s_eos_sdk_lib_handle = nullptr; - pew::eos::eos_library_helpers::EOS_Initialize_ptr = nullptr; - pew::eos::eos_library_helpers::EOS_Shutdown_ptr = nullptr; - pew::eos::eos_library_helpers::EOS_Platform_Create_ptr = nullptr; + logging::log_inform("start eos init"); + + eos_init(eos_config); + + eos_set_loglevel_via_config(); + + eos_create(eos_config); + + s_eos_sdk_lib_handle = nullptr; + EOS_Initialize_ptr = nullptr; + EOS_Shutdown_ptr = nullptr; + EOS_Platform_Create_ptr = nullptr; } else { - pew::eos::logging::log_warn("unable to find EOS_Initialize"); + logging::log_warn("unable to find EOS_Initialize"); } } else { - pew::eos::logging::log_warn("Couldn't find dll " SDK_DLL_NAME); + logging::log_warn("Couldn't find dll " SDK_DLL_NAME); } } @@ -212,8 +180,8 @@ DLL_EXPORT(void) UnityPluginUnload() { FuncApplicationWillShutdown(); } - pew::eos::eos_library_helpers::unload_library(pew::eos::eos_library_helpers::s_eos_sdk_overlay_lib_handle); - pew::eos::eos_library_helpers::s_eos_sdk_overlay_lib_handle = nullptr; + unload_library(s_eos_sdk_overlay_lib_handle); + s_eos_sdk_overlay_lib_handle = nullptr; - pew::eos::logging::global_log_close(); + logging::global_log_close(); } diff --git a/lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/eos_helpers.cpp b/lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/eos_helpers.cpp index 1e7d1f9ae..da05d3973 100644 --- a/lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/eos_helpers.cpp +++ b/lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/eos_helpers.cpp @@ -29,6 +29,40 @@ #include "io_helpers.h" #include "json_helpers.h" #include "logging.h" +#include + + /** + * @brief Retrieves the system cache directory. + * + * Retrieves the system's temporary directory and converts it to a UTF-8 encoded string. + * + * @return A pointer to a UTF-8 encoded string containing the system cache directory. + * This pointer is statically allocated, so it should not be freed by the caller. + */ +char* GetCacheDirectory(); + +/** + * @brief Loads and initializes the Steam API DLL using a string path. + * + * Attempts to load the Steam API DLL from the specified path. If the DLL is not already + * loaded, this function tries to load it and then calls `SteamAPI_Init`. + * + * @param steam_dll_path The string path to the Steam API DLL. + */ +void eos_call_steam_init(const std::string& steam_dll_path); + +/** + * @brief Loads the Steam API DLL from a specified path. + * + * Loads the Steam API DLL and initializes it if necessary. Attempts to load the DLL from + * the specified path, or defaults to `steam_api.dll` if no path is specified. + * + * This function assumes that if the caller has already loaded the steam + * DLL, that SteamAPI_Init doesn't need to be called + * + * @param steam_dll_path The path to the Steam API DLL. + */ +void eos_call_steam_init(const std::filesystem::path& steam_dll_path); namespace pew::eos { @@ -112,7 +146,7 @@ namespace pew::eos logging::log_inform(output.str().c_str()); } - void eos_init(const config::EOSConfig& eos_config) + void eos_init(const config::EOSConfig eos_config) { static int reserved[2] = { 1, 1 }; EOS_InitializeOptions SDKOptions = { 0 }; @@ -209,28 +243,28 @@ namespace pew::eos return s_tempPathBuffer; } - void eos_create(config::EOSConfig& eosConfig) + void eos_create(config::EOSConfig eos_config) { EOS_Platform_Options platform_options = { 0 }; platform_options.ApiVersion = EOS_PLATFORM_OPTIONS_API_LATEST; - platform_options.bIsServer = eosConfig.isServer; - platform_options.Flags = eosConfig.flags; + platform_options.bIsServer = eos_config.isServer; + platform_options.Flags = eos_config.flags; platform_options.CacheDirectory = GetCacheDirectory(); - platform_options.EncryptionKey = eosConfig.encryptionKey.length() > 0 ? eosConfig.encryptionKey.c_str() : nullptr; - platform_options.OverrideCountryCode = eosConfig.overrideCountryCode.length() > 0 ? eosConfig.overrideCountryCode.c_str() : nullptr; - platform_options.OverrideLocaleCode = eosConfig.overrideLocaleCode.length() > 0 ? eosConfig.overrideLocaleCode.c_str() : nullptr; - platform_options.ProductId = eosConfig.productID.c_str(); - platform_options.SandboxId = eosConfig.sandboxID.c_str(); - platform_options.DeploymentId = eosConfig.deploymentID.c_str(); - platform_options.ClientCredentials.ClientId = eosConfig.clientID.c_str(); - platform_options.ClientCredentials.ClientSecret = eosConfig.clientSecret.c_str(); + platform_options.EncryptionKey = eos_config.encryptionKey.length() > 0 ? eos_config.encryptionKey.c_str() : nullptr; + platform_options.OverrideCountryCode = eos_config.overrideCountryCode.length() > 0 ? eos_config.overrideCountryCode.c_str() : nullptr; + platform_options.OverrideLocaleCode = eos_config.overrideLocaleCode.length() > 0 ? eos_config.overrideLocaleCode.c_str() : nullptr; + platform_options.ProductId = eos_config.productID.c_str(); + platform_options.SandboxId = eos_config.sandboxID.c_str(); + platform_options.DeploymentId = eos_config.deploymentID.c_str(); + platform_options.ClientCredentials.ClientId = eos_config.clientID.c_str(); + platform_options.ClientCredentials.ClientSecret = eos_config.clientSecret.c_str(); - platform_options.TickBudgetInMilliseconds = eosConfig.tickBudgetInMilliseconds; + platform_options.TickBudgetInMilliseconds = eos_config.tickBudgetInMilliseconds; - if (eosConfig.taskNetworkTimeoutSeconds > 0) + if (eos_config.taskNetworkTimeoutSeconds > 0) { - platform_options.TaskNetworkTimeoutSeconds = &eosConfig.taskNetworkTimeoutSeconds; + platform_options.TaskNetworkTimeoutSeconds = &eos_config.taskNetworkTimeoutSeconds; } EOS_Platform_RTCOptions rtc_options = { 0 }; @@ -281,7 +315,7 @@ namespace pew::eos // type of binary the GfxPluginNativeRender if (!std::filesystem::exists(found_steam_path) || eos_steam_config.OverrideLibraryPath.value().empty()) { - found_steam_path = io_helpers::get_path_relative_to_current_module(STEAM_DLL_NAME); + found_steam_path = io_helpers::get_path_relative_to_current_module(STEAM_API_DLL); } if (std::filesystem::exists(found_steam_path)) @@ -292,7 +326,7 @@ namespace pew::eos } else { - auto found_steam_path = io_helpers::get_path_relative_to_current_module(STEAM_DLL_NAME); + auto found_steam_path = io_helpers::get_path_relative_to_current_module(STEAM_API_DLL); if (exists(found_steam_path)) { eos_steam_config.OverrideLibraryPath = converter.to_bytes(found_steam_path.wstring()); @@ -375,6 +409,4 @@ namespace pew::eos logging::log_error("failed to create the platform"); } } - - } diff --git a/lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/eos_helpers.h b/lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/eos_helpers.h index 606ea813e..162e945ce 100644 --- a/lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/eos_helpers.h +++ b/lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/eos_helpers.h @@ -23,7 +23,6 @@ */ #pragma once -#include namespace std { @@ -76,40 +75,7 @@ namespace pew::eos * * @param eos_config The EOS configuration settings. */ - void eos_init(const config::EOSConfig& eos_config); - - /** - * @brief Loads the Steam API DLL from a specified path. - * - * Loads the Steam API DLL and initializes it if necessary. Attempts to load the DLL from - * the specified path, or defaults to `steam_api.dll` if no path is specified. - * - * This function assumes that if the caller has already loaded the steam - * DLL, that SteamAPI_Init doesn't need to be called - * - * @param steam_dll_path The path to the Steam API DLL. - */ - void eos_call_steam_init(const std::filesystem::path& steam_dll_path); - - /** - * @brief Loads and initializes the Steam API DLL using a string path. - * - * Attempts to load the Steam API DLL from the specified path. If the DLL is not already - * loaded, this function tries to load it and then calls `SteamAPI_Init`. - * - * @param steam_dll_path The string path to the Steam API DLL. - */ - void eos_call_steam_init(const std::string& steam_dll_path); - - /** - * @brief Retrieves the system cache directory. - * - * Retrieves the system's temporary directory and converts it to a UTF-8 encoded string. - * - * @return A pointer to a UTF-8 encoded string containing the system cache directory. - * This pointer is statically allocated, so it should not be freed by the caller. - */ - char* GetCacheDirectory(); + void eos_init(const config::EOSConfig eos_config); /** * @brief Creates an EOS platform using the specified configuration. @@ -117,8 +83,8 @@ namespace pew::eos * Configures and creates an EOS platform instance. This includes setting up RTC options, * integrated platform options, and other settings defined in the configuration. * - * @param eosConfig The configuration object containing EOS platform settings. + * @param eos_config The configuration object containing EOS platform settings. */ - void eos_create(config::EOSConfig& eosConfig); + void eos_create(config::EOSConfig eos_config); } #endif diff --git a/lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/eos_library_helpers.cpp b/lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/eos_library_helpers.cpp index 91bc17b39..f7efcefce 100644 --- a/lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/eos_library_helpers.cpp +++ b/lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/eos_library_helpers.cpp @@ -111,7 +111,7 @@ namespace pew::eos::eos_library_helpers const uint32_t RegFlags = (RegistryIndex == 0) ? KEY_WOW64_32KEY : KEY_WOW64_64KEY; if (RegOpenKeyEx(InKey, InSubKey, 0, KEY_READ | RegFlags, &Key) == ERROR_SUCCESS) { - ::DWORD Size = 0; + DWORD Size = 0; // First, we'll call RegQueryValueEx to find out how large of a buffer we need if ((RegQueryValueEx(Key, InValueName, NULL, NULL, NULL, &Size) == ERROR_SUCCESS) && Size) { @@ -144,16 +144,16 @@ namespace pew::eos::eos_library_helpers const TCHAR* RegValue = TEXT("OverlayPath"); std::wstring OverlayDllDirectory; - if (!eos_library_helpers::QueryRegKey(HKEY_CURRENT_USER, RegKey, RegValue, OverlayDllDirectory)) + if (!QueryRegKey(HKEY_CURRENT_USER, RegKey, RegValue, OverlayDllDirectory)) { - if (!eos_library_helpers::QueryRegKey(HKEY_LOCAL_MACHINE, RegKey, RegValue, OverlayDllDirectory)) + if (!QueryRegKey(HKEY_LOCAL_MACHINE, RegKey, RegValue, OverlayDllDirectory)) { return false; } } *OutDllPath = std::filesystem::path(OverlayDllDirectory) / OVERLAY_DLL_NAME; - return std::filesystem::exists(*OutDllPath) && std::filesystem::is_regular_file(*OutDllPath); + return exists(*OutDllPath) && is_regular_file(*OutDllPath); #else log_inform("Trying to get a DLL path on a platform without DLL paths searching"); return false; diff --git a/lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/pch.h b/lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/pch.h index 95dccd940..1649b1acf 100644 --- a/lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/pch.h +++ b/lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/pch.h @@ -12,25 +12,14 @@ // Windows Header Files #include - #if _WIN32 || _WIN64 #define PLATFORM_WINDOWS 1 #endif -#if _WIN64 -#define PLATFORM_64BITS 1 -#define PLATFORM_BITS_DEBUG_STR "64-bits" -#else -#define PLATFORM_32BITS 1 -#define PLATFORM_BITS_DEBUG_STR "32-bits" -#endif - #define STATIC_EXPORT(return_type) extern "C" return_type - #define _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING - #if PLATFORM_WINDOWS #include "processenv.h" #endif @@ -38,32 +27,8 @@ #include "eos_sdk.h" #include "Windows/eos_Windows.h" -// This define exists because UWP -// Originally, this would load the library with the name as shipped by the .zip file -#define USE_PLATFORM_WITHOUT_BITS 0 - -#if USE_PLATFORM_WITHOUT_BITS -#define DLL_PLATFORM "-Win" -#else -#if PLATFORM_64BITS -#define DLL_PLATFORM "-Win64" -#else -#define DLL_PLATFORM "-Win32" -#endif -#endif - -#if PLATFORM_64BITS -#define STEAM_DLL_NAME "steam_api64.dll" -#else -#define STEAM_DLL_NAME "steam_api.dll" -#endif - -#define DLL_SUFFIX "-Shipping.dll" - #define SHOW_DIALOG_BOX_ON_WARN 0 #define ENABLE_DLL_BASED_EOS_CONFIG 1 -#define OVERLAY_DLL_NAME "EOSOVH" DLL_PLATFORM DLL_SUFFIX -#define SDK_DLL_NAME "EOSSDK" DLL_PLATFORM DLL_SUFFIX #define XAUDIO2_DLL_NAME "xaudio2_9redist.dll" #define EOS_SERVICE_CONFIG_FILENAME "EpicOnlineServicesConfig.json"