-
-
Notifications
You must be signed in to change notification settings - Fork 18
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 #125 from OliBomby/dev
Dev update 1.7.1.0
- Loading branch information
Showing
66 changed files
with
2,191 additions
and
770 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
using System; | ||
|
||
namespace Mapping_Tools.Classes.BeatmapHelper { | ||
public interface IBeatDivisor : IEquatable<IBeatDivisor> { | ||
double GetValue(); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
Mapping Tools/Classes/BeatmapHelper/IrrationalBeatDivisor.cs
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,38 @@ | ||
namespace Mapping_Tools.Classes.BeatmapHelper { | ||
public class IrrationalBeatDivisor : IBeatDivisor { | ||
public readonly double Value; | ||
|
||
public IrrationalBeatDivisor(double value) { | ||
Value = value; | ||
} | ||
|
||
public static implicit operator IrrationalBeatDivisor(double value) { | ||
return new IrrationalBeatDivisor(value); | ||
} | ||
|
||
public double GetValue() { | ||
return Value; | ||
} | ||
|
||
protected bool Equals(IrrationalBeatDivisor other) { | ||
return Value.Equals(other.Value); | ||
} | ||
|
||
public bool Equals(IBeatDivisor other) { | ||
if (other is null) return false; | ||
if (ReferenceEquals(this, other)) return true; | ||
if (other is IrrationalBeatDivisor otherIrrational) return Equals(otherIrrational); | ||
return false; | ||
} | ||
|
||
public override bool Equals(object obj) { | ||
if (obj is null) return false; | ||
if (ReferenceEquals(this, obj)) return true; | ||
return obj.GetType() == GetType() && Equals((IrrationalBeatDivisor) obj); | ||
} | ||
|
||
public override int GetHashCode() { | ||
return Value.GetHashCode(); | ||
} | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
Mapping Tools/Classes/BeatmapHelper/RationalBeatDivisor.cs
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,62 @@ | ||
| ||
using Newtonsoft.Json; | ||
|
||
namespace Mapping_Tools.Classes.BeatmapHelper { | ||
public class RationalBeatDivisor : IBeatDivisor { | ||
/// <summary> | ||
/// The number above the line in a vulgar fraction showing how many of the parts indicated by the denominator are taken, for example, 2 in 2/3. | ||
/// </summary> | ||
public readonly int Numerator; | ||
|
||
/// <summary> | ||
/// The number below the line in a vulgar fraction; a divisor. | ||
/// </summary> | ||
public readonly int Denominator; | ||
|
||
public RationalBeatDivisor(int denominator) { | ||
Numerator = 1; | ||
Denominator = denominator; | ||
} | ||
|
||
[JsonConstructor] | ||
public RationalBeatDivisor(int numerator, int denominator) { | ||
Numerator = numerator; | ||
Denominator = denominator; | ||
} | ||
|
||
public static implicit operator RationalBeatDivisor(int denominator) { | ||
return new RationalBeatDivisor(denominator); | ||
} | ||
|
||
public double GetValue() { | ||
return (double) Numerator / Denominator; | ||
} | ||
|
||
protected bool Equals(RationalBeatDivisor other) { | ||
return Numerator == other.Numerator && Denominator == other.Denominator; | ||
} | ||
|
||
public bool Equals(IBeatDivisor other) { | ||
if (other is null) return false; | ||
if (ReferenceEquals(this, other)) return true; | ||
if (other is RationalBeatDivisor otherRational) return Equals(otherRational); | ||
return false; | ||
} | ||
|
||
public override bool Equals(object obj) { | ||
if (obj is null) return false; | ||
if (ReferenceEquals(this, obj)) return true; | ||
return obj.GetType() == GetType() && Equals((RationalBeatDivisor) obj); | ||
} | ||
|
||
public override int GetHashCode() { | ||
unchecked { | ||
return (Numerator * 397) ^ Denominator; | ||
} | ||
} | ||
|
||
public static IBeatDivisor[] GetDefaultBeatDivisors() { | ||
return new IBeatDivisor[] {new RationalBeatDivisor(16), new RationalBeatDivisor(12)}; | ||
} | ||
} | ||
} |
Oops, something went wrong.