Skip to content

Commit

Permalink
PATCH v3.0.3 (Null handling fix)
Browse files Browse the repository at this point in the history
  • Loading branch information
weedeej committed Feb 26, 2022
1 parent ea87dd0 commit 014c17b
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 34 deletions.
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.2</Version>
<Version>3.0.3</Version>
<SignAssembly>false</SignAssembly>
</PropertyGroup>

Expand Down
51 changes: 23 additions & 28 deletions ValorantCC/src/Binder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,48 +52,43 @@ public partial class CrosshairProfile

public partial class ProfileSettings
{
public CrosshairColor Color { get; set; }
public bool bHasOutline { get; set; }
public float OutlineThickness { get; set; }
public CrosshairColor OutlineColor { get; set; }
public float OutlineOpacity { get; set; }
public float CenterDotSize { get; set; }
public float CenterDotOpacity { get; set; }
public bool bDisplayCenterDot { get; set; }
public bool bFixMinErrorAcrossWeapons { get; set; }
public LineSettings InnerLines { get; set; }
public LineSettings OuterLines { get; set; }
public CrosshairColor Color { get; set; } = new CrosshairColor();
public bool bHasOutline { get; set; } = false;
public float OutlineThickness { get; set; } = 1;
public CrosshairColor OutlineColor { get; set; } = new CrosshairColor();
public float OutlineOpacity { get; set; } = 0;
public float CenterDotSize { get; set; } = 1;
public float CenterDotOpacity { get; set; } = 0;
public bool bDisplayCenterDot { get; set; } = false;
public bool bFixMinErrorAcrossWeapons { get; set; } = false;
public LineSettings InnerLines { get; set; } = new LineSettings();
public LineSettings OuterLines { get; set; } = new LineSettings();

}

public partial class SniperSettings
{
public CrosshairColor CenterDotColor { get; set; }
public float CenterDotSize { get; set; }
public float CenterDotOpacity { get; set; }
public bool bDisplayCenterDot { get; set; }
public CrosshairColor CenterDotColor { get; set; } = new CrosshairColor();
public float CenterDotSize { get; set; } = 0;
public float CenterDotOpacity { get; set; } = 0;
public bool bDisplayCenterDot { get; set; } = false;
}
public partial class CrosshairColor : ICloneable
public partial class CrosshairColor
{
public byte R { get; set; }
public byte G { get; set; }
public byte B { get; set; }
public byte A { get; set; }

public object Clone()
{
throw new NotImplementedException();
}
public byte R { get; set; } = 0;
public byte G { get; set; } = 0;
public byte B { get; set; } = 0;
public byte A { get; set; } = 0;
}

public partial class LineSettings
{
public float LineThickness { get; set; } = 2;
public float LineLength { get; set; } = 4;
public float LineOffset { get; set; } = 2;
public bool bShowMovementError { get; set; }
public bool bShowShootingError { get; set; }
public bool bShowMinError { get; set; }
public bool bShowMovementError { get; set; } = false;
public bool bShowShootingError { get; set; } = false;
public bool bShowMinError { get; set; } = false;
public float Opacity { get; set; } = 1;
public bool bShowLines { get; set; } = true;
public float firingErrorScale { get; set; }
Expand Down
20 changes: 17 additions & 3 deletions ValorantCC/src/Crosshair_Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ public enum Position
West = 2,
East = 3,
}

static CrosshairColor defaultColor = new CrosshairColor();
public static void Generate(int column, Grid grid, ProfileSettings settings)
{
settings = settings ?? new ProfileSettings();
Rectangle[] rectangles = new Rectangle[16];
int recindex = 0;
for (int i = 0; i < rectangles.Length; i++)
Expand Down Expand Up @@ -56,6 +57,8 @@ public static void Generate(int column, Grid grid, ProfileSettings settings)
recindex++;

rectangle_redraw(rectangles[i], rectangles[i + 1], pos, settings);
settings.Color = settings.Color ?? defaultColor;
settings.OutlineColor = settings.OutlineColor ?? defaultColor;
rectangles[i].Fill = new SolidColorBrush(Color.FromArgb(settings.Color.A, settings.Color.R, settings.Color.G, settings.Color.B));
rectangles[i + 1].Stroke = new SolidColorBrush(Color.FromArgb(settings.OutlineColor.A, settings.OutlineColor.R, settings.OutlineColor.G, settings.OutlineColor.B));
Grid.SetColumn(rectangles[i], column);
Expand All @@ -77,6 +80,8 @@ public static void Generate(int column, Grid grid, ProfileSettings settings)
};

