diff --git a/CHANGELOG.md b/CHANGELOG.md
index dfc1725..8380f02 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -18,7 +18,6 @@ Jump to version:
### MLEM
Additions
- **Added the ability for formatted (tokenized) strings to be drawn with custom rotation, origin and flipping**
-- **Added a public Combinations collection and associated constructor to Keybind**
- Added a RectangleF.FromCorners overload that accepts points
- Added indexers and Count to SpriteAnimation and SpriteAnimationGroup
diff --git a/MLEM/Input/Keybind.cs b/MLEM/Input/Keybind.cs
index 3e8140e..2d58fd1 100644
--- a/MLEM/Input/Keybind.cs
+++ b/MLEM/Input/Keybind.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Collections.ObjectModel;
using System.Linq;
using System.Runtime.Serialization;
@@ -21,43 +20,27 @@ namespace MLEM.Input {
private static readonly Combination[] EmptyCombinations = new Combination[0];
private static readonly GenericInput[] EmptyInputs = new GenericInput[0];
- ///
- /// A read-only collection containing all combinations that this keybind has.
- /// This property is serializable using the .
- ///
[DataMember]
- public readonly IList Combinations;
-
- private readonly List combinations = new List();
+ private Combination[] combinations = Keybind.EmptyCombinations;
///
/// Creates a new keybind and adds the given key and modifiers using
///
/// The key to be pressed.
/// The modifier keys that have to be held down.
- public Keybind(GenericInput key, params GenericInput[] modifiers) : this() {
+ public Keybind(GenericInput key, params GenericInput[] modifiers) {
this.Add(key, modifiers);
}
///
- public Keybind(GenericInput key, ModifierKey modifier) : this() {
+ public Keybind(GenericInput key, ModifierKey modifier) {
this.Add(key, modifier);
}
- ///
- /// Creates a new keybind from the given set of . This constructor can be used when manually serializing and deserializing a keybind's .
- ///
- /// The combinations to add.
- public Keybind(IList combinations) : this() {
- this.combinations.AddRange(combinations);
- }
-
///
/// Creates a new keybind with no default combinations
///
- public Keybind() {
- this.Combinations = new ReadOnlyCollection(this.combinations);
- }
+ public Keybind() {}
///
/// Adds a new key combination to this keybind that can optionally be pressed for the keybind to trigger.
@@ -75,7 +58,7 @@ namespace MLEM.Input {
/// The combination to add.
/// This keybind, for chaining
public Keybind Add(Combination combination) {
- this.combinations.Add(combination);
+ this.combinations = this.combinations.Append(combination).ToArray();
return this;
}
@@ -104,7 +87,7 @@ namespace MLEM.Input {
/// The combination to insert.
/// This keybind, for chaining.
public Keybind Insert(int index, Combination combination) {
- this.combinations.Insert(index, combination);
+ this.combinations = this.combinations.Take(index).Append(combination).Concat(this.combinations.Skip(index)).ToArray();
return this;
}
@@ -120,7 +103,7 @@ namespace MLEM.Input {
///
/// This keybind, for chaining
public Keybind Clear() {
- this.combinations.Clear();
+ this.combinations = Keybind.EmptyCombinations;
return this;
}
@@ -130,10 +113,7 @@ namespace MLEM.Input {
/// The predicate to match against
/// This keybind, for chaining
public Keybind Remove(Func predicate) {
- // we can't use RemoveAll here because it doesn't provide an index
- var keep = this.combinations.Where((c, i) => !predicate(c, i)).ToArray();
- this.combinations.Clear();
- this.combinations.AddRange(keep);
+ this.combinations = this.combinations.Where((c, i) => !predicate(c, i)).ToArray();
return this;
}
@@ -144,7 +124,7 @@ namespace MLEM.Input {
/// The keybind to copy from
/// This keybind, for chaining
public Keybind CopyFrom(Keybind other) {
- this.combinations.AddRange(other.combinations);
+ this.combinations = this.combinations.Concat(other.combinations).ToArray();
return this;
}
@@ -305,7 +285,7 @@ namespace MLEM.Input {
/// The combination, or default if this method returns false.
/// Whether the combination could be successfully retrieved or the index was out of bounds of this keybind's combination collection.
public bool TryGetCombination(int index, out Combination combination) {
- if (index >= 0 && index < this.combinations.Count) {
+ if (index >= 0 && index < this.combinations.Length) {
combination = this.combinations[index];
return true;
} else {