Skip to content

Commit

Permalink
Dev phase 2
Browse files Browse the repository at this point in the history
  • Loading branch information
weedeej committed Jan 4, 2022
1 parent 6e7fb0d commit 4265b86
Show file tree
Hide file tree
Showing 8 changed files with 308 additions and 28 deletions.
37 changes: 16 additions & 21 deletions ValorantCC/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
<Window.Resources>
Expand All @@ -17,7 +17,7 @@
<BitmapImage x:Key="crosshairBG4" UriSource="Resources/CrosshairBG4.png"/>
<BitmapImage x:Key="crosshairBG5" UriSource="Resources/CrosshairBG5.png"/>
</Window.Resources>
<Border Background="#232429"
<Border Background="#232429"
CornerRadius="7">
<UserControl Foreground="{x:Null}" OpacityMask="#FFA42727">
<UserControl.Resources>
Expand All @@ -32,9 +32,8 @@
</Style>
</ResourceDictionary>
</UserControl.Resources>
<StackPanel MouseDown="StackPanel_MouseDown">
<StackPanel MouseDown="StackPanel_MouseDown" HorizontalAlignment="Left">
<Grid Loaded="Grid_Loaded">

<Grid.Background>
<ImageBrush/>
</Grid.Background>
Expand All @@ -54,7 +53,7 @@
</Grid>
</Border>
</Grid>
<Grid Margin="0,3,0,0" MouseDown="StackPanel_MouseDown">
<Grid Margin="0,3,0,0" MouseDown="StackPanel_MouseDown" MaxWidth="500" MaxHeight="411">
<Grid.ColumnDefinitions>
<ColumnDefinition MaxWidth="65" Width="65*"/>
<ColumnDefinition Width="43*"/>
Expand All @@ -68,29 +67,25 @@
<TextBlock FontWeight="Bold" Grid.Column="0" Margin="5,0,43,0" Foreground="White" FontFamily="Segoe UI Semibold" VerticalAlignment="Top" Grid.ColumnSpan="2"><Run Text="Logged In:"/></TextBlock>
<TextBlock Margin="2,-5,0,0" FontWeight="Bold" Foreground="#FFF90C0C" x:Name="txt_LoggedIn" FontSize="18" Grid.Column="1" VerticalAlignment="Top" HorizontalAlignment="Left"><Run Text=""/></TextBlock>
<ComboBox x:Name="profiles" Grid.Column="5" SelectionChanged="profiles_SelectionChanged" SelectedIndex="0" IsEditable="True" IsReadOnly="True" Text="Profiles" TextBoxBase.TextChanged="profiles_TextChanged" Background="#FF232429" Foreground="White" Margin="0,-1,2,1" FontFamily="Quicksand" TextBlock.FontFamily="Segoe UI Semibold" TextBlock.FontWeight="Bold"/>

<!--<TextBlock FontWeight="Bold" Grid.Column="2" Foreground="White">Current Color: </TextBlock>
<TextBlock Margin="0,1,0,0" FontWeight="Bold" Grid.Column="3" Foreground="Black"
x:Name="txt_CurrentColor">
</TextBlock>-->

<!--<TextBlock FontWeight="Bold" Grid.Column="6" Foreground="White">Current Profile:</TextBlock>
<TextBlock Margin="0,1,0,0" FontWeight="Bold" Grid.Column="7" Foreground="Red"
x:Name="txt_CurrentProfile">
N/A
</TextBlock>-->
</Grid>
<Grid>
<Grid MaxWidth="500" MaxHeight="411">
<Image x:Name="CrosshairBG" Source="{StaticResource crosshairBG0}" Margin="1,3,-1,3"/>

<StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Right">
<CheckBox Name="chkbxShareable" Content="Shareable?" VerticalAlignment="Center" FontWeight="Bold" Foreground="White" Margin="0,0,25,0" FlowDirection="LeftToRight" Click="chkbxShareable_Click"/>
<Button Name="btnCommunityProfiles" Background="{x:Null}" BorderBrush="{x:Null}" Foreground="{x:Null}" Style="{DynamicResource RightButtonStyle}" Cursor="Hand" MouseEnter="ClipboardButtonEnter" MouseLeave="ClipboardButtonLeave" Click="btnCommunityProfiles_Click" Margin="0,0,10,0">
<StackPanel Orientation="Horizontal">
<Label Name="communitylist_label" Content="Community Profiles" Foreground="White" FontWeight="Bold" VerticalContentAlignment="Center"/>
<Image Source="Resources/menu.png" Width="24"/>
</StackPanel>
</Button>
<Button Name="btnCopyLogs" Background="{x:Null}" BorderBrush="{x:Null}" Foreground="{x:Null}" Style="{DynamicResource RightButtonStyle}" Cursor="Hand" MouseEnter="ClipboardButtonEnter" MouseLeave="ClipboardButtonLeave" Click="btnOpenLogs_Click">
<StackPanel Orientation="Horizontal">
<Label Name="CopyButtonLabel" Content="Logs Folder" Foreground="White" FontWeight="Bold" VerticalContentAlignment="Center"/>
<Image Source="Resources/folder.png" Stretch="None"/>
</StackPanel>
</Button>

</StackPanel>
<Grid>
<Grid.ColumnDefinitions>
Expand Down Expand Up @@ -184,9 +179,9 @@
</Button>
</Grid>

<Path Data="M28,378 L573,378" Fill="#16171B" Height="1" Stretch="Fill" Stroke="White" Width="538"/>
<Path Data="M28,378 L573,378" MaxWidth="500" MaxHeight="411" Fill="#16171B" Height="1" Stretch="Fill" Stroke="White" Width="500"/>

<Grid Margin="3" Height="26" RenderTransformOrigin="0.5,0.5" Width="494">
<Grid Margin="3" Height="26" RenderTransformOrigin="0.5,0.5" Width="494" MaxWidth="500" MaxHeight="411">
<Grid.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleY="1"/>
Expand All @@ -209,7 +204,7 @@
<Button x:Name="btnLogin" Style="{DynamicResource RoundButton}" Content="Login" HorizontalContentAlignment="Left" Click="btnLogin_Click" Cursor="Hand" Height="25" VerticalContentAlignment="Top" HorizontalAlignment="Left" VerticalAlignment="Center" Width="124" Background="#FF295FFE" FontFamily="Quicksand" FontSize="11" FontWeight="DemiBold" TextBlock.FontFamily="Segoe UI Semibold" TextBlock.FontWeight="Bold" Margin="0,0,0,0"/>

</Grid>
<Grid Width="495">
<Grid Width="495" MaxWidth="495" MaxHeight="411">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="119*"/>
<ColumnDefinition Width="46*"/>
Expand Down
46 changes: 39 additions & 7 deletions ValorantCC/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<Color> 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
Expand All @@ -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();
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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<Window>().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;
}
}
}
Binary file added ValorantCC/Resources/chevron-up.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ValorantCC/Resources/menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 63 additions & 0 deletions ValorantCC/SubWindow/ProfilesWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<Window x:Class="ValorantCC.ProfilesWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
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">
<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"/>
<Button Name="btnSearchCode" Content="Search Code" MinWidth="85" Background="#FF393B44" Foreground="White" Click="btnSearchCode_Click"/>
</StackPanel>
<StackPanel Name="ShareablesContainer" HorizontalAlignment="Center">
<Border Background="#FF393B44" MinHeight="95" MaxHeight="95" MinWidth="330" MaxWidth="330" Margin="0,5">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="2.5*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>

<Image Source="../Resources/CrosshairBG5.png" Grid.ColumnSpan="3" Grid.Row="0" Stretch="Fill" Margin="2,0,2,2"/>
<Label Grid.Column="2" Grid.Row="0" Content="Deeej's Profile" Foreground="White" VerticalAlignment="Bottom" HorizontalAlignment="Right"/>

<Rectangle Fill="#FF404661" Height="auto" Grid.Row="1" Grid.ColumnSpan="3"/>
<Button Style="{DynamicResource RoundButton}" Margin="5,0" Grid.Row="1" Grid.Column="0" Content="Share" FontWeight="Bold" FontSize="12"/>
<Button Style="{DynamicResource RoundButton}" Margin="5,0" Grid.Row="1" Grid.Column="1" Content="Details" FontWeight="Bold" FontSize="12"/>
<Button Style="{DynamicResource RoundButton}" Margin="5,0" Grid.Row="1" Grid.Column="2" Content="Apply" FontWeight="Bold" FontSize="12"/>
</Grid>
</Border>
<Border Background="#FF393B44" MinHeight="95" MaxHeight="95" MinWidth="330" MaxWidth="330" Margin="0,5">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="2.5*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>

<Image Source="../Resources/CrosshairBG1.png" Grid.ColumnSpan="3" Grid.Row="0" Stretch="Fill" Margin="2,0,2,2"/>
<Label Grid.Column="2" Grid.Row="0" Content="Haruki's Profile" Foreground="White" VerticalAlignment="Bottom" HorizontalAlignment="Right"/>

<Rectangle Fill="#FF404661" Height="auto" Grid.Row="1" Grid.ColumnSpan="3"/>
<Button Style="{DynamicResource RoundButton}" Margin="5,0" Grid.Row="1" Grid.Column="0" Content="Share" FontWeight="Bold" FontSize="12"/>
<Button Style="{DynamicResource RoundButton}" Margin="5,0" Grid.Row="1" Grid.Column="1" Content="Details" FontWeight="Bold" FontSize="12"/>
<Button Style="{DynamicResource RoundButton}" Margin="5,0" Grid.Row="1" Grid.Column="2" Content="Apply" FontWeight="Bold" FontSize="12"/>
</Grid>
</Border>
<Border Background="#FF393B44" MinHeight="95" MaxHeight="95" MinWidth="330" MaxWidth="330" Margin="0,5"/>
<Border Background="#FF393B44" MinHeight="95" MaxHeight="95" MinWidth="330" MaxWidth="330" Margin="0,5"/>
</StackPanel>
</StackPanel>
</Border>
</Window>
88 changes: 88 additions & 0 deletions ValorantCC/SubWindow/ProfilesWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Interaction logic for ProfilesWindow.xaml
/// </summary>

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<PublicProfile> PublicProfiles = new List<PublicProfile>();
public ProfilesWindow(CrosshairProfile current, API ValCCAPI)
{
InitializeComponent();
main = (MainWindow) Application.Current.MainWindow;
ValCCApi = ValCCAPI;
InitialFetch();
RenderProfiles();
}

/// <summary>
/// Returns the searched sharecode or the list of shareables depending if sharecode is provided or not.
/// </summary>
/// <param name="sharecode">Nullable. Searched Code</param>
private static void InitialFetch(String sharecode = null)
{
List<ShareableProfile> 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<CrosshairProfile>(currentShareable.settings);
}
catch
{
continue;
}
PublicProfiles.Add(new PublicProfile() { owner = currentShareable.displayName, settings = profile });
}
}

/// <summary>
/// Render the PublicProfiles var into frontend.
/// </summary>
private static void RenderProfiles()
{

}
private void btnSearchCode_Click(object sender, RoutedEventArgs e)
{
if (SearchCode.Text == null || SearchCode.Text == "") return;
InitialFetch(SearchCode.Text);
RenderProfiles();
}
}
}
8 changes: 8 additions & 0 deletions ValorantCC/ValorantCC.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
<ItemGroup>
<None Remove="Resources\chevron-left.png" />
<None Remove="Resources\chevron-right.png" />
<None Remove="Resources\chevron-up.png" />
<None Remove="Resources\menu.png" />
<None Remove="Resources\CrosshairBG0.png" />
<None Remove="Resources\CrosshairBG1.png" />
<None Remove="Resources\CrosshairBG2.png" />
Expand All @@ -37,6 +39,12 @@
</Resource>
<Resource Include="Resources\chevron-right.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Resource Include="Resources\chevron-up.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Resource Include="Resources\menu.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Resource Include="Resources\CrosshairBG0.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand Down
Loading

0 comments on commit 4265b86

Please # to comment.