Skip to content

Commit

Permalink
Fixes for recent bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
weedeej committed Feb 13, 2022
1 parent 3ff4ad8 commit d6bb70e
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 36 deletions.
8 changes: 5 additions & 3 deletions ValorantCC/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public MainWindow()

InitializeComponent();
Utils.Log($"App Started | v{ProgramFileVersion}. Replaced old logfile.");
Txt_CurrVer.Content = $"v{ProgramFileVersion}";
Txt_CurrVer.Content = $"ValorantCC3.0b - v{ProgramFileVersion}";
BackgroundAuth auth = new BackgroundAuth(DataProcessor);
auth.LoopCheck();
}
Expand Down Expand Up @@ -88,7 +88,7 @@ private async void btnSave_Click(object sender, RoutedEventArgs e)
Utils.MessageText("Saved! Restart Valorant.", Brushes.Lime);
return;
}
Utils.MessageText("Failed. Consult developer.", Brushes.Red);
Utils.MessageText("Your session expired! Please restart ValorantCC/Valorant", Brushes.Red);

return;
}
Expand Down Expand Up @@ -130,7 +130,9 @@ private async void btnReload_Click(object sender, RoutedEventArgs e)
return;
}
Utils.Log("Reload Clicked > Reconstructing Processor.");
await DataProcessor.Construct();
if (!(await DataProcessor.Construct()))
Utils.MessageText("Your session expired! Please restart ValorantCC/Valorant", Brushes.Red);

profiles.ItemsSource = DataProcessor.ProfileNames;
profiles.Items.Refresh();
profiles.SelectedIndex = DataProcessor.CurrentProfile;
Expand Down
2 changes: 1 addition & 1 deletion ValorantCC/SubWindow/ProfilesWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public partial class ProfilesWindow : Window
public ProfilesWindow(CrosshairProfile current, API ValCCAPI)
{
InitializeComponent();
main = (MainWindow)this.Owner;
main = (MainWindow)Application.Current.MainWindow;
selected = current;
ValCCApi = ValCCAPI;
}
Expand Down
2 changes: 1 addition & 1 deletion ValorantCC/ValorantCC.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<AssemblyVersion></AssemblyVersion>
<FileVersion></FileVersion>
<Version>3.0.0</Version>
<Version>2.9.0</Version>
<SignAssembly>false</SignAssembly>
</PropertyGroup>

Expand Down
41 changes: 41 additions & 0 deletions ValorantCC/src/Modifier.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
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
{
public static class Modifier
{
public static Data ChangeActiveProfile(List<Color> Colors, int SelectedIndex, Data UserSettings, ProfileList FetchedProfiles)
{
Utils.Log("Updating active color");
try
{
Stringsetting activeProfileColor = UserSettings.stringSettings.First(setting => setting.settingEnum == "EAresStringSettingName::CrosshairColor");
activeProfileColor.value = Utils.ColorToString(Colors[0]);
}
catch (ArgumentNullException ex)
{
UserSettings.stringSettings.Add(new Stringsetting { settingEnum = "EAresStringSettingName::CrosshairColor", value = Utils.ColorToString(Colors[0]) });
}
if (FetchedProfiles.Profiles[SelectedIndex].bUseAdvancedOptions)
{
Utils.Log("Removing Old colors.");
UserSettings.stringSettings.RemoveAll(setting => setting.settingEnum == "EAresStringSettingName::CrosshairSniperCenterDotColor");
UserSettings.stringSettings.RemoveAll(setting => setting.settingEnum == "EAresStringSettingName::CrosshairADSColor");
UserSettings.stringSettings.RemoveAll(setting => setting.settingEnum == "EAresStringSettingName::CrosshairOutlineColor");
UserSettings.stringSettings.RemoveAll(setting => setting.settingEnum == "EAresStringSettingName::CrosshairADSOutlineColor");
}
Utils.Log("Appending new colors.");
UserSettings.stringSettings.Add(new Stringsetting { settingEnum = "EAresStringSettingName::CrosshairSniperCenterDotColor", value = Utils.ColorToString(Colors[4]) });
UserSettings.stringSettings.Add(new Stringsetting { settingEnum = "EAresStringSettingName::CrosshairADSColor", value = Utils.ColorToString(Colors[2]) });
UserSettings.stringSettings.Add(new Stringsetting { settingEnum = "EAresStringSettingName::CrosshairOutlineColor", value = Utils.ColorToString(Colors[1]) });
UserSettings.stringSettings.Add(new Stringsetting { settingEnum = "EAresStringSettingName::CrosshairADSOutlineColor", value = Utils.ColorToString(Colors[3]) });
return UserSettings;
}
}
}
48 changes: 17 additions & 31 deletions ValorantCC/src/Processor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
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
{
public class Processor
Expand Down Expand Up @@ -36,6 +37,8 @@ public async Task<bool> Construct()
Utils.Log("Constructing Properties -->");

UserSettings = await FetchUserSettings();
if (UserSettings.settingsProfiles == null) return false;

ProfileListed = CheckIfList(UserSettings);
Utils.Log($"Multiple Profiles: {ProfileListed}");
Stringsetting SavedProfiles;
Expand Down Expand Up @@ -80,9 +83,18 @@ private async Task<Data> FetchUserSettings()
Utils.Log("Obtaining User Settings");
RestRequest request = new RestRequest("/playerPref/v3/getPreference/Ares.PlayerSettings", Method.Get);
request.AddHeaders(Utils.ConstructHeaders(AuthResponse));
string responseContext = (await client.ExecuteAsync(request)).Content;
Dictionary<string, object> response = JsonConvert.DeserializeObject<Dictionary<string, object>>(responseContext);
Data settings = Utils.Decompress(Convert.ToString(response["data"]));
string responseContent = (await client.ExecuteAsync(request)).Content;
RestResponse resp = await client.ExecuteAsync(request);
Dictionary<string, object> response = JsonConvert.DeserializeObject<Dictionary<string, object>>(responseContent);
Data settings = new Data();
try
{
settings = Utils.Decompress(Convert.ToString(response["data"]));
}catch (KeyNotFoundException)
{
return settings;
}

return settings;
}

