Skip to content
This repository has been archived by the owner on Jun 19, 2023. It is now read-only.

Commit

Permalink
Fix UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Johnnymc2001 committed Dec 3, 2021
1 parent 8b59a56 commit 726ed87
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 18 deletions.
4 changes: 2 additions & 2 deletions MainProgram/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
<configuration>
<appSettings>
<add key="Lobby_Detail" value="{USERNAME}" />
<add key="Lobby_State" value="{ID}" />
<add key="Lobby_State" value="Chilling in the lobby..." />
<add key="Ingame_ShowMap" value="True" />
<add key="Ingame_ShowTeam" value="True" />
<add key="Ingame_Detail" value="{Mode} - {Map}" />
<add key="Ingame_State" value="[𝗧 {TScore}] ({Round}) [{CTScore} 𝗖𝗧] {Phase}" />
<add key="Ingame_State" value="[𝗧 {TScore}] &lt;&lt;{Round}&gt;&gt; [{CTScore} 𝗖𝗧]" />
<add key="Ingame_LargeText" value="{Map}" />
<add key="Ingame_SmallText" value="{Name} [{Kill}/{Death}/{Assist} ({Score}) [{MVP}⭐]" />
</appSettings>
Expand Down
16 changes: 16 additions & 0 deletions MainProgram/Form1.Designer.cs

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

50 changes: 34 additions & 16 deletions MainProgram/Form1.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using CSGSI;
using CSGSI.Nodes;
using DiscordRPC;
using Microsoft.Win32;
using Newtonsoft.Json;
Expand Down Expand Up @@ -139,7 +140,7 @@ private string ParsePlaceHolder(GameState gs, string str)
.Replace("{Mode}", game.Mode.ToString() ?? "")

.Replace("{Name}", player.Name)
.Replace("{Team}", player.Team.ToString())
.Replace("{Team}", player.Team.ToString() ?? "")
.Replace("{Kill}", stat.Kills.ToString() ?? "")
.Replace("{Death}", stat.Deaths.ToString() ?? "")
.Replace("{Assist}", stat.Assists.ToString() ?? "")
Expand All @@ -155,6 +156,8 @@ private string ParsePlaceHolder(GameState gs, string str)

private void OnNewGameState(GameState gs)
{
Trace.Write(gs.JSON);

var player = gs.Player;
var activity = player.Activity;

Expand All @@ -170,24 +173,34 @@ private void OnNewGameState(GameState gs)
}
else if (activity.ToString().ToLower() == "playing")
{
var game = gs.Map;
var stat = player.MatchStats;
try
{


var game = gs.Map;

string map = game.Name;
string largeKey = "";
string smallKey = "";

string detail = ParsePlaceHolder(gs, IngameSetting.Detail);
string state = ParsePlaceHolder(gs, IngameSetting.State);
string largeText = ParsePlaceHolder(gs, IngameSetting.LargeText);
string smallText = ParsePlaceHolder(gs, IngameSetting.SmallText);
var stat = player.MatchStats;

if (IngameSetting.ShowMap) largeKey = $"{map}";
if (IngameSetting.ShowTeam) smallKey = player.Team.ToString() == "T" ? "terrorists" : "counterterrorists" ?? "spec";
string map = game?.Name ?? "";
string largeKey = "";
string smallKey = "";

UpdatePresence($"{detail}", $"{state}", largeKey, largeText, smallKey, smallText);
string detail = ParsePlaceHolder(gs, IngameSetting.Detail);
string state = ParsePlaceHolder(gs, IngameSetting.State);
string largeText = ParsePlaceHolder(gs, IngameSetting.LargeText);
string smallText = ParsePlaceHolder(gs, IngameSetting.SmallText);

if (IngameSetting.ShowMap) largeKey = $"{map}";
if (IngameSetting.ShowTeam) smallKey = player.Team.ToString() == "T" ? "terrorists" : "counterterrorists" ?? "spec";

UpdatePresence($"{detail}", $"{state}", largeKey, largeText, smallKey, smallText);
}
catch
{

}
}
Trace.Write(gs.JSON);
}

private void UpdateGUI()
Expand Down Expand Up @@ -410,8 +423,13 @@ private void OnMouseDown(object sender, MouseEventArgs e)

private void btn_Exit_Click(object sender, EventArgs e)
{
DeInitService();
Environment.Exit(0);
DialogResult f = MessageBox.Show("Are you sure you want to exit the program? The discord rich presence will be stopped!", "Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

if (f == DialogResult.Yes)
{
DeInitService();
Environment.Exit(0);
}
}

private void btn_Minimize_Click(object sender, EventArgs e)
Expand Down

0 comments on commit 726ed87

Please sign in to comment.