File InstructionalButtons.cs
File List > LemonUI > LemonUI > Scaleform > InstructionalButtons.cs
Go to the documentation of this file
#if FIVEM
using CitizenFX.Core;
using CitizenFX.Core.Native;
#elif RAGEMP
using RAGE.Game;
#elif RPH
using Rage.Native;
using Control = Rage.GameControl;
#elif SHVDN3 || SHVDNC
using GTA;
using GTA.Native;
#endif
using System;
using System.Collections.Generic;
namespace LemonUI.Scaleform
{
public class InstructionalButtons : BaseScaleform
{
#region Fields
private readonly List<InstructionalButton> buttons = new List<InstructionalButton>();
#endregion
#region Constructors
public InstructionalButtons(params InstructionalButton[] buttons) : base("INSTRUCTIONAL_BUTTONS")
{
this.buttons.AddRange(buttons);
}
#endregion
#region Functions
public void Add(InstructionalButton button)
{
// If the item is already in the list, raise an exception
if (buttons.Contains(button))
{
throw new InvalidOperationException("The button is already in the Scaleform.");
}
// Otherwise, add it to the list of items
buttons.Add(button);
}
public void Remove(InstructionalButton button)
{
// If the button is not in the list, return
if (!buttons.Contains(button))
{
return;
}
// Otherwise, remove it
buttons.Remove(button);
}
public void Clear()
{
buttons.Clear();
}
public override void Update()
{
// Clear all of the existing items
CallFunction("CLEAR_ALL");
CallFunction("TOGGLE_MOUSE_BUTTONS", 0);
CallFunction("CREATE_CONTAINER");
// And add them again
for (int i = 0; i < buttons.Count; i++)
{
InstructionalButton button = buttons[i];
CallFunction("SET_DATA_SLOT", i, button.Raw, button.Description);
}
CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);
}
#endregion
}
}