Skip to content

Commit 121664e

Browse files
committed
feat(Util): Reuse overload withinrange
1 parent d3814f7 commit 121664e

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

Assets/JCSUnity/Scripts/Input/JCS_ButtonSelectionGroup.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ public void SelectSelection(int selectionIndex, bool hoverCheck = false)
203203
{
204204
if (hoverCheck)
205205
{
206-
if (JCS_Util.WithInArrayRange(selectionIndex, mSelections))
206+
if (JCS_Util.WithInRange(selectionIndex, mSelections))
207207
{
208208
if (mSelections[selectionIndex].Skip)
209209
return;
@@ -214,15 +214,15 @@ public void SelectSelection(int selectionIndex, bool hoverCheck = false)
214214
if (mCurrentSelectIndex == selectionIndex)
215215
return;
216216

217-
if (JCS_Util.WithInArrayRange(mCurrentSelectIndex, mSelections))
217+
if (JCS_Util.WithInRange(mCurrentSelectIndex, mSelections))
218218
{
219219
// disable current active selection.
220220
mSelections[mCurrentSelectIndex].Active = false;
221221
}
222222

223223
this.mCurrentSelectIndex = selectionIndex;
224224

225-
this.mCurrentSelectIndex = JCS_Util.LoopInArray(this.mCurrentSelectIndex, mSelections);
225+
this.mCurrentSelectIndex = JCS_Util.LoopIn(this.mCurrentSelectIndex, mSelections);
226226

227227
// active the new active selection.
228228
mSelections[mCurrentSelectIndex].Active = true;

Assets/JCSUnity/Scripts/UI/LinkedObject/JCS_TransformLinkedObjectController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public List<JCS_TransformLinkedObject> NewLinked(int n = 1, int startIndex = 0)
151151
/// <returns> List of removed linked object. </returns>
152152
public List<JCS_TransformLinkedObject> RemoveLinked(int n = 1, int startIndex = 0)
153153
{
154-
if (!JCS_Util.WithInArrayRange(startIndex, mManagedList))
154+
if (!JCS_Util.WithInRange(startIndex, mManagedList))
155155
{
156156
JCS_Debug.LogReminder("Can't remove linked node with index lower than 0");
157157
return null;

Assets/JCSUnity/Scripts/UI/Page/JCS_PageIndicators.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public void SetPage(int page)
5555
{
5656
SetSprite(mInactiveSprite);
5757

58-
if (!JCS_Util.WithInArrayRange(page, mIndicators))
58+
if (!JCS_Util.WithInRange(page, mIndicators))
5959
{
6060
JCS_Debug.LogWarning("Page indicators out of range exception");
6161
return;

Assets/JCSUnity/Scripts/Util/JCS_Util.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public static bool WithInRange(float minRange, float maxRange, float currentVal)
195195
/// With in array range. (Array)
196196
/// </summary>
197197
/// <returns></returns>
198-
public static bool WithInArrayRange<T>(int index, T[] arr)
198+
public static bool WithInRange<T>(int index, T[] arr)
199199
{
200200
return index >= 0 && index < arr.Length;
201201
}
@@ -204,7 +204,7 @@ public static bool WithInArrayRange<T>(int index, T[] arr)
204204
/// With in array range. (List)
205205
/// </summary>
206206
/// <returns></returns>
207-
public static bool WithInArrayRange<T>(int index, List<T> arr)
207+
public static bool WithInRange<T>(int index, List<T> arr)
208208
{
209209
return index >= 0 && index < arr.Count;
210210
}
@@ -216,7 +216,7 @@ public static bool WithInArrayRange<T>(int index, List<T> arr)
216216
/// <param name="index"> Index </param>
217217
/// <param name="arr"> Array. </param>
218218
/// <returns> index that looped. </returns>
219-
public static int LoopInArray<T>(int index, T[] arr)
219+
public static int LoopIn<T>(int index, T[] arr)
220220
{
221221
// loop through the array, if at the tail of the array set it to head.
222222
if (index < 0)
@@ -234,7 +234,7 @@ public static int LoopInArray<T>(int index, T[] arr)
234234
/// <param name="index"> Index </param>
235235
/// <param name="arr"> List. </param>
236236
/// <returns> index that looped. </returns>
237-
public static int LoopInArray<T>(int index, List<T> arr)
237+
public static int LoopIn<T>(int index, List<T> arr)
238238
{
239239
// loop through the array, if at the tail of the array set it to head.
240240
if (index < 0)

docs/ScriptReference/Util/JCS_Util.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ All code utility is stored here.
1212
| FindObjectByType | Retrieves the first active loaded object of Type type. |
1313
| FindObjectsByType | Retrieves a list of all loaded objects of Type type. |
1414
| WithInRange | Check if the value is within the range. |
15-
| WithInArrayRange | Check if the index valid within the array length.&nbsp&nbsp(0 ~ (length - 1)) |
16-
| LoopInArray | Make the index is within the array length by setting the maxinum of (legnth - 1) or mininum of 0. |
15+
| WithInRange | Check if the index valid within the array length. |
16+
| LoopIn | Make the index is within the array length by setting the maxinum of (legnth - 1) or mininum of 0. |
1717
| SpawnAnimateObject | Spawn a gameobject with animation attached. |
1818
| SpawnAnimateObjectDeathEvent | Spawn a gameobject with the animator and death event on it. |
1919
| SetActiveToAllChildren | Active all the child in a transform. |

0 commit comments

Comments
 (0)