Skip to content

Commit

Permalink
V1.0.24 - Rebase (#205)
Browse files Browse the repository at this point in the history
* 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] <support@github.com>

* Fix to allow for New Range

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
HeyM1ke and dependabot[bot] authored Aug 3, 2024
1 parent 6f71d63 commit fd3db04
Show file tree
Hide file tree
Showing 27 changed files with 477 additions and 72 deletions.
2 changes: 1 addition & 1 deletion Assist.Shared
Submodule Assist.Shared updated 0 files
85 changes: 77 additions & 8 deletions Assist/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -17,22 +18,29 @@
using Avalonia.Markup.Xaml;
using Assist.ViewModels;
using Assist.Views;
using Assist.Views.Extras;
using Assist.Views.Startup;
using AsyncImageLoader;
using AsyncImageLoader.Loaders;
using Avalonia.Controls;
using Avalonia.Styling;
using Avalonia.Threading;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Win32;
using Serilog;
using Serilog.Sinks.SystemConsole.Themes;

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();
Expand All @@ -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();
Expand All @@ -72,11 +80,9 @@ private void OnStartup()
CreateLogger();
CheckForSettings();
ImageLoader.AsyncImageLoader = new DiskCachedWebImageLoader(AssistSettings.CacheFolderPath);

HandleProtocol();
}



private void CreateDirectories()
{
Directory.CreateDirectory(GetApplicationDataFolder());
Expand Down Expand Up @@ -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");
}
2 changes: 1 addition & 1 deletion Assist/Assist.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.4.1" />
<PackageReference Include="System.Management" Version="8.0.0" />
<PackageReference Include="System.Text.Json" Version="8.0.3" />
<PackageReference Include="System.Text.Json" Version="8.0.4" />
<PackageReference Include="Velopack" Version="0.0.359" />
<PackageReference Include="websocketsharp.core" Version="1.0.0" />
<PackageReference Include="YamlDotNet" Version="15.1.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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">

<Design.DataContext>
Expand All @@ -20,12 +21,12 @@
Background="{DynamicResource AssistControlBackground}"
BorderBrush="{DynamicResource AssistControlOutline}"
BorderThickness="1"

CornerRadius="10"
Padding="10">
<Grid>
Padding="10"
MinWidth="250"
Height="250">
<Grid HorizontalAlignment="Center">
<StackPanel VerticalAlignment="Center"
HorizontalAlignment="Left"
Orientation="Vertical"
Spacing="8">
<StackPanel Orientation="Horizontal" Spacing="10">
Expand Down
5 changes: 4 additions & 1 deletion Assist/Helpers/ValorantHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string> MapsByPath = new Dictionary<string, string>
Expand All @@ -249,13 +250,15 @@ 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},
{"/game/maps/hurm/hurm_bowl/hurm_bowl",Properties.Resources.VALORANT_Kasbah},
{"/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}

};

Expand Down Expand Up @@ -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":
Expand Down
9 changes: 9 additions & 0 deletions Assist/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Assist/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,9 @@
<data name="VALORANT_Drift" xml:space="preserve">
<value>Drift</value>
</data>
<data name="VALORANT_Abyss" xml:space="preserve">
<value>Abyss</value>
</data>
<data name="VALORANT_UnknownMap" xml:space="preserve">
<value>Temple</value>
</data>
Expand Down
3 changes: 3 additions & 0 deletions Assist/Services/Riot/ValorantWebsocketClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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)
Expand Down
11 changes: 6 additions & 5 deletions Assist/Themes/Dark.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
<!-- Add Resources Here -->
<Color x:Key="AssistPrimaryColor">#F71D51</Color>

<Color x:Key="AssistBackground">#0C0F0D</Color>
<Color x:Key="AssistBackground85">#D90C0F0D</Color>
<Color x:Key="AssistSecondaryBackground">#15171A</Color>
<Color x:Key="AssistBackground">#171717</Color>
<Color x:Key="AssistBackground85">#D9171717</Color>
<Color x:Key="AssistSecondaryBackground">#262626</Color>

<Color x:Key="AssistControlBackground">#121514</Color>
<Color x:Key="AssistControlOutline">#232633</Color>
<Color x:Key="AssistControlBackground">#1e1e1e</Color>
<Color x:Key="AssistControlOutline">#2f2f2f</Color>
<!--414342old color-->
<Color x:Key="AssistForeground">#FBFBFB</Color>
<Color x:Key="AssistSecondaryForeground">#A3A3A3</Color>


<Color x:Key="AssistButtonControlBackground">#151719</Color>
Expand Down
14 changes: 8 additions & 6 deletions Assist/ViewModels/Assist/AssistAccountDuelFormViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,21 @@ 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);
}

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]
Expand Down Expand Up @@ -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;
Expand All @@ -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)
Expand Down
13 changes: 7 additions & 6 deletions Assist/ViewModels/Assist/AssistAccountLoginFormViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,21 @@ 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);
}

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]
Expand Down Expand Up @@ -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;
Expand All @@ -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)
Expand Down
Loading

0 comments on commit fd3db04

Please sign in to comment.