diff --git a/LemonUI/Elements/ScaledText.cs b/LemonUI/Elements/ScaledText.cs index 05fffb2..9da274f 100644 --- a/LemonUI/Elements/ScaledText.cs +++ b/LemonUI/Elements/ScaledText.cs @@ -13,6 +13,7 @@ using GTA.UI; using Font = GTA.UI.Font; #endif +using System; using System.Collections.Generic; using System.Drawing; using System.Text; @@ -89,7 +90,7 @@ public string Text get => text; set { - text = value; + text = value ?? throw new ArgumentNullException(nameof(value)); Slice(); } } @@ -236,7 +237,6 @@ public float LineHeight public ScaledText(PointF pos, string text) : this(pos, text, 1f, Font.ChaletLondon) { } - /// /// Creates a text with the specified options. /// @@ -246,7 +246,6 @@ public ScaledText(PointF pos, string text) : this(pos, text, 1f, Font.ChaletLond public ScaledText(PointF pos, string text, float scale) : this(pos, text, scale, Font.ChaletLondon) { } - /// /// Creates a text with the specified options /// @@ -257,7 +256,7 @@ public ScaledText(PointF pos, string text, float scale) : this(pos, text, scale, public ScaledText(PointF pos, string text, float scale, Font font) { Position = pos; - Text = text; + Text = text ?? throw new ArgumentNullException(nameof(text)); Scale = scale; Font = font; } diff --git a/LemonUI/Menus/BadgeSet.cs b/LemonUI/Menus/BadgeSet.cs index 5566f4a..e0fb2d5 100644 --- a/LemonUI/Menus/BadgeSet.cs +++ b/LemonUI/Menus/BadgeSet.cs @@ -1,3 +1,5 @@ +using System; + namespace LemonUI.Menus { /// @@ -5,24 +7,49 @@ namespace LemonUI.Menus /// public class BadgeSet { + #region Fields + + private string normalDict = string.Empty; + private string normalTexture = string.Empty; + private string hoveredDict = string.Empty; + private string hoveredTexture = string.Empty; + + #endregion + #region Properties /// /// The texture dictionary where the normal texture is located. /// - public string NormalDictionary { get; set; } = string.Empty; + public string NormalDictionary + { + get => normalDict; + set => normalDict = value ?? throw new ArgumentNullException(nameof(value)); + } /// /// The texture to use when the item is not hovered. /// - public string NormalTexture { get; set; } = string.Empty; + public string NormalTexture + { + get => normalTexture; + set => normalTexture = value ?? throw new ArgumentNullException(nameof(value)); + } /// /// The texture dictionary where the normal texture is located. /// - public string HoveredDictionary { get; set; } = string.Empty; + public string HoveredDictionary + { + get => hoveredDict; + set => hoveredDict = value ?? throw new ArgumentNullException(nameof(value)); + } /// /// The texture to use when the item is hovered. /// - public string HoveredTexture { get; set; } = string.Empty; + public string HoveredTexture + { + get => hoveredTexture; + set => hoveredTexture = value ?? throw new ArgumentNullException(nameof(value)); + } #endregion @@ -42,10 +69,10 @@ public BadgeSet() /// The hovered texture name. public BadgeSet(string dict, string normal, string hovered) { - NormalDictionary = dict; - NormalTexture = normal; - HoveredDictionary = dict; - HoveredTexture = hovered; + normalDict = dict ?? throw new ArgumentNullException(nameof(dict)); + normalTexture = normal ?? throw new ArgumentNullException(nameof(normal)); + hoveredDict = dict; + hoveredTexture = hovered ?? throw new ArgumentNullException(nameof(hovered)); } /// /// Creates a new where both textures are in different dictionaries. @@ -56,10 +83,10 @@ public BadgeSet(string dict, string normal, string hovered) /// The hovered texture name. public BadgeSet(string normalDict, string normalTexture, string hoveredDict, string hoveredTexture) { - NormalDictionary = normalDict; - NormalTexture = normalTexture; - HoveredDictionary = hoveredDict; - HoveredTexture = hoveredTexture; + this.normalDict = normalDict ?? throw new ArgumentNullException(nameof(normalDict)); + this.normalTexture = normalTexture ?? throw new ArgumentNullException(nameof(normalTexture)); + this.hoveredDict = hoveredDict ?? throw new ArgumentNullException(nameof(hoveredDict)); + this.hoveredTexture = hoveredTexture ?? throw new ArgumentNullException(nameof(hoveredTexture)); } #endregion diff --git a/LemonUI/Menus/NativeColorData.cs b/LemonUI/Menus/NativeColorData.cs index d032135..53f3698 100644 --- a/LemonUI/Menus/NativeColorData.cs +++ b/LemonUI/Menus/NativeColorData.cs @@ -1,4 +1,5 @@ -using System.Drawing; +using System; +using System.Drawing; using LemonUI.Elements; namespace LemonUI.Menus @@ -10,6 +11,7 @@ public class NativeColorData { #region Fields + private string name = string.Empty; internal readonly ScaledRectangle rectangle = new ScaledRectangle(PointF.Empty, SizeF.Empty); #endregion @@ -19,7 +21,11 @@ public class NativeColorData /// /// The name of the color. /// - public string Name { get; set; } + public string Name + { + get => name; + set => name = value ?? throw new ArgumentNullException(nameof(value)); + } /// /// The RGBA values of the color. /// @@ -40,7 +46,7 @@ public Color Color /// The RGBA values of the color. public NativeColorData(string name, Color color) { - Name = name; + this.name = name ?? throw new ArgumentNullException(nameof(name)); rectangle.Color = color; } diff --git a/LemonUI/Menus/NativeColorPanel.cs b/LemonUI/Menus/NativeColorPanel.cs index 5991fbf..0044cc5 100644 --- a/LemonUI/Menus/NativeColorPanel.cs +++ b/LemonUI/Menus/NativeColorPanel.cs @@ -24,7 +24,6 @@ namespace LemonUI.Menus /// public class NativeColorPanel : NativePanel, IEnumerable { - #region Constants /// @@ -310,7 +309,6 @@ public int SelectedIndex Sound?.PlayFrontend(); } } - /// /// The Title used for the Panel when is set to . /// @@ -319,11 +317,10 @@ public string Title get => simpleTitle; set { - simpleTitle = value; + simpleTitle = value ?? throw new ArgumentNullException(nameof(value)); UpdateTitle(); } } - /// /// The style of the Panel Title. /// @@ -336,7 +333,6 @@ public ColorTitleStyle TitleStyle UpdateTitle(); } } - /// /// If the count of items should be shown as part of the title. /// @@ -349,7 +345,6 @@ public bool ShowCount UpdateTitle(); } } - /// /// THe maximum number of items shown on the screen. /// @@ -368,7 +363,6 @@ public int MaxItems UpdateTitle(); } } - /// /// The colors shown on this Panel. /// @@ -388,7 +382,6 @@ public int MaxItems public NativeColorPanel() : this(string.Empty) { } - /// /// Creates a Panel with a specific Title and set of Colors. /// @@ -396,9 +389,7 @@ public NativeColorPanel() : this(string.Empty) /// The colors of the panel. public NativeColorPanel(string title, params NativeColorData[] colors) { - // Set the title of the Panel - Title = title; - // Add the colors that we got + Title = title ?? throw new ArgumentNullException(nameof(title)); Colors.AddRange(colors); } @@ -422,7 +413,6 @@ private void UpdateTitle() break; case ColorTitleStyle.ColorName: newTitle = SelectedItem == null ? string.Empty : SelectedItem.Name; - break; } @@ -756,4 +746,4 @@ public override void Process() #endregion } -} \ No newline at end of file +} diff --git a/LemonUI/Menus/NativeGridPanel.cs b/LemonUI/Menus/NativeGridPanel.cs index afc3a78..8b88464 100644 --- a/LemonUI/Menus/NativeGridPanel.cs +++ b/LemonUI/Menus/NativeGridPanel.cs @@ -136,7 +136,7 @@ public float Y public string LabelTop { get => labelTop.Text; - set => labelTop.Text = value; + set => labelTop.Text = value ?? throw new ArgumentNullException(nameof(value)); } /// /// The text label shown on the bottom. @@ -144,7 +144,7 @@ public string LabelTop public string LabelBottom { get => labelBottom.Text; - set => labelBottom.Text = value; + set => labelBottom.Text = value ?? throw new ArgumentNullException(nameof(value)); } /// /// The text label shown on the left. @@ -152,7 +152,7 @@ public string LabelBottom public string LabelLeft { get => labelLeft.Text; - set => labelLeft.Text = value; + set => labelLeft.Text = value ?? throw new ArgumentNullException(nameof(value)); } /// /// The text label shown on the right. @@ -160,7 +160,7 @@ public string LabelLeft public string LabelRight { get => labelRight.Text; - set => labelRight.Text = value; + set => labelRight.Text = value ?? throw new ArgumentNullException(nameof(value)); } /// /// The style of this grid. diff --git a/LemonUI/Menus/NativeItem.cs b/LemonUI/Menus/NativeItem.cs index 9bbbd7c..3d3b6d4 100644 --- a/LemonUI/Menus/NativeItem.cs +++ b/LemonUI/Menus/NativeItem.cs @@ -56,6 +56,7 @@ public class NativeItem : IDrawable private BadgeSet badgeSetRight; private ColorSet colors = new ColorSet(); private ScaledRectangle background = new ScaledRectangle(PointF.Empty, SizeF.Empty); + private string description = string.Empty; #endregion @@ -88,7 +89,7 @@ public bool Enabled public string Title { get => title.Text; - set => title.Text = value; + set => title.Text = value ?? throw new ArgumentNullException(nameof(value)); } /// /// The alternative title of the item shown on the right. @@ -98,7 +99,7 @@ public string AltTitle get => altTitle.Text; set { - altTitle.Text = value; + altTitle.Text = value ?? throw new ArgumentNullException(nameof(value)); Recalculate(); } } @@ -121,7 +122,11 @@ public Font AltTitleFont /// /// The description of the item. /// - public string Description { get; set; } + public string Description + { + get => description; + set => description = value ?? throw new ArgumentNullException(nameof(value)); + } /// /// The Left badge of the Item. /// diff --git a/LemonUI/Menus/NativeMenu.cs b/LemonUI/Menus/NativeMenu.cs index 758480d..e61d1d9 100644 --- a/LemonUI/Menus/NativeMenu.cs +++ b/LemonUI/Menus/NativeMenu.cs @@ -520,7 +520,7 @@ public string Name get => name; set { - name = value; + name = value ?? throw new ArgumentNullException(nameof(value)); nameText.Text = value.ToUpperInvariant(); } } diff --git a/LemonUI/Menus/NativeStatsInfo.cs b/LemonUI/Menus/NativeStatsInfo.cs index a187bb8..72b8cff 100644 --- a/LemonUI/Menus/NativeStatsInfo.cs +++ b/LemonUI/Menus/NativeStatsInfo.cs @@ -29,7 +29,7 @@ public class NativeStatsInfo public string Name { get => text.Text; - set => text.Text = value; + set => text.Text = value ?? throw new ArgumentNullException(nameof(value)); } /// /// The value of the Stats bar. @@ -67,7 +67,7 @@ public NativeStatsInfo(string name) : this(name, 0) /// public NativeStatsInfo(string name, int value) { - Name = name; + Name = name ?? throw new ArgumentNullException(nameof(name)); this.value = value; for (int i = 0; i < 5; i++) diff --git a/LemonUI/Menus/NativeSubmenuItem.cs b/LemonUI/Menus/NativeSubmenuItem.cs index 62ab6a6..940ae08 100644 --- a/LemonUI/Menus/NativeSubmenuItem.cs +++ b/LemonUI/Menus/NativeSubmenuItem.cs @@ -31,8 +31,8 @@ public NativeSubmenuItem(NativeMenu menu, NativeMenu parent) : this(menu, parent /// /// The menu that this item will open. /// The parent menu where this item will be located. - /// The alternative title of the item, shown on the right. - public NativeSubmenuItem(NativeMenu menu, NativeMenu parent, string endlabel) : base(menu.Name, menu.Description, endlabel) + /// The alternative title of the item, shown on the right. + public NativeSubmenuItem(NativeMenu menu, NativeMenu parent, string endLabel) : base(menu.Name, menu.Description, endLabel) { Menu = menu ?? throw new ArgumentNullException(nameof(menu)); Menu.Parent = parent ?? throw new ArgumentNullException(nameof(parent)); diff --git a/LemonUI/Sound.cs b/LemonUI/Sound.cs index 54c0ab0..99459cb 100644 --- a/LemonUI/Sound.cs +++ b/LemonUI/Sound.cs @@ -7,6 +7,7 @@ using Rage; using Rage.Native; #elif SHVDN3 || SHVDNC +using System; using GTA; using GTA.Native; #elif ALTV @@ -21,6 +22,13 @@ namespace LemonUI /// public class Sound { + #region Fields + + private string set = string.Empty; + private string file = string.Empty; + + #endregion + #region Properties /// @@ -30,11 +38,19 @@ public class Sound /// /// The Set where the sound is located. /// - public string Set { get; set; } + public string Set + { + get => set; + set => set = value ?? throw new ArgumentNullException(nameof(value)); + } /// /// The name of the sound file. /// - public string File { get; set; } + public string File + { + get => file; + set => file = value ?? throw new ArgumentNullException(nameof(value)); + } #endregion @@ -47,8 +63,8 @@ public class Sound /// The name of the sound file. public Sound(string set, string file) { - Set = set; - File = file; + Set = set ?? throw new ArgumentNullException(nameof(set)); + File = file ?? throw new ArgumentNullException(nameof(file)); } #endregion