dot_redraw(dot, dotOT, settings);
settings.Color = settings.Color ?? defaultColor;
settings.OutlineColor = settings.OutlineColor ?? defaultColor;
dot.Fill = new SolidColorBrush(Color.FromArgb(settings.Color.A, settings.Color.R, settings.Color.G, settings.Color.B));
dotOT.Stroke = new SolidColorBrush(Color.FromArgb(settings.OutlineColor.A, settings.OutlineColor.R, settings.OutlineColor.G, settings.OutlineColor.B));
Grid.SetColumn(dot, column);
Expand All @@ -92,6 +97,8 @@ public static void Generate(int column, Grid grid, SniperSettings settings)
{
Ellipse ellipse = new();
dot_redraw(ellipse, settings);
settings = settings ?? new SniperSettings();
settings.CenterDotColor = settings.CenterDotColor ?? defaultColor;
ellipse.Fill = new SolidColorBrush(Color.FromArgb(settings.CenterDotColor.A, settings.CenterDotColor.R, settings.CenterDotColor.G, settings.CenterDotColor.B));
Grid.SetColumn(ellipse, column);
Grid.SetRow(ellipse, 0);
Expand Down Expand Up @@ -121,6 +128,7 @@ public static void dot_redraw(Rectangle Rect, Rectangle RectOT, ProfileSettings

public static void dot_redraw(Ellipse ellipse, SniperSettings settings)
{
settings = settings ?? new SniperSettings();
ellipse.Width = ellipse.Height = settings.CenterDotSize * 6;
ellipse.Opacity = settings.CenterDotOpacity;

Expand All @@ -137,10 +145,16 @@ public static void rectangle_redraw(Rectangle Rect, Rectangle RectOT, Position p
Width = Rect.Width;
Height = Rect.Height;

settings = settings ?? new ProfileSettings();
LineSettings line = settings.InnerLines;
if (Rect.Name.Contains("OL"))
line = settings.OuterLines;

line = line ?? new LineSettings()
{
bShowLines = false,
Opacity = 0
};
if (line.bShowShootingError)
Margin += 8;

Expand Down Expand Up @@ -180,12 +194,12 @@ public static void rectangle_redraw(Rectangle Rect, Rectangle RectOT, Position p
RectOT.Opacity = settings.OutlineOpacity;


if (line.bShowLines)
if (line.bShowLines || line.Opacity > 0)
Rect.Visibility = Visibility.Visible;
else
Rect.Visibility = Visibility.Hidden;

if (settings.bHasOutline && line.LineThickness > 0 && line.bShowLines)
if (settings.bHasOutline && line.LineThickness > 0 && line.bShowLines && line.Opacity > 0)
RectOT.Visibility = Visibility.Visible;
else
RectOT.Visibility = Visibility.Hidden;
Expand Down
7 changes: 5 additions & 2 deletions ValorantCC/src/Processor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,18 +165,20 @@ private async Task<bool> putUserSettings(Data newData)
return false;
}


private ProfileList FetchProfiles(string SettingValue, string? PrimOutlineColor, string? ADSColorValue, string? ADSOutlineColor, string? SniperCenterdotColor)
{
string DefaultUserSettings = JsonConvert.SerializeObject(UserSettings);
Utilities.Utils.Log("Fetching/Creating Profile/s");
Utilities.Utils.Log($"Setting Value: {DefaultUserSettings}");
if (ProfileListed) return JsonConvert.DeserializeObject<ProfileList>(SettingValue);

CrosshairColor PrimaryColor = Utilities.Utils.parseCrosshairColor(SettingValue);
#nullable enable
CrosshairColor PrimaryOutlineColor = Utilities.Utils.parseCrosshairColor(PrimOutlineColor);
CrosshairColor ADSColor = Utilities.Utils.parseCrosshairColor(ADSColorValue);
CrosshairColor aDSOutlineColor = Utilities.Utils.parseCrosshairColor(ADSOutlineColor);
CrosshairColor sniperCenterdotColor = Utilities.Utils.parseCrosshairColor(SniperCenterdotColor);
CrosshairColor sniperCenterdotColor = Utilities.Utils.parseCrosshairColor(SniperCenterdotColor);
#nullable disable
string profileName = UserSettings.stringSettings.FirstOrDefault(setting => setting.settingEnum == "EAresStringSettingName::CrosshairProfileName").value;

return new ProfileList
Expand All @@ -196,6 +198,7 @@ private ProfileList FetchProfiles(string SettingValue, string? PrimOutlineColor,
};
}


private List<string> FetchProfileNames(ProfileList ProfileList)
{
Utilities.Utils.Log("Fetching Profile names");
Expand Down

0 comments on commit 014c17b

Please # to comment.