Expand Down Expand Up @@ -147,39 +159,13 @@ public CrosshairProfile ProfileFromIndex(int Index)
return FetchedProfiles.Profiles[Index];
}

private void ChangeActiveProfile(List<Color> Colors, int SelectedIndex)
{
Utils.Log("Updating active color");
try
{
Stringsetting activeProfileColor = UserSettings.stringSettings.First(setting => setting.settingEnum == "EAresStringSettingName::CrosshairColor");
activeProfileColor.value = Utils.ColorToString(Colors[0]);
}
catch (ArgumentNullException ex)
{
UserSettings.stringSettings.Add(new Stringsetting { settingEnum = "EAresStringSettingName::CrosshairColor", value = Utils.ColorToString(Colors[0]) });
}
if (FetchedProfiles.Profiles[SelectedIndex].bUseAdvancedOptions)
{
Utils.Log("Removing Old colors.");
UserSettings.stringSettings.RemoveAll(setting => setting.settingEnum == "EAresStringSettingName::CrosshairSniperCenterDotColor");
UserSettings.stringSettings.RemoveAll(setting => setting.settingEnum == "EAresStringSettingName::CrosshairADSColor");
UserSettings.stringSettings.RemoveAll(setting => setting.settingEnum == "EAresStringSettingName::CrosshairOutlineColor");
UserSettings.stringSettings.RemoveAll(setting => setting.settingEnum == "EAresStringSettingName::CrosshairADSOutlineColor");
}
Utils.Log("Appending new colors.");
UserSettings.stringSettings.Add(new Stringsetting { settingEnum = "EAresStringSettingName::CrosshairSniperCenterDotColor", value = Utils.ColorToString(Colors[4]) });
UserSettings.stringSettings.Add(new Stringsetting { settingEnum = "EAresStringSettingName::CrosshairADSColor", value = Utils.ColorToString(Colors[2]) });
UserSettings.stringSettings.Add(new Stringsetting { settingEnum = "EAresStringSettingName::CrosshairOutlineColor", value = Utils.ColorToString(Colors[1]) });
UserSettings.stringSettings.Add(new Stringsetting { settingEnum = "EAresStringSettingName::CrosshairADSOutlineColor", value = Utils.ColorToString(Colors[3]) });
}
private void SaveListedSettings(List<Color> Colors, int SelectedIndex)
{
if (SelectedIndex == FetchedProfiles.CurrentProfile)
{
try
{
ChangeActiveProfile(Colors, SelectedIndex);
UserSettings = Modifier.ChangeActiveProfile(Colors, SelectedIndex, UserSettings, FetchedProfiles);
}
catch (Exception e)
{
Expand Down

0 comments on commit d6bb70e

Please # to comment.