Skip to content

Commit

Permalink
Implemented IEnumerable<T> on classes that hold object's
Browse files Browse the repository at this point in the history
Closes #97
  • Loading branch information
justalemon committed Oct 24, 2022
1 parent 172818b commit e3a616e
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 5 deletions.
7 changes: 6 additions & 1 deletion LemonUI/Menus/NativeColorPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#endif
using LemonUI.Elements;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;

Expand All @@ -19,7 +20,7 @@ namespace LemonUI.Menus
/// <summary>
/// A Panel that allows you to select a Color.
/// </summary>
public class NativeColorPanel : NativePanel
public class NativeColorPanel : NativePanel, IEnumerable<NativeColorData>
{
#region Constants

Expand Down Expand Up @@ -487,6 +488,10 @@ private void UpdateOpacityBar()

#region Public Functions

/// <inheritdoc/>
public IEnumerator<NativeColorData> GetEnumerator() => Colors.GetEnumerator();
/// <inheritdoc/>
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
/// <summary>
/// Moves to the Previous Color.
/// </summary>
Expand Down
7 changes: 6 additions & 1 deletion LemonUI/Menus/NativeListItem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using LemonUI.Elements;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;

Expand Down Expand Up @@ -29,7 +30,7 @@ public NativeListItem(string title, string subtitle) : base(title, subtitle)
/// <summary>
/// An item that allows you to scroll between a set of objects.
/// </summary>
public class NativeListItem<T> : NativeListItem
public class NativeListItem<T> : NativeListItem, IEnumerable<T>
{
#region Fields

Expand Down Expand Up @@ -188,6 +189,10 @@ private void UpdateIndex()

#region Functions

/// <inheritdoc/>
public IEnumerator<T> GetEnumerator() => Items.GetEnumerator();
/// <inheritdoc/>
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
/// <summary>
/// Adds a <typeparamref name="T" /> into this item.
/// </summary>
Expand Down
12 changes: 11 additions & 1 deletion LemonUI/Menus/NativeMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
using LemonUI.Extensions;
using LemonUI.Scaleform;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;

Expand All @@ -32,7 +33,7 @@ namespace LemonUI.Menus
/// <summary>
/// Menu that looks like the ones used by Rockstar.
/// </summary>
public class NativeMenu : IContainer<NativeItem>
public class NativeMenu : IContainer<NativeItem>, IEnumerable<NativeItem>
{
#region Public Fields

Expand Down Expand Up @@ -1361,12 +1362,21 @@ private void Draw()

#region Public Functions

/// <inheritdoc/>
public IEnumerator<NativeItem> GetEnumerator() => Items.GetEnumerator();
/// <inheritdoc/>
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
/// <summary>
/// Adds an item at the end of the menu.
/// </summary>
/// <param name="item">The item to add.</param>
public void Add(NativeItem item) => Add(Items.Count, item);
/// <summary>
/// Adds a specific menu as a submenu with an item.
/// </summary>
/// <param name="menu">The menu to add.</param>
public void Add(NativeMenu menu) => AddSubMenu(menu);
/// <summary>
/// Adds an item at the specified position.
/// </summary>
/// <param name="position">The position of the item.</param>
Expand Down
7 changes: 6 additions & 1 deletion LemonUI/Menus/NativeStatsPanel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using LemonUI.Elements;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;

Expand All @@ -8,7 +9,7 @@ namespace LemonUI.Menus
/// <summary>
/// Represents a Statistics panel.
/// </summary>
public class NativeStatsPanel : NativePanel, IContainer<NativeStatsInfo>
public class NativeStatsPanel : NativePanel, IContainer<NativeStatsInfo>, IEnumerable<NativeStatsInfo>
{
#region Fields

Expand Down Expand Up @@ -75,6 +76,10 @@ public NativeStatsPanel(params NativeStatsInfo[] stats)

#region Functions

/// <inheritdoc/>
public IEnumerator<NativeStatsInfo> GetEnumerator() => fields.GetEnumerator();
/// <inheritdoc/>
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
/// <summary>
/// Adds a stat to the player field.
/// </summary>
Expand Down
7 changes: 6 additions & 1 deletion LemonUI/ObjectPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using GTA.UI;
#endif
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;

Expand Down Expand Up @@ -75,7 +76,7 @@ internal SafeZoneChangedEventArgs(float before, float after)
/// <summary>
/// Manager for Menus and Items.
/// </summary>
public class ObjectPool
public class ObjectPool : IEnumerable<IProcessable>
{
#region Private Fields

Expand Down Expand Up @@ -206,6 +207,10 @@ private void DetectSafezoneChanges()

#region Public Function

/// <inheritdoc/>
public IEnumerator<IProcessable> GetEnumerator() => objects.GetEnumerator();
/// <inheritdoc/>
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
/// <summary>
/// Adds the object into the pool.
/// </summary>
Expand Down

0 comments on commit e3a616e

Please sign in to comment.