Skip to content

Commit 94769f6

Browse files
authored
Merge pull request #1081 from PlayEveryWare/fix/steam-integration
fix: Restore Steam Integration
2 parents 33a7ef1 + 0ce4326 commit 94769f6

File tree

12 files changed

+133
-43
lines changed

12 files changed

+133
-43
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:b2566815097f8df84c3481ef36648226a4f184744154e19335eb58b643c53f15
2+
oid sha256:969153308fe56d512c998509226a5a84918b8624c4691f06345a434396d136a7
33
size 122880
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:5984497fc9cb68e8dd2d25dc8e6fe45b8322d282f88b82b1bfe6eea3c10d7732
3-
size 592896
2+
oid sha256:fcd9618285bb1bf56c72f46f64e228cda95aa27e64ea2a0199d649dbfebd8c10
3+
size 604672
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:1926250dbc34f8519f4fab17ca42aea9808bbd6472fe7f6490bf4a40fe7fb7ed
2+
oid sha256:cf018202e613caa46f9f32301f728a6386cfb9b3c036b0f4b300725336f4e5e1
33
size 87040
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:feb614c1f35aa2339572866a481cb293924701dd3970922170537cd518f1743a
3-
size 457728
2+
oid sha256:361b0b0201d2b0afbf8f982cd529faa6cf148aeb7e9d303df7dff7854b61414f
3+
size 467968

lib/NativeCode/DynamicLibraryLoaderHelper/Directory.Build.props

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,19 @@
1515
<NormalizedPlatform Condition="'$(Platform)' == 'x86' or '$(Platform)' == 'Win32'">x86</NormalizedPlatform>
1616
<NormalizedPlatform Condition="'$(Platform)' == 'x64'">x64</NormalizedPlatform>
1717

18-
<!--
18+
<EOS_SDK_DLL_NAME Condition="'$(NormalizedPlatform)' == 'x64'">EOSSDK-Win64-Shipping.dll</EOS_SDK_DLL_NAME>
19+
<STEAM_API_DLL_NAME Condition="'$(NormalizedPlatform)' == 'x64'">steam_api64.dll</STEAM_API_DLL_NAME>
20+
21+
<EOS_SDK_DLL_NAME Condition="'$(NormalizedPlatform)' == 'x86'">EOSSDK-Win32-Shipping.dll</EOS_SDK_DLL_NAME>
22+
<STEAM_API_DLL_NAME Condition="'$(NormalizedPlatform)' == 'x86'">steam_api.dll</STEAM_API_DLL_NAME>
23+
24+
<!--
1925
Define a property with the SolutionDir path but with backslashes replaced
2026
by forward slashes
2127
-->
2228
<SolutionDirForwardSlashes>$(SolutionDir.Replace('\', '/'))</SolutionDirForwardSlashes>
2329
<UnityStreamingAssetsDirectory>$(SolutionDirForwardSlashes)../../../Assets/StreamingAssets/</UnityStreamingAssetsDirectory>
24-
<OutputUnityAssetsDirectory>$(SolutionDir)..\..\..\Assets\Plugins\Windows\$(NormalizedPlatform)\</OutputUnityAssetsDirectory>
30+
<SteamLibraryDirectory>$(SolutionDirForwardSlashes)../../../Library/PackageCache/com.rlabrecque.steamworks.net*/Plugins/</SteamLibraryDirectory>
31+
<OutputUnityAssetsDirectory>$(SolutionDirForwardSlashes)../../../Assets/Plugins/Windows/$(NormalizedPlatform)/</OutputUnityAssetsDirectory>
2532
</PropertyGroup>
2633
</Project>

lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/NativeRender.vcxproj

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,23 +81,16 @@
8181
<PreprocessorDefinitions>PEW_EOS_EXPORT;OVERLAY_DLL_NAME="$(OverlayDllName)";STEAM_API_DLL="$(SteamApiDll)";SDK_DLL_NAME="$(SdkDllName)";CONFIG_DIRECTORY="$(ConfigDirectory)";_DEBUG;NATIVERENDER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
8282
</ClCompile>
8383
<PreBuildEvent>
84-
<!-- When debugging, make sure to copy the EOSSDK Dll to the output directory -->
85-
<Command>
86-
@echo Copying "$(OutputUnityAssetsDirectory)$(SdkDllName)" to "$(TargetDir)"
87-
copy "$(OutputUnityAssetsDirectory)$(SdkDllName)" "$(TargetDir)" /Y
88-
</Command>
84+
<!-- Execute the prebuild powershell command -->
85+
<Command>powershell -NoProfile -ExecutionPolicy Bypass -File "$(ProjectDir)scripts\prebuild.ps1" -Configuration "$(Configuration)" -OutputUnityAssetsDirectory "$(OutputUnityAssetsDirectory)" -EOS_SDK_DLL_NAME "$(EOS_SDK_DLL_NAME)" -STEAM_API_DLL_NAME "$(STEAM_API_DLL_NAME)" -TargetDir $(TargetDir) -SteamLibraryDirectory "$(SteamLibraryDirectory)" -SolutionDir "$(SolutionDir)"</Command>
8986
</PreBuildEvent>
9087
<PostBuildEvent>
9188
<!-- Copy the meta file stored in the solution directory, since it's values have been properly set in such a way that Unity interacts with the DLL in the intended manner. -->
92-
<Command>
93-
@echo Copying "$(SolutionDir)$(ProjectName)-$(NormalizedPlatform).dll.meta" to "$(OutputUnityAssetsDirectory)"
94-
copy $(SolutionDir)$(ProjectName)-$(NormalizedPlatform).dll.meta $(OutputUnityAssetsDirectory) /Y
95-
</Command>
89+
<Command>@echo Copying "$(SolutionDir)$(ProjectName)-$(NormalizedPlatform).dll.meta" to "$(OutputUnityAssetsDirectory)"
90+
copy $(SolutionDir)$(ProjectName)-$(NormalizedPlatform).dll.meta $(OutputUnityAssetsDirectory) /Y</Command>
9691
<!-- Copy the output files into the appropriate assets directory alongside the aforementioned .dll.meta file.-->
97-
<Command>
98-
@echo Copying "$(TargetDir)$(ProjectName)-$(NormalizedPlatform)*" to "$(OutputUnityAssetsDirectory)"
99-
copy "$(TargetDir)$(ProjectName)*" "$(OutputUnityAssetsDirectory)" /Y
100-
</Command>
92+
<Command>@echo Copying "$(TargetDir)$(ProjectName)-$(NormalizedPlatform)*" to "$(OutputUnityAssetsDirectory)"
93+
copy "$(TargetDir)$(ProjectName)*" "$(OutputUnityAssetsDirectory)" /Y</Command>
10194
</PostBuildEvent>
10295
</ItemDefinitionGroup>
10396
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">

lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/include/Config/SteamConfig.hpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,23 @@ namespace pew::eos::config
107107
steam_sdk_major_version(0),
108108
steam_sdk_minor_version(0)
109109
{
110-
// TODO: Restore STEAM_SDK_DLL_NAME
111-
//_library_path = common::get_path_relative_to_current_module(STEAM_SDK_DLL_NAME);
110+
_library_path = io_helpers::get_path_relative_to_current_module(STEAM_SDK_DLL_NAME);
112111
}
113112

114113
void parse_json_element(const std::string& name, json_value_s& value) override
115114
{
116115
if (name == "overrideLibraryPath")
117116
{
118-
// TODO: Make sure this is applied appropriately.
117+
const auto override_library_path_element = json_value_as_string(&value);
118+
if (override_library_path_element == nullptr)
119+
{
120+
return;
121+
}
122+
const char* path = override_library_path_element->string;
123+
if (!string_helpers::is_empty_or_whitespace(path))
124+
{
125+
_library_path = path;
126+
}
119127
}
120128
else if (name == "steamSDKMajorVersion")
121129
{

lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/include/string_helpers.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,5 +146,12 @@ namespace pew::eos::string_helpers
146146
* @return A UTF-8 encoded `std::string` representation of the path.
147147
*/
148148
std::string to_utf8_str(const std::filesystem::path& path);
149+
150+
/**
151+
* @brief Determines if a given C string is either empty or contains only whitespace characters.
152+
* @param str The string to check.
153+
* @return True if the string is empty or contains only whitespace characters.
154+
*/
155+
bool is_empty_or_whitespace(const char* str);
149156
}
150157
#endif

lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/pch.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@
3333
#include "eos_sdk.h"
3434
#include "Windows/eos_Windows.h"
3535

36+
#if _WIN64
37+
#define STEAM_SDK_DLL_NAME "steam_api64.dll"
38+
#elif _WIN32
39+
#define STEAM_SDK_DLL_NAME "steam_api.dll"
40+
#endif
41+
3642
#define SHOW_DIALOG_BOX_ON_WARN 0
3743
#define ENABLE_DLL_BASED_EOS_CONFIG 1
3844
#define XAUDIO2_DLL_NAME "xaudio2_9redist.dll"
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
param(
2+
[string]$Configuration,
3+
[string]$OutputUnityAssetsDirectory,
4+
[string]$EOS_SDK_DLL_NAME,
5+
[string]$STEAM_API_DLL_NAME,
6+
[string]$TargetDir,
7+
[string]$SteamLibraryDirectory,
8+
[string]$SolutionDir
9+
)
10+
11+
Write-Host "=============== Start of Prebuild Script =========================="
12+
13+
# If in debug mode, we want to copy the eos sdk dll, the steam app id file, and
14+
# The steam DLL into the output directory
15+
if ($Configuration -eq "Debug")
16+
{
17+
$filesToCopy = @(
18+
(Join-Path $SolutionDir "..\..\..\steam_appid.txt"),
19+
(Join-Path $SteamLibraryDirectory $STEAM_API_DLL_NAME),
20+
(Join-Path $OutputUnityAssetsDirectory $EOS_SDK_DLL_NAME)
21+
)
22+
23+
$filesToCopy | ForEach-Object {
24+
if (-Not(Test-Path -LiteralPath $_)) {
25+
Write-Host ("WARNING: Could not copy file '{0}' because it does not exist. This might not be a problem." -f $_);
26+
continue
27+
}
28+
29+
$itemBeingCopied = Get-Item $_;
30+
Write-Host ('Copying file "{0}" to "{1}".' -f $itemBeingCopied.FullName, $TargetDir);
31+
Copy-Item -LiteralPath $itemBeingCopied.FullName -Destination $TargetDir -Force;
32+
}
33+
}
34+
35+
Write-Host "=============== End of Prebuild Script =========================="

0 commit comments

Comments
 (0)