-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #273 from SpaceWarpDev/1.6
1.6 -> Main For Possible SW 1.6
- Loading branch information
Showing
22 changed files
with
545 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using BepInEx.Configuration; | ||
|
||
namespace SpaceWarp.API.Configuration; | ||
|
||
public interface IValueConstraint | ||
{ | ||
public bool IsConstrained(object o); | ||
public AcceptableValueBase ToAcceptableValueBase(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using BepInEx.Configuration; | ||
using JetBrains.Annotations; | ||
|
||
namespace SpaceWarp.API.Configuration; | ||
|
||
public class ListConstraint<T> : ValueConstraint<T> where T : IEquatable<T> | ||
{ | ||
[PublicAPI] | ||
public List<T> AcceptableValues; | ||
|
||
public ListConstraint(IEnumerable<T> acceptableValues) | ||
{ | ||
AcceptableValues = acceptableValues.ToList(); | ||
} | ||
|
||
public ListConstraint(params T[] acceptableValues) | ||
{ | ||
AcceptableValues = acceptableValues.ToList(); | ||
} | ||
|
||
public override bool IsValid(T o) => AcceptableValues.Any(x => x.Equals(o)); | ||
public override AcceptableValueBase ToAcceptableValueBase() | ||
{ | ||
return new AcceptableValueList<T>(AcceptableValues.ToArray()); | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
StringBuilder sb = new(); | ||
sb.Append("["); | ||
for (int i = 0; i < AcceptableValues.Count; i++) | ||
{ | ||
if (i != 0) | ||
{ | ||
sb.Append(", "); | ||
} | ||
|
||
sb.Append(AcceptableValues[i]); | ||
} | ||
|
||
sb.Append("]"); | ||
return sb.ToString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System; | ||
using BepInEx.Configuration; | ||
using JetBrains.Annotations; | ||
|
||
namespace SpaceWarp.API.Configuration; | ||
|
||
public class RangeConstraint<T> : ValueConstraint<T> where T : IComparable<T>, IComparable | ||
{ | ||
[PublicAPI] | ||
public T Minimum; | ||
[PublicAPI] | ||
public T Maximum; | ||
|
||
public RangeConstraint(T minimum, T maximum) | ||
{ | ||
Minimum = minimum; | ||
Maximum = maximum; | ||
} | ||
|
||
public override bool IsValid(T o) => Minimum.CompareTo(o) <= 0 && Maximum.CompareTo(o) >= 0; | ||
public override AcceptableValueBase ToAcceptableValueBase() | ||
{ | ||
return new AcceptableValueRange<T>(Minimum, Maximum); | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
return $"{Minimum} - {Maximum}"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using BepInEx.Configuration; | ||
|
||
namespace SpaceWarp.API.Configuration; | ||
|
||
public abstract class ValueConstraint<T> : IValueConstraint | ||
{ | ||
public abstract bool IsValid(T o); | ||
public bool IsValid(object o) | ||
{ | ||
return IsValid((T)o); | ||
} | ||
|
||
public bool IsConstrained(object o) | ||
{ | ||
return IsValid((T)o); | ||
} | ||
|
||
public abstract AcceptableValueBase ToAcceptableValueBase(); | ||
} |
Oops, something went wrong.