@@ -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===\n rpcClientUpdateInterval: { cfg . rpcThreadUpdateInt } \n kbDetectInterval: { cfg . kbThreadUpdateInt } \n startHidden: { 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 ( ) ;
0 commit comments