Skip to content

Commit

Permalink
Add steam
Browse files Browse the repository at this point in the history
  • Loading branch information
GrantBartlett committed Feb 18, 2025
1 parent de1d080 commit 4163026
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ClientCore/Settings/UserINISettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,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 @@ -197,6 +198,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
2 changes: 2 additions & 0 deletions CommonAssemblies.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
ClientUpdater.dll
ClientUpdater.pdb
DiscordRPC.dll
Facepunch.Steamworks.Win64.dll
lzo.net.dll
Microsoft.Extensions.Configuration.Abstractions.dll
Microsoft.Extensions.Configuration.Binder.dll
Expand Down Expand Up @@ -35,5 +36,6 @@ OpenMcdf.dll
Rampastring.Tools.dll
SixLabors.ImageSharp.dll
System.CodeDom.dll
steam_api64.dll
System.Net.Http.Formatting.dll
TextCopy.dll
2 changes: 2 additions & 0 deletions CommonAssembliesNetFx.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
ClientUpdater.dll
ClientUpdater.pdb
DiscordRPC.dll
Facepunch.Steamworks.Win64.dll
lzo.net.dll
Microsoft.Bcl.AsyncInterfaces.dll
Microsoft.Extensions.Configuration.Abstractions.dll
Expand Down Expand Up @@ -35,6 +36,7 @@ Newtonsoft.Json.dll
OpenMcdf.dll
Rampastring.Tools.dll
SixLabors.ImageSharp.dll
steam_api64.dll
System.Buffers.dll
System.CodeDom.dll
System.Diagnostics.DiagnosticSource.dll
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
6 changes: 6 additions & 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" GeneratePathProperty="true"/>
<PackageReference Include="SixLabors.ImageSharp" />
<PackageReference Include="DiscordRichPresence" />
<PackageReference Include="lzo.net" />
Expand All @@ -39,4 +40,9 @@
<ProjectReference Include="..\DTAConfig\DTAConfig.csproj" />
<ProjectReference Include="..\ClientUpdater\ClientUpdater.csproj" />
</ItemGroup>
<ItemGroup>
<None Include="$(PkgFacepunch_Steamworks)\content\steam_api64.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
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 @@ -156,6 +157,25 @@ public void Execute()
}
#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
1 change: 1 addition & 0 deletions 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.4.1" />
<PackageVersion Include="ImeSharp" Version="1.4.0" />
<PackageVersion Include="lzo.net" Version="0.0.6" />
<PackageVersion Include="Microsoft.AspNet.WebApi.Client" Version="6.0.0" />
Expand Down
Binary file added References/Facepunch.Steamworks.2.4.1.nupkg
Binary file not shown.

0 comments on commit 4163026

Please sign in to comment.