Skip to content

Commit

Permalink
random custom color to legit white fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Haruki1707 committed Feb 21, 2022
1 parent 0cbf823 commit dcfe6c7
Show file tree
Hide file tree
Showing 12 changed files with 68 additions and 47 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
<img src="https://user-images.githubusercontent.com/72423267/153475468-c7894eb9-6f3d-4afe-a961-8f534a45146a.png">
<img src="https://user-images.githubusercontent.com/72423267/154873333-3f56b4e5-00d9-45a2-a3a4-9d99e39cd56e.png">

## Usage
- Either Open this first or Riot client or Valorant it doesn't matter.
Expand Down
1 change: 0 additions & 1 deletion ValorantCC/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Threading;
using Utilities;

namespace ValorantCC
{
Expand Down
15 changes: 4 additions & 11 deletions ValorantCC/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
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.Documents;
using System.Windows.Input;
using System.Windows.Media;
using Utilities;
using ValorantCC.src;
using ValorantCC.SubWindow;
using Newtonsoft.Json;

namespace ValorantCC
{
Expand All @@ -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();
Expand Down Expand Up @@ -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);
}

Expand All @@ -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.");
Expand Down
2 changes: 0 additions & 2 deletions ValorantCC/SubWindow/ProfilesWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using ValorantCC.SubWindow;
using Utilities;
namespace ValorantCC
{
/// <summary>
Expand Down
7 changes: 3 additions & 4 deletions ValorantCC/SubWindow/UpdateWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
17 changes: 9 additions & 8 deletions ValorantCC/src/API.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Threading.Tasks;
using Utilities;
using ValorantCC.src.Community;

namespace ValorantCC
{
public struct SetCallResponse
Expand Down Expand Up @@ -51,9 +52,9 @@ public API(AuthTokens Tokens, CrosshairProfile TargetProfile, int ActionInt, boo
public async Task<FetchResponse> 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);
Expand All @@ -64,13 +65,13 @@ public async Task<FetchResponse> Fetch(String sharecode = null)
}
if (response.StatusCode == System.Net.HttpStatusCode.NotFound)
{
return new FetchResponse() { success = true, data = new List<ShareableProfile>()};
return new FetchResponse() { success = true, data = new List<ShareableProfile>() };
}

return new FetchResponse()
{
success = true,
data = JsonConvert.DeserializeObject<List<ShareableProfile>>(response.Content)
return new FetchResponse()
{
success = true,
data = JsonConvert.DeserializeObject<List<ShareableProfile>>(response.Content)
};
}

Expand Down Expand Up @@ -106,7 +107,7 @@ public async Task<SetCallResponse> 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;
Expand Down
1 change: 0 additions & 1 deletion ValorantCC/src/Auth.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.IO;
using System.Text;
using System.Threading.Tasks;
using Utilities;
namespace ValorantCC
{
public partial class AuthTokens
Expand Down
10 changes: 7 additions & 3 deletions ValorantCC/src/BackgroundAuth.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -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;
Expand Down Expand Up @@ -59,14 +58,19 @@ 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;
main.chkbxShareable.Visibility = Visibility.Visible;

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;
}
Expand Down
4 changes: 0 additions & 4 deletions ValorantCC/src/Community/SCGen.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down
3 changes: 0 additions & 3 deletions ValorantCC/src/Modifier.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down
52 changes: 44 additions & 8 deletions ValorantCC/src/Processor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -20,6 +18,19 @@ public class Processor
public List<string> ProfileNames;
private ProfileList FetchedProfiles;
public int CurrentProfile;
//Haruki's "bug" fix
private List<Color> DefaultColors = new List<Color>();

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<AuthResponse> Login()
{
Expand Down Expand Up @@ -51,7 +62,8 @@ public async Task<bool> 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
Expand Down Expand Up @@ -90,11 +102,12 @@ private async Task<Data> FetchUserSettings()
try
{
settings = Utilities.Utils.Decompress(Convert.ToString(response["data"]));
}catch (KeyNotFoundException)
}
catch (KeyNotFoundException)
{
return settings;
}

return settings;
}

Expand All @@ -109,13 +122,13 @@ private async Task<bool> 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<string, object> responseDict = JsonConvert.DeserializeObject<Dictionary<string, object>>(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;
}

Expand Down Expand Up @@ -199,10 +212,33 @@ private void SaveListedSettings(List<Color> Colors, int SelectedIndex)
public async Task<bool> SaveNewColor(List<Color> 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);
Expand Down
1 change: 0 additions & 1 deletion ValorantCC/src/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit dcfe6c7

Please # to comment.