Skip to content

Commit

Permalink
Print floats with CultureInfo.InvariantCulture
Browse files Browse the repository at this point in the history
  • Loading branch information
cooolbros committed Jun 4, 2024
1 parent b2e83bc commit bb57658
Show file tree
Hide file tree
Showing 16 changed files with 27 additions and 14 deletions.
3 changes: 2 additions & 1 deletion src/HUDAnimations/Models/Animations/Animate.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Globalization;

namespace HUDAnimations.Models.Animations;

Expand All @@ -14,6 +15,6 @@ public class Animate : HUDAnimationBase

public override string ToString()
{
return $"{Type} {Print(Element)} {Print(Property)} {Print(Value)} {Interpolator} {Delay} {Duration}" + PrintConditional();
return $"{Type} {Print(Element)} {Print(Property)} {Print(Value)} {Interpolator} {Print(Delay)} {Print(Duration)}" + PrintConditional();
}
}
2 changes: 1 addition & 1 deletion src/HUDAnimations/Models/Animations/FireCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ public class FireCommand : HUDAnimationBase

public override string ToString()
{
return $"{Type} {Delay} {Print(Command)}" + PrintConditional();
return $"{Type} {Print(Delay)} {Print(Command)}" + PrintConditional();
}
}
2 changes: 1 addition & 1 deletion src/HUDAnimations/Models/Animations/PlaySound.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ public class PlaySound : HUDAnimationBase

public override string ToString()
{
return $"{Type} {Delay} {Print(Sound)}" + PrintConditional();
return $"{Type} {Print(Delay)} {Print(Sound)}" + PrintConditional();
}
}
2 changes: 1 addition & 1 deletion src/HUDAnimations/Models/Animations/RunEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ public class RunEvent : HUDAnimationBase

public override string ToString()
{
return $"{Type} {Print(Event)} {Delay}" + PrintConditional();
return $"{Type} {Print(Event)} {Print(Delay)}" + PrintConditional();
}
}
2 changes: 1 addition & 1 deletion src/HUDAnimations/Models/Animations/RunEventChild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ public class RunEventChild : HUDAnimationBase

public override string ToString()
{
return $"{Type} {Print(Element)} {Print(Event)} {Delay}" + PrintConditional();
return $"{Type} {Print(Element)} {Print(Event)} {Print(Delay)}" + PrintConditional();
}
}
2 changes: 1 addition & 1 deletion src/HUDAnimations/Models/Animations/SetInputEnabled.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ public class SetInputEnabled : HUDAnimationBase

public override string ToString()
{
return $"{Type} {Print(Element)} {Convert.ToByte(Enabled)} {Delay}" + PrintConditional();
return $"{Type} {Print(Element)} {Convert.ToByte(Enabled)} {Print(Delay)}" + PrintConditional();
}
}
2 changes: 1 addition & 1 deletion src/HUDAnimations/Models/Animations/SetVisible.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ public class SetVisible : HUDAnimationBase

public override string ToString()
{
return $"{Type} {Print(Element)} {Convert.ToByte(Visible)} {Delay}" + PrintConditional();
return $"{Type} {Print(Element)} {Convert.ToByte(Visible)} {Print(Delay)}" + PrintConditional();
}
}
2 changes: 1 addition & 1 deletion src/HUDAnimations/Models/Animations/StopAnimation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ public class StopAnimation : HUDAnimationBase

public override string ToString()
{
return $"{Type} {Print(Element)} {Print(Property)} {Delay}" + PrintConditional();
return $"{Type} {Print(Element)} {Print(Property)} {Print(Delay)}" + PrintConditional();
}
}
2 changes: 1 addition & 1 deletion src/HUDAnimations/Models/Animations/StopEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ public class StopEvent : HUDAnimationBase

public override string ToString()
{
return $"{Type} {Print(Event)} {Delay}" + PrintConditional();
return $"{Type} {Print(Event)} {Print(Delay)}" + PrintConditional();
}
}
2 changes: 1 addition & 1 deletion src/HUDAnimations/Models/Animations/StopPanelAnimations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ public class StopPanelAnimations : HUDAnimationBase

public override string ToString()
{
return $"{Type} {Print(Element)} {Delay}" + PrintConditional();
return $"{Type} {Print(Element)} {Print(Delay)}" + PrintConditional();
}
}
6 changes: 6 additions & 0 deletions src/HUDAnimations/Models/HUDAnimationBase.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Globalization;
using System.Text.RegularExpressions;

namespace HUDAnimations.Models;
Expand All @@ -16,6 +17,11 @@ protected static string Print(string str)
return WhitespaceRegex().IsMatch(str) ? $"\"{str}\"" : str;
}

protected static string Print(float num)
{
return num.ToString(CultureInfo.InvariantCulture);
}

protected string PrintConditional()
{
return Conditional != null ? $" {Conditional}" : "";
Expand Down
6 changes: 6 additions & 0 deletions src/HUDAnimations/Models/InterpolatorBase.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
using System;
using System.Globalization;

namespace HUDAnimations.Models;

public abstract class InterpolatorBase
{
public abstract override string ToString();

protected static string Print(float num)
{
return num.ToString(CultureInfo.InvariantCulture);
}
}
2 changes: 1 addition & 1 deletion src/HUDAnimations/Models/Interpolators/BiasInterpolator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ public class BiasInterpolator : InterpolatorBase
{
public required float Bias { get; init; }

public override string ToString() => $"Bias {Bias}";
public override string ToString() => $"Bias {Print(Bias)}";
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ public class FlickerInterpolator : InterpolatorBase
{
public required float Randomness { get; init; }

public override string ToString() => $"Flicker {Randomness}";
public override string ToString() => $"Flicker {Print(Randomness)}";
}
2 changes: 1 addition & 1 deletion src/HUDAnimations/Models/Interpolators/GainInterpolator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ public class GainInterpolator : InterpolatorBase
{
public required float Bias { get; init; }

public override string ToString() => $"Gain {Bias}";
public override string ToString() => $"Gain {Print(Bias)}";
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ public class PulseInterpolator : InterpolatorBase
{
public required float Frequency { get; init; }

public override string ToString() => $"Pulse {Frequency}";
public override string ToString() => $"Pulse {Print(Frequency)}";
}

0 comments on commit bb57658

Please sign in to comment.