• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

luttje / Key2Joy / 9836432308

08 Jul 2024 08:46AM UTC coverage: 43.937% (-0.8%) from 44.758%
9836432308

Pull #66

github

web-flow
Merge aa8186077 into 3bfa3ba36
Pull Request #66: Bugfix recently discovered input bugs

793 of 2455 branches covered (32.3%)

Branch coverage included in aggregate %.

19 of 278 new or added lines in 20 files covered. (6.83%)

43 existing lines in 11 files now uncovered.

4012 of 8481 relevant lines covered (47.31%)

1567.5 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

14.29
/Core/Key2Joy.Core/Mapping/Actions/Logic/SetDelayedFunctionsAction.cs
1
using System;
2
using System.Text.Json.Serialization;
3
using System.Threading.Tasks;
4
using Key2Joy.Contracts.Mapping;
5
using Key2Joy.Contracts.Mapping.Actions;
6
using Key2Joy.Contracts.Mapping.Triggers;
7

8
namespace Key2Joy.Mapping.Actions.Logic;
9

10
[Action(
11
    Description = "Timeout for a specified duration before executing a function",
12
    Visibility = MappingMenuVisibility.Never,
13
    NameFormat = "Timeout for {0}ms",
14
    GroupName = "Logic",
15
    GroupImage = "application_xp_terminal"
16
)]
17
public class SetDelayedFunctionsAction : CoreAction
18
{
19
    [JsonInclude]
20
    public TimeSpan WaitTime;
21

22
    public SetDelayedFunctionsAction(string name)
23
        : base(name)
11✔
24
    {
25
    }
11✔
26

27
    /// <markdown-doc>
28
    /// <parent-name>Logic</parent-name>
29
    /// <path>Api/Logic</path>
30
    /// </markdown-doc>
31
    /// <summary>
32
    /// Execute functions whilst waiting the specified time between them.
33
    ///
34
    /// The first function is executed immediately.
35
    /// </summary>
36
    /// <markdown-example>
37
    /// Shows how to count down from 3 and execute a command using Lua.
38
    /// <code language="lua">
39
    /// <![CDATA[
40
    /// SetDelayedFunctions(
41
    ///    1000,
42
    ///    function ()
43
    ///       Print("Aborting in 3 second...")
44
    ///    end,
45
    ///    function ()
46
    ///       Print("Three")
47
    ///    end,
48
    ///    function ()
49
    ///       Print("Two")
50
    ///    end,
51
    ///    function ()
52
    ///       Print("One")
53
    ///    end,
54
    ///    function ()
55
    ///       App.Command("Abort")
56
    ///    end
57
    /// )
58
    /// ]]>
59
    /// </code>
60
    /// </markdown-example>
61
    /// <param name="waitTime">Time to wait (in milliseconds) between function calls</param>
62
    /// <param name="callbacks">One or more functions to execute</param>
63
    /// <name>SetDelayedFunctions</name>
64
    [ExposesScriptingMethod("SetDelayedFunctions")]
65
    public async void ExecuteForScript(long waitTime, params Action[] callbacks)
66
    {
NEW
67
        this.WaitTime = TimeSpan.FromMilliseconds(waitTime);
×
68

NEW
69
        for (var i = 0; i < callbacks.Length; i++)
×
70
        {
NEW
71
            if (i > 0)
×
72
            {
NEW
73
                await Task.Delay(this.WaitTime);
×
74
            }
75

NEW
76
            callbacks[i].Invoke();
×
77
        }
NEW
78
    }
×
79

80
    public override Task Execute(AbstractInputBag inputBag = null) =>
81
        // Irrelevant because only scripts should use this function
NEW
82
        Task.Delay(this.WaitTime);
×
83

84
    public override string GetNameDisplay() =>
85
        // Irrelevant because only scripts should use this function
NEW
86
        this.Name.Replace("{0}", this.WaitTime.TotalMilliseconds.ToString());
×
87
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc