diff --git a/ValorantCC/App.xaml b/ValorantCC/App.xaml
index c84e840..424113c 100644
--- a/ValorantCC/App.xaml
+++ b/ValorantCC/App.xaml
@@ -92,6 +92,14 @@
+
+
+
+
+
+
+
+
diff --git a/ValorantCC/MainWindow.xaml b/ValorantCC/MainWindow.xaml
index 3108f21..7ee7601 100644
--- a/ValorantCC/MainWindow.xaml
+++ b/ValorantCC/MainWindow.xaml
@@ -6,7 +6,7 @@
xmlns:local="clr-namespace:ValorantCC" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:Controls="clr-namespace:Xceed.Wpf.AvalonDock.Themes.Controls;assembly=Xceed.Wpf.AvalonDock.Themes.Aero" x:Class="ValorantCC.MainWindow"
mc:Ignorable="d"
- Title="vTools - ValorantCC" Height="411 " Width="500" SizeToContent="Manual" AllowsTransparency="True" WindowStartupLocation="CenterScreen" WindowState="Normal" ResizeMode="CanMinimize" WindowStyle="None" Icon="Resources/vtools-colored.ico"
+ Title="vTools - ValorantCC" Height="423 " Width="500" SizeToContent="Manual" AllowsTransparency="True" WindowStartupLocation="CenterScreen" WindowState="Normal" ResizeMode="CanMinimize" WindowStyle="None" Icon="Resources/vtools-colored.ico"
Background="Transparent"
RenderOptions.BitmapScalingMode="Fant">
@@ -55,18 +55,15 @@
-
-
-
-
-
-
-
-
+
+
-
-
-
+
+
+
+
+
+
@@ -85,7 +82,7 @@
-
+
@@ -199,9 +196,9 @@
-
-
-
+
+
+
@@ -215,6 +212,7 @@
+
@@ -230,6 +228,12 @@
+
+
+
+
+
+
diff --git a/ValorantCC/MainWindow.xaml.cs b/ValorantCC/MainWindow.xaml.cs
index b14ede4..89e7d9c 100644
--- a/ValorantCC/MainWindow.xaml.cs
+++ b/ValorantCC/MainWindow.xaml.cs
@@ -19,21 +19,17 @@ namespace ValorantCC
public partial class MainWindow : Window
{
readonly string LoggingDir = Environment.GetEnvironmentVariable("LocalAppData") + @"\VTools\Logs\";
- Processor DataProcessor = new Processor();
+ public Processor DataProcessor = new Processor();
BrushConverter bc = new BrushConverter();
public AuthResponse AuthResponse;
public CrosshairProfile SelectedProfile;
List SelectedColors;
- private API ValCCAPI;
- int SelectedIndex;
- bool LoggedIn;
+ public API ValCCAPI;
+ public int SelectedIndex;
+ public bool LoggedIn;
public MainWindow()
{
- /**
- * Note to myself, You were sleepy when you made this commit. Just test the app and see what you messed with.
- * You probably messed with something here in main relating to the checkbox. goodluck debugging!
- */
// Create logging dir
if (!Directory.Exists(LoggingDir)) Directory.CreateDirectory(LoggingDir);
// Replace old logs
@@ -44,6 +40,8 @@ public MainWindow()
InitializeComponent();
Utils.Log($"App Started | v{ProgramFileVersion}. Replaced old logfile.");
Txt_CurrVer.Content = $"v{ProgramFileVersion}";
+ BackgroundAuth auth = new BackgroundAuth(DataProcessor);
+ auth.LoopCheck();
}
private async void Grid_Loaded(object sender, RoutedEventArgs e)
@@ -61,7 +59,7 @@ private void btnSave_Click(object sender, RoutedEventArgs e)
{
if (!LoggedIn)
{
- MessageBox.Show("You are not logged in!");
+ MessageTxt.Text = "You are not logged in!";
return;
}
if (DataProcessor.ProfileListed)
@@ -77,30 +75,14 @@ private void btnSave_Click(object sender, RoutedEventArgs e)
DataProcessor.Construct();
profiles.Items.Refresh();
profiles.SelectedIndex = DataProcessor.CurrentProfile;
- MessageBox.Show("Saved! If Valorant is open, Please restart it without touching the settings.");
+ MessageTxt.Foreground = Brushes.Lime;
+ MessageTxt.Text = "Saved! Restart Valorant.";
return;
}
- MessageBox.Show("Failed. Consult the developer.");
+ MessageTxt.Foreground = Brushes.Red;
+ MessageTxt.Text = "Failed. Consult developer.";
return;
}
- private void btnLogin_Click(object sender, RoutedEventArgs e)
- {
- AuthResponse AuthResponse = DataProcessor.Login();
- LoggedIn = AuthResponse.Success;
- if (!LoggedIn)
- {
- MessageBox.Show(AuthResponse.Response);
- return;
- }
-
- profiles.ItemsSource = DataProcessor.ProfileNames;
- txt_LoggedIn.Foreground = Brushes.Lime;
- profiles.SelectedIndex = DataProcessor.CurrentProfile;
- profiles.IsReadOnly = false;
- MessageBox.Show(Utils.LoginResponse(DataProcessor));
- btnLogin.IsEnabled = false;
- ValCCAPI = new API(AuthResponse.AuthTokens, SelectedProfile, 2, (chkbxShareable.IsChecked ?? false));
- }
private void profiles_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
@@ -124,9 +106,6 @@ private void profiles_SelectionChanged(object sender, SelectionChangedEventArgs
ads_color.SelectedColor = Color.FromRgb(SelectedProfile.aDS.Color.R, SelectedProfile.aDS.Color.G, SelectedProfile.aDS.Color.B);
ads_outline_color.SelectedColor = Color.FromRgb(SelectedProfile.aDS.OutlineColor.R, SelectedProfile.aDS.OutlineColor.G, SelectedProfile.aDS.OutlineColor.B);
sniper_dot_color.SelectedColor = Color.FromRgb(SelectedProfile.Sniper.CenterDotColor.R, SelectedProfile.Sniper.CenterDotColor.G, SelectedProfile.Sniper.CenterDotColor.B);
-
- if (ValCCAPI != null) ValCCAPI.profile = SelectedProfile;
- if (ValCCAPI != null && (chkbxShareable.IsChecked ?? false)) ValCCAPI.Set();
Crosshair_load();
}
private void StackPanel_MouseDown(object sender, MouseButtonEventArgs e)
@@ -138,7 +117,7 @@ private void btnReload_Click(object sender, RoutedEventArgs e)
{
if (!LoggedIn)
{
- MessageBox.Show("You are not logged in!");
+ MessageTxt.Text = "You are not logged in!";
return;
}
Utils.Log("Reload Clicked > Reconstructing Processor.");
@@ -288,7 +267,8 @@ private void btnOpenLogs_Click(object sender, RoutedEventArgs e)
Process p = new Process();
p.StartInfo = new ProcessStartInfo() { FileName = LoggingDir, UseShellExecute = true };
p.Start();
- MessageBox.Show("Log folder opened. Please include the OLD file on your report as this helps us recreate the bug/error you will report.");
+ MessageTxt.Foreground = Brushes.Lime;
+ MessageTxt.Text = "Log folder opened! Please include OLD files to your report if exists.";
}
private void next_Click(object sender, RoutedEventArgs e)
@@ -317,7 +297,7 @@ private void btnCommunityProfiles_Click(object sender, RoutedEventArgs e)
{
if (!LoggedIn)
{
- MessageBox.Show("You are not logged in!");
+ MessageTxt.Text = "You are not logged in!";
return;
}
try
@@ -336,11 +316,22 @@ private void chkbxShareable_Click(object sender, RoutedEventArgs e)
{
if (!LoggedIn)
{
- MessageBox.Show("You are not logged in!");
+ MessageTxt.Text = "You are not logged in!";
((CheckBox)sender).IsChecked = !((CheckBox)sender).IsChecked;
return;
}
+ }
+
+ private void btnShare_Click(object sender, RoutedEventArgs e)
+ {
+ if (!LoggedIn)
+ {
+ MessageTxt.Text = "You are not logged in!";
+ return;
+ }
+ MessageTxt.Text = "Your profile has been saved! Make sure you have the 'shareable' checkbox checked!";
ValCCAPI.Shareable = (bool)chkbxShareable.IsChecked;
+ ValCCAPI.profile = SelectedProfile;
_ = ValCCAPI.Set();
}
}
diff --git a/ValorantCC/Resources/vtspinner.gif b/ValorantCC/Resources/vtspinner.gif
new file mode 100644
index 0000000..70bc0a0
Binary files /dev/null and b/ValorantCC/Resources/vtspinner.gif differ
diff --git a/ValorantCC/SubWindow/ProfilesWindow.xaml b/ValorantCC/SubWindow/ProfilesWindow.xaml
index 9327538..142fe7e 100644
--- a/ValorantCC/SubWindow/ProfilesWindow.xaml
+++ b/ValorantCC/SubWindow/ProfilesWindow.xaml
@@ -4,6 +4,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ValorantCC"
+ xmlns:gif="http://wpfanimatedgif.codeplex.com"
mc:Ignorable="d"
Title="ProfilesWindow" Height="Auto" Width="Auto" ResizeMode="NoResize" SizeToContent="WidthAndHeight" ShowInTaskbar="False" WindowStartupLocation="CenterOwner">
@@ -14,7 +15,7 @@
- L o a d i n g . . . :D
+
diff --git a/ValorantCC/SubWindow/ProfilesWindow.xaml.cs b/ValorantCC/SubWindow/ProfilesWindow.xaml.cs
index c48bb94..e56b12a 100644
--- a/ValorantCC/SubWindow/ProfilesWindow.xaml.cs
+++ b/ValorantCC/SubWindow/ProfilesWindow.xaml.cs
@@ -49,9 +49,9 @@ public ProfilesWindow(CrosshairProfile current, API ValCCAPI)
private async void Border_Loaded(object sender, RoutedEventArgs e)
{
- LoadingTxt.Visibility = Visibility.Visible;
+ LoadingPlaceHolder.Visibility = Visibility.Visible;
await InitialFetch();
- LoadingTxt.Visibility = Visibility.Collapsed;
+ LoadingPlaceHolder.Visibility = Visibility.Collapsed;
await RenderProfiles();
}
@@ -266,7 +266,8 @@ private async Task CreateRender(PublicProfile profile)
Grid0.Children.Add(detailsButton);
Grid0.Children.Add(applyButton);
- var cross = profile.settings.Primary;
+ ProfileSettings cross = profile.settings.Primary;
+
Crosshair_Parser.Generate(0, Grid0, cross);
if (!profile.settings.bUsePrimaryCrosshairForADS)
cross = profile.settings.aDS;
diff --git a/ValorantCC/ValorantCC.csproj b/ValorantCC/ValorantCC.csproj
index 689af23..60e205e 100644
--- a/ValorantCC/ValorantCC.csproj
+++ b/ValorantCC/ValorantCC.csproj
@@ -31,6 +31,7 @@
+
@@ -64,13 +65,20 @@
PreserveNewest
+
+ PreserveNewest
+
+
+
+ PreserveNewest
+
-
+
-
-
+
+
@@ -93,11 +101,4 @@
<_DeploymentManifestIconFile Remove="Resources\vtools-colored.ico" />
-
-
- PreserveNewest
-
-
-
-
diff --git a/ValorantCC/src/Auth.cs b/ValorantCC/src/Auth.cs
index 1ce2a91..cef2fe6 100644
--- a/ValorantCC/src/Auth.cs
+++ b/ValorantCC/src/Auth.cs
@@ -3,6 +3,8 @@
using System.IO;
using System.Net;
using System.Text;
+using System.Linq;
+using System.Threading.Tasks;
using Utilities;
namespace ValorantCC
{
@@ -51,36 +53,26 @@ public partial class VersionData
}
public class AuthObj
{
- public AuthResponse StartAuth(bool wait = false)
+ LockfileData LocalCredentials;
+ public async Task StartAuth()
{
string LockfilePath = Environment.GetEnvironmentVariable("LocalAppData") + "\\Riot Games\\Riot Client\\Config\\lockfile";
- if (wait)
- {
- Utils.Log("Waiting for Lockfile");
-
- bool LockfileExists = CheckLockFile(LockfilePath);
- while (!LockfileExists)
- {
- LockfileExists = CheckLockFile(LockfilePath);
- }
- }
-
- LockfileData LocalCredentials = ObtainLockfileData(LockfilePath);
+ LocalCredentials = ObtainLockfileData(LockfilePath);
if (!LocalCredentials.Success) return new AuthResponse() { Success = false, Response = "Please login to Riot Client or Start Valorant." };
- AuthTokens Tokens = ObtainAuthTokens(LocalCredentials.Basic, LocalCredentials.Port);
+ AuthTokens Tokens = await ObtainAuthTokens();
if (!Tokens.Success) return new AuthResponse() { Success = false, Response = "Please login to Riot Client or Start Valorant." };
- return new AuthResponse() { Success = true, AuthTokens = Tokens, LockfileData = LocalCredentials, Version = GetVersion() };
+ return new AuthResponse() { Success = true, AuthTokens = Tokens, LockfileData = LocalCredentials, Version = await GetVersion() };
}
- private static bool CheckLockFile(string LockfilePath)
+ public static bool CheckLockFile(string LockfilePath)
{
return File.Exists(LockfilePath);
}
- private static LockfileData ObtainLockfileData(string LockfilePath)
+ public static LockfileData ObtainLockfileData(string LockfilePath)
{
string LockfileRaw;
try
@@ -111,19 +103,23 @@ private static LockfileData ObtainLockfileData(string LockfilePath)
};
}
- private AuthTokens ObtainAuthTokens(string Basic, int port)
+ private async Task ObtainAuthTokens()
{
+ await Task.Delay(1);
Utils.Log("Creating Auth Request");
- HttpWebRequest request = HttpWebRequest.CreateHttp($"https://127.0.0.1:{port}/entitlements/v1/token");
+ HttpWebRequest request = HttpWebRequest.CreateHttp($"https://127.0.0.1:{LocalCredentials.Port}/entitlements/v1/token");
request.Method = "GET";
- request.Headers.Add("Authorization", $"Basic {Basic}");
+ request.Headers.Add("Authorization", $"Basic {LocalCredentials.Basic}");
request.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;
- HttpWebResponse resp;
+ WebResponse resp;
try
{
Utils.Log("Sending Auth Request");
- resp = (HttpWebResponse)request.GetResponse();
+ Task taskResp = Task.Factory.FromAsync(
+ request.BeginGetResponse, request.EndGetResponse,
+ (object)null);
+ resp = await taskResp;
}
catch (WebException ex)
{
@@ -137,13 +133,21 @@ private AuthTokens ObtainAuthTokens(string Basic, int port)
return tokens;
}
- private static string GetVersion()
+ private async static Task GetVersion()
{
+ await Task.Delay(1);
HttpWebRequest request = HttpWebRequest.CreateHttp("https://valorant-api.com/v1/version");
request.Method = "GET";
- HttpWebResponse response = (HttpWebResponse)request.GetResponse();
- StreamReader sr = new StreamReader(response.GetResponseStream());
- VersionResponse RespData = JsonConvert.DeserializeObject(sr.ReadToEnd());
+ Task taskResp = Task.Factory.FromAsync(
+ request.BeginGetResponse,
+ asyncResult => request.EndGetResponse(asyncResult),
+ (object)null);
+ VersionResponse RespData = await taskResp.ContinueWith(r =>
+ {
+ WebResponse response = (WebResponse)r.Result;
+ StreamReader sr = new StreamReader(response.GetResponseStream());
+ return JsonConvert.DeserializeObject(sr.ReadToEnd());
+ });
return RespData.Data.RiotClientVersion;
}
}
diff --git a/ValorantCC/src/BackgroundAuth.cs b/ValorantCC/src/BackgroundAuth.cs
new file mode 100644
index 0000000..c96f1f0
--- /dev/null
+++ b/ValorantCC/src/BackgroundAuth.cs
@@ -0,0 +1,89 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Media;
+using System.IO;
+using System.Diagnostics;
+using Utilities;
+
+namespace ValorantCC
+{
+ class BackgroundAuth
+ {
+ MainWindow main = (MainWindow) Application.Current.MainWindow;
+ Processor processor;
+ public BackgroundAuth(Processor processor1)
+ {
+ processor = processor1;
+ }
+ public async void LoopCheck()
+ {
+ string LockfilePath = Environment.GetEnvironmentVariable("LocalAppData") + "\\Riot Games\\Riot Client\\Config\\lockfile"; //Copy pasted from Auth.cs because why not?
+ bool lockfilexists = false;
+ while (true)
+ {
+ if (AuthObj.CheckLockFile(LockfilePath) && !lockfilexists)
+ {
+ main.StatusTxt.Foreground = Brushes.Yellow;
+ main.StatusTxt.Text = "Waiting for session. . .";
+ lockfilexists = true;
+ }
+ if (!await LoginFlagExists())
+ {
+ await Task.Delay(1500);
+ continue;
+ }
+ if (lockfilexists && AuthObj.ObtainLockfileData(LockfilePath).Success)
+ {
+ main.StatusTxt.Text = "Logging in. . .";
+ processor.Login();
+ AuthResponse AuthResponse = processor.Login();
+ main.DataProcessor = processor;
+ main.LoggedIn = AuthResponse.Success;
+ if (!main.LoggedIn)
+ {
+ main.StatusTxt.Text = "Failed. Please login to Riot Client or Start Valorant.";
+ await Task.Delay(1500);
+ continue;
+ }
+ main.profiles.ItemsSource = processor.ProfileNames;
+ main.profiles.SelectedIndex = processor.CurrentProfile;
+ main.profiles.IsReadOnly = false;
+ main.ValCCAPI = new API(AuthResponse.AuthTokens, main.SelectedProfile, 2, (main.chkbxShareable.IsChecked ?? false));
+
+ main.DotTxt.Foreground = Brushes.Lime;
+ main.StatusTxt.Foreground = Brushes.Lime;
+ main.MessageTxt.Foreground = Brushes.Lime;
+ main.MessageTxt.Text = Utils.LoginResponse(processor);
+ main.StatusTxt.Text = "Logged In!";
+ return;
+ }
+ await Task.Delay(1500);
+ }
+ }
+
+ public async static Task LoginFlagExists()
+ {
+ String LogDir = Environment.GetEnvironmentVariable("LocalAppData") + "\\Riot Games\\Riot Client\\Logs\\Riot Client Logs";
+ String[] logs = Directory.GetFiles(LogDir, "*.log");
+ string content;
+ using (FileStream fileStream = File.Open(logs.Last(), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
+ {
+ using (StreamReader sr = new StreamReader(fileStream))
+ {
+ content = sr.ReadToEnd();
+ }
+ }
+ bool t = false;
+ if (content.Contains("riot-messaging-service: State is now Connected"))
+ {
+ t = true;
+ }
+ await Task.Delay(1);
+ return t;
+ }
+ }
+}
diff --git a/ValorantCC/src/Processor.cs b/ValorantCC/src/Processor.cs
index b26865f..4240888 100644
--- a/ValorantCC/src/Processor.cs
+++ b/ValorantCC/src/Processor.cs
@@ -4,11 +4,12 @@
using System.Collections.Generic;
using System.Linq;
using System.Windows.Media;
+using System.Threading.Tasks;
using Utilities;
namespace ValorantCC
{
- class Processor
+ public class Processor
{
private AuthResponse AuthResponse;
public bool isLoggedIn = false;
@@ -24,7 +25,7 @@ public AuthResponse Login()
{
Utils.Log("Login started");
AuthObj AuthObj = new AuthObj();
- AuthResponse = AuthObj.StartAuth(false);
+ AuthResponse = Task.Run(AuthObj.StartAuth).Result;
if (!AuthResponse.Success) return AuthResponse;
Utils.Log("Auth Success");
Construct();