Skip to content

Commit

Permalink
Removes keys from the config, patch duplicate bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Smaltin committed Jul 19, 2024
1 parent d3dff34 commit d1fc170
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 39 deletions.
14 changes: 0 additions & 14 deletions DiscordPresenceConfig.ini
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
music.ui=true=807774172574253056
spotify=true=802222525110812725
musicbee=true=820837854385012766
microsoft.media.player=true=807774172574253056
wmplayer=true=807774172574253056
wavelink=true=927328178618376212
tidal=true=922625678271197215
amazon music=true=808571949227049000
mediamonkeyengine=true=1096929771511873587
foobar2000=true=1009193842211299428
musiccenter=true=1224842583340089424
msedge=false=1223074808540037310
amplibraryagent=true=868974911178285056

verbose=false
debug missing player=false
#spotify-style-rp:
Expand Down
57 changes: 32 additions & 25 deletions MDRP/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ internal partial class Program

//ID, process name
//process name, enabled y/n
private static readonly Dictionary<string, bool> EnabledClients = new Dictionary<string, bool>
{
{ "music.ui", true }
};
private static readonly Dictionary<string, bool> EnabledClients = new Dictionary<string, bool>();

private static Dictionary<string, ConsoleColor> PlayerColors = new Dictionary<string, ConsoleColor>();

Expand Down Expand Up @@ -1191,31 +1188,40 @@ private static void LoadSettings()
{
//Format: executable name==display name==enabled==discord application id==console color==asset link
string execName = explodedLine[0];
string displayName = explodedLine[1];
string appid = explodedLine[3];
ConsoleColor color;
if (Enum.IsDefined(typeof(ConsoleColor), explodedLine[4]))
if (!EnabledClients.ContainsKey(execName))
{
color =
(ConsoleColor)Enum.Parse(typeof(ConsoleColor), explodedLine[4], true);
string displayName = explodedLine[1];
string appid = explodedLine[3];
ConsoleColor color;
if (Enum.IsDefined(typeof(ConsoleColor), explodedLine[4]))
{
color =
(ConsoleColor)Enum.Parse(typeof(ConsoleColor), explodedLine[4], true);
}
else
{
Functions.SendToDebugServer("The color '" + explodedLine[4] +
"' is not a valid ConsoleColor in C#. Defaulting to ConsoleColor.Gray");
color = ConsoleColor.Gray;
}

string assetLink = explodedLine[5];

EnabledClients.Add(execName, explodedLine[2].ToLower() == "true");
DefaultClients.Add(execName, new DiscordRpcClient(appid, autoEvents: false));
PlayerColors.Add(execName, color);
Aliases.Add(execName, displayName);
BigAssets.Add(execName, assetLink);
LittleAssets.Add(execName, assetLink);
Whatpeoplecallthisplayer.Add(execName, displayName);
if (!InverseWhatpeoplecallthisplayer.ContainsKey(displayName))
InverseWhatpeoplecallthisplayer.Add(displayName, execName);
ValidPlayers.Add(execName);
}
else
{
Functions.SendToDebugServer("The color '" + explodedLine[4] + "' is not a valid ConsoleColor in C#. Defaulting to ConsoleColor.Gray");
color = ConsoleColor.Gray;
Functions.SendToDebugServer("Duplicated executable on line " + iterator + ", skipping");
}

string assetLink = explodedLine[5];

DefaultClients.Add(execName, new DiscordRpcClient(appid, autoEvents: false));
PlayerColors.Add(execName, color);
Aliases.Add(execName, displayName);
BigAssets.Add(execName, assetLink);
LittleAssets.Add(execName, assetLink);
Whatpeoplecallthisplayer.Add(execName, displayName);
if (!InverseWhatpeoplecallthisplayer.ContainsKey(displayName))
InverseWhatpeoplecallthisplayer.Add(displayName, execName);
ValidPlayers.Add(execName);
}
}

Expand Down Expand Up @@ -1244,6 +1250,7 @@ private static void LoadSettings()
string firstPortion = firstPortionRaw.Trim().ToLower();
string secondPortionRaw = explodedLine.Length > 1 ? explodedLine[1] : "";
string secondPortion = secondPortionRaw.Trim().ToLower();
/*
if (ValidPlayers.Contains(firstPortion))
{
EnabledClients[firstPortionRaw] = secondPortion == "true";
Expand All @@ -1260,7 +1267,7 @@ private static void LoadSettings()
DefaultClients[InverseWhatpeoplecallthisplayer[firstPortionRaw]] =
new DiscordRpcClient(explodedLine[2], autoEvents: false);
}
else if (firstPortion == "verbose" && explodedLine.Length > 1)
else */if (firstPortion == "verbose" && explodedLine.Length > 1)
{
ScreamAtUser = secondPortion == "true";
}
Expand Down
Binary file modified MDRP/bin/Release/MDRP.exe
Binary file not shown.

0 comments on commit d1fc170

Please sign in to comment.