diff --git a/README.md b/README.md index 767aba3..f58275e 100644 --- a/README.md +++ b/README.md @@ -7,17 +7,28 @@ # ValorantCC (Valorant Crosshair Changer) [Download Here](https://github.com/weedeej/ValorantCC/releases/latest/download/ValorantCC.exe) Change your Crosshair's color to **ANY** color you want for style and/or visiblity. - +![image](https://user-images.githubusercontent.com/87055977/155284250-d01577c2-5661-43b1-8759-a6a8525e7709.png) + +Share your crosshair across the ValorantCC comunity!
+![image](https://user-images.githubusercontent.com/87055977/155284365-c802a73e-5062-4d36-b089-4116c2d85e9a.png) + +## Requirement +- .NET6.0 (This comes with windows updates. If you have the latest version of windows, This should be installed automatically. if not, download .NET6.0 **DESKTOP RUNTIME**. ## Usage - Either Open this first or Riot client or Valorant it doesn't matter. -- Click Login on this app. -- Select the profile you want to change color. -- Change to color. +- Wait for the app to login itself. +- Select the profile you want to change color via the dropdown on top-right. +- Change the colors. - Save. -- Restart Valorant \*(**IMPORTANT**)\*. +- Restart Valorant if Valorant is running \*(**IMPORTANT**)\*. -Also don't forget to enjoy. +## +- If you experience any Issues such as not working, Join us on [Discord](https://discord.gg/ME5EdK8U9v) and we'll try to fix it. +- You don't need to keep this app running in the background. Once you saved it, It will stay there. +- This does not change the game files nor touch Valorant's memory related stuff. The app only uses the Client API and send it directly to Valorant's Server. +- Yes. Other players can see it too as it is saved server side. +- THIS IS **NOT** AN OVERLAY/HACK/CHEAT/AIMBOT. ## Disclaimer The images, endpoints and other material used in this project are owned by Riot Games. diff --git a/ValorantCC/App.xaml b/ValorantCC/App.xaml index c84e840..3bde1c2 100644 --- a/ValorantCC/App.xaml +++ b/ValorantCC/App.xaml @@ -4,220 +4,15 @@ xmlns:local="clr-namespace:ValorantCC" StartupUri="MainWindow.xaml"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + diff --git a/ValorantCC/App.xaml.cs b/ValorantCC/App.xaml.cs index 22b1cb2..d988525 100644 --- a/ValorantCC/App.xaml.cs +++ b/ValorantCC/App.xaml.cs @@ -1,12 +1,10 @@ using System; +using System.Runtime.ExceptionServices; +using System.Threading.Tasks; using System.Windows; using System.Windows.Interop; using System.Windows.Media; using System.Windows.Threading; -using System.Threading; -using Utilities; -using System.Runtime.ExceptionServices; -using System.Threading.Tasks; namespace ValorantCC { @@ -19,7 +17,7 @@ protected override void OnStartup(StartupEventArgs e) { //Copy pasta for logging :V Startup += new StartupEventHandler(AppEventHandler); - + DispatcherUnhandledException += LogDispatcherUnhandled; TaskScheduler.UnobservedTaskException += LogUnobservedTaskException; @@ -34,12 +32,12 @@ private void AppEventHandler(object sender, StartupEventArgs e) private void LogFirstChanceException(object sender, FirstChanceExceptionEventArgs e) { - Utils.Log($"{e.Exception.Message}: {e.Exception.StackTrace}"); + Utilities.Utils.Log($"{e.Exception.Message}: {e.Exception.StackTrace}"); } private void LogDispatcherUnhandled(object sender, DispatcherUnhandledExceptionEventArgs e) { - Utils.Log($"{e.Exception.Message}: {e.Exception.StackTrace}"); + Utilities.Utils.Log($"{e.Exception.Message}: {e.Exception.StackTrace}"); e.Handled = false; } @@ -48,13 +46,13 @@ private void LogUnhandled(object sender, UnhandledExceptionEventArgs e) var ex = e.ExceptionObject as Exception; if (e.IsTerminating) { - Utils.Log($"{ex.Message}: {ex.StackTrace}"); + Utilities.Utils.Log($"{ex.Message}: {ex.StackTrace}"); } } private void LogUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) { - Utils.Log($"{e.Exception.Message}: {e.Exception.StackTrace}"); + Utilities.Utils.Log($"{e.Exception.Message}: {e.Exception.StackTrace}"); e.SetObserved(); } } diff --git a/ValorantCC/MainWindow.xaml b/ValorantCC/MainWindow.xaml index 6a53b93..10ad1c7 100644 --- a/ValorantCC/MainWindow.xaml +++ b/ValorantCC/MainWindow.xaml @@ -1,105 +1,64 @@ - + - - - - - - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + + + + + + + + + + + + @@ -127,11 +86,13 @@ + - - - - + + + + + @@ -159,84 +120,139 @@ + - - - - - - - - - - + + + + + + + + + - - + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + diff --git a/ValorantCC/MainWindow.xaml.cs b/ValorantCC/MainWindow.xaml.cs index fe3c342..1e028ce 100644 --- a/ValorantCC/MainWindow.xaml.cs +++ b/ValorantCC/MainWindow.xaml.cs @@ -1,69 +1,54 @@ using EZ_Updater; +using MahApps.Metro.Controls; +using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; +using System.Linq; using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; -using System.Windows.Shapes; -using Utilities; using ValorantCC.src; +using ValorantCC.SubWindow; namespace ValorantCC { - public partial class MainWindow : Window + public partial class MainWindow : MetroWindow { - Processor DataProcessor = new Processor(); - bool LoggedIn; - CrosshairProfile SelectedProfile; - List SelectedColors; - int SelectedIndex; + public Processor DataProcessor = new Processor(); BrushConverter bc = new BrushConverter(); - readonly string LoggingDir = Environment.GetEnvironmentVariable("LocalAppData") + @"\VTools\Logs\"; + public AuthResponse AuthResponse; + public CrosshairProfile SelectedProfile; + List SelectedColors; + public API ValCCAPI; + public int SelectedIndex; + public bool LoggedIn; + private string _sharecode; + private FetchResponse? sharedProfileResp; public MainWindow() { // Create logging dir - if (!Directory.Exists(LoggingDir)) Directory.CreateDirectory(LoggingDir); - // Replace old logs - string LogFile = LoggingDir + "/logs.txt"; - if (File.Exists(LogFile)) File.Move(LogFile, LogFile + ".old", true); + if (!Directory.Exists(Path.GetDirectoryName(Utilities.Utils.LoggingFile))) Directory.CreateDirectory(Path.GetDirectoryName(Utilities.Utils.LoggingFile)); + // Replace old logs + if (File.Exists(Utilities.Utils.LoggingFile)) File.Move(Utilities.Utils.LoggingFile, Path.GetDirectoryName(Utilities.Utils.LoggingFile) + "\\" + Path.GetFileNameWithoutExtension(Utilities.Utils.LoggingFile) + "-old" + Path.GetExtension(Utilities.Utils.LoggingFile), true); Version ProgramFileVersion = new Version(FileVersionInfo.GetVersionInfo(Process.GetCurrentProcess().MainModule.FileName).ProductVersion); InitializeComponent(); - Utils.Log($"App Started | v{ProgramFileVersion}. Replaced old logfile."); - Txt_CurrVer.Content = $"v{ProgramFileVersion}"; - } - - private async void Grid_Loaded(object sender, RoutedEventArgs e) - { - Updater.CustomLogger = Utils.Log; - Updater.OriginalFileName = "ValorantCC"; - if (await Updater.CheckUpdateAsync("weedeej", "ValorantCC")) - { - try - { - File.Create("./valccPermsTest.null").Close(); - File.Delete("./valccPermsTest.null"); - } - catch(UnauthorizedAccessException) - { - Utils.Log("User is not authorized to create a file on current valcc dir. Consider moving."); - MessageBox.Show("There's an update available but you have no access to write on this folder.\nPlease consider moving the app to a folder created by you or running the app as administrator."); - this.Close(); - } - var update = new UpdateWindow(); - update.Owner = this; - update.ShowDialog(); - } + Utilities.Utils.Log($"App Started | v{ProgramFileVersion}. Replaced old logfile."); + this.Title = $"ValorantCC v{ProgramFileVersion}"; + BackgroundAuth auth = new BackgroundAuth(DataProcessor); + auth.LoopCheck(); + Random nClicks = new Random(); + for (int i = 0; i < nClicks.Next(0, Resources.MergedDictionaries[0].Count - 1); i++) + next_Click(null, null); } - - private void btnSave_Click(object sender, RoutedEventArgs e) + private async void btnSave_Click(object sender, RoutedEventArgs e) { if (!LoggedIn) { - MessageBox.Show("You are not logged in!"); + Utilities.Utils.MessageText("You are not logged in!", Brushes.Red); return; } if (DataProcessor.ProfileListed) @@ -74,36 +59,20 @@ private void btnSave_Click(object sender, RoutedEventArgs e) { SelectedColors = new List { (Color)primary_color.SelectedColor }; } - if (DataProcessor.SaveNewColor(SelectedColors, profiles.SelectedIndex, profiles.Text)) + if (await DataProcessor.SaveNewColor(SelectedColors, profiles.SelectedIndex, profiles.Text)) { - DataProcessor.Construct(); + await DataProcessor.Construct(); profiles.Items.Refresh(); profiles.SelectedIndex = DataProcessor.CurrentProfile; - MessageBox.Show("Saved! If Valorant is open, Please restart it without touching the settings."); - return; - } - MessageBox.Show("Failed. Consult the developer."); - return; - } - private void btnLogin_Click(object sender, RoutedEventArgs e) - { - AuthResponse AuthResponse = DataProcessor.Login(); - LoggedIn = AuthResponse.Success; - if (!LoggedIn) - { - MessageBox.Show(AuthResponse.Response); + Utilities.Utils.MessageText("Saved! Restart Valorant.", Brushes.Lime); return; } + Utilities.Utils.MessageText("Your session expired! Please restart ValorantCC/Valorant", Brushes.Red); - profiles.ItemsSource = DataProcessor.ProfileNames; - txt_LoggedIn.Foreground = Brushes.Lime; - profiles.SelectedIndex = DataProcessor.CurrentProfile; - profiles.IsReadOnly = false; - MessageBox.Show(Utils.LoginResponse(DataProcessor)); - btnLogin.IsEnabled = true; + return; } - private void profiles_SelectionChanged(object sender, SelectionChangedEventArgs e) + private async void profiles_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (profiles.SelectedIndex == -1) return; @@ -121,11 +90,34 @@ private void profiles_SelectionChanged(object sender, SelectionChangedEventArgs } prim_outline_color.SelectedColor = Color.FromRgb(SelectedProfile.Primary.OutlineColor.R, SelectedProfile.Primary.OutlineColor.G, SelectedProfile.Primary.OutlineColor.B); if (SelectedProfile.aDS == null) SelectedProfile.aDS = SelectedProfile.Primary; - if(SelectedProfile.bUsePrimaryCrosshairForADS) SelectedProfile.aDS.Color = SelectedProfile.Primary.Color; + if (SelectedProfile.bUsePrimaryCrosshairForADS) SelectedProfile.aDS.Color = SelectedProfile.Primary.Color; 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 (!sharedProfileResp.HasValue) + { + if (ValCCAPI != null) sharedProfileResp = await ValCCAPI.ObtainSelfSaved(); + } + else + { + var respData = sharedProfileResp.Value; + if (respData.success && respData.data != null) + { + var data = respData.data.FirstOrDefault(); + _sharecode = data.shareCode; + CrosshairProfile fromDb = JsonConvert.DeserializeObject(data.settings); + if (SelectedProfile.ProfileName == fromDb.ProfileName) + { + chkbxShareable.IsChecked = data.shareable; + btnCopyShareCode.Visibility = Visibility.Visible; + } + else + { + chkbxShareable.IsChecked = false; + btnCopyShareCode.Visibility = Visibility.Collapsed; + } + } + } Crosshair_load(); } private void StackPanel_MouseDown(object sender, MouseButtonEventArgs e) @@ -133,15 +125,17 @@ private void StackPanel_MouseDown(object sender, MouseButtonEventArgs e) if (e.LeftButton == MouseButtonState.Pressed) DragMove(); } - private void btnReload_Click(object sender, RoutedEventArgs e) + private async void btnReload_Click(object sender, RoutedEventArgs e) { if (!LoggedIn) { - MessageBox.Show("You are not logged in!"); + Utilities.Utils.MessageText("You are not logged in!", Brushes.Red); return; } - Utils.Log("Reload Clicked > Reconstructing Processor."); - DataProcessor.Construct(); + Utilities.Utils.Log("Reload Clicked > Reconstructing Processor."); + if (!(await DataProcessor.Construct())) + Utilities.Utils.MessageText("Your session expired! Please restart ValorantCC/Valorant", Brushes.Red); + profiles.ItemsSource = DataProcessor.ProfileNames; profiles.Items.Refresh(); profiles.SelectedIndex = DataProcessor.CurrentProfile; @@ -155,7 +149,7 @@ private void profiles_TextChanged(object sender, TextChangedEventArgs e) profiles.SelectedIndex = SelectedIndex; } - private void Crosshair_load() + public void Crosshair_load() { //Primary Crosshair_Parser.dot_redraw(primeDOT, primeDOTOT, SelectedProfile.Primary); @@ -271,19 +265,23 @@ private void TabButtonLeave(object sender, MouseEventArgs e) private void ClipboardButtonEnter(object sender, MouseEventArgs e) { - CopyButtonLabel.FontSize += 1; + Button button = (Button)sender; + if (button.Name == "btnCopyLogs") CopyButtonLabel.FontSize += 1; + else communitylist_label.FontSize += 1; } private void ClipboardButtonLeave(object sender, MouseEventArgs e) { - CopyButtonLabel.FontSize -= 1; + Button button = (Button)sender; + if (button.Name == "btnCopyLogs") CopyButtonLabel.FontSize -= 1; + else communitylist_label.FontSize -= 1; } private void btnOpenLogs_Click(object sender, RoutedEventArgs e) { Process p = new Process(); - p.StartInfo = new ProcessStartInfo() { FileName = LoggingDir, UseShellExecute = true }; + p.StartInfo = new ProcessStartInfo() { FileName = Path.GetDirectoryName(Utilities.Utils.LoggingFile), 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."); + Utilities.Utils.MessageText("Log folder opened! Please include OLD files to your report if exists.", Brushes.Lime); } private void next_Click(object sender, RoutedEventArgs e) @@ -300,12 +298,99 @@ private ImageSource Get_CrosshairBG(bool next = true) { int number = int.Parse(System.IO.Path.GetFileNameWithoutExtension(CrosshairBG.Source.ToString()).Replace("CrosshairBG", "")) + (next ? 1 : -1); - if (next && number > Resources.Count - 1) + if (next && number > Resources.MergedDictionaries[0].Count - 1) number = 0; else if (number < 0) - number = Resources.Count - 1; + number = Resources.MergedDictionaries[0].Count - 1; return (ImageSource)FindResource("crosshairBG" + number); } + + private void btnCommunityProfiles_Click(object sender, RoutedEventArgs e) + { + if (!LoggedIn) + { + Utilities.Utils.MessageText("You are not logged in !", Brushes.Red); + return; + } + try + { + Window publicProfiles = Application.Current.Windows.Cast().Single(window => window.GetType().ToString() == "ValorantCC.ProfilesWindow"); + publicProfiles.Activate(); + } + catch (Exception) + { + ProfilesWindow publicProfiles = new ProfilesWindow(SelectedProfile, ValCCAPI); + publicProfiles.Owner = this; + publicProfiles.Show(); + } + } + + private void chkbxShareable_Click(object sender, RoutedEventArgs e) + { + if (!LoggedIn) + { + Utilities.Utils.MessageText("You are not logged in !", Brushes.Red); + ((CheckBox)sender).IsChecked = !((CheckBox)sender).IsChecked; + return; + } + } + + private async void btnShare_Click(object sender, RoutedEventArgs e) + { + if (!LoggedIn) + { + Utilities.Utils.MessageText("You are not logged in !", Brushes.Red); + return; + } + Utilities.Utils.MessageText("Your profile is being saved...", Brushes.Yellow); + + ValCCAPI.Shareable = (bool)chkbxShareable.IsChecked; + ValCCAPI.profile = SelectedProfile; + SetCallResponse response = await ValCCAPI.Set(); + if (!response.success) + { + Utilities.Utils.Log($"Unable to share crosshair: {response.message}"); + Utilities.Utils.MessageText("Unable to share crosshair: Internal Error/Conflict", Brushes.Red); + return; + } + String sharecode = response.message; + Clipboard.SetText(sharecode); + MessageWindow.Show($"Your sharecode is: \"{sharecode}\" and is copied.\nIf you want this profile accessible across the community,\nPlease be sure that you have the 'shareable' checkbox checked.", "Profile shared!"); + + Utilities.Utils.MessageText("Your profile has been saved. It can now be browsed if \"shareable\" checkbox is checked before saving.", Brushes.Lime); + } + + private async void spinner_Loaded(object sender, RoutedEventArgs e) + { + Trace.WriteLine(ValorantCC.src.Community.SCGen.GenerateShareCode("64f8b630-64c6-5838-9daa-916f8bbf5587")); + Trace.WriteLine(ValorantCC.src.Community.SCGen.GenerateShareCode("b19f4928-e1ed-5f63-a9d0-8a7fd202e3b2")); + Updater.CustomLogger = Utilities.Utils.Log; + Updater.OriginalFileName = "ValorantCC"; + Updater.LogInterfix = " | "; + if (await Updater.CheckUpdateAsync("weedeej", "ValorantCC")) + { + if (Updater.CannotWriteOnDir) + { + Utilities.Utils.Log("User is not authorized to create a file on current valcc dir. Consider moving."); + MessageWindow.Show("There's an update available but you have no access to write on this folder.\nPlease consider moving the app to a folder created by you or running the app as administrator."); + this.Close(); + } + var update = new UpdateWindow(); + update.Owner = this; + update.ShowDialog(); + } + } + + private void btnCopyShareCode_Click(object sender, RoutedEventArgs e) + { + Clipboard.SetText(_sharecode); + Utilities.Utils.MessageText("Your sharecode has been copied!", Brushes.Lime); + } + + private void _zoom_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) + { + Trace.WriteLine(_zoom.Value); + } } } diff --git a/ValorantCC/References/Xceed.Wpf.AvalonDock.Themes.Aero.dll b/ValorantCC/References/Xceed.Wpf.AvalonDock.Themes.Aero.dll deleted file mode 100644 index 4e51591..0000000 Binary files a/ValorantCC/References/Xceed.Wpf.AvalonDock.Themes.Aero.dll and /dev/null differ diff --git a/ValorantCC/References/Xceed.Wpf.AvalonDock.dll b/ValorantCC/References/Xceed.Wpf.AvalonDock.dll deleted file mode 100644 index bbddc15..0000000 Binary files a/ValorantCC/References/Xceed.Wpf.AvalonDock.dll and /dev/null differ diff --git a/ValorantCC/References/Xceed.Wpf.Toolkit.dll b/ValorantCC/References/Xceed.Wpf.Toolkit.dll deleted file mode 100644 index e686971..0000000 Binary files a/ValorantCC/References/Xceed.Wpf.Toolkit.dll and /dev/null differ diff --git a/ValorantCC/Resources/BGdictionary.xaml b/ValorantCC/Resources/BGdictionary.xaml new file mode 100644 index 0000000..82f69ee --- /dev/null +++ b/ValorantCC/Resources/BGdictionary.xaml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/ValorantCC/Resources/CrosshairBG1.png b/ValorantCC/Resources/CrosshairBG1.png index 9c504b0..d98bc01 100644 Binary files a/ValorantCC/Resources/CrosshairBG1.png and b/ValorantCC/Resources/CrosshairBG1.png differ diff --git a/ValorantCC/Resources/CrosshairBG2.png b/ValorantCC/Resources/CrosshairBG2.png index 09d5c9d..9002b37 100644 Binary files a/ValorantCC/Resources/CrosshairBG2.png and b/ValorantCC/Resources/CrosshairBG2.png differ diff --git a/ValorantCC/Resources/CrosshairBG3.png b/ValorantCC/Resources/CrosshairBG3.png index 81bfa7b..848c834 100644 Binary files a/ValorantCC/Resources/CrosshairBG3.png and b/ValorantCC/Resources/CrosshairBG3.png differ diff --git a/ValorantCC/Resources/CrosshairBG4.png b/ValorantCC/Resources/CrosshairBG4.png index e1b6252..e63ecf0 100644 Binary files a/ValorantCC/Resources/CrosshairBG4.png and b/ValorantCC/Resources/CrosshairBG4.png differ diff --git a/ValorantCC/Resources/CrosshairBG5.png b/ValorantCC/Resources/CrosshairBG5.png index e619566..b6fe745 100644 Binary files a/ValorantCC/Resources/CrosshairBG5.png and b/ValorantCC/Resources/CrosshairBG5.png differ diff --git a/ValorantCC/Resources/chevron-up.png b/ValorantCC/Resources/chevron-up.png new file mode 100644 index 0000000..1fb3c54 Binary files /dev/null and b/ValorantCC/Resources/chevron-up.png differ diff --git a/ValorantCC/Resources/menu.png b/ValorantCC/Resources/menu.png new file mode 100644 index 0000000..1354eb8 Binary files /dev/null and b/ValorantCC/Resources/menu.png differ diff --git a/ValorantCC/Resources/vtspinner optimized.gif b/ValorantCC/Resources/vtspinner optimized.gif new file mode 100644 index 0000000..299ed7e Binary files /dev/null and b/ValorantCC/Resources/vtspinner optimized.gif differ 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/MessageWindow.xaml b/ValorantCC/SubWindow/MessageWindow.xaml new file mode 100644 index 0000000..a8305bf --- /dev/null +++ b/ValorantCC/SubWindow/MessageWindow.xaml @@ -0,0 +1,20 @@ + + + +