Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Steamworks SDK #595

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ClientCore/ClientConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ public void RefreshSettings()

public string LocalGame => clientDefinitionsIni.GetStringValue(SETTINGS, "LocalGame", "DTA");

public int SteamGameId => clientDefinitionsIni.GetIntValue(SETTINGS, "SteamGameId", 2229850);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should be configured to the default value of YR one explicitly. you should check if it's a YR or Ares config via ifdef and use that as default, elif TS - use Steam TS one, else assign a missing ID value (idk if 0 is correct for Steam?) and check before even initializing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
image
What about this instead

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? It's not hard to change the default value for something sane based on the build config, and I don't think having am ability for people change steam app ID is something that should be exposed a lot. Besides, there are only two such games that are on Steam and are supported by the client - TS and YR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about this instead

Why Steam Game Identityficator can be set from ClientDefinitions.ini? Is there possible situation when modder publish its mod in the Steam as the standalone game? If not -- better to hardcode YR and TS Steam IDs as Kerbiter said.

In addition to the above, i believe a button to enable/disable feature (like DRP) is needed.


public bool SidebarHack => clientDefinitionsIni.GetBooleanValue(SETTINGS, "SidebarHack", false);

public int MinimumRenderWidth => clientDefinitionsIni.GetIntValue(SETTINGS, "MinimumRenderWidth", 1280);
Expand Down
3 changes: 3 additions & 0 deletions DXMainClient/DXMainClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
<PackageReference Include="lzo.net" />
<PackageReference Include="Microsoft.Extensions.Hosting" />
<PackageReference Include="OpenMcdf" />
<PackageReference Include="SteamworksSharp" />
<PackageReference Include="SteamworksSharp.Native" />
<PackageReference Include="SteamworksSharp.Native.Windows_x64" />
<PackageReference Include="System.Management" />
<PackageReference Include="System.DirectoryServices" />
</ItemGroup>
Expand Down
21 changes: 21 additions & 0 deletions DXMainClient/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
using Microsoft.Xna.Framework.Graphics;
using DTAConfig;
using System.Collections.Generic;
using SteamworksSharp.Native;
using SteamworksSharp;

namespace DTAClient
{
Expand Down Expand Up @@ -62,7 +64,7 @@
thread.Start();
}

GenerateOnlineIdAsync();

Check warning on line 67 in DXMainClient/Startup.cs

View workflow job for this annotation

GitHub Actions / build-clients (Ares)

Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.

Check warning on line 67 in DXMainClient/Startup.cs

View workflow job for this annotation

GitHub Actions / build-clients (TS)

Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.

Check warning on line 67 in DXMainClient/Startup.cs

View workflow job for this annotation

GitHub Actions / build-clients (YR)

Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.

#if ARES
Task.Factory.StartNew(() => PruneFiles(SafePath.GetDirectory(ProgramConstants.GamePath, "debug"), DateTime.Now.AddDays(-7)));
Expand Down Expand Up @@ -153,6 +155,25 @@
fhc.CalculateHashes();
}
#endif
// Load native steam binaries.
SteamNative.Initialize();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, does the Steam SDK work (or at least doesn't crash the client) in Linux? It's better to test it. If not (I don't know whether it works or not), an if statement should be introduced to skip the Steam API if the OS is not Windows.


if (SteamApi.IsSteamRunning())
{
// Provide appId so it automatically creates a "steam_appid.txt" file.
if (SteamApi.Initialize(ClientConfiguration.Instance.SteamGameId))
{
Logger.Log($"Logged in as: {SteamApi.SteamFriends.GetPersonaName()}");
}
else
{
Logger.Log("SteamApi failed to initialize.");
}
}
else
{
Logger.Log("Steam is not running.");
}

gameClass.Run();
}
Expand Down
4 changes: 3 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
<PackageVersion Include="Rampastring.XNAUI.UniversalGL.Debug" Version="$(RampastringXNAUIVersion)" />
<PackageVersion Include="Rampastring.XNAUI.WindowsXNA.Debug" Version="$(RampastringXNAUIVersion)" />
<PackageVersion Include="SixLabors.ImageSharp" Version="2.1.9" />
<PackageVersion Include="SteamworksSharp" Version="1.0.8" />
<PackageVersion Include="SteamworksSharp.Native" Version="1.0.8" />
<PackageVersion Include="SteamworksSharp.Native.Windows_x64" Version="1.0.8" />
Comment on lines +29 to +31
Copy link
Member

@Metadorius Metadorius Dec 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
image

Uhh I don't think we should be using this. This is a pretty random wrapper wrote by a random person 6 years ago.

For a 1:1 Steamworks mappings use Steamworks.NET. For a preoprly C# one I think Facepunch.Steamworks should be used (based on some quick reading up I would pick that, even if it's a bit outdated). Please research this question a bit more, maybe there are other better alternatives.

<PackageVersion Include="System.DirectoryServices" Version="$(DotnetLibrariesVersion)" />
<PackageVersion Include="System.Management" Version="$(DotnetLibrariesVersion)" />
<PackageVersion Include="System.Text.Encoding.CodePages" Version="$(DotnetLibrariesVersion)" />
Expand All @@ -51,7 +54,6 @@
<!-- and -p:Engine=WindowsDX -f net48 -->
<PackageReference Include="NETStandard.Library" />
<PackageVersion Include="NETStandard.Library" Version="2.0.3" />

<PackageReference Include="System.IO.FileSystem" />
<PackageVersion Include="System.IO.FileSystem" Version="4.3.0" />
</ItemGroup>
Expand Down
Loading