Skip to content

Commit

Permalink
1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
vonderborch committed Apr 13, 2021
1 parent fc07fbd commit 10b4d1c
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<RepositoryUrl>https://github.com/vonderborch/Velentr.Input</RepositoryUrl>
<PackageTags>FNA, Input, Keyboard, Mouse, GamePad, Touch, Voice</PackageTags>
<Description>A simple and easy-to-use input library for XNA/Monogame/FNA.</Description>
<Version>1.2.0</Version>
<Version>1.2.1</Version>
<PackageProjectUrl>https://github.com/vonderborch/Velentr.Input</PackageProjectUrl>
<PackageLicenseExpression></PackageLicenseExpression>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<PackageTags>Monogame, Input, Keyboard, Mouse, GamePad, Touch, Voice</PackageTags>
<Description>A simple and easy-to-use input library for XNA/Monogame/FNA.</Description>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>1.2.0</Version>
<Version>1.2.1</Version>
<PackageProjectUrl>https://github.com/vonderborch/Velentr.Input</PackageProjectUrl>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
4 changes: 2 additions & 2 deletions Velentr.Input/Velentr.Input.Core/Conditions/AllCondition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public AllCondition(InputManager manager, params InputCondition[] conditions) :
/// <returns></returns>
public override bool InternalConditionMet(bool consumable, bool allowedIfConsumed)
{
GameTime time = null;
TimeSpan time;
_arguments = new List<ConditionEventArguments>(Conditions.Length);

for (var i = 0; i < Conditions.Length; i++)
Expand All @@ -84,7 +84,7 @@ public override bool InternalConditionMet(bool consumable, bool allowedIfConsume
return false;
}

if (time == null || time.TotalGameTime <= Conditions[i].CurrentStateStart.TotalGameTime)
if (time == null || time <= Conditions[i].CurrentStateStart)
{
time = Conditions[i].CurrentStateStart;
_arguments.Add(Conditions[i].GetArguments());
Expand Down
14 changes: 8 additions & 6 deletions Velentr.Input/Velentr.Input.Core/Conditions/InputCondition.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Microsoft.Xna.Framework;
using System;
using Microsoft.Xna.Framework;
using Velentr.Input.Enums;
using Velentr.Input.EventArguments;
using ValueType = Velentr.Input.Enums.ValueType;

namespace Velentr.Input.Conditions
{
Expand Down Expand Up @@ -83,7 +85,7 @@ protected InputCondition(InputManager manager, InputSource source, bool windowMu
/// <value>
/// The current state start.
/// </value>
public GameTime CurrentStateStart { get; protected set; }
public TimeSpan CurrentStateStart { get; protected set; }

/// <summary>
/// Gets a value indicating whether [window must be active].
Expand Down Expand Up @@ -115,7 +117,7 @@ protected InputCondition(InputManager manager, InputSource source, bool windowMu
/// <value>
/// The last fire time.
/// </value>
public GameTime LastFireTime { get; protected set; }
public TimeSpan LastFireTime { get; protected set; }

/// <summary>
/// Gets the milliseconds when inputs are valid between the condition being met.
Expand Down Expand Up @@ -210,11 +212,11 @@ protected void UpdateState(bool newState)
if (newState != ConditionMetState)
{
ConditionMetState = newState;
CurrentStateStart = Manager.CurrentTime;
CurrentStateStart = Manager.CurrentTime.TotalGameTime;

if (newState)
{
LastFireTime = null;
LastFireTime = TimeSpan.Zero;
}
}
}
Expand All @@ -231,7 +233,7 @@ protected void ConditionMetCleanup(bool consumable, ConditionEventArguments argu
Consume();
}

LastFireTime = Manager.CurrentTime;
LastFireTime = Manager.CurrentTime.TotalGameTime;
if (Event.Delegates.Count > 0)
{
Event.TriggerEvent(this, arguments);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public abstract class ConditionEventArguments : EventArgs

public InputCondition Condition { get; internal set; }

public GameTime ConditionStateStartTime { get; internal set; }
public TimeSpan ConditionStateStartTime { get; internal set; }

public uint ConditionStateTimeMilliSeconds { get; internal set; }

Expand Down
30 changes: 2 additions & 28 deletions Velentr.Input/Velentr.Input.Core/Helpers/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,9 @@ public static bool CoordinateInRectangle(Point point, Rectangle rectangle)
return rectangle.X <= point.X && point.X <= rectangle.Width && rectangle.Y <= point.Y && point.Y <= rectangle.Height;
}

public static uint ElapsedSeconds(GameTime startTime, GameTime endTime)
public static uint ElapsedMilliSeconds(TimeSpan startTime, GameTime endTime)
{
return Convert.ToUInt32((endTime.TotalGameTime - startTime.TotalGameTime).TotalSeconds);
}

public static uint ElapsedMilliSeconds(GameTime startTime, GameTime endTime)
{
if (startTime == null && endTime == null)
{
throw new ArgumentException("At least one time must not be null!");
}
if (startTime == null)
{
return Convert.ToUInt32(endTime.TotalGameTime.TotalMilliseconds);
}
if (endTime == null)
{
return Convert.ToUInt32(startTime.TotalGameTime.TotalMilliseconds);
}

var start = startTime;
var end = endTime;
if (start.TotalGameTime > end.TotalGameTime)
{
start = endTime;
end = startTime;
}

return Convert.ToUInt32((end.TotalGameTime - start.TotalGameTime).TotalMilliseconds);
return Convert.ToUInt32(Math.Abs((endTime.TotalGameTime - startTime).TotalMilliseconds));
}

public static Point ScalePointToChild(Point coordinates, Rectangle parentArea, Rectangle childArea)
Expand Down
2 changes: 1 addition & 1 deletion Velentr.Input/Velentr.Input.Core/Velentr.Input.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace>Velentr.Input</RootNamespace>
<AssemblyName>Velentr.Input</AssemblyName>
<Version>1.2.0</Version>
<Version>1.2.1</Version>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.0.1641">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public override void RemovePhrases(List<string> phrases)
/// <param name="phrase">The phrase.</param>
public override void PhraseRecognized(string phrase)
{
_availablePhrases[phrase] = new RecognizedPhrase(phrase, false, Manager.CurrentTime);
_availablePhrases[phrase] = new RecognizedPhrase(phrase, false, Manager.CurrentTime.TotalGameTime);
}
}

Expand Down
7 changes: 4 additions & 3 deletions Velentr.Input/Velentr.Input.Core/Voice/RecognizedPhrase.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using Microsoft.Xna.Framework;
using System;
using Microsoft.Xna.Framework;

namespace Velentr.Input.Voice
{
public class RecognizedPhrase
{

public RecognizedPhrase(string phrase, bool consumed, GameTime timeStamp)
public RecognizedPhrase(string phrase, bool consumed, TimeSpan timeStamp)
{
Phrase = phrase;
Consumed = consumed;
Expand All @@ -16,6 +17,6 @@ public RecognizedPhrase(string phrase, bool consumed, GameTime timeStamp)

public string Phrase { get; }

public GameTime PhraseSaid { get; }
public TimeSpan PhraseSaid { get; }
}
}

0 comments on commit 10b4d1c

Please sign in to comment.