forked from Revolutionary-Games/Thrive
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved applying to godot inputmap code Fixed comments Made more things static Moved Children modification code Refactoring Code cleanup Created BuildGUI methods cleanup Removed unneccecary back reference
- Loading branch information
1 parent
0af3873
commit 3cf396e
Showing
15 changed files
with
201 additions
and
204 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 |
---|---|---|
@@ -1,32 +1,55 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Godot; | ||
|
||
/// <summary> | ||
/// Stores an godot input action and its associated events | ||
/// Stores godot input actions and their associated events | ||
/// </summary> | ||
public class InputDataList : ICloneable | ||
{ | ||
public InputDataList(Dictionary<string, List<ThriveInputEventWithModifiers>> data) | ||
public InputDataList(Dictionary<string, List<SpecifiedInputKey>> data) | ||
{ | ||
Data = data; | ||
} | ||
|
||
public Dictionary<string, List<ThriveInputEventWithModifiers>> Data { get; } | ||
public Dictionary<string, List<SpecifiedInputKey>> Data { get; } | ||
|
||
public List<ThriveInputEventWithModifiers> this[string index] => Data[index]; | ||
public List<SpecifiedInputKey> this[string index] => Data[index]; | ||
|
||
public object Clone() | ||
{ | ||
var result = new Dictionary<string, List<ThriveInputEventWithModifiers>>(); | ||
var result = new Dictionary<string, List<SpecifiedInputKey>>(); | ||
foreach (var keyValuePair in Data) | ||
{ | ||
result[keyValuePair.Key] = new List<ThriveInputEventWithModifiers>(); | ||
result[keyValuePair.Key] = new List<SpecifiedInputKey>(); | ||
foreach (var inputEventWithModifiers in keyValuePair.Value) | ||
{ | ||
result[keyValuePair.Key].Add((ThriveInputEventWithModifiers)inputEventWithModifiers.Clone()); | ||
result[keyValuePair.Key].Add((SpecifiedInputKey)inputEventWithModifiers.Clone()); | ||
} | ||
} | ||
|
||
return new InputDataList(result); | ||
} | ||
|
||
/// <summary> | ||
/// Applies the current controls to the InputMap. | ||
/// </summary> | ||
internal void ApplyToGodotInputMap() | ||
{ | ||
foreach (var action in Data) | ||
{ | ||
// Clear all old input events | ||
InputMap.ActionEraseEvents(action.Key); | ||
|
||
// Add the new input events | ||
foreach (var inputEvent in action.Value) | ||
{ | ||
// If the game is waiting for an input | ||
if (inputEvent == null) | ||
return; | ||
|
||
InputMap.ActionAddEvent(action.Key, inputEvent.ToInputEvent()); | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.