Skip to content

Commit b2c5f99

Browse files
committed
1 parent 1d57f7b commit b2c5f99

4 files changed

Lines changed: 48 additions & 0 deletions

File tree

docs/articles/overview-of-wrapper-and-api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ IMaaDisposable Derived:
184184
| IMaaContext.RunAction() | `MaaContextRunAction` |
185185
| IMaaContext.RunRecognitionDirect() | `MaaContextRunRecognitionDirect` |
186186
| IMaaContext.RunActionDirect() | `MaaContextRunActionDirect` |
187+
| IMaaContext.WaitFreezes() | `MaaContextWaitFreezes` |
187188
| IMaaContext.OverridePipeline() | `MaaContextOverridePipeline` |
188189
| IMaaContext.OverrideNext() | `MaaContextOverrideNext` |
189190
| IMaaContext.OverrideImage() | `MaaContextOverrideImage` |

src/MaaFramework.Binding.Native/Interop/Framework/Instance/MaaContext.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ public static partial class MaaContext
4949
[LibraryImport("MaaFramework", StringMarshalling = StringMarshalling.Utf8)]
5050
public static partial MaaActId MaaContextRunActionDirect(MaaContextHandle context, string actionType, string actionParam, MaaRectHandle box, string recoDetail);
5151

52+
[LibraryImport("MaaFramework", StringMarshalling = StringMarshalling.Utf8)]
53+
[return: MarshalAs(UnmanagedType.U1)]
54+
public static partial bool MaaContextWaitFreezes(MaaContextHandle context, MaaSize time, MaaRectHandle roi, string waitFreezesParam);
55+
5256
[LibraryImport("MaaFramework", StringMarshalling = StringMarshalling.Utf8)]
5357
[return: MarshalAs(UnmanagedType.U1)]
5458
public static partial bool MaaContextOverridePipeline(MaaContextHandle context, string pipelineOverride);

src/MaaFramework.Binding.Native/MaaContext.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,28 @@ public MaaContext(MaaContextHandle contextHandle, MaaTasker tasker)
158158
: ActionDetail.Query<MaaRectBuffer>(actionId, Tasker);
159159
}
160160

161+
/// <inheritdoc/>
162+
public bool WaitFreezes(TimeSpan time, IMaaRectBuffer recognitionBox, [StringSyntax("Json")] string waitFreezesParam = "{}")
163+
=> WaitFreezes((MaaSize)time.TotalMilliseconds, (MaaRectBuffer)recognitionBox, waitFreezesParam);
164+
165+
/// <inheritdoc cref="IMaaContext.WaitFreezes(TimeSpan, IMaaRectBuffer, string)"/>
166+
public bool WaitFreezes(TimeSpan time, MaaRectBuffer recognitionBox, [StringSyntax("Json")] string waitFreezesParam = "{}")
167+
=> WaitFreezes((MaaSize)time.TotalMilliseconds, recognitionBox, waitFreezesParam);
168+
169+
/// <inheritdoc/>
170+
public bool WaitFreezes(MaaSize millisecondsTime, IMaaRectBuffer recognitionBox, [StringSyntax("Json")] string waitFreezesParam = "{}")
171+
=> WaitFreezes(millisecondsTime, (MaaRectBuffer)recognitionBox, waitFreezesParam);
172+
173+
/// <inheritdoc cref="IMaaContext.WaitFreezes(ulong, IMaaRectBuffer, string)"/>
174+
/// <remarks>
175+
/// Wrapper of <see cref="MaaContextWaitFreezes"/>.
176+
/// </remarks>
177+
public bool WaitFreezes(MaaSize millisecondsTime, MaaRectBuffer recognitionBox, [StringSyntax("Json")] string waitFreezesParam = "{}")
178+
{
179+
ArgumentNullException.ThrowIfNull(recognitionBox);
180+
return MaaContextWaitFreezes(Handle, millisecondsTime, recognitionBox.Handle, waitFreezesParam);
181+
}
182+
161183
/// <inheritdoc/>
162184
/// <remarks>
163185
/// Wrapper of <see cref="MaaContextOverridePipeline"/>.

src/MaaFramework.Binding/IMaaContext.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,27 @@ public interface IMaaContext : ICloneable
7676
/// <exception cref="ArgumentNullException"/>
7777
ActionDetail? RunActionDirect(string type, [StringSyntax("Json")] string param, IMaaRectBuffer recognitionBox, [StringSyntax("Json")] string recognitionDetail = "");
7878

79+
/// <summary>
80+
/// Waits for screen to stabilize (freeze).
81+
/// </summary>
82+
/// <param name="millisecondsTime">The wait time in milliseconds.</param>
83+
/// <param name="recognitionBox">The recognition hit box, used when target is Self to calculate ROI.</param>
84+
/// <param name="waitFreezesParam">The wait parameters.<para>Supports time, target, target_offset, threshold, method, rate_limit, timeout.</para></param>
85+
/// <returns><see langword="true"/> if the operation was executed successfully; otherwise, <see langword="false"/>.</returns>
86+
/// <remarks>
87+
/// <paramref name="millisecondsTime"/> and <paramref name="waitFreezesParam"/>.time are mutually exclusive.
88+
/// </remarks>
89+
bool WaitFreezes(MaaSize millisecondsTime, IMaaRectBuffer recognitionBox, [StringSyntax("Json")] string waitFreezesParam = "{}");
90+
91+
/// <param name="time">The wait time.</param>
92+
/// <param name="recognitionBox">The recognition hit box, used when target is Self to calculate ROI.</param>
93+
/// <param name="waitFreezesParam">The wait parameters.<para>Supports time, target, target_offset, threshold, method, rate_limit, timeout.</para></param>
94+
/// <remarks>
95+
/// <paramref name="time"/> and <paramref name="waitFreezesParam"/>.time are mutually exclusive.
96+
/// </remarks>
97+
/// <inheritdoc cref="WaitFreezes(ulong, IMaaRectBuffer, string)"/>
98+
bool WaitFreezes(TimeSpan time, IMaaRectBuffer recognitionBox, [StringSyntax("Json")] string waitFreezesParam = "{}");
99+
79100
/// <summary>
80101
/// Overrides a pipeline.
81102
/// </summary>

0 commit comments

Comments
 (0)