Skip to content

Commit e4ba24b

Browse files
committed
Added application config (v1.1)
1 parent 48607ab commit e4ba24b

20 files changed

Lines changed: 183 additions & 65 deletions

.vs/Multi-DiscordRPC/v16/.suo

26 KB
Binary file not shown.

Multi-DiscordRPC/Multi-DiscordRPC.csproj

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,21 @@
1212
<FileAlignment>512</FileAlignment>
1313
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
1414
<Deterministic>true</Deterministic>
15+
<PublishUrl>publish\</PublishUrl>
16+
<Install>true</Install>
17+
<InstallFrom>Disk</InstallFrom>
18+
<UpdateEnabled>false</UpdateEnabled>
19+
<UpdateMode>Foreground</UpdateMode>
20+
<UpdateInterval>7</UpdateInterval>
21+
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
22+
<UpdatePeriodically>false</UpdatePeriodically>
23+
<UpdateRequired>false</UpdateRequired>
24+
<MapFileExtensions>true</MapFileExtensions>
25+
<ApplicationRevision>0</ApplicationRevision>
26+
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
27+
<IsWebBootstrapper>false</IsWebBootstrapper>
28+
<UseApplicationTrust>false</UseApplicationTrust>
29+
<BootstrapperEnabled>true</BootstrapperEnabled>
1530
</PropertyGroup>
1631
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1732
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -53,6 +68,8 @@
5368
<Reference Include="System.Xml" />
5469
</ItemGroup>
5570
<ItemGroup>
71+
<Compile Include="cConfig.cs" />
72+
<Compile Include="dRpcApplication.cs" />
5673
<Compile Include="Program.cs" />
5774
<Compile Include="Properties\AssemblyInfo.cs" />
5875
</ItemGroup>
@@ -63,5 +80,17 @@
6380
<ItemGroup>
6481
<Content Include="icon.ico" />
6582
</ItemGroup>
83+
<ItemGroup>
84+
<BootstrapperPackage Include=".NETFramework,Version=v4.7.2">
85+
<Visible>False</Visible>
86+
<ProductName>Microsoft .NET Framework 4.7.2 %28x86 and x64%29</ProductName>
87+
<Install>true</Install>
88+
</BootstrapperPackage>
89+
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
90+
<Visible>False</Visible>
91+
<ProductName>.NET Framework 3.5 SP1</ProductName>
92+
<Install>false</Install>
93+
</BootstrapperPackage>
94+
</ItemGroup>
6695
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
6796
</Project>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<PublishUrlHistory>publish\</PublishUrlHistory>
5+
<InstallUrlHistory />
6+
<SupportUrlHistory />
7+
<UpdateUrlHistory />
8+
<BootstrapperUrlHistory />
9+
<ErrorReportUrlHistory />
10+
<FallbackCulture>en-US</FallbackCulture>
11+
<VerifyUploadedFiles>false</VerifyUploadedFiles>
12+
</PropertyGroup>
13+
</Project>

Multi-DiscordRPC/Program.cs

