Skip to content

Commit

Permalink
dev phase 4.69
Browse files Browse the repository at this point in the history
  • Loading branch information
weedeej committed Jan 16, 2022
1 parent 9fd52fe commit 26a6df4
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 50 deletions.
7 changes: 5 additions & 2 deletions ValorantCC/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
using System.Windows.Shapes;
using Utilities;
using ValorantCC.src;
using System.Threading;
using System.Threading.Tasks;

namespace ValorantCC
{
Expand Down Expand Up @@ -97,7 +99,7 @@ private void btnLogin_Click(object sender, RoutedEventArgs e)
profiles.IsReadOnly = false;
MessageBox.Show(Utils.LoginResponse(DataProcessor));
btnLogin.IsEnabled = false;
ValCCAPI = new API(AuthResponse.AuthTokens, SelectedProfile, 2, (bool)chkbxShareable.IsChecked);
ValCCAPI = new API(AuthResponse.AuthTokens, SelectedProfile, 2, (chkbxShareable.IsChecked ?? false));
}

private void profiles_SelectionChanged(object sender, SelectionChangedEventArgs e)
Expand Down Expand Up @@ -334,10 +336,11 @@ private void chkbxShareable_Click(object sender, RoutedEventArgs e)
if (!LoggedIn)
{
MessageBox.Show("You are not logged in!");
((CheckBox)sender).IsChecked = !((CheckBox)sender).IsChecked;
return;
}
ValCCAPI.Shareable = (bool)chkbxShareable.IsChecked;
ValCCAPI.Set();
_ = ValCCAPI.Set();
}
}
}
2 changes: 1 addition & 1 deletion ValorantCC/SubWindow/ProfilesWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
xmlns:local="clr-namespace:ValorantCC"
mc:Ignorable="d"
Title="ProfilesWindow" Height="Auto" Width="Auto" ResizeMode="NoResize" SizeToContent="WidthAndHeight">
<Border Background="#232429" Height="450" Width="350" Loaded="Border_Loaded">
<Border Background="#232429" Height="450" Width="351" Loaded="Border_Loaded">
<StackPanel Name="Container" HorizontalAlignment="Center" Margin="0,5">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<TextBox Name="SearchCode" MinWidth="165" MaxWidth="165" Background="#FF393B44" Margin="0,0,5,0" Foreground="White"/>
Expand Down
11 changes: 8 additions & 3 deletions ValorantCC/SubWindow/ProfilesWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,14 @@ private static async Task<bool> InitialFetch(String sharecode = null)
if (sharecode != null)
{
ValCCApi.Action = 3;
Shareables = ValCCApi.Fetch(sharecode).data;
Shareables = (await ValCCApi.Fetch(sharecode)).data;
}
else
{
ValCCApi.Action = 2;
Shareables = (await ValCCApi.Fetch()).data;

}
else Shareables = ValCCApi.Fetch().data;

if (Shareables.Count == 0) return true;
for (int i = 0; i < Shareables.Count; i++)
Expand Down Expand Up @@ -208,7 +213,7 @@ private async Task<UIElement> CreateRender(PublicProfile profile)
Grid0.Children.Add(applyButton);

Crosshair_Parser.Generate(0, Grid0, profile.settings.Primary);

Crosshair_Parser.Generate(2, Grid0, profile.settings.aDS);
template.Child = Grid0;
await Task.Delay(1);
return template;
Expand Down
20 changes: 12 additions & 8 deletions ValorantCC/src/API.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Newtonsoft.Json;
using System.Text.RegularExpressions;
using System.Diagnostics;
using RestSharp.Authenticators;

namespace ValorantCC
{
Expand Down Expand Up @@ -54,7 +55,7 @@ public API(AuthTokens Tokens, CrosshairProfile TargetProfile ,int ActionInt, boo
Shareable = isShareable;
}

public FetchResponse Fetch(String sharecode = null)
public async Task<FetchResponse> Fetch(String sharecode = null)
{
PostPayload payload = new PostPayload()
{
Expand All @@ -70,26 +71,29 @@ public FetchResponse Fetch(String sharecode = null)
}
RestRequest request = new RestRequest() { Method = Method.POST};
request.AddJsonBody(payload);
RestResponse response = (RestResponse)client.Execute(request);
RestResponse response = (RestResponse)await client.ExecuteAsync(request);

if (response.StatusCode != System.Net.HttpStatusCode.OK) return new FetchResponse() { success = false };
return JsonConvert.DeserializeObject<FetchResponse>(Regex.Unescape(response.Content));
return JsonConvert.DeserializeObject<FetchResponse>(response.Content);
}

public VoidCallResponse Set()
public async Task<VoidCallResponse> Set()
{
PostPayload payload = new PostPayload()
{
subject = AuthTokens.Subject,
settings = JsonConvert.SerializeObject(profile),
shareable = Shareable,
action = Action
action = 1
};
RestRequest request = new RestRequest() { Method = Method.POST };
//client.Authenticator = new JwtAuthenticator(AuthTokens.AccessToken);
request.RequestFormat = DataFormat.Json;
request.AddJsonBody(payload);
request.AddHeader("Authorization", $"Bearer {AuthTokens.AccessToken}"); // Pass to server so nobody can set somebody's saved profile.
RestResponse response = (RestResponse)client.Execute(request);
request.AddOrUpdateHeader("Authorization", $"Bearer {AuthTokens.AccessToken}"); // Pass to server so nobody can set somebody's saved profile.
RestResponse response = (RestResponse)await client.ExecuteAsync(request);
if (response.StatusCode != System.Net.HttpStatusCode.OK) return new VoidCallResponse() { success = false };
return JsonConvert.DeserializeObject<VoidCallResponse>(Regex.Unescape(response.Content));
return JsonConvert.DeserializeObject<VoidCallResponse>(response.Content);
}

}
Expand Down
36 changes: 0 additions & 36 deletions ValorantCC/src/Crosshair_Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,42 +20,6 @@ public static void Generate(int column, Grid grid, ProfileSettings settings)
{
Rectangle[] rectangles = new Rectangle[16];
int recindex = 0;
/*for (int i = 1; i <= 4; i++)
{
string name = $"prime{}";
switch (i)
{
case 0:
name += "X";
break;
case 1:
name += "Y";
break;
case 2:
name += "OLX";
break;
case 3:
name += "OLY";
break;
}
for (int j = 1; j <= 4; j++)
{
string subname = name;
if (j % 2 != 0)
subname += "OT";
Rectangle rectangle = new Rectangle()
{
Name = subname,
Width = 3,
Height = 3
};
rectangles[recindex] = rectangle;
recindex++;
}
}*/

for (int i = 0; i < rectangles.Length; i++)
{
Rectangle rectangle = new Rectangle()
Expand Down

0 comments on commit 26a6df4

Please # to comment.