Skip to content

Commit

Permalink
BaseScaleform - Loaded & LoadScaleform() (#46)
Browse files Browse the repository at this point in the history
* Add LoadScaleform to BaseScaleform

* Create Loaded property for BaseScaleform

* Update BaseScaleform.cs
  • Loading branch information
Sander0542 authored Oct 21, 2021
1 parent f5cc178 commit 5f9d108
Showing 1 changed file with 34 additions and 5 deletions.
39 changes: 34 additions & 5 deletions LemonUI/Scaleform/BaseScaleform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,22 @@ public abstract class BaseScaleform : IScaleform
/// If the Scaleform should be visible or not.
/// </summary>
public bool Visible { get; set; }
/// <summary>
/// If the Scaleform is loaded or not.
/// </summary>
public bool IsLoaded
{
get
{
#if FIVEM
return API.HasScaleformMovieLoaded(Handle);
#elif RPH
return NativeFunction.CallByHash<bool>(0x85F01B8D5B90570E, Handle);
#elif (SHVDN2 || SHVDN3)
return Function.Call<bool>(Hash.HAS_SCALEFORM_MOVIE_LOADED, Handle);
#endif
}
}

#endregion

Expand All @@ -56,19 +72,32 @@ public abstract class BaseScaleform : IScaleform
public BaseScaleform(string sc)
{
Name = sc;

LoadScaleform();
}

#endregion

#region Protected Functions

/// <summary>
/// Load a given Scaleform
/// </summary>
protected void LoadScaleform()
{
#if FIVEM
Handle = API.RequestScaleformMovie(sc);
Handle = API.RequestScaleformMovie(Name);
#elif RPH
Handle = NativeFunction.CallByHash<int>(0x11FE353CF9733E6F, sc);
Handle = NativeFunction.CallByHash<int>(0x11FE353CF9733E6F, Name);
#elif (SHVDN2 || SHVDN3)
Handle = Function.Call<int>(Hash.REQUEST_SCALEFORM_MOVIE, sc);
Handle = Function.Call<int>(Hash.REQUEST_SCALEFORM_MOVIE, Name);
#endif

#pragma warning disable CS0618 // Type or member is obsolete
#if FIVEM
scaleform = new CitizenFX.Core.Scaleform(sc);
scaleform = new CitizenFX.Core.Scaleform(Name);
#elif (SHVDN2 || SHVDN3)
scaleform = new GTA.Scaleform(sc);
scaleform = new GTA.Scaleform(Name);
#endif
#pragma warning restore CS0618 // Type or member is obsolete
}
Expand Down

0 comments on commit 5f9d108

Please sign in to comment.