Skip to content

Commit

Permalink
Make the bink video id disposable
Browse files Browse the repository at this point in the history
  • Loading branch information
justalemon committed Dec 16, 2023
1 parent 70b73a5 commit 4628300
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion LemonUI/Elements/ScaledBink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace LemonUI.Elements
/// <summary>
/// A Bink Video file.
/// </summary>
public class ScaledBink : BaseElement
public class ScaledBink : BaseElement, IDisposable
{
#region Fields

Expand Down Expand Up @@ -91,6 +91,11 @@ public ScaledBink(string name, PointF pos, SizeF size) : base(pos, size)
/// </summary>
public override void Draw()
{
if (id == -1)
{
return;
}

#if ALTV
Alt.Natives.PlayBinkMovie(id);
Alt.Natives.DrawBinkMovie(id, relativePosition.X, relativePosition.Y, relativeSize.Width, relativeSize.Height, 0.0f, 255, 255, 255, 255);
Expand All @@ -116,6 +121,11 @@ public override void Draw()
/// </remarks>
public void Stop()
{
if (id == -1)
{
return;
}

#if ALTV
Alt.Natives.StopBinkMovie(id);
#elif FIVEM
Expand All @@ -128,6 +138,30 @@ public void Stop()
Function.Call<int>(Hash.STOP_BINK_MOVIE, id);
#endif
}
/// <summary>
/// Disposes the Bink Video ID.
/// </summary>
public void Dispose()
{
if (id == -1)
{
return;
}

#if ALTV
Alt.Natives.ReleaseBinkMovie(id);
#elif FIVEM
API.ReleaseBinkMovie(id);
#elif RAGEMP
Invoker.Invoke<int>(0x04D950EEFA4EED8C, id);
#elif RPH
NativeFunction.CallByHash<int>(0x04D950EEFA4EED8C, id);
#elif SHVDN3 || SHVDNC
Function.Call<int>(Hash.RELEASE_BINK_MOVIE, id);
#endif

id = -1;
}
/// <inheritdoc/>
public override void Recalculate()
{
Expand Down

0 comments on commit 4628300

Please sign in to comment.