Skip to content

Commit

Permalink
Show the Northstar icon if using Northstar client (#165)
Browse files Browse the repository at this point in the history
  • Loading branch information
IncPlusPlus authored Dec 24, 2021
1 parent 5b569f0 commit fcf8a8d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
7 changes: 4 additions & 3 deletions titanfall2-rp/PresenceUpdateThread.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ namespace titanfall2_rp
{
public class PresenceUpdateThread
{
private const int ProcessOpenWaitTimeInMinutes = 1;
private static readonly ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod()!.DeclaringType);
private static System.Timers.Timer? _presenceUpdateTimer;
private const int ProcessOpenWaitTimeInMinutes = 1;
private readonly DiscordRpcClient _discordRpcClient;
private readonly Titanfall2Api _tf2Api;
private readonly EventWaitHandle _userExitEvent;
Expand Down Expand Up @@ -106,8 +106,9 @@ private static void SetCurrentPresence(DiscordRpcClient client, Titanfall2Api tf
Timestamps = timestamps,
Assets = assets ?? new Assets
{
LargeImageKey = "icon-900x900",
LargeImageText = "titanfall2-rp " + (Constants.IsLocalBuild ? "(dev version)" : UpdateHelper.AppVersion) + " by IncPlusPlus",
LargeImageKey = tf2Api.IsNorthstarClient ? "northstar-icon" : "icon-900x900",
LargeImageText =
$"titanfall2-rp {(Constants.IsLocalBuild ? "(dev version)" : UpdateHelper.AppVersion)} by IncPlusPlus",
}
});
}
Expand Down
7 changes: 4 additions & 3 deletions titanfall2-rp/SegmentManager/SegmentManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
using System.IO;
using System.Reflection;
using Common;
using DiscordRPC.Message;
using log4net;
using Segment;
using Segment.Model;
using titanfall2_rp.misc;
using titanfall2_rp.updater;
using Config = Common.Config;
using DiscordRPC.Message;

namespace titanfall2_rp.SegmentManager
{
public static class SegmentManager
{
private static readonly ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod()!.DeclaringType);
private const string WriteKey = "DAXSzUgf2tu57mPFgnWSggNyD3v4BEhC";
private const string AnonymousIdentifierFileName = "IDENTIFIER";
private static readonly ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod()!.DeclaringType);
private static bool _enableSegment = true;
private static bool _initialized;
private static bool _hasIdentifiedSelf;
Expand Down Expand Up @@ -117,7 +117,8 @@ private static void TrackGameplay(TrackableEvent @event, PresenceMessage presenc
{ "rpc_small_image", presence.Assets.SmallImageKey },
{ "rpc_small_text", presence.Assets.SmallImageText },
{ "gamemode_and_map_name", _tf2Api?.GetGameModeAndMapName() },
{ "game_version", _tf2Api?.GetGameVersion() }
{ "game_version", _tf2Api?.GetGameVersion() },
{ "northstar_client", _tf2Api?.IsNorthstarClient }
}, new Options().SetAnonymousId(GetAnonymousIdentifier()));
}

Expand Down
6 changes: 6 additions & 0 deletions titanfall2-rp/Titanfall2API.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using System;
using System.Collections.Specialized;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Web;
using log4net;
using Process.NET;
using Process.NET.Extensions;
using titanfall2_rp.enums;
using titanfall2_rp.SegmentManager;
using static titanfall2_rp.ProcessApi;
Expand All @@ -21,6 +23,7 @@ public class Titanfall2Api
public IntPtr EngineDllBaseAddress { get; private set; }
public IntPtr ClientDllBaseAddress { get; private set; }
public IntPtr ServerDllBaseAddress { get; private set; }
public bool IsNorthstarClient { get; private set; }

public MpStats GetMultiPlayerGameStats()
{
Expand Down Expand Up @@ -204,6 +207,9 @@ private void _populateFields(ProcessSharp sharp)
EngineDllBaseAddress = GetModuleBaseAddress(sharp.Native, "engine.dll");
ClientDllBaseAddress = GetModuleBaseAddress(sharp.Native, "client.dll");
ServerDllBaseAddress = GetModuleBaseAddress(sharp.Native, "server.dll");
IsNorthstarClient = System.Diagnostics.Process.GetProcessById(sharp.Native.Id)
.GetModules()
.Any(module => module.ModuleName.Equals("Northstar.dll"));
}
}
}

0 comments on commit fcf8a8d

Please sign in to comment.