diff --git a/ValorantCC/MainWindow.xaml b/ValorantCC/MainWindow.xaml
index 6a53b93..3108f21 100644
--- a/ValorantCC/MainWindow.xaml
+++ b/ValorantCC/MainWindow.xaml
@@ -6,7 +6,7 @@
xmlns:local="clr-namespace:ValorantCC" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:Controls="clr-namespace:Xceed.Wpf.AvalonDock.Themes.Controls;assembly=Xceed.Wpf.AvalonDock.Themes.Aero" x:Class="ValorantCC.MainWindow"
mc:Ignorable="d"
- Title="vTools - ValorantCC" Height="411" Width="500" SizeToContent="Manual" AllowsTransparency="True" WindowStartupLocation="CenterScreen" WindowState="Normal" ResizeMode="CanMinimize" WindowStyle="None" Icon="Resources/vtools-colored.ico"
+ Title="vTools - ValorantCC" Height="411 " Width="500" SizeToContent="Manual" AllowsTransparency="True" WindowStartupLocation="CenterScreen" WindowState="Normal" ResizeMode="CanMinimize" WindowStyle="None" Icon="Resources/vtools-colored.ico"
Background="Transparent"
RenderOptions.BitmapScalingMode="Fant">
@@ -17,7 +17,7 @@
-
@@ -32,9 +32,8 @@
-
+
-
@@ -54,7 +53,7 @@
-
+
@@ -68,29 +67,25 @@
-
-
-
-
-
+
+
+
+
@@ -184,9 +179,9 @@
-
+
-
+
@@ -209,7 +204,7 @@
-
+
diff --git a/ValorantCC/MainWindow.xaml.cs b/ValorantCC/MainWindow.xaml.cs
index 3a07eeb..35afd89 100644
--- a/ValorantCC/MainWindow.xaml.cs
+++ b/ValorantCC/MainWindow.xaml.cs
@@ -7,6 +7,7 @@
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
+using System.Linq;
using System.Windows.Shapes;
using Utilities;
using ValorantCC.src;
@@ -15,13 +16,16 @@ namespace ValorantCC
{
public partial class MainWindow : Window
{
+ readonly string LoggingDir = Environment.GetEnvironmentVariable("LocalAppData") + @"\VTools\Logs\";
Processor DataProcessor = new Processor();
- bool LoggedIn;
+ BrushConverter bc = new BrushConverter();
+ public AuthResponse AuthResponse;
CrosshairProfile SelectedProfile;
List SelectedColors;
+ private API ValCCAPI;
int SelectedIndex;
- BrushConverter bc = new BrushConverter();
- readonly string LoggingDir = Environment.GetEnvironmentVariable("LocalAppData") + @"\VTools\Logs\";
+ bool LoggedIn;
+
public MainWindow()
{
// Create logging dir
@@ -39,7 +43,6 @@ public MainWindow()
private async void Grid_Loaded(object sender, RoutedEventArgs e)
{
Updater.CustomLogger = Utils.Log;
-
if (await Updater.CheckUpdateAsync("weedeej", "ValorantCC"))
{
var update = new UpdateWindow();
@@ -89,7 +92,8 @@ private void btnLogin_Click(object sender, RoutedEventArgs e)
profiles.SelectedIndex = DataProcessor.CurrentProfile;
profiles.IsReadOnly = false;
MessageBox.Show(Utils.LoginResponse(DataProcessor));
- btnLogin.IsEnabled = true;
+ btnLogin.IsEnabled = false;
+ ValCCAPI = new API(AuthResponse.AuthTokens, SelectedProfile, 2, (bool)chkbxShareable.IsChecked);
}
private void profiles_SelectionChanged(object sender, SelectionChangedEventArgs e)
@@ -98,6 +102,7 @@ private void profiles_SelectionChanged(object sender, SelectionChangedEventArgs
SelectedIndex = profiles.SelectedIndex;
SelectedProfile = DataProcessor.ProfileFromIndex(SelectedIndex);
+ ValCCAPI.profile = SelectedProfile;
primary_color.SelectedColor = Color.FromRgb(SelectedProfile.Primary.Color.R, SelectedProfile.Primary.Color.G, SelectedProfile.Primary.Color.B);
if (!DataProcessor.ProfileListed)
@@ -260,11 +265,15 @@ 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)
@@ -296,5 +305,28 @@ private ImageSource Get_CrosshairBG(bool next = true)
return (ImageSource)FindResource("crosshairBG" + number);
}
+
+ private void btnCommunityProfiles_Click(object sender, RoutedEventArgs e)
+ {
+ if (!LoggedIn)
+ {
+ MessageBox.Show("You are not logged in!");
+ return;
+ }
+ try
+ {
+ Window publicProfiles = Application.Current.Windows.Cast().Single(window => window.GetType().ToString() == "ValorantCC.ProfilesWindow");
+ publicProfiles.Activate();
+ }catch(Exception ex)
+ {
+ ProfilesWindow publicProfiles = new ProfilesWindow(SelectedProfile, ValCCAPI);
+ publicProfiles.Show();
+ }
+ }
+
+ private void chkbxShareable_Click(object sender, RoutedEventArgs e)
+ {
+ if (LoggedIn) ValCCAPI.Shareable = (bool)chkbxShareable.IsChecked;
+ }
}
}
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/SubWindow/ProfilesWindow.xaml b/ValorantCC/SubWindow/ProfilesWindow.xaml
new file mode 100644
index 0000000..2b37202
--- /dev/null
+++ b/ValorantCC/SubWindow/ProfilesWindow.xaml
@@ -0,0 +1,63 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ValorantCC/SubWindow/ProfilesWindow.xaml.cs b/ValorantCC/SubWindow/ProfilesWindow.xaml.cs
new file mode 100644
index 0000000..8a53fde
--- /dev/null
+++ b/ValorantCC/SubWindow/ProfilesWindow.xaml.cs
@@ -0,0 +1,88 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+using Newtonsoft.Json;
+namespace ValorantCC
+{
+ ///
+ /// Interaction logic for ProfilesWindow.xaml
+ ///
+
+ public struct PublicProfile
+ {
+ public String owner { get; set; }
+ public CrosshairProfile settings { get; set; }
+ }
+
+ public partial class ProfilesWindow : Window
+ {
+ public CrosshairProfile selected;
+ private static API ValCCApi;
+ private static MainWindow main;
+ private static List PublicProfiles = new List();
+ public ProfilesWindow(CrosshairProfile current, API ValCCAPI)
+ {
+ InitializeComponent();
+ main = (MainWindow) Application.Current.MainWindow;
+ ValCCApi = ValCCAPI;
+ InitialFetch();
+ RenderProfiles();
+ }
+
+ ///
+ /// Returns the searched sharecode or the list of shareables depending if sharecode is provided or not.
+ ///
+ /// Nullable. Searched Code
+ private static void InitialFetch(String sharecode = null)
+ {
+ List Shareables;
+ if (sharecode != null)
+ {
+ ValCCApi.Action = 3;
+ Shareables = ValCCApi.Fetch(sharecode).data;
+ }
+ else Shareables = ValCCApi.Fetch().data;
+
+
+ for (int i = 0; i < Shareables.Count; i++)
+ {
+ ShareableProfile currentShareable = Shareables[i];
+ CrosshairProfile profile;
+ try
+ {
+ profile = JsonConvert.DeserializeObject(currentShareable.settings);
+ }
+ catch
+ {
+ continue;
+ }
+ PublicProfiles.Add(new PublicProfile() { owner = currentShareable.displayName, settings = profile });
+ }
+ }
+
+ ///
+ /// Render the PublicProfiles var into frontend.
+ ///
+ private static void RenderProfiles()
+ {
+
+ }
+ private void btnSearchCode_Click(object sender, RoutedEventArgs e)
+ {
+ if (SearchCode.Text == null || SearchCode.Text == "") return;
+ InitialFetch(SearchCode.Text);
+ RenderProfiles();
+ }
+ }
+}
diff --git a/ValorantCC/ValorantCC.csproj b/ValorantCC/ValorantCC.csproj
index 1fe33e0..689af23 100644
--- a/ValorantCC/ValorantCC.csproj
+++ b/ValorantCC/ValorantCC.csproj
@@ -21,6 +21,8 @@
+
+
@@ -37,6 +39,12 @@
PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
PreserveNewest
diff --git a/ValorantCC/src/API.cs b/ValorantCC/src/API.cs
new file mode 100644
index 0000000..76604d5
--- /dev/null
+++ b/ValorantCC/src/API.cs
@@ -0,0 +1,94 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using RestSharp;
+using Newtonsoft.Json;
+
+namespace ValorantCC
+{
+ public struct VoidCallResponse
+ {
+ public bool success { get; set; }
+ public Object data { get; set; }
+ }
+
+ public struct FetchResponse
+ {
+ public bool success { get; set; }
+ public List data {get; set; }
+ }
+
+ public struct ShareableProfile
+ {
+ public String shareCode { get; }
+ public String settings { get; }
+ public bool shareable { get; }
+ public String displayName { get; }
+ }
+
+ public partial class PostPayload
+ {
+ public String subject { get; set; }
+ public String settings { get; set; }
+ public bool shareable { get; set; }
+ public String sharecode { get; set; } = null;
+ public int action { get; set; }
+ }
+ public class API
+ {
+ private static AuthTokens AuthTokens;
+ private static RestClient client = new RestClient("https://valorantcc.000webhostapp.com/api.php");
+
+ public CrosshairProfile profile;
+ public int Action;
+ public bool Shareable;
+ public API(AuthTokens Tokens, CrosshairProfile TargetProfile ,int ActionInt, bool isShareable)
+ {
+ AuthTokens = Tokens;
+ profile = TargetProfile;
+ Action = ActionInt;
+ Shareable = isShareable;
+ }
+
+ public FetchResponse Fetch(String sharecode = null)
+ {
+ PostPayload payload = new PostPayload()
+ {
+ subject = AuthTokens.Subject,
+ settings = JsonConvert.SerializeObject(profile),
+ shareable = Shareable,
+ action = Action
+ };
+ if (sharecode != null)
+ {
+ payload.sharecode = sharecode;
+ payload.action = Action;
+ }
+ RestRequest request = new RestRequest() { Method = Method.POST};
+ request.AddParameter("application/json", payload, ParameterType.RequestBody);
+ RestResponse response = (RestResponse)client.Execute(request);
+ if (response.StatusCode != System.Net.HttpStatusCode.OK) return new FetchResponse() { success = false };
+ return JsonConvert.DeserializeObject(response.Content);
+ }
+
+ public VoidCallResponse Set()
+ {
+ PostPayload payload = new PostPayload()
+ {
+ subject = AuthTokens.Subject,
+ settings = JsonConvert.SerializeObject(profile),
+ shareable = Shareable,
+ action = Action
+ };
+ RestRequest request = new RestRequest() { Method = Method.POST };
+ request.AddParameter("application/json", payload, ParameterType.RequestBody);
+ request.AddHeader("Authorization", $"Bearer {AuthTokens.AccessToken}"); // Pass to server so nobody can set somebody's saved profile.
+ RestResponse response = (RestResponse)client.Execute(request);
+ if (response.StatusCode != System.Net.HttpStatusCode.OK) return new VoidCallResponse() { success = false };
+ return JsonConvert.DeserializeObject(response.Content);
+ }
+
+ }
+}