Lines changed: 19 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -14,69 +14,9 @@ namespace Multi_DiscordRPC
1414
public static class AppInfo
1515
{
1616
public static string appName = "Multi Discord RPC";
17-
public static string appVersion = "1.0";
17+
public static string appVersion = "1.1";
1818
public static string appAuthor = "Bonk";
1919
}
20-
public class dRPCApplication
21-
{
22-
[JsonProperty("state")]
23-
/// <summary>
24-
/// Bottom Text
25-
/// </summary>
26-
public string sState;
27-
[JsonProperty("details")]
28-
/// <summary>
29-
/// Top Text
30-
/// </summary>
31-
public string sDetails;
32-
33-
[JsonProperty("large_img_key")]
34-
public string sLargeImgKey;
35-
36-
[JsonProperty("small_img_key")]
37-
public string sSmallImgKey;
38-
39-
[JsonProperty("large_img_text")]
40-
public string sLargeImgText;
41-
42-
[JsonProperty("small_img_text")]
43-
public string sSmallImgText;
44-
45-
[JsonProperty("proc_name")]
46-
public string sProcessName; /* No Extension */
47-
48-
[JsonProperty("app_id")]
49-
public string sAppId;
50-
51-
[JsonProperty("app_name")]
52-
public string sAppName;
53-
/// <summary>
54-
/// Class for storing defined discord Apps/RPC Data (JSON Friendly)
55-
/// </summary>
56-
/// <param name="mState">Bottom Text of RPresence</param>
57-
/// <param name="mDetails">Top Text of RPresence</param>
58-
/// <param name="mLargeImgKey">Primary image name</param>
59-
/// <param name="mSmallImgKey">Secondary image name</param>
60-
/// <param name="mLargeImgText">Text when hovering on primary image</param>
61-
/// <param name="mSmallImgText">Text when hovering on secondary image</param>
62-
/// <param name="mProcessName">Process name to look for (No Extension)</param>
63-
/// <param name="mAppId">Application ID</param>
64-
public dRPCApplication(string mDetails = null, string mState = null, string mLargeImgKey = null,
65-
string mSmallImgKey = null, string mLargeImgText = null, string mSmallImgText = null, string mProcessName = null, string mAppId = null, string mAppName = null)
66-
{
67-
sState = mState;
68-
sDetails = mDetails;
69-
sLargeImgKey = mLargeImgKey;
70-
sSmallImgKey = mSmallImgKey;
71-
sLargeImgText = mLargeImgText;
72-
sSmallImgText = mSmallImgText;
73-
74-
sProcessName = mProcessName;
75-
sAppId = mAppId;
76-
77-
sAppName = mAppName;
78-
}
79-
}
8020
class Program
8121
{
8222
static void pPrint(string text, ConsoleColor fg, ConsoleColor bg = ConsoleColor.Black)
@@ -96,6 +36,8 @@ static void pPrint(string text, ConsoleColor fg, ConsoleColor bg = ConsoleColor.
9636
static Thread thr_ProcessDetection;
9737
static bool bConsoleHidden = false;
9838

39+
public static cConfig cfg;
40+
9941
static void setCurrentRPCApp(dRPCApplication app, bool reInit = true)
10042
{
10143
pPrint($"[I] Setting RPresence to: '{app.sAppName}'...", ConsoleColor.DarkYellow);
@@ -174,7 +116,7 @@ static void rpcProcessHandler()
174116
pPrint($"[I] Application '{app.sAppName}' (Process: '{app.sProcessName}.exe') appears to be closed. Clearing Presence...", ConsoleColor.DarkYellow);
175117
}
176118
}
177-
Thread.Sleep(2000);
119+
Thread.Sleep(cfg.rpcThreadUpdateInt);
178120
}
179121
}
180122

@@ -218,7 +160,7 @@ static void keyStateHandler()
218160
setConsoleState(nApiWindowState.SW_SHOW);
219161
}
220162
}
221-
Thread.Sleep(150);
163+
Thread.Sleep(cfg.kbThreadUpdateInt);
222164
}
223165
}
224166
class ConsoleLoggerFormatted : ILogger
@@ -312,6 +254,20 @@ static Task setRPCApps()
312254

313255
async Task MainAsync()
314256
{
257+
try
258+
{
259+
cfg = JsonConvert.DeserializeObject<cConfig>(File.ReadAllText(Environment.CurrentDirectory + "\\config.json"));
260+
}
261+
catch (Exception e)
262+
{
263+
pPrint("[E] Failed to read config! Using defaults.", ConsoleColor.Red);
264+
cfg = new cConfig(2000, 150, false);
265+
}
266+
pPrint($"===APP CONFIG===\nrpcClientUpdateInterval: {cfg.rpcThreadUpdateInt}\nkbDetectInterval: {cfg.kbThreadUpdateInt}\nstartHidden: {cfg.isHidden}\n================", ConsoleColor.Cyan);
267+
if (cfg.isHidden)
268+
{
269+
setConsoleState(nApiWindowState.SW_HIDE);
270+
}
315271
AppDomain.CurrentDomain.ProcessExit += new EventHandler(cDomain_onProcessExit);
316272
await setRPCApps();
317273
await InitializeRpcClient();
1 KB
Binary file not shown.
6 KB
Binary file not shown.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"app_name": "Google Chrome",
3+
"app_id": "{APPLICATION ID}",
4+
"proc_name": "chrome",
5+
6+
"details": "Watching Youtube",
7+
"state": "I don't know",
8+
"large_img_key": "{LARGE ICON}",
9+
"large_img_text": "Oh hello!",
10+
"small_img_key": "{SMALL ICON}",
11+
"small_img_text": "Cats!"
12+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"rpcThreadUpdateInterval": 2000,
3+
"kbThreadDetectInterval": 150,
4+
"startHidden": false
5+
}
1 KB
Binary file not shown.
6 KB
Binary file not shown.

0 commit comments

Comments
 (0)