From dcfe6c7dd419a0a0bda76786a1cfdae4206cbb33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20G=C3=B3mez?= <72423267+Haruki1707@users.noreply.github.com> Date: Sun, 20 Feb 2022 19:07:21 -0600 Subject: [PATCH] random custom color to legit white fix --- README.md | 2 +- ValorantCC/App.xaml.cs | 1 - ValorantCC/MainWindow.xaml.cs | 15 ++---- ValorantCC/SubWindow/ProfilesWindow.xaml.cs | 2 - ValorantCC/SubWindow/UpdateWindow.xaml.cs | 7 ++- ValorantCC/src/API.cs | 17 +++---- ValorantCC/src/Auth.cs | 1 - ValorantCC/src/BackgroundAuth.cs | 10 ++-- ValorantCC/src/Community/SCGen.cs | 4 -- ValorantCC/src/Modifier.cs | 3 -- ValorantCC/src/Processor.cs | 52 +++++++++++++++++---- ValorantCC/src/Utils.cs | 1 - 12 files changed, 68 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index 32c31ec..25e09fe 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ # 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. - + ## Usage - Either Open this first or Riot client or Valorant it doesn't matter. diff --git a/ValorantCC/App.xaml.cs b/ValorantCC/App.xaml.cs index d62e6b6..d988525 100644 --- a/ValorantCC/App.xaml.cs +++ b/ValorantCC/App.xaml.cs @@ -5,7 +5,6 @@ using System.Windows.Interop; using System.Windows.Media; using System.Windows.Threading; -using Utilities; namespace ValorantCC { diff --git a/ValorantCC/MainWindow.xaml.cs b/ValorantCC/MainWindow.xaml.cs index 11a9d95..59acc2f 100644 --- a/ValorantCC/MainWindow.xaml.cs +++ b/ValorantCC/MainWindow.xaml.cs @@ -1,5 +1,6 @@ using EZ_Updater; using MahApps.Metro.Controls; +using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Diagnostics; @@ -7,13 +8,10 @@ using System.Linq; using System.Windows; using System.Windows.Controls; -using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; -using Utilities; using ValorantCC.src; using ValorantCC.SubWindow; -using Newtonsoft.Json; namespace ValorantCC { @@ -34,7 +32,7 @@ public MainWindow() // Create logging dir 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, Utilities.Utils.LoggingFile + ".old", true); + 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(); @@ -356,7 +354,7 @@ private async void btnShare_Click(object sender, RoutedEventArgs e) 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); } @@ -369,12 +367,7 @@ private async void spinner_Loaded(object sender, RoutedEventArgs e) Updater.LogInterfix = " | "; if (await Updater.CheckUpdateAsync("weedeej", "ValorantCC")) { - try - { - File.Create("./valccPermsTest.null").Close(); - File.Delete("./valccPermsTest.null"); - } - catch (UnauthorizedAccessException) + 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."); diff --git a/ValorantCC/SubWindow/ProfilesWindow.xaml.cs b/ValorantCC/SubWindow/ProfilesWindow.xaml.cs index e663898..47e266d 100644 --- a/ValorantCC/SubWindow/ProfilesWindow.xaml.cs +++ b/ValorantCC/SubWindow/ProfilesWindow.xaml.cs @@ -1,7 +1,6 @@ using Newtonsoft.Json; using System; using System.Collections.Generic; -using System.Diagnostics; using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Windows; @@ -9,7 +8,6 @@ using System.Windows.Input; using System.Windows.Media; using ValorantCC.SubWindow; -using Utilities; namespace ValorantCC { /// diff --git a/ValorantCC/SubWindow/UpdateWindow.xaml.cs b/ValorantCC/SubWindow/UpdateWindow.xaml.cs index 0babd2d..0566521 100644 --- a/ValorantCC/SubWindow/UpdateWindow.xaml.cs +++ b/ValorantCC/SubWindow/UpdateWindow.xaml.cs @@ -19,13 +19,12 @@ private void UIChange(object sender, EventArgs e) Messagelbl.Content = Updater.Message; progressBar1.Value = Updater.ProgressPercentage; - switch (Updater.State) + switch (Updater.ShortState) { - case UpdaterState.Canceled: - case UpdaterState.InstallFailed: + case UpdaterShortState.Canceled: OKbtn.Visibility = Visibility.Visible; break; - case UpdaterState.Installed: + case UpdaterShortState.Installed: Process.Start(Updater.ProgramFileName); Application.Current.Shutdown(); break; diff --git a/ValorantCC/src/API.cs b/ValorantCC/src/API.cs index 24a3bea..602306d 100644 --- a/ValorantCC/src/API.cs +++ b/ValorantCC/src/API.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using Utilities; using ValorantCC.src.Community; + namespace ValorantCC { public struct SetCallResponse @@ -51,9 +52,9 @@ public API(AuthTokens Tokens, CrosshairProfile TargetProfile, int ActionInt, boo public async Task Fetch(String sharecode = null) { RestRequest request; - if (sharecode != null) + if (sharecode != null) request = new RestRequest($"/sharecode/{sharecode}", Method.Get); - else + else request = new RestRequest("/profiles", Method.Get); RestResponse response = await client.ExecuteAsync(request); @@ -64,13 +65,13 @@ public async Task Fetch(String sharecode = null) } if (response.StatusCode == System.Net.HttpStatusCode.NotFound) { - return new FetchResponse() { success = true, data = new List()}; + return new FetchResponse() { success = true, data = new List() }; } - return new FetchResponse() - { - success = true, - data = JsonConvert.DeserializeObject>(response.Content) + return new FetchResponse() + { + success = true, + data = JsonConvert.DeserializeObject>(response.Content) }; } @@ -106,7 +107,7 @@ public async Task Set() request.AddJsonBody(payload); request.AddOrUpdateHeader("Authorization", $"Bearer {AuthTokens.AccessToken}"); // Pass to server so nobody can set somebody's saved profile. RestResponse response = await client.ExecuteAsync(request); - if (!response.IsSuccessful) + if (!response.IsSuccessful) { Utils.Log(response.Content.ToString()); int retry = 0; diff --git a/ValorantCC/src/Auth.cs b/ValorantCC/src/Auth.cs index 704a899..711dadd 100644 --- a/ValorantCC/src/Auth.cs +++ b/ValorantCC/src/Auth.cs @@ -4,7 +4,6 @@ using System.IO; using System.Text; using System.Threading.Tasks; -using Utilities; namespace ValorantCC { public partial class AuthTokens diff --git a/ValorantCC/src/BackgroundAuth.cs b/ValorantCC/src/BackgroundAuth.cs index 7b3ea8a..490a6d2 100644 --- a/ValorantCC/src/BackgroundAuth.cs +++ b/ValorantCC/src/BackgroundAuth.cs @@ -1,10 +1,10 @@ using System; +using System.Diagnostics; using System.IO; using System.Linq; using System.Threading.Tasks; using System.Windows; using System.Windows.Media; -using Utilities; namespace ValorantCC { @@ -20,7 +20,6 @@ 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; - double OriginalHeight = main.Height; main.ch_display.Visibility = Visibility.Collapsed; main.buttons_group.Visibility = Visibility.Collapsed; main.controls_group.Visibility = Visibility.Collapsed; @@ -59,6 +58,9 @@ public async void LoopCheck() Utilities.Utils.MessageText(Utilities.Utils.LoginResponse(processor), Brushes.Lime); main.StatusTxt.Text = "Logged In!"; + main.UpdateLayout(); + double OriginalHeight = main.Height; + main.ch_display.Visibility = Visibility.Visible; main.buttons_group.Visibility = Visibility.Visible; main.controls_group.Visibility = Visibility.Visible; @@ -66,7 +68,9 @@ public async void LoopCheck() main.spinner.Visibility = Visibility.Collapsed; main.spinner.Spin = false; - main.Top = main.Top - (main.Height - OriginalHeight); + main.UpdateLayout(); + Trace.WriteLine(main.Height + " || " + OriginalHeight); + main.Top = main.Top - (main.Height - OriginalHeight) / 2; return; } diff --git a/ValorantCC/src/Community/SCGen.cs b/ValorantCC/src/Community/SCGen.cs index 9711c58..f9e256b 100644 --- a/ValorantCC/src/Community/SCGen.cs +++ b/ValorantCC/src/Community/SCGen.cs @@ -1,9 +1,5 @@ using System; -using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Numerics; namespace ValorantCC.src.Community { diff --git a/ValorantCC/src/Modifier.cs b/ValorantCC/src/Modifier.cs index 0490be6..373af5b 100644 --- a/ValorantCC/src/Modifier.cs +++ b/ValorantCC/src/Modifier.cs @@ -1,10 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Media; -using Utilities; namespace ValorantCC.src { diff --git a/ValorantCC/src/Processor.cs b/ValorantCC/src/Processor.cs index 2a1b681..0768f7f 100644 --- a/ValorantCC/src/Processor.cs +++ b/ValorantCC/src/Processor.cs @@ -2,11 +2,9 @@ using RestSharp; using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; using System.Threading.Tasks; using System.Windows.Media; -using Utilities; using ValorantCC.src; namespace ValorantCC { @@ -20,6 +18,19 @@ public class Processor public List ProfileNames; private ProfileList FetchedProfiles; public int CurrentProfile; + //Haruki's "bug" fix + private List DefaultColors = new List(); + + public Processor() + { + DefaultColors.Add(new Color { R = 0, G = 255, B = 0 }); + DefaultColors.Add(new Color { R = 127, G = 255, B = 0 }); + DefaultColors.Add(new Color { R = 255, G = 255, B = 0 }); + DefaultColors.Add(new Color { R = 0, G = 255, B = 255 }); + DefaultColors.Add(new Color { R = 255, G = 0, B = 255 }); + DefaultColors.Add(new Color { R = 255, G = 0, B = 0 }); + DefaultColors.Add(new Color { R = 255, G = 255, B = 255 }); + } public async Task Login() { @@ -51,7 +62,8 @@ public async Task Construct() try { SavedProfiles = UserSettings.stringSettings.First(setting => setting.settingEnum == "EAresStringSettingName::CrosshairColor"); - }catch (ArgumentNullException) + } + catch (ArgumentNullException) { Utilities.Utils.Log("User is new account/Using White Color"); UserSettings.stringSettings.Add(new Stringsetting @@ -90,11 +102,12 @@ private async Task FetchUserSettings() try { settings = Utilities.Utils.Decompress(Convert.ToString(response["data"])); - }catch (KeyNotFoundException) + } + catch (KeyNotFoundException) { return settings; } - + return settings; } @@ -109,13 +122,13 @@ private async Task putUserSettings(Data newData) RestResponse response = await client.ExecuteAsync(request); if (!response.IsSuccessful) { - Utilities.Utils.Log("savePreference Unsuccessfull: "+response.Content.ToString()); + Utilities.Utils.Log("savePreference Unsuccessfull: " + response.Content.ToString()); return false; } Dictionary responseDict = JsonConvert.DeserializeObject>(response.Content); if (responseDict.ContainsKey("data")) return true; - Utilities.Utils.Log("savePreference Unsuccessfull: "+response.Content.ToString()); + Utilities.Utils.Log("savePreference Unsuccessfull: " + response.Content.ToString()); return false; } @@ -199,10 +212,33 @@ private void SaveListedSettings(List Colors, int SelectedIndex) public async Task SaveNewColor(List Colors, int SelectedIndex, string ProfileName) { Utilities.Utils.Log("Save button clicked. Saving..."); + + if (ProfileListed) + SaveListedSettings(Colors, SelectedIndex); + + foreach (var item in FetchedProfiles.Profiles) + { + foreach (var color in DefaultColors) + { + var prfColor = item.Primary.Color; + if (prfColor.R == color.R && prfColor.G == color.G && prfColor.B == color.B) + if (prfColor.R != 0) + prfColor.R--; + else + prfColor.G--; + + prfColor = item.aDS.Color; + if (prfColor.R == color.R && prfColor.G == color.G && prfColor.B == color.B) + if (prfColor.R != 0) + prfColor.R--; + else + prfColor.G--; + } + } + if (ProfileListed) { Utilities.Utils.Log("Profile type: List"); - SaveListedSettings(Colors, SelectedIndex); FetchedProfiles.Profiles[SelectedIndex].ProfileName = ProfileName; Stringsetting SavedProfiles = UserSettings.stringSettings.FirstOrDefault(setting => setting.settingEnum == "EAresStringSettingName::SavedCrosshairProfileData"); SavedProfiles.value = JsonConvert.SerializeObject(FetchedProfiles); diff --git a/ValorantCC/src/Utils.cs b/ValorantCC/src/Utils.cs index 52de863..77e78fa 100644 --- a/ValorantCC/src/Utils.cs +++ b/ValorantCC/src/Utils.cs @@ -8,7 +8,6 @@ using System.Text.RegularExpressions; using System.Windows; using System.Windows.Controls; -using System.Windows.Documents; using System.Windows.Media; using ValorantCC;