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 all commits
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/Settings/UserINISettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ protected UserINISettings(IniFile iniFile)
PersistentMode = new BoolSetting(iniFile, MULTIPLAYER, "PersistentMode", false);
AutomaticCnCNetLogin = new BoolSetting(iniFile, MULTIPLAYER, "AutomaticCnCNetLogin", false);
DiscordIntegration = new BoolSetting(iniFile, MULTIPLAYER, "DiscordIntegration", true);
SteamIntegration = new BoolSetting(iniFile, MULTIPLAYER, "SteamIntegration", true);
AllowGameInvitesFromFriendsOnly = new BoolSetting(iniFile, MULTIPLAYER, "AllowGameInvitesFromFriendsOnly", false);
NotifyOnUserListChange = new BoolSetting(iniFile, MULTIPLAYER, "NotifyOnUserListChange", true);
DisablePrivateMessagePopups = new BoolSetting(iniFile, MULTIPLAYER, "DisablePrivateMessagePopups", false);
Expand Down Expand Up @@ -194,6 +195,7 @@ protected UserINISettings(IniFile iniFile)
public BoolSetting PersistentMode { get; private set; }
public BoolSetting AutomaticCnCNetLogin { get; private set; }
public BoolSetting DiscordIntegration { get; private set; }
public BoolSetting SteamIntegration { get; private set; }
public BoolSetting AllowGameInvitesFromFriendsOnly { get; private set; }

public BoolSetting NotifyOnUserListChange { get; private set; }
Expand Down
13 changes: 13 additions & 0 deletions DTAConfig/OptionPanels/CnCNetOptionsPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public CnCNetOptionsPanel(WindowManager windowManager, UserINISettings iniSettin
XNAClientCheckBox chkPersistentMode;
XNAClientCheckBox chkConnectOnStartup;
XNAClientCheckBox chkDiscordIntegration;
XNAClientCheckBox chkSteamIntegration;
XNAClientCheckBox chkAllowGameInvitesFromFriendsOnly;
XNAClientCheckBox chkDisablePrivateMessagePopup;

Expand Down Expand Up @@ -160,6 +161,16 @@ private void InitOptions()
chkAllowGameInvitesFromFriendsOnly.Text = "Only receive game invitations from friends".L10N("Client:DTAConfig:FriendsOnly");

AddChild(chkAllowGameInvitesFromFriendsOnly);


chkSteamIntegration = new XNAClientCheckBox(WindowManager);
chkSteamIntegration.Name = nameof(chkSteamIntegration);
chkSteamIntegration.ClientRectangle = new Rectangle(
chkAllowGameInvitesFromFriendsOnly.X,
chkAllowGameInvitesFromFriendsOnly.Bottom + 12, 0, 0);
chkSteamIntegration.Text = "Show the game being played in Steam".L10N("Client:DTAConfig:SteamStatus");

AddChild(chkSteamIntegration);
}

private void InitAllowPrivateMessagesFromDropdown()
Expand Down Expand Up @@ -316,6 +327,7 @@ public override void Load()
chkConnectOnStartup.Checked = IniSettings.AutomaticCnCNetLogin;
chkSkipLoginWindow.Checked = IniSettings.SkipConnectDialog;
chkPersistentMode.Checked = IniSettings.PersistentMode;
chkSteamIntegration.Checked = IniSettings.SteamIntegration;

chkDiscordIntegration.Checked = !ClientConfiguration.Instance.DiscordIntegrationGloballyDisabled
&& IniSettings.DiscordIntegration;
Expand Down Expand Up @@ -351,6 +363,7 @@ public override bool Save()
IniSettings.AutomaticCnCNetLogin.Value = chkConnectOnStartup.Checked;
IniSettings.SkipConnectDialog.Value = chkSkipLoginWindow.Checked;
IniSettings.PersistentMode.Value = chkPersistentMode.Checked;
IniSettings.SteamIntegration.Value = chkSteamIntegration.Checked;

if (!ClientConfiguration.Instance.DiscordIntegrationGloballyDisabled)
{
Expand Down
1 change: 1 addition & 0 deletions DXMainClient/DXMainClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<Content Include="clienticon.ico" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Facepunch.Steamworks" />
<PackageReference Include="SixLabors.ImageSharp" />
<PackageReference Include="DiscordRichPresence" />
<PackageReference Include="lzo.net" />
Expand Down
Binary file added DXMainClient/Resources/steam_api64.dll
Binary file not shown.
20 changes: 20 additions & 0 deletions DXMainClient/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using Microsoft.Xna.Framework.Graphics;
using DTAConfig;
using System.Collections.Generic;
using Steamworks;

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

GenerateOnlineIdAsync();

Check warning on line 66 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 66 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 66 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 @@ -154,6 +155,25 @@
}
#endif

#if ISWINDOWS
if (UserINISettings.Instance.SteamIntegration)
{
try
{
Logger.Log("Steam init called");
#if YR || ARES
SteamClient.Init(2229850);
#else
SteamClient.Init(2229880);
#endif
}
catch (System.Exception e)
{
Logger.Log("Steam init failed: " + e.Message);
// Couldn't init for some reason (steam is closed etc)
}
}
#endif
gameClass.Run();
}

Expand Down
5 changes: 4 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
</ItemGroup>
<ItemGroup>
<PackageVersion Include="DiscordRichPresence" Version="1.1.3.18" />
<PackageVersion Include="Facepunch.Steamworks" Version="2.3.3" />
<PackageVersion Include="lzo.net" Version="0.0.6" />
<PackageVersion Include="Microsoft.AspNet.WebApi.Client" Version="6.0.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3" />
Expand All @@ -25,6 +26,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 +55,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