Skip to content

Commit 6591de1

Browse files
committed
fix: Enable steam integration in standalone windows builds.
1 parent a385bd4 commit 6591de1

File tree

11 files changed

+62
-25
lines changed

11 files changed

+62
-25
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:52a3eb89f83ef7b4c9f5778cda651d57c9e991ffadf9dfc2ac27815f93e96aaf
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:a312eb5588ecde5e82b4a6cc572fda32813ca09b0c8dc6cfeacf46b029ee161d
3+
size 603648
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:3cb9944297474f09fbab125aa7650d4f493b668c635da4eab0f5a8b0ad5e1482
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:aee2e3184efe8305ea97f61d80c16b168d90564e10846e7e3c3dd4e7b132345f
3+
size 466944

lib/NativeCode/DynamicLibraryLoaderHelper/Directory.Build.props

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
-->
2222
<SolutionDirForwardSlashes>$(SolutionDir.Replace('\', '/'))</SolutionDirForwardSlashes>
2323
<UnityStreamingAssetsDirectory>$(SolutionDirForwardSlashes)../../../Assets/StreamingAssets/</UnityStreamingAssetsDirectory>
24-
<OutputUnityAssetsDirectory>$(SolutionDir)..\..\..\Assets\Plugins\Windows\$(NormalizedPlatform)\</OutputUnityAssetsDirectory>
24+
<SteamLibraryDirectory>$(SolutionDirForwardSlashes)../../../Library/PackageCache/com.rlabrecque.steamworks.net*/Plugins/</SteamLibraryDirectory>
25+
<OutputUnityAssetsDirectory>$(SolutionDirForwardSlashes)../../../Assets/Plugins/Windows/$(NormalizedPlatform)/</OutputUnityAssetsDirectory>
2526
</PropertyGroup>
2627
</Project>

lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/NativeRender.vcxproj

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,21 +83,23 @@
8383
<PreBuildEvent>
8484
<!-- When debugging, make sure to copy the EOSSDK Dll to the output directory -->
8585
<Command>
86-
@echo Copying "$(OutputUnityAssetsDirectory)$(SdkDllName)" to "$(TargetDir)"
87-
copy "$(OutputUnityAssetsDirectory)$(SdkDllName)" "$(TargetDir)" /Y
88-
</Command>
86+
@echo Copying "$(OutputUnityAssetsDirectory)$(SdkDllName)" to "$(TargetDir)"
87+
copy "$(OutputUnityAssetsDirectory)$(SdkDllName)" "$(TargetDir)" /Y
88+
89+
@echo Copying "$(SteamLibraryDirectory)steam_api*.dll" to "$(TargetDir)"
90+
powershell -NoProfile -ExecutionPolicy Bypass -Command "try { Get-ChildItem -Path '$(SteamLibraryDirectory)steam_api*.dll' -Recurse | Copy-Item -Destination '$(TargetDir)' -Force } catch { Write-Error $_; exit 1 }"
91+
92+
@echo Copying "$(SolutionDirForwardSlashes)../../../steam_appid.txt" "$(TargetDir)"
93+
xcopy "$(SolutionDirForwardSlashes)../../../steam_appid.txt" "$(TargetDir)" /Y
94+
</Command>
8995
</PreBuildEvent>
9096
<PostBuildEvent>
9197
<!-- 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>
98+
<Command>@echo Copying "$(SolutionDir)$(ProjectName)-$(NormalizedPlatform).dll.meta" to "$(OutputUnityAssetsDirectory)"
99+
copy $(SolutionDir)$(ProjectName)-$(NormalizedPlatform).dll.meta $(OutputUnityAssetsDirectory) /Y</Command>
96100
<!-- 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>
101+
<Command>@echo Copying "$(TargetDir)$(ProjectName)-$(NormalizedPlatform)*" to "$(OutputUnityAssetsDirectory)"
102+
copy "$(TargetDir)$(ProjectName)*" "$(OutputUnityAssetsDirectory)" /Y</Command>
101103
</PostBuildEvent>
102104
</ItemDefinitionGroup>
103105
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,18 @@ 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 char* path = json_value_as_string(&value)->string;
118+
if (!string_helpers::is_empty_or_whitespace(path))
119+
{
120+
_library_path = path;
121+
}
119122
}
120123
else if (name == "steamSDKMajorVersion")
121124
{

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"

lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/src/eos_helpers.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,19 +250,19 @@ namespace pew::eos
250250

251251
// Get a pointer to the SteamAPI_Init function within the steam
252252
// library.
253-
const auto SteamAPI_Init = pew::eos::eos_library_helpers::load_function_with_name<SteamAPI_Init_t>(steam_dll_handle, "SteamAPI_Init");
253+
const auto SteamAPI_Init_Fn = pew::eos::eos_library_helpers::load_function_with_name<SteamAPI_Init_t>(steam_dll_handle, "SteamAPI_InitSafe");
254254

255255
// If the SteamAPI_Init function pointer is null, then it was not
256256
// correctly retrieved from the steam library. Log an error and stop
257-
if (SteamAPI_Init == nullptr)
257+
if (SteamAPI_Init_Fn == nullptr)
258258
{
259259
logging::log_error(
260260
"Could not load a pointer to the SteamAPI_Init "
261261
"function within the loaded steam library handle.");
262262
return;
263263
}
264264

265-
if (SteamAPI_Init())
265+
if (SteamAPI_Init_Fn())
266266
{
267267
logging::log_inform("SteamAPI_Init returned true. "
268268
"Steam has been initialized.");
@@ -373,7 +373,7 @@ namespace pew::eos
373373

374374
platform_options.RTCOptions = platform_config.get_platform_rtc_options().get();
375375

376-
// TODO-STEAM: enable apply_steam_settings(platform_options);
376+
apply_steam_settings(platform_options);
377377

378378
return platform_options;
379379
}

0 commit comments

Comments
 (0)