Skip to content

Commit

Permalink
Crosshair generator fix & center child window to parent
Browse files Browse the repository at this point in the history
  • Loading branch information
Haruki1707 authored and weedeej committed Jan 18, 2022
1 parent b4a8200 commit 9197b5b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
1 change: 1 addition & 0 deletions ValorantCC/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ private void btnCommunityProfiles_Click(object sender, RoutedEventArgs e)
}catch(Exception ex)
{
ProfilesWindow publicProfiles = new ProfilesWindow(SelectedProfile, ValCCAPI);
publicProfiles.Owner = this;
publicProfiles.Show();
}
}
Expand Down
2 changes: 1 addition & 1 deletion ValorantCC/SubWindow/ProfilesWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
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">
Title="ProfilesWindow" Height="Auto" Width="Auto" ResizeMode="NoResize" SizeToContent="WidthAndHeight" ShowInTaskbar="False" WindowStartupLocation="CenterOwner">
<Border Background="#232429" Height="450" Width="351" Loaded="Border_Loaded">
<StackPanel Name="Container" HorizontalAlignment="Center" Margin="0,5">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
Expand Down
8 changes: 6 additions & 2 deletions ValorantCC/SubWindow/ProfilesWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,12 @@ private async Task<UIElement> CreateRender(PublicProfile profile)
Grid0.Children.Add(detailsButton);
Grid0.Children.Add(applyButton);

Crosshair_Parser.Generate(0, Grid0, profile.settings.Primary);
Crosshair_Parser.Generate(2, Grid0, profile.settings.aDS);
var cross = profile.settings.Primary;
Crosshair_Parser.Generate(0, Grid0, cross);
if (!profile.settings.bUsePrimaryCrosshairForADS)
cross = profile.settings.aDS;
Crosshair_Parser.Generate(1, Grid0, cross);
Crosshair_Parser.Generate(2, Grid0, profile.settings.Sniper);
template.Child = Grid0;
await Task.Delay(1);
return template;
Expand Down
27 changes: 21 additions & 6 deletions ValorantCC/src/Crosshair_Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ public static void Generate(int column, Grid grid, ProfileSettings settings)
int recindex = 0;
for (int i = 0; i < rectangles.Length; i++)
{
Rectangle rectangle = new Rectangle()
Rectangle rectangle = new()
{
Width = 3,
Height = 3
};
if (recindex > 7)
rectangle.Name = "OL";
rectangles[recindex] = rectangle;
recindex++;
}
Expand All @@ -35,7 +37,7 @@ public static void Generate(int column, Grid grid, ProfileSettings settings)
for (int i = 0; i < rectangles.Length; i+=2)
{
var pos = Position.East;
switch (recindex % 4)
switch (recindex)
{
case 1:
pos = Position.East;
Expand All @@ -46,13 +48,13 @@ public static void Generate(int column, Grid grid, ProfileSettings settings)
case 3:
pos = Position.North;
break;
case 0:
case 4:
pos = Position.South;
break;
}
recindex++;
if(recindex == 4)
recindex = 0;
recindex++;

rectangle_redraw(rectangles[i], rectangles[i + 1], pos, settings);
rectangles[i].Fill = new SolidColorBrush(Color.FromRgb(settings.Color.R, settings.Color.G, settings.Color.B));
Expand All @@ -62,8 +64,8 @@ public static void Generate(int column, Grid grid, ProfileSettings settings)
Grid.SetColumn(rectangles[i + 1], column);
Grid.SetRow(rectangles[i + 1], 0);

grid.Children.Add(rectangles[i]);
grid.Children.Add(rectangles[i + 1]);
grid.Children.Add(rectangles[i]);
}

Rectangle dot = new Rectangle()
Expand All @@ -76,13 +78,26 @@ public static void Generate(int column, Grid grid, ProfileSettings settings)
};

dot_redraw(dot, dotOT, settings);
dot.Fill = new SolidColorBrush(Color.FromRgb(settings.Color.R, settings.Color.G, settings.Color.B));
dotOT.Stroke = new SolidColorBrush(Color.FromRgb(settings.OutlineColor.R, settings.OutlineColor.G, settings.OutlineColor.B));
Grid.SetColumn(dot, column);
Grid.SetRow(dot, 0);
Grid.SetColumn(dotOT, column);
Grid.SetColumn(dotOT, 0);

grid.Children.Add(dot);
grid.Children.Add(dotOT);
grid.Children.Add(dot);
}

public static void Generate(int column, Grid grid, SniperSettings settings)
{
Ellipse ellipse = new();
dot_redraw(ellipse, settings);
ellipse.Fill = new SolidColorBrush(Color.FromRgb(settings.CenterDotColor.R, settings.CenterDotColor.G, settings.CenterDotColor.B));
Grid.SetColumn(ellipse, column);
Grid.SetRow(ellipse, 0);

grid.Children.Add(ellipse);
}

public static void dot_redraw(Rectangle Rect, Rectangle RectOT, ProfileSettings settings)
Expand Down

0 comments on commit 9197b5b

Please # to comment.