Skip to content

Commit

Permalink
fix merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
zefanjajobse committed Oct 3, 2022
1 parent be5ce35 commit 2871798
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 27 deletions.
19 changes: 8 additions & 11 deletions Battlefield rich presence/Api.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System;
using System.Net.Http;
using BattlefieldRichPresence.Properties;
using BattlefieldRichPresence.Structs;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;

namespace BattlefieldRichPresence
Expand Down Expand Up @@ -48,12 +46,12 @@ public static ServerInfo GetBf5CurrentServer(string playerName)
{
throw new Exception("not in a server");
}
return jsonSerializer.Deserialize<ServerInfo>(data);
return JsonConvert.DeserializeObject<ServerInfo>(responseContent);
}

public static void PostPlayerlist(GameReader.CurrentServerReader currentServerReader, Guid guid)
{
var post = new
var payload = new
{
guid = guid.ToString(),
serverinfo = new
Expand All @@ -73,13 +71,12 @@ public static void PostPlayerlist(GameReader.CurrentServerReader currentServerRe
scoreteam2FromFlags = currentServerReader.Team2ScoreFromFlags,
}
};
JavaScriptSerializer jsonSerializer = new JavaScriptSerializer();
string dataString = jsonSerializer.Serialize(post);
WebClient webClient = new WebClient();
string jwtData = Jwt.Create(dataString, guid.ToString());
webClient.Headers.Add(HttpRequestHeader.ContentType, "application/json");
string postData = jsonSerializer.Serialize(new { data = jwtData });
webClient.UploadString(new Uri("https://api.gametools.network/seederplayerlist/bf1"), "POST", postData);
string dataString = JsonConvert.SerializeObject(payload);
string jwtData = Jwt.Create(dataString);
string stringPayload = JsonConvert.SerializeObject(new { data = jwtData });
StringContent httpContent = new StringContent(stringPayload, Encoding.UTF8, "application/json");
HttpResponseMessage httpResponse = new HttpClient().PostAsync("https://api.gametools.network/seederplayerlist/bf1", httpContent).Result;
_ = httpResponse.Content.ReadAsStringAsync().Result;
}
}
}
11 changes: 11 additions & 0 deletions Battlefield rich presence/Battlefield rich presence.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
<OutputPath>bin\x64\Release\</OutputPath>
</PropertyGroup>
<ItemGroup>
<Compile Update="Properties\Settings.Designer.cs">
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<Compile Update="TimerPlus.cs">
<SubType>Component</SubType>
</Compile>
Expand Down Expand Up @@ -88,4 +93,10 @@
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
<ItemGroup>
<None Update="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions Battlefield rich presence/Config.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using BattlefieldRichPresence.Properties;
using System;

namespace BattlefieldRichPresence
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using BattlefieldRichPresence.Structs;

namespace BattlefieldRichPresence.GameReader
{
Expand Down
2 changes: 1 addition & 1 deletion Battlefield rich presence/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 16 additions & 14 deletions Battlefield rich presence/TrayItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ namespace BattlefieldRichPresence
{
public class TrayItem : ApplicationContext
{
TimerPlus _timer = new TimerPlus();
TimerPlus _trayUpdateTimer = new TimerPlus();
private NotifyIcon _trayIcon;
private Config _config;
private readonly TimerPlus _timer = new();
private readonly TimerPlus _trayUpdateTimer = new();
private readonly Config _config = new();
private readonly NotifyIcon _trayIcon;

public TrayItem()
{
_config = new Config();
// Initialize Tray Icon
_trayIcon = new NotifyIcon
{
Expand All @@ -25,6 +24,7 @@ public TrayItem()
//new MenuItem($"Player: {_config.PlayerName}", Void),
new ToolStripMenuItem("Next update in ...", null, Void),
new ToolStripMenuItem("Edit settings", null, Edit),
new ToolStripMenuItem("Copy BF1 sender id (anonymous)", null, Copy),
new ToolStripMenuItem("Exit", null, Exit),
});
_trayIcon.ContextMenuStrip.Items[0].Enabled = false;
Expand Down Expand Up @@ -53,18 +53,20 @@ void UpdateTrayItems()
{
if (_config.GatherServerInfo)
{
_trayIcon.ContextMenu = new ContextMenu(new[] {
new MenuItem("Next update in ...", Void),
new MenuItem("Copy bf1 sender id (anonymous)", Copy),
new MenuItem("Edit settings", Edit),
new MenuItem("Exit", Exit),
_trayIcon.ContextMenuStrip.Items.Clear();
_trayIcon.ContextMenuStrip.Items.AddRange(new ToolStripItem[] {
new ToolStripMenuItem("Next update in ...", null, Void),
new ToolStripMenuItem("Copy bf1 sender id (anonymous)", null, Copy),
new ToolStripMenuItem("Edit settings", null, Edit),
new ToolStripMenuItem("Exit", null, Exit),
});
} else
{
_trayIcon.ContextMenu = new ContextMenu(new[] {
new MenuItem("Next update in ...", Void),
new MenuItem("Edit settings", Edit),
new MenuItem("Exit", Exit),
_trayIcon.ContextMenuStrip.Items.Clear();
_trayIcon.ContextMenuStrip.Items.AddRange(new ToolStripItem[] {
new ToolStripMenuItem("Next update in ...", null, Void),
new ToolStripMenuItem("Edit settings", null, Edit),
new ToolStripMenuItem("Exit", null, Exit),
});
}
}
Expand Down

0 comments on commit 2871798

Please sign in to comment.