25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

8 달 전
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using Example.Models;
  5. using Example.Models.StaticData;
  6. using Example.Helpers;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading;
  11. using System.Threading.Tasks;
  12. using Color = System.Drawing.Color;
  13. namespace Example.Connectors
  14. {
  15. public class CheckInfo
  16. {
  17. public static ServerInfoModel BattlemetricsInfo { get; set; }
  18. private static FileSystemWatcher fileWatcher;
  19. private static string _scumLogsPath;
  20. public static void ConfirmGameOpen()
  21. {
  22. switch (UserPCSettings.gameDetection)
  23. {
  24. case true:
  25. {
  26. }
  27. break;
  28. }
  29. }
  30. public async static Task ConfirmServerWhaleyServerConnection()
  31. {
  32. if (UserPCSettings.gameDetection)
  33. {
  34. switch (UserPCSettings.serverConnection)
  35. {
  36. case false:
  37. {
  38. if (CreateCategoryLists.CreatedCategoryList.Count != 0)
  39. {
  40. CreateCategoryLists.CreatedCategoryList.Clear();
  41. CreateTaxiList._TaxiList.Clear();
  42. CreateSquad.SquadMembersInfo.Clear();
  43. }
  44. }
  45. break;
  46. case true:
  47. {
  48. if (GetLogedInServer._currentServerLoggedOn.status == false)
  49. {
  50. Form1Module.OverlayCanOpen = "Off";
  51. Form1Module.OverlayCanOpenForecolor = Color.Red;
  52. Form1Module.OverlayCanOpenBackcolor = Color.DarkGray;
  53. Thread.Sleep(1000);
  54. await GetLogedInServer.LoadServerData(UserPCSettings.activeSteamID);
  55. }
  56. else
  57. {
  58. var serverChanged = await IfServerAsChanged();
  59. if (serverChanged == true)
  60. {
  61. await GetPlayerInfo.LoadPlayerData(UserPCSettings.activeSteamID, GetLogedInServer._currentServerLoggedOn.serverID);
  62. await ConfirmPlayerIsLinked();
  63. }
  64. else
  65. {
  66. if (GetLogedInServer._currentServerLoggedOn != null)
  67. {
  68. if (GetLogedInServer._currentServerLoggedOn.serverID != null || GetLogedInServer._currentServerLoggedOn.serverID != string.Empty)
  69. {
  70. await GetPlayerInfo.LoadPlayerData(UserPCSettings.activeSteamID, GetLogedInServer._currentServerLoggedOn.serverID);
  71. await ConfirmPlayerIsLinked();
  72. }
  73. }
  74. else
  75. {
  76. Thread.Sleep(10000);
  77. await IfServerAsChanged();
  78. }
  79. }
  80. }
  81. }
  82. break;
  83. }
  84. }
  85. }
  86. public async static Task ConfirmPlayerIsLinked()
  87. {
  88. if (UserPCSettings.serverConnection)
  89. {
  90. switch (GetLogedInServer._currentServerLoggedOn.status)
  91. {
  92. case false:
  93. {
  94. Form1Module.WarningMsg = "Info: Unable to load Information please login into a WhalleyBot supported server!";
  95. Form1Module.OverlayCanOpen = "Off";
  96. Form1Module.OverlayCanOpenForecolor = Color.Red;
  97. Form1Module.OverlayCanOpenBackcolor = Color.DarkGray;
  98. Form1Module.OverlayCanOpenCheckBox = false;
  99. Form1Module.CurrentServer = "0";
  100. Thread.Sleep(1000);
  101. CreateCategoryLists.CreatedCategoryList.Clear();
  102. CreateTaxiList._TaxiList.Clear();
  103. CreateSquad.SquadMembersInfo.Clear();
  104. await GetLogedInServer.LoadServerData(UserPCSettings.activeSteamID);
  105. }
  106. break;
  107. case true:
  108. {
  109. if (GetPlayerInfo.PlayerDetails.isLinked)
  110. {
  111. if (CreateCategoryLists.CreatedCategoryList.Count == 0)
  112. {
  113. await CreateCategoryLists.GetPacksList();
  114. await CreateTaxiList.GetTaxiList();
  115. Thread.Sleep(100);
  116. Form1Module.OverlayCanOpenCheckBox = true;
  117. }
  118. await CreateSquad.GetSquadmembers();
  119. }
  120. else
  121. {
  122. Form1Module.WarningMsg = "INFO - Please Visit Server's Discord to request your WelcomePack! Thank you.";
  123. Form1Module.OverlayCanOpen = "Off";
  124. Form1Module.OverlayCanOpenBackcolor = Color.DarkGray;
  125. Form1Module.OverlayCanOpenForecolor = Color.Red;
  126. Form1Module.OverlayCanOpenCheckBox = false;
  127. ConfirmServerWhaleyServerConnection();
  128. }
  129. }
  130. break;
  131. }
  132. }
  133. }
  134. public async static Task<bool> IfServerAsChanged()
  135. {
  136. switch (Form1Module.CurrentServer != GetLogedInServer._currentServerLoggedOn.serverID)
  137. {
  138. case false:
  139. {
  140. if (UserPCSettings.serverConnection)
  141. {
  142. Thread.Sleep(10000);
  143. await GetLogedInServer.LoadServerData(UserPCSettings.activeSteamID);
  144. }
  145. return false;
  146. }
  147. case true:
  148. {
  149. Form1Module.OverlayCanOpen = "Loading...";
  150. Form1Module.OverlayCanOpenBackcolor = Color.DarkGray;
  151. Form1Module.OverlayCanOpenForecolor = Color.Yellow;
  152. if (CreateCategoryLists.CreatedCategoryList.Count != 0)
  153. {
  154. CreateCategoryLists.CreatedCategoryList.Clear();
  155. CreateTaxiList._TaxiList.Clear();
  156. CreateSquad.SquadMembersInfo.Clear();
  157. }
  158. Thread.Sleep(10000);
  159. await GetLogedInServer.LoadServerData(UserPCSettings.activeSteamID);
  160. Form1Module.CurrentServer = GetLogedInServer._currentServerLoggedOn.serverID;
  161. return true;
  162. }
  163. }
  164. return false;
  165. }
  166. public async static Task GetBattlemetricData()
  167. {
  168. try
  169. {
  170. var CurrentLoggedServer = await GetLogedInServer.SearchServer(UserPCSettings.joinedGameIP + ":" + UserPCSettings.joinedGamePort);
  171. List<ServerInfoModel> logged = CurrentLoggedServer.data.Where(x => x.attributes.ip == UserPCSettings.joinedGameIP && x.attributes.port == UserPCSettings.joinedGamePort).ToList();
  172. BattlemetricsInfo = logged.First();
  173. }
  174. catch (Exception ex)
  175. {
  176. Debug.WriteLine(ex.Source + ex.Message + ex.Data + ex.StackTrace);
  177. }
  178. }
  179. // Initialize the FileSystemWatcher in your setup or initialization code
  180. public static void InitializeReadingScumLogFile()
  181. {
  182. //fileCreatedDate = File.GetCreationTime(UserPCSettings.gameLogsPath);
  183. //if (DateTime.Now.AddMinutes(1) > fileCreatedDate)
  184. //{
  185. // Add your logic to read the newly added lines in the log file here
  186. using (var file = File.Open(UserPCSettings.gameLogsPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
  187. {
  188. if (UserPCSettings._scumLogPathPosition == file.Length)
  189. return;
  190. if (UserPCSettings._scumLogPathPosition > file.Length)
  191. {
  192. UserPCSettings._scumLogPathPosition = 0;
  193. return;
  194. }
  195. file.Position = UserPCSettings._scumLogPathPosition;
  196. //using (var reader = new StreamReader(file))
  197. //{
  198. // string line;
  199. // while ((line = reader.ReadLine()) != null)
  200. // {
  201. // if (!string.IsNullOrEmpty(line))
  202. // {
  203. // if (line.Contains("[LogEOSAnalytics] Start Session"))
  204. // {
  205. // Form1Module.lbl_Main_GameOpen = "Game Loading";
  206. // UserPCSettings.serverConnection = false;
  207. // Form1Module.lbl_Main_ServerConnection = "Waiting...";
  208. // }
  209. // else if (line.Contains("LogEOS: [LogEOSMessaging] Succesfully connected to Stomp."))
  210. // {
  211. // Form1Module.lbl_Main_GameOpen = "At main menu";
  212. // UserPCSettings._scumAtMainMenu = true;
  213. // Form1Module.lbl_Main_ServerConnection = "Waiting...";
  214. // }
  215. // else if (line.Contains("LogSCUM: Starting multiplayer game on "))
  216. // {
  217. // try
  218. // {
  219. // var GetServerIp = line.Split("LogSCUM: ")[1].Replace("Starting multiplayer game on ", "").Replace(" with response port ", "|").Split(":");
  220. // UserPCSettings.joinedGameIP = GetServerIp[0];
  221. // UserPCSettings.joinedGamePort = GetServerIp[1].Split("|")[1];
  222. // UserPCSettings._scumAtMainMenu = false;
  223. // Form1Module.lbl_Main_ServerConnection = "Connecting";
  224. // Form1Module.lbl_Main_GameOpen = "Online";
  225. // }
  226. // catch (Exception ex)
  227. // {
  228. // Console.WriteLine(ex.Message);
  229. // }
  230. // }
  231. // else if (line.Contains("LogSCUM: APrisoner::HandlePossessedBy:"))
  232. // {
  233. // UserPCSettings.serverConnection = true;
  234. // SetThreadStatus.dochecks = 2;
  235. // Form1Module.ShowInventoryOverlayButton = 2;
  236. // Form1Module.lbl_Main_ServerConnection = "Connected";
  237. // Form1Module.lbl_Main_GameOpen = "Online";
  238. // }
  239. // else if (line.Contains("LogNet: UNetConnection::Close: [UNetConnection] RemoteAddr:"))
  240. // {
  241. // UserPCSettings.serverConnection = false;
  242. // Form1Module.lbl_Main_ServerConnection = "Waiting...";
  243. // Form1Module.lbl_Main_GameOpen = "At main menu";
  244. // }
  245. // else if (line.Contains("LogViewport: Display: Viewport MouseLockMode Changed, LockOnCapture -> LockAlways")/*&& line.Contains("LogViewport: Display: Viewport MouseCaptureMode Changed, CapturePermanently->CaptureDuringMouseDown")*/)
  246. // {
  247. // try
  248. // {
  249. // var showoverlayButton = line.Split("][")[1].Replace("]LogViewport: Display: Viewport MouseCaptureMode Changed, CapturePermanently -> CaptureDuringMouseDown", "");
  250. // if (Form1Module.num != showoverlayButton)
  251. // {
  252. // Form1Module.ShowInventoryOverlayButton = 1;
  253. // }
  254. // Form1Module.num = showoverlayButton;
  255. // }
  256. // catch (Exception ex)
  257. // {
  258. // Debug.WriteLine(ex.Message);
  259. // }
  260. // }
  261. // else if (line.Contains("LogViewport: Display: Viewport MouseLockMode Changed, LockAlways -> LockOnCapture")/*&& line.Contains("LogViewport: Display: Viewport MouseCaptureMode Changed, NoCapture -> CapturePermanently")*/)
  262. // {
  263. // try
  264. // {
  265. // var showoverlayButton = line.Split("][")[1].Replace("]LogViewport: Display: Viewport MouseLockMode Changed, LockAlways -> LockOnCapture", "");
  266. // if (Form1Module.num != showoverlayButton)
  267. // {
  268. // Form1Module.ShowInventoryOverlayButton = 0;
  269. // }
  270. // Form1Module.num = showoverlayButton;
  271. // }
  272. // catch (Exception ex)
  273. // {
  274. // Debug.WriteLine(ex.Message);
  275. // }
  276. // }
  277. // else if (line.Contains("LogViewport: Display: Viewport MouseLockMode Changed, LockOnCapture -> DoNotLock")/*&& line.Contains("LogViewport: Display: Viewport MouseCaptureMode Changed, NoCapture -> CapturePermanently")*/)
  278. // {
  279. // try
  280. // {
  281. // var showoverlayButton = line.Split("][")[1].Replace("]LogViewport: Display: Viewport MouseLockMode Changed, LockOnCapture -> DoNotLock", "");
  282. // if (Form1Module.num != showoverlayButton)
  283. // {
  284. // Form1Module.ShowSquadMembers = true;
  285. // }
  286. // Form1Module.num = showoverlayButton;
  287. // }
  288. // catch (Exception ex)
  289. // {
  290. // Debug.WriteLine(ex.Message);
  291. // }
  292. // }
  293. // else if (line.Contains("LogViewport: Display: Player bShowMouseCursor Changed, False -> True")/*&& line.Contains("LogViewport: Display: Viewport MouseCaptureMode Changed, NoCapture -> CapturePermanently")*/)
  294. // {
  295. // try
  296. // {
  297. // var showoverlayButton = line.Split("][")[1].Replace("]LogViewport: Display: Player bShowMouseCursor Changed, False -> True", "");
  298. // if (Form1Module.num == showoverlayButton)
  299. // {
  300. // Form1Module.ShowSquadMembers = false;
  301. // }
  302. // Form1Module.num = showoverlayButton;
  303. // }
  304. // catch (Exception ex)
  305. // {
  306. // Debug.WriteLine(ex.Message);
  307. // }
  308. // }
  309. // else if (line.Contains("LogViewport: Display: Viewport MouseLockMode Changed, DoNotLock -> LockOnCapture")/*&& line.Contains("LogViewport: Display: Viewport MouseCaptureMode Changed, NoCapture -> CapturePermanently")*/)
  310. // {
  311. // try
  312. // {
  313. // var showoverlayButton = line.Split("][")[1].Replace("]LogViewport: Display: Viewport MouseLockMode Changed, DoNotLock -> LockOnCapture", "");
  314. // if (Form1Module.num != showoverlayButton)
  315. // {
  316. // Form1Module.ShowSquadMembers = false;
  317. // }
  318. // Form1Module.num = showoverlayButton;
  319. // }
  320. // catch (Exception ex)
  321. // {
  322. // Debug.WriteLine(ex.Message);
  323. // }
  324. // }
  325. // else if (line.Contains("LogExit: Exiting."))
  326. // {
  327. // UserPCSettings.serverConnection = false;
  328. // Form1Module.lbl_Main_ServerConnection = "Offline";
  329. // Form1Module.lbl_Main_GameOpen = "Game Closed";
  330. // UserPCSettings.gameDetection = false;
  331. // }
  332. // }
  333. // UserPCSettings._scumLogPathPosition = file.Position;
  334. // }
  335. //}
  336. }
  337. Thread.Sleep(10);
  338. }
  339. }
  340. }