|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379 |
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using Example.Models;
- using Example.Models.StaticData;
- using Example.Helpers;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using Color = System.Drawing.Color;
-
- namespace Example.Connectors
- {
- public class CheckInfo
- {
- public static ServerInfoModel BattlemetricsInfo { get; set; }
- private static FileSystemWatcher fileWatcher;
- private static string _scumLogsPath;
- public static void ConfirmGameOpen()
- {
- switch (UserPCSettings.gameDetection)
- {
- case true:
- {
- }
- break;
- }
- }
-
- public async static Task ConfirmServerWhaleyServerConnection()
- {
- if (UserPCSettings.gameDetection)
- {
- switch (UserPCSettings.serverConnection)
- {
- case false:
- {
- if (CreateCategoryLists.CreatedCategoryList.Count != 0)
- {
- CreateCategoryLists.CreatedCategoryList.Clear();
- CreateTaxiList._TaxiList.Clear();
- CreateSquad.SquadMembersInfo.Clear();
- }
- }
- break;
-
- case true:
- {
- if (GetLogedInServer._currentServerLoggedOn.status == false)
- {
- Form1Module.OverlayCanOpen = "Off";
- Form1Module.OverlayCanOpenForecolor = Color.Red;
- Form1Module.OverlayCanOpenBackcolor = Color.DarkGray;
- Thread.Sleep(1000);
- await GetLogedInServer.LoadServerData(UserPCSettings.activeSteamID);
- }
- else
- {
- var serverChanged = await IfServerAsChanged();
- if (serverChanged == true)
- {
- await GetPlayerInfo.LoadPlayerData(UserPCSettings.activeSteamID, GetLogedInServer._currentServerLoggedOn.serverID);
- await ConfirmPlayerIsLinked();
-
- }
- else
- {
- if (GetLogedInServer._currentServerLoggedOn != null)
- {
- if (GetLogedInServer._currentServerLoggedOn.serverID != null || GetLogedInServer._currentServerLoggedOn.serverID != string.Empty)
- {
- await GetPlayerInfo.LoadPlayerData(UserPCSettings.activeSteamID, GetLogedInServer._currentServerLoggedOn.serverID);
-
- await ConfirmPlayerIsLinked();
- }
- }
- else
- {
- Thread.Sleep(10000);
- await IfServerAsChanged();
- }
- }
- }
- }
- break;
- }
- }
-
-
- }
-
- public async static Task ConfirmPlayerIsLinked()
- {
- if (UserPCSettings.serverConnection)
- {
- switch (GetLogedInServer._currentServerLoggedOn.status)
- {
- case false:
- {
- Form1Module.WarningMsg = "Info: Unable to load Information please login into a WhalleyBot supported server!";
- Form1Module.OverlayCanOpen = "Off";
- Form1Module.OverlayCanOpenForecolor = Color.Red;
- Form1Module.OverlayCanOpenBackcolor = Color.DarkGray;
- Form1Module.OverlayCanOpenCheckBox = false;
- Form1Module.CurrentServer = "0";
- Thread.Sleep(1000);
- CreateCategoryLists.CreatedCategoryList.Clear();
- CreateTaxiList._TaxiList.Clear();
- CreateSquad.SquadMembersInfo.Clear();
- await GetLogedInServer.LoadServerData(UserPCSettings.activeSteamID);
- }
- break;
-
- case true:
- {
- if (GetPlayerInfo.PlayerDetails.isLinked)
- {
-
- if (CreateCategoryLists.CreatedCategoryList.Count == 0)
- {
-
- await CreateCategoryLists.GetPacksList();
- await CreateTaxiList.GetTaxiList();
- Thread.Sleep(100);
- Form1Module.OverlayCanOpenCheckBox = true;
- }
- await CreateSquad.GetSquadmembers();
-
- }
- else
- {
- Form1Module.WarningMsg = "INFO - Please Visit Server's Discord to request your WelcomePack! Thank you.";
- Form1Module.OverlayCanOpen = "Off";
- Form1Module.OverlayCanOpenBackcolor = Color.DarkGray;
- Form1Module.OverlayCanOpenForecolor = Color.Red;
- Form1Module.OverlayCanOpenCheckBox = false;
- ConfirmServerWhaleyServerConnection();
- }
- }
- break;
- }
- }
- }
- public async static Task<bool> IfServerAsChanged()
- {
- switch (Form1Module.CurrentServer != GetLogedInServer._currentServerLoggedOn.serverID)
- {
- case false:
- {
- if (UserPCSettings.serverConnection)
- {
- Thread.Sleep(10000);
- await GetLogedInServer.LoadServerData(UserPCSettings.activeSteamID);
- }
- return false;
- }
-
- case true:
- {
- Form1Module.OverlayCanOpen = "Loading...";
- Form1Module.OverlayCanOpenBackcolor = Color.DarkGray;
- Form1Module.OverlayCanOpenForecolor = Color.Yellow;
- if (CreateCategoryLists.CreatedCategoryList.Count != 0)
- {
- CreateCategoryLists.CreatedCategoryList.Clear();
- CreateTaxiList._TaxiList.Clear();
- CreateSquad.SquadMembersInfo.Clear();
- }
- Thread.Sleep(10000);
- await GetLogedInServer.LoadServerData(UserPCSettings.activeSteamID);
- Form1Module.CurrentServer = GetLogedInServer._currentServerLoggedOn.serverID;
- return true;
- }
- }
- return false;
- }
-
- public async static Task GetBattlemetricData()
- {
- try
- {
- var CurrentLoggedServer = await GetLogedInServer.SearchServer(UserPCSettings.joinedGameIP + ":" + UserPCSettings.joinedGamePort);
- List<ServerInfoModel> logged = CurrentLoggedServer.data.Where(x => x.attributes.ip == UserPCSettings.joinedGameIP && x.attributes.port == UserPCSettings.joinedGamePort).ToList();
- BattlemetricsInfo = logged.First();
- }
- catch (Exception ex)
- {
- Debug.WriteLine(ex.Source + ex.Message + ex.Data + ex.StackTrace);
- }
-
- }
-
-
-
-
- // Initialize the FileSystemWatcher in your setup or initialization code
- public static void InitializeReadingScumLogFile()
- {
-
- //fileCreatedDate = File.GetCreationTime(UserPCSettings.gameLogsPath);
-
- //if (DateTime.Now.AddMinutes(1) > fileCreatedDate)
- //{
- // Add your logic to read the newly added lines in the log file here
- using (var file = File.Open(UserPCSettings.gameLogsPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
- {
- if (UserPCSettings._scumLogPathPosition == file.Length)
- return;
- if (UserPCSettings._scumLogPathPosition > file.Length)
- {
- UserPCSettings._scumLogPathPosition = 0;
- return;
- }
-
-
- file.Position = UserPCSettings._scumLogPathPosition;
- //using (var reader = new StreamReader(file))
- //{
- // string line;
- // while ((line = reader.ReadLine()) != null)
- // {
- // if (!string.IsNullOrEmpty(line))
- // {
- // if (line.Contains("[LogEOSAnalytics] Start Session"))
- // {
- // Form1Module.lbl_Main_GameOpen = "Game Loading";
- // UserPCSettings.serverConnection = false;
- // Form1Module.lbl_Main_ServerConnection = "Waiting...";
- // }
- // else if (line.Contains("LogEOS: [LogEOSMessaging] Succesfully connected to Stomp."))
- // {
- // Form1Module.lbl_Main_GameOpen = "At main menu";
- // UserPCSettings._scumAtMainMenu = true;
- // Form1Module.lbl_Main_ServerConnection = "Waiting...";
- // }
- // else if (line.Contains("LogSCUM: Starting multiplayer game on "))
- // {
- // try
- // {
- // var GetServerIp = line.Split("LogSCUM: ")[1].Replace("Starting multiplayer game on ", "").Replace(" with response port ", "|").Split(":");
- // UserPCSettings.joinedGameIP = GetServerIp[0];
- // UserPCSettings.joinedGamePort = GetServerIp[1].Split("|")[1];
- // UserPCSettings._scumAtMainMenu = false;
- // Form1Module.lbl_Main_ServerConnection = "Connecting";
-
- // Form1Module.lbl_Main_GameOpen = "Online";
- // }
- // catch (Exception ex)
- // {
- // Console.WriteLine(ex.Message);
- // }
-
- // }
- // else if (line.Contains("LogSCUM: APrisoner::HandlePossessedBy:"))
- // {
- // UserPCSettings.serverConnection = true;
- // SetThreadStatus.dochecks = 2;
- // Form1Module.ShowInventoryOverlayButton = 2;
- // Form1Module.lbl_Main_ServerConnection = "Connected";
-
- // Form1Module.lbl_Main_GameOpen = "Online";
- // }
- // else if (line.Contains("LogNet: UNetConnection::Close: [UNetConnection] RemoteAddr:"))
- // {
- // UserPCSettings.serverConnection = false;
- // Form1Module.lbl_Main_ServerConnection = "Waiting...";
- // Form1Module.lbl_Main_GameOpen = "At main menu";
- // }
- // else if (line.Contains("LogViewport: Display: Viewport MouseLockMode Changed, LockOnCapture -> LockAlways")/*&& line.Contains("LogViewport: Display: Viewport MouseCaptureMode Changed, CapturePermanently->CaptureDuringMouseDown")*/)
- // {
- // try
- // {
- // var showoverlayButton = line.Split("][")[1].Replace("]LogViewport: Display: Viewport MouseCaptureMode Changed, CapturePermanently -> CaptureDuringMouseDown", "");
- // if (Form1Module.num != showoverlayButton)
- // {
- // Form1Module.ShowInventoryOverlayButton = 1;
- // }
- // Form1Module.num = showoverlayButton;
- // }
- // catch (Exception ex)
- // {
- // Debug.WriteLine(ex.Message);
- // }
-
- // }
- // else if (line.Contains("LogViewport: Display: Viewport MouseLockMode Changed, LockAlways -> LockOnCapture")/*&& line.Contains("LogViewport: Display: Viewport MouseCaptureMode Changed, NoCapture -> CapturePermanently")*/)
- // {
- // try
- // {
- // var showoverlayButton = line.Split("][")[1].Replace("]LogViewport: Display: Viewport MouseLockMode Changed, LockAlways -> LockOnCapture", "");
- // if (Form1Module.num != showoverlayButton)
- // {
- // Form1Module.ShowInventoryOverlayButton = 0;
- // }
- // Form1Module.num = showoverlayButton;
- // }
- // catch (Exception ex)
- // {
- // Debug.WriteLine(ex.Message);
-
- // }
- // }
- // else if (line.Contains("LogViewport: Display: Viewport MouseLockMode Changed, LockOnCapture -> DoNotLock")/*&& line.Contains("LogViewport: Display: Viewport MouseCaptureMode Changed, NoCapture -> CapturePermanently")*/)
- // {
- // try
- // {
- // var showoverlayButton = line.Split("][")[1].Replace("]LogViewport: Display: Viewport MouseLockMode Changed, LockOnCapture -> DoNotLock", "");
- // if (Form1Module.num != showoverlayButton)
- // {
- // Form1Module.ShowSquadMembers = true;
- // }
- // Form1Module.num = showoverlayButton;
- // }
- // catch (Exception ex)
- // {
- // Debug.WriteLine(ex.Message);
-
- // }
- // }
- // else if (line.Contains("LogViewport: Display: Player bShowMouseCursor Changed, False -> True")/*&& line.Contains("LogViewport: Display: Viewport MouseCaptureMode Changed, NoCapture -> CapturePermanently")*/)
- // {
- // try
- // {
- // var showoverlayButton = line.Split("][")[1].Replace("]LogViewport: Display: Player bShowMouseCursor Changed, False -> True", "");
- // if (Form1Module.num == showoverlayButton)
- // {
- // Form1Module.ShowSquadMembers = false;
- // }
- // Form1Module.num = showoverlayButton;
- // }
- // catch (Exception ex)
- // {
- // Debug.WriteLine(ex.Message);
-
- // }
- // }
- // else if (line.Contains("LogViewport: Display: Viewport MouseLockMode Changed, DoNotLock -> LockOnCapture")/*&& line.Contains("LogViewport: Display: Viewport MouseCaptureMode Changed, NoCapture -> CapturePermanently")*/)
- // {
- // try
- // {
- // var showoverlayButton = line.Split("][")[1].Replace("]LogViewport: Display: Viewport MouseLockMode Changed, DoNotLock -> LockOnCapture", "");
- // if (Form1Module.num != showoverlayButton)
- // {
- // Form1Module.ShowSquadMembers = false;
- // }
- // Form1Module.num = showoverlayButton;
- // }
- // catch (Exception ex)
- // {
- // Debug.WriteLine(ex.Message);
-
- // }
- // }
- // else if (line.Contains("LogExit: Exiting."))
- // {
- // UserPCSettings.serverConnection = false;
- // Form1Module.lbl_Main_ServerConnection = "Offline";
- // Form1Module.lbl_Main_GameOpen = "Game Closed";
- // UserPCSettings.gameDetection = false;
- // }
-
- // }
- // UserPCSettings._scumLogPathPosition = file.Position;
-
- // }
-
-
- //}
- }
- Thread.Sleep(10);
-
-
- }
-
-
- }
- }
|