From fd3db04e626bdf14f3d03ac204843c9d596215ce Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 2 Aug 2024 20:26:25 -0400 Subject: [PATCH] V1.0.24 - Rebase (#205) * Assist Command Protocol Basic Addition Added the Basic code to add the protocol and check for admin permissions. * Temp Windows * Modification to Discord Auth/Design * Discord Auth Changes Changes towards the session ID being generated, and Time extended * Small Fix within MatchTrack Crashes * Small Fix * Possible Color Changes * Open Logs Folder Button * Minor Deceive/WSM Support * Abyss Support * New Map Name Change * Bump System.Text.Json from 8.0.3 to 8.0.4 in /Assist Bumps System.Text.Json from 8.0.3 to 8.0.4. --- updated-dependencies: - dependency-name: System.Text.Json dependency-type: direct:production ... Signed-off-by: dependabot[bot] * Fix to allow for New Range --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Assist.Shared | 2 +- Assist/App.axaml.cs | 85 +++++++- Assist/Assist.csproj | 2 +- .../AssistAccountLoginForm.axaml | 9 +- Assist/Helpers/ValorantHelper.cs | 5 +- Assist/Properties/Resources.Designer.cs | 9 + Assist/Properties/Resources.resx | 3 + .../Services/Riot/ValorantWebsocketClient.cs | 3 + Assist/Themes/Dark.axaml | 11 +- .../Assist/AssistAccountDuelFormViewModel.cs | 14 +- .../Assist/AssistAccountLoginFormViewModel.cs | 13 +- Assist/ViewModels/Game/IngamePageViewModel.cs | 23 ++- Assist/ViewModels/Game/LiveViewViewModel.cs | 182 +++++++++++++++--- .../Game/MatchTrackMatchViewModel.cs | 5 +- Assist/ViewModels/Game/MenusPageViewModel.cs | 2 + .../ViewModels/Game/PregamePageViewModel.cs | 21 ++ .../Settings/GeneralSettingsPageViewModel.cs | 16 ++ Assist/ViewModels/Startup/StartupViewModel.cs | 5 +- Assist/ViewModels/Store/StoreViewModel.cs | 2 +- Assist/Views/Extras/AssistJoinWindow.axaml | 38 ++++ Assist/Views/Extras/AssistJoinWindow.axaml.cs | 13 ++ Assist/Views/Extras/AssistLaunchWindow.axaml | 38 ++++ .../Views/Extras/AssistLaunchWindow.axaml.cs | 13 ++ Assist/Views/Game/Live/LiveView.axaml.cs | 2 +- .../Pages/GeneralSettingsPageView.axaml | 10 + .../Store/Pages/BonusStorePageView.axaml | 10 + .../Store/Pages/BonusStorePageView.axaml.cs | 13 ++ 27 files changed, 477 insertions(+), 72 deletions(-) create mode 100644 Assist/Views/Extras/AssistJoinWindow.axaml create mode 100644 Assist/Views/Extras/AssistJoinWindow.axaml.cs create mode 100644 Assist/Views/Extras/AssistLaunchWindow.axaml create mode 100644 Assist/Views/Extras/AssistLaunchWindow.axaml.cs create mode 100644 Assist/Views/Store/Pages/BonusStorePageView.axaml create mode 100644 Assist/Views/Store/Pages/BonusStorePageView.axaml.cs diff --git a/Assist.Shared b/Assist.Shared index f460db8c..f72912b7 160000 --- a/Assist.Shared +++ b/Assist.Shared @@ -1 +1 @@ -Subproject commit f460db8c731ca857aa0a9219d09c3df924ca8d1b +Subproject commit f72912b76167d88f7f545a88848d94d64bdae7eb diff --git a/Assist/App.axaml.cs b/Assist/App.axaml.cs index 201b1b28..4e4aa45f 100644 --- a/Assist/App.axaml.cs +++ b/Assist/App.axaml.cs @@ -4,6 +4,7 @@ using System.Globalization; using System.IO; using System.Runtime.InteropServices; +using System.Security.Principal; using System.Text.Json; using System.Threading; using Assist.Models.Enums; @@ -17,6 +18,7 @@ using Avalonia.Markup.Xaml; using Assist.ViewModels; using Assist.Views; +using Assist.Views.Extras; using Assist.Views.Startup; using AsyncImageLoader; using AsyncImageLoader.Loaders; @@ -24,6 +26,7 @@ using Avalonia.Styling; using Avalonia.Threading; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Win32; using Serilog; using Serilog.Sinks.SystemConsole.Themes; @@ -31,8 +34,13 @@ namespace Assist; public partial class App : Application { - - +#if DEBUG + public const string APPPROTOCOL = "assistdebug"; +#else + public const string APPPROTOCOL = "assist"; +#endif + public bool IsElevated => new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator); + public override void Initialize() { OnStartup(); @@ -46,10 +54,10 @@ public override void RegisterServices() public override void OnFrameworkInitializationCompleted() { - if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) + + if (OperatingSystem.IsWindows()) { - //desktop.Exit += OnExit; - desktop.MainWindow = new MainWindow(); + HandleWindowsDesktopInitialization(); } base.OnFrameworkInitializationCompleted(); @@ -72,11 +80,9 @@ private void OnStartup() CreateLogger(); CheckForSettings(); ImageLoader.AsyncImageLoader = new DiskCachedWebImageLoader(AssistSettings.CacheFolderPath); - + HandleProtocol(); } - - private void CreateDirectories() { Directory.CreateDirectory(GetApplicationDataFolder()); @@ -201,5 +207,68 @@ public static void ChangeLanguage() }); } + private void HandleProtocol() + { + Log.Information("Handling Protocol"); + + // First Check for Permissions of the app. + RegistryKey key = Registry.ClassesRoot.OpenSubKey(APPPROTOCOL); + if (key == null) + { + Log.Information("Key does not exist."); + if (IsElevated) + CreateAssistAppProtocol(); + else + Log.Information("No Admin Access"); + } + } + + private void HandleWindowsDesktopInitialization() + { + // args[0] is always going to be the application path. When using the protocol it will show it. + if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) + { + + + if (desktop.Args.Length <= 0) + { + desktop.MainWindow = new MainWindow(); + return; + } + + switch (desktop.Args[0].ToLower()) + { + case { } uri when uri.Contains($"{APPPROTOCOL}://launch/"): + desktop.MainWindow = new AssistLaunchWindow(); + break; + case { } uri when uri.Contains($"{APPPROTOCOL}://join/"): + desktop.MainWindow = new AssistJoinWindow(); + break; + default: + desktop.MainWindow = new MainWindow(); + break; + } + } + } + private void CreateAssistAppProtocol() + { + Log.Information("Creating Assist Protocol"); + RegistryKey key = Registry.ClassesRoot.OpenSubKey(APPPROTOCOL); + string applicationPath = Process.GetCurrentProcess().MainModule.FileName; + if (key == null) + { + + key = Registry.ClassesRoot.CreateSubKey(APPPROTOCOL); + key.SetValue(string.Empty, "URL: " + APPPROTOCOL); + key.SetValue("URL Protocol", string.Empty); + + key = key.CreateSubKey(@"shell\open\command"); + key.SetValue(string.Empty, applicationPath + " " + "%1"); + key.Close(); + } + + Log.Information("Created Assist Protocol"); + } + private static string GetApplicationDataFolder() => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "AssistData"); } \ No newline at end of file diff --git a/Assist/Assist.csproj b/Assist/Assist.csproj index b70d4bb7..a34c0190 100644 --- a/Assist/Assist.csproj +++ b/Assist/Assist.csproj @@ -49,7 +49,7 @@ - + diff --git a/Assist/Controls/Assist/Authentication/AssistAccountLoginForm.axaml b/Assist/Controls/Assist/Authentication/AssistAccountLoginForm.axaml index 172e676d..2cbeda15 100644 --- a/Assist/Controls/Assist/Authentication/AssistAccountLoginForm.axaml +++ b/Assist/Controls/Assist/Authentication/AssistAccountLoginForm.axaml @@ -6,6 +6,7 @@ xmlns:assist="clr-namespace:Assist.ViewModels.Assist" xmlns:lang="clr-namespace:Assist.Properties" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" + x:Class="Assist.Controls.Assist.Authentication.AssistAccountLoginForm"> @@ -20,12 +21,12 @@ Background="{DynamicResource AssistControlBackground}" BorderBrush="{DynamicResource AssistControlOutline}" BorderThickness="1" - CornerRadius="10" - Padding="10"> - + Padding="10" + MinWidth="250" + Height="250"> + diff --git a/Assist/Helpers/ValorantHelper.cs b/Assist/Helpers/ValorantHelper.cs index 1ec9f7f6..aa103d69 100644 --- a/Assist/Helpers/ValorantHelper.cs +++ b/Assist/Helpers/ValorantHelper.cs @@ -236,6 +236,7 @@ public class ValorantHelper {"de28aa9b-4cbe-1003-320e-6cb3ec309557",Properties.Resources.VALORANT_Piazza}, {"92584fbe-486a-b1b2-9faa-39b0f486b498",Properties.Resources.VALORANT_Sunset}, {"2c09d728-42d5-30d8-43dc-96a05cc7ee9d",Properties.Resources.VALORANT_Drift}, + {"224b0a95-48b9-f703-1bd8-67aca101a61f", Properties.Resources.VALORANT_Abyss} }; public static Dictionary MapsByPath = new Dictionary @@ -249,6 +250,7 @@ public class ValorantHelper {"/game/maps/pitt/pitt",Properties.Resources.VALORANT_Pearl}, {"/game/maps/port/port",Properties.Resources.VALORANT_Icebox}, {"/game/maps/poveglia/range",Properties.Resources.VALORANT_TheRange}, + {"/game/maps/povegliav2/rangev2",Properties.Resources.VALORANT_TheRange}, {"/game/maps/triad/triad",Properties.Resources.VALORANT_Haven}, {"/game/maps/jam/jam",Properties.Resources.VALORANT_Lotus}, {"/game/maps/hurm/hurm_alley/hurm_alley",Properties.Resources.VALORANT_District}, @@ -256,6 +258,7 @@ public class ValorantHelper {"/game/maps/hurm/hurm_yard/hurm_yard",Properties.Resources.VALORANT_Piazza}, {"/game/maps/juliett/juliett",Properties.Resources.VALORANT_Sunset}, {"/game/maps/hurm/hurm_helix/hurm_helix",Properties.Resources.VALORANT_Drift}, + {"/game/maps/infinity/infinity" , Properties.Resources.VALORANT_Abyss} }; @@ -364,7 +367,7 @@ public static string DetermineQueueKey(string codeNameQueue) case "lotus": return "Lotus"; case "newmap": - return "Sunset"; + return Properties.Resources.VALORANT_Abyss; case "premier-seasonmatch": return "Premier"; case "premier": diff --git a/Assist/Properties/Resources.Designer.cs b/Assist/Properties/Resources.Designer.cs index d63f3177..36eb29af 100644 --- a/Assist/Properties/Resources.Designer.cs +++ b/Assist/Properties/Resources.Designer.cs @@ -1481,6 +1481,15 @@ public static string Store_Store { } } + /// + /// Looks up a localized string similar to Abyss. + /// + public static string VALORANT_Abyss { + get { + return ResourceManager.GetString("VALORANT_Abyss", resourceCulture); + } + } + /// /// Looks up a localized string similar to Ascent. /// diff --git a/Assist/Properties/Resources.resx b/Assist/Properties/Resources.resx index f3551be8..b15a3883 100644 --- a/Assist/Properties/Resources.resx +++ b/Assist/Properties/Resources.resx @@ -713,6 +713,9 @@ Drift + + Abyss + Temple diff --git a/Assist/Services/Riot/ValorantWebsocketClient.cs b/Assist/Services/Riot/ValorantWebsocketClient.cs index 62d5288a..5bd7dfee 100644 --- a/Assist/Services/Riot/ValorantWebsocketClient.cs +++ b/Assist/Services/Riot/ValorantWebsocketClient.cs @@ -76,6 +76,7 @@ public async Task Connect() Log.Information("Socket is Alive"); } + ClientSocket.Send(RWS_SUBTOEVENTS); ClientSocket.Send(RWS_SUBTOEVENTS); Log.Information("Subscribing to Socket Events"); @@ -113,6 +114,8 @@ private void ClientSocketOnOnError(object? sender, ErrorEventArgs e) Log.Fatal("Websocket Error:"); Log.Fatal(e.Exception.Message); Log.Fatal(e.Exception.StackTrace); + + Connect(); } private void ClientSocketOnOnMessage(object? sender, MessageEventArgs e) diff --git a/Assist/Themes/Dark.axaml b/Assist/Themes/Dark.axaml index 2bfd3db2..2fa743d3 100644 --- a/Assist/Themes/Dark.axaml +++ b/Assist/Themes/Dark.axaml @@ -4,14 +4,15 @@ #F71D51 - #0C0F0D - #D90C0F0D - #15171A + #171717 + #D9171717 + #262626 - #121514 - #232633 + #1e1e1e + #2f2f2f #FBFBFB + #A3A3A3 #151719 diff --git a/Assist/ViewModels/Assist/AssistAccountDuelFormViewModel.cs b/Assist/ViewModels/Assist/AssistAccountDuelFormViewModel.cs index 45ceb8ed..ec69dbb2 100644 --- a/Assist/ViewModels/Assist/AssistAccountDuelFormViewModel.cs +++ b/Assist/ViewModels/Assist/AssistAccountDuelFormViewModel.cs @@ -39,7 +39,7 @@ public async Task DiscordOAuthCommand() IsProcessing = true; Log.Information("Creating Custom State"); - var bytes = new byte[16]; + var bytes = new byte[new Random().NextInt64(16,64)]; using (var rng = new RNGCryptoServiceProvider()) { rng.GetBytes(bytes); @@ -47,13 +47,13 @@ public async Task DiscordOAuthCommand() string hash1 = BitConverter.ToString(bytes); - var state = string.Concat(hash1, MotionCat.GetHardwareId()); + var randHash = hash1.Replace("-", ""); Log.Information("Opening Discord Window"); - - OpenDiscordOAuth(state); + Log.Information("Session Code: " + randHash); + OpenDiscordOAuth(randHash); - await CheckForClientUpdate(state); + await CheckForClientUpdate(randHash); } [RelayCommand] @@ -133,9 +133,11 @@ private void OpenDiscordOAuth(string state) private async Task CheckForClientUpdate(string stateCode) { + AssistTokens? tokens = null; for (int i = 0; i < 20; i++) { + await Task.Delay(5000); if (RequestedCancel) { RequestedCancel = false; @@ -152,7 +154,7 @@ private async Task CheckForClientUpdate(string stateCode) { Log.Error($"Failed to get Client on try {i} : {e.Message}"); } - await Task.Delay(3000); + } if (tokens is null) diff --git a/Assist/ViewModels/Assist/AssistAccountLoginFormViewModel.cs b/Assist/ViewModels/Assist/AssistAccountLoginFormViewModel.cs index e1d7fe47..160e20e6 100644 --- a/Assist/ViewModels/Assist/AssistAccountLoginFormViewModel.cs +++ b/Assist/ViewModels/Assist/AssistAccountLoginFormViewModel.cs @@ -38,7 +38,7 @@ public async Task DiscordOAuthCommand() IsProcessing = true; Log.Information("Creating Custom State"); - var bytes = new byte[16]; + var bytes = new byte[new Random().NextInt64(16,64)]; using (var rng = new RNGCryptoServiceProvider()) { rng.GetBytes(bytes); @@ -46,13 +46,13 @@ public async Task DiscordOAuthCommand() string hash1 = BitConverter.ToString(bytes); - var state = string.Concat(hash1, MotionCat.GetHardwareId()); + var randHash = hash1.Replace("-", ""); Log.Information("Opening Discord Window"); - - OpenDiscordOAuth(state); + Log.Information("Session Code: " + randHash); + OpenDiscordOAuth(randHash); - await CheckForClientUpdate(state); + await CheckForClientUpdate(randHash); } [RelayCommand] @@ -116,6 +116,7 @@ private async Task CheckForClientUpdate(string stateCode) AssistTokens? tokens = null; for (int i = 0; i < 20; i++) { + await Task.Delay(5000); if (RequestedCancel) { RequestedCancel = false; @@ -132,7 +133,7 @@ private async Task CheckForClientUpdate(string stateCode) { Log.Error($"Failed to get Client on try {i} : {e.Message}"); } - await Task.Delay(3000); + } if (tokens is null) diff --git a/Assist/ViewModels/Game/IngamePageViewModel.cs b/Assist/ViewModels/Game/IngamePageViewModel.cs index d2a78ea9..d159d8cc 100644 --- a/Assist/ViewModels/Game/IngamePageViewModel.cs +++ b/Assist/ViewModels/Game/IngamePageViewModel.cs @@ -7,8 +7,11 @@ using System.Threading.Tasks; using Assist.Controls.Game.Live; using Assist.Core.Helpers; +using Assist.Models.Enums; using Assist.Services.Assist; using Assist.Shared.Models.Assist; +using Assist.Views.Game.Live; +using Assist.Views.Game.Live.Pages; using Avalonia.Media; using Avalonia.Threading; using CommunityToolkit.Mvvm.ComponentModel; @@ -16,6 +19,7 @@ using ValNet.Objects.Coregame; using ValNet.Objects.Exceptions; using ValNet.Objects.Local; +using WebSocketSharp; namespace Assist.ViewModels.Game; @@ -132,6 +136,21 @@ public async Task UpdateData() { Log.Fatal("COREGAME TOKEN ERROR: "); await AssistApplication.RefreshService.CurrentUserOnTokensExpired(); + return; + } + + if (e.Content.Contains("match was not found", StringComparison.OrdinalIgnoreCase)) + { + try + { + var getPlayerResp = await AssistApplication.ActiveUser.CoreGame.FetchPlayer(); + LiveView._viewModel.ChangePage(new MenusPageView()); + LiveView._viewModel.CurrentPage = ELivePage.MENUS; + } + catch (Exception exception) + { + return; + } } return; @@ -255,7 +274,7 @@ private async Task HandleMatchData(CoregameMatch Match, ChatV4PresenceObj.Presen Log.Information("Getting map data for ID of: " + Match.MapID.ToLower()); MapName = ValorantHelper.MapsByPath?[Match.MapID.ToLower()].ToUpper(); - if (Match.MapID.Equals("/game/maps/poveglia/range", StringComparison.OrdinalIgnoreCase)) + if (Match.MapID.Contains("poveglia", StringComparison.OrdinalIgnoreCase)) IsRange = true; else MapImage = $"https://cdn.assistval.com/maps/{ValorantHelper.MapsByPath?[Match.MapID.ToLower()]}_Featured.png"; @@ -273,7 +292,7 @@ private async Task HandleMatchData(CoregameMatch Match, ChatV4PresenceObj.Presen // Check if the Queue is Deathmatch. IsDeathmatch = Match.MatchData.QueueID.ToLower() == "deathmatch"; - IsRange = Match.MapID.Equals("/game/maps/poveglia/range"); // this is dumb but works. + IsRange = Match.MapID.Contains("poveglia"); // this is dumb but works. QueueName = queueName.ToUpper(); try diff --git a/Assist/ViewModels/Game/LiveViewViewModel.cs b/Assist/ViewModels/Game/LiveViewViewModel.cs index 19f00792..b0cd56c8 100644 --- a/Assist/ViewModels/Game/LiveViewViewModel.cs +++ b/Assist/ViewModels/Game/LiveViewViewModel.cs @@ -40,11 +40,33 @@ private async void RiotWebsocketServiceOnUserPresenceMessageEvent(PresenceV4Mess public async Task AttemptCurrentPage() { - AssistApplication.RiotWebsocketService.UserPresenceMessageEvent += RiotWebsocketServiceOnUserPresenceMessageEvent; - var pres = await AssistApplication.ActiveUser.Presence.GetPresences(); - var user = pres.presences.Find(p => p.puuid == AssistApplication.ActiveUser.UserData.sub); - var data = await GetPresenceData(user); - await DeterminePage(data, user); + try + { + AssistApplication.RiotWebsocketService.UserPresenceMessageEvent += RiotWebsocketServiceOnUserPresenceMessageEvent; + if (AssistApplication.ActiveUser != null) + { + Log.Information("AttemptCurrentPage: Getting Presences"); + var pres = await AssistApplication.ActiveUser.Presence.GetPresences(); + Log.Information($"AttemptCurrentPage: Got Pres? {pres is not null}"); + var user = pres.presences.Find(p => p.puuid == AssistApplication.ActiveUser.UserData.sub); + Log.Information($"AttemptCurrentPage: Got User? {user is not null}"); + PlayerPresence data = null; + if (user != null) + { + Log.Information($"AttemptCurrentPage: user != null, Getting Data"); + data = await GetPresenceData(user); + Log.Information($"AttemptCurrentPage: Got Data"); + } + await DeterminePage(data, user); + } + } + catch (Exception e) + { + Log.Error("Error Attempting to find Current Page."); + Log.Error(e.Message); + Log.Error(e.StackTrace); + Log.Error(e.Source); + } } private async Task DeterminePage(PlayerPresence dataMessage, PresenceV4Message fullMessage = null) @@ -81,53 +103,153 @@ private async Task DeterminePage(PlayerPresence dataMessage, PresenceV4Message f public async Task GetPresenceData(ChatV4PresenceObj.Presence data) { + Log.Information($"GetPresenceData: Checking if Data is Null {data is null}"); if (data is null) return new PlayerPresence(); + Log.Information($"GetPresenceData: Checking string.IsNullOrEmpty(data.Private) {string.IsNullOrEmpty(data.Private)}"); if (string.IsNullOrEmpty(data.Private)) return new PlayerPresence(); + Log.Information($"GetPresenceData: Converting Data"); var stringData = Convert.FromBase64String(data.Private); var decodedString = Encoding.UTF8.GetString(stringData); + Log.Information($"GetPresenceData: Deserializing"); return JsonSerializer.Deserialize(decodedString); } - private async Task DeterminePage(PlayerPresence dataMessage, ChatV4PresenceObj.Presence fullMessage = null) + private async Task DeterminePage(PlayerPresence? dataMessage, ChatV4PresenceObj.Presence fullMessage = null) { - Dispatcher.UIThread.InvokeAsync(() => + Log.Information($"Determining Page"); + Dispatcher.UIThread.InvokeAsync(async () => { - switch (dataMessage!.sessionLoopState) + Log.Information($"Determining Page: is datamessage null? {dataMessage is null}"); + if (dataMessage != null) { - case "MENUS": - if (CurrentPage != ELivePage.MENUS) + switch (dataMessage!.sessionLoopState) + { + case "MENUS": + if (CurrentPage != ELivePage.MENUS) + { + Log.Information("Changing to Menus"); + ChangePage(new MenusPageView(fullMessage)); + CurrentPage = ELivePage.MENUS; + }; + break; + case "INGAME": + if (CurrentPage != ELivePage.INGAME) { + Log.Information("Changing to Ingame"); + ChangePage(new IngamePageView()); + CurrentPage = ELivePage.INGAME; + }; + break; + case "PREGAME": + if (CurrentPage != ELivePage.PREGAME) { + Log.Information("Changing to Pregame"); + ChangePage(new PregamePageView()); + CurrentPage = ELivePage.PREGAME; + }; + break; + default: + Log.Information("Unknown Session Loop State: " + dataMessage.sessionLoopState); + break; + } + } + + if (dataMessage is null) + { + Log.Information("USING BACKUP ON LIVEVIEWVIEWMODELPAGE"); + try + { + var test1 = await AssistApplication.ActiveUser.Pregame.GetPlayer(); + if (!string.IsNullOrEmpty(test1.MatchID)) { - ChangePage(new MenusPageView(fullMessage)); - CurrentPage = ELivePage.MENUS; - }; - break; - case "INGAME": - if (CurrentPage != ELivePage.INGAME) { - ChangePage(new IngamePageView()); - CurrentPage = ELivePage.INGAME; - }; - break; - case "PREGAME": - if (CurrentPage != ELivePage.PREGAME) { - ChangePage(new PregamePageView()); - CurrentPage = ELivePage.PREGAME; - }; - break; - default: - Log.Information("Unknown Session Loop State: " + dataMessage.sessionLoopState); - break; + if (CurrentPage != ELivePage.PREGAME) { + Log.Information("Changing to Pregame"); + ChangePage(new PregamePageView()); + CurrentPage = ELivePage.PREGAME; + return; + }; + } + } + catch (Exception e) + { + Log.Information("USING BACKUP ON LIVEVIEWVIEWMODELPAGE: Not Pregame"); + } + + try + { + var test1 = await AssistApplication.ActiveUser.CoreGame.FetchPlayer(); + if (!string.IsNullOrEmpty(test1.MatchID)) + { + if (CurrentPage != ELivePage.INGAME) { + Log.Information("Changing to Ingame"); + ChangePage(new IngamePageView()); + CurrentPage = ELivePage.INGAME; + return; + }; + } + } + catch (Exception e) + { + Log.Information("USING BACKUP ON LIVEVIEWVIEWMODELPAGE: Not Coregame"); + } + + try + { + var test1 = await AssistApplication.ActiveUser.Party.FetchParty(); + if (!string.IsNullOrEmpty(test1.ID)) + { + if (CurrentPage != ELivePage.MENUS) + { + Log.Information("Changing to Menus"); + ChangePage(new MenusPageView(fullMessage)); + CurrentPage = ELivePage.MENUS; + return; + }; + } + } + catch (Exception e) + { + Log.Information("USING BACKUP ON LIVEVIEWVIEWMODELPAGE: Not Party"); + } } }); + + switch (dataMessage?.sessionLoopState) + { + case "MENUS": + if (CurrentPage != ELivePage.MENUS) + { + Log.Information("Changing to Menus"); + ChangePage(new MenusPageView(fullMessage)); + CurrentPage = ELivePage.MENUS; + }; + break; + case "INGAME": + if (CurrentPage != ELivePage.INGAME) { + Log.Information("Changing to Ingame"); + ChangePage(new IngamePageView()); + CurrentPage = ELivePage.INGAME; + }; + break; + case "PREGAME": + if (CurrentPage != ELivePage.PREGAME) { + Log.Information("Changing to Pregame"); + ChangePage(new PregamePageView()); + CurrentPage = ELivePage.PREGAME; + }; + break; + default: + Log.Information("Unknown Session Loop State: " + dataMessage?.sessionLoopState); + break; + } } public void Unsubscribe(){ AssistApplication.RiotWebsocketService.UserPresenceMessageEvent -= RiotWebsocketServiceOnUserPresenceMessageEvent; } - private void ChangePage(UserControl newPageView) + public void ChangePage(UserControl newPageView) { CurrentView = newPageView; } diff --git a/Assist/ViewModels/Game/MatchTrackMatchViewModel.cs b/Assist/ViewModels/Game/MatchTrackMatchViewModel.cs index cae1d36a..1d8727d4 100644 --- a/Assist/ViewModels/Game/MatchTrackMatchViewModel.cs +++ b/Assist/ViewModels/Game/MatchTrackMatchViewModel.cs @@ -46,8 +46,9 @@ public async Task SetupDisplay() { if (RecentMatchData is null) return; - - MapImage = $"https://cdn.assistval.com/maps/{ValorantHelper.MapsByPath[RecentMatchData.MapId.ToLower()]}_BWlistview.png"; + + if (!string.IsNullOrEmpty(RecentMatchData.MapId)) + MapImage = $"https://cdn.assistval.com/maps/{ValorantHelper.MapsByPath[RecentMatchData.MapId.ToLower()]}_BWlistview.png"; // Determine Match State diff --git a/Assist/ViewModels/Game/MenusPageViewModel.cs b/Assist/ViewModels/Game/MenusPageViewModel.cs index ac2af7b0..c733a6eb 100644 --- a/Assist/ViewModels/Game/MenusPageViewModel.cs +++ b/Assist/ViewModels/Game/MenusPageViewModel.cs @@ -225,6 +225,8 @@ private async Task CreatePartyPlayerControl(ValorantPartyPlayer member) await ply.Setup(); LiveViewViewModel.ValorantPlayers.TryAdd(member.Subject, ply); + Log.Information("Party Member Info: SUB : {0} | PCARD : {1}", member.Subject, member.PlayerCardID); + Dispatcher.UIThread.InvokeAsync(async () => { AddUserToList( diff --git a/Assist/ViewModels/Game/PregamePageViewModel.cs b/Assist/ViewModels/Game/PregamePageViewModel.cs index d183cbe0..388d621c 100644 --- a/Assist/ViewModels/Game/PregamePageViewModel.cs +++ b/Assist/ViewModels/Game/PregamePageViewModel.cs @@ -9,9 +9,12 @@ using Assist.Controls.Game.Live; using Assist.Controls.Store; using Assist.Core.Helpers; +using Assist.Models.Enums; using Assist.Models.Socket; using Assist.Services.Assist; using Assist.Shared.Models.Assist; +using Assist.Views.Game.Live; +using Assist.Views.Game.Live.Pages; using Avalonia.Media; using Avalonia.Threading; using CommunityToolkit.Mvvm.ComponentModel; @@ -66,6 +69,24 @@ public async Task PageSetup() if(ex.StatusCode == HttpStatusCode.BadRequest){ Log.Fatal("PREGAME TOKEN ERROR: "); await AssistApplication.RefreshService.CurrentUserOnTokensExpired(); + return; + } + + if (ex.Content.Contains("PREGAME_MNF", StringComparison.OrdinalIgnoreCase)) + { + try + { + var getPlayerResp = await AssistApplication.ActiveUser.CoreGame.FetchPlayer(); + Dispatcher.UIThread.Invoke(() => + { + LiveView._viewModel.ChangePage(new IngamePageView()); + LiveView._viewModel.CurrentPage = ELivePage.INGAME; + }); + } + catch (Exception exception) + { + return; + } } } diff --git a/Assist/ViewModels/Settings/GeneralSettingsPageViewModel.cs b/Assist/ViewModels/Settings/GeneralSettingsPageViewModel.cs index db7acb1d..64cf9e61 100644 --- a/Assist/ViewModels/Settings/GeneralSettingsPageViewModel.cs +++ b/Assist/ViewModels/Settings/GeneralSettingsPageViewModel.cs @@ -1,5 +1,7 @@ using System; using System.Collections.ObjectModel; +using System.Diagnostics; +using System.IO; using System.Threading.Tasks; using Assist.Core.Settings.Options; using Assist.Models.Enums; @@ -69,4 +71,18 @@ public async void CheckForUpdates() } } + + [RelayCommand] + public async void OpenFolder() + { + try + { + Process.Start("explorer.exe", $"{Path.Combine(AssistSettings.FolderPath, "Logs")}"); + } + catch (Exception e) + { + + } + + } } diff --git a/Assist/ViewModels/Startup/StartupViewModel.cs b/Assist/ViewModels/Startup/StartupViewModel.cs index 229ba522..0107f1f3 100644 --- a/Assist/ViewModels/Startup/StartupViewModel.cs +++ b/Assist/ViewModels/Startup/StartupViewModel.cs @@ -191,10 +191,7 @@ private async Task LauncherSetup() private bool IsValorantRunning() { - var processlist = Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Where(process => process.Id != Process.GetCurrentProcess().Id).ToList(); - processlist.AddRange(Process.GetProcessesByName("VALORANT-Win64-Shipping")); - - return processlist.Any(); + return Process.GetProcessesByName("VALORANT-Win64-Shipping").Any(process => process.Id != Process.GetCurrentProcess().Id); } private async Task AttemptAuthentication() diff --git a/Assist/ViewModels/Store/StoreViewModel.cs b/Assist/ViewModels/Store/StoreViewModel.cs index cde3aabe..d6eaa4ce 100644 --- a/Assist/ViewModels/Store/StoreViewModel.cs +++ b/Assist/ViewModels/Store/StoreViewModel.cs @@ -56,7 +56,7 @@ public async Task SetupStoreView() if (store.Store.BonusStore is not null) { Log.Information("Night market is Active, Loading Night Market Tab"); - //NightMarketActive = true; + NightMarketActive = true; } var wallet = await GetCurrentUserWallet(); diff --git a/Assist/Views/Extras/AssistJoinWindow.axaml b/Assist/Views/Extras/AssistJoinWindow.axaml new file mode 100644 index 00000000..878a3850 --- /dev/null +++ b/Assist/Views/Extras/AssistJoinWindow.axaml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + diff --git a/Assist/Views/Extras/AssistJoinWindow.axaml.cs b/Assist/Views/Extras/AssistJoinWindow.axaml.cs new file mode 100644 index 00000000..60d3b4ec --- /dev/null +++ b/Assist/Views/Extras/AssistJoinWindow.axaml.cs @@ -0,0 +1,13 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; + +namespace Assist.Views.Extras; + +public partial class AssistJoinWindow : Window +{ + public AssistJoinWindow() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/Assist/Views/Extras/AssistLaunchWindow.axaml b/Assist/Views/Extras/AssistLaunchWindow.axaml new file mode 100644 index 00000000..e8b82fdd --- /dev/null +++ b/Assist/Views/Extras/AssistLaunchWindow.axaml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + diff --git a/Assist/Views/Extras/AssistLaunchWindow.axaml.cs b/Assist/Views/Extras/AssistLaunchWindow.axaml.cs new file mode 100644 index 00000000..64491419 --- /dev/null +++ b/Assist/Views/Extras/AssistLaunchWindow.axaml.cs @@ -0,0 +1,13 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; + +namespace Assist.Views.Extras; + +public partial class AssistLaunchWindow : Window +{ + public AssistLaunchWindow() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/Assist/Views/Game/Live/LiveView.axaml.cs b/Assist/Views/Game/Live/LiveView.axaml.cs index 12c805e3..28e35df8 100644 --- a/Assist/Views/Game/Live/LiveView.axaml.cs +++ b/Assist/Views/Game/Live/LiveView.axaml.cs @@ -13,7 +13,7 @@ namespace Assist.Views.Game.Live; public partial class LiveView : UserControl { - private readonly LiveViewViewModel _viewModel; + public static LiveViewViewModel _viewModel; public LiveView() { diff --git a/Assist/Views/Settings/Pages/GeneralSettingsPageView.axaml b/Assist/Views/Settings/Pages/GeneralSettingsPageView.axaml index eaf5e06f..0f197ef7 100644 --- a/Assist/Views/Settings/Pages/GeneralSettingsPageView.axaml +++ b/Assist/Views/Settings/Pages/GeneralSettingsPageView.axaml @@ -70,5 +70,15 @@ HorizontalAlignment="Right" VerticalAlignment="Center"> + + + + + diff --git a/Assist/Views/Store/Pages/BonusStorePageView.axaml b/Assist/Views/Store/Pages/BonusStorePageView.axaml new file mode 100644 index 00000000..5da5ca19 --- /dev/null +++ b/Assist/Views/Store/Pages/BonusStorePageView.axaml @@ -0,0 +1,10 @@ + + + + + diff --git a/Assist/Views/Store/Pages/BonusStorePageView.axaml.cs b/Assist/Views/Store/Pages/BonusStorePageView.axaml.cs new file mode 100644 index 00000000..cdf3a1d8 --- /dev/null +++ b/Assist/Views/Store/Pages/BonusStorePageView.axaml.cs @@ -0,0 +1,13 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; + +namespace Assist.Views.Store.Pages; + +public partial class BonusStorePageView : UserControl +{ + public BonusStorePageView() + { + InitializeComponent(); + } +} \ No newline at end of file