Skip to content

File InstructionalButton.cs

File List > LemonUI > LemonUI > Scaleform > InstructionalButton.cs

Go to the documentation of this file


#if FIVEM
using CitizenFX.Core;
using CitizenFX.Core.Native;
#elif RAGEMP
using RAGE.Game;
#elif ALTV
using AltV.Net.Client;
using LemonUI.Elements;
#elif RPH
using Rage.Native;
using Control = Rage.GameControl;
#elif SHVDN3 || SHVDNC
using GTA;
using GTA.Native;
#endif
using System;

namespace LemonUI.Scaleform
{
    public struct InstructionalButton
    {
        #region Fields

        private Control control;
        private string raw;
        private string description;

        #endregion

        #region Properties

        public string Description
        {
            get => description;
            set => description = value ?? throw new ArgumentNullException(nameof(value));
        }
        public Control Control
        {
            get => control;
            set
            {
                control = value;
#if FIVEM
                raw = API.GetControlInstructionalButton(2, (int)value, 1);
#elif RAGEMP
                raw = Invoker.Invoke<string>(Natives.GetControlInstructionalButton, 2, (int)value, 1);
#elif RPH
                raw = (string)NativeFunction.CallByHash(0x0499D7B09FC9B407, typeof(string), 2, (int)control, 1);
#elif SHVDN3 || SHVDNC
                raw = Function.Call<string>(Hash.GET_CONTROL_INSTRUCTIONAL_BUTTONS_STRING, 2, (int)value, 1);
#elif ALTV
                raw = Alt.Natives.GetControlInstructionalButtonsString(2, (int)value, true);
#endif
            }
        }
        public string Raw
        {
            get => raw;
            set
            {
                raw = value ?? throw new ArgumentNullException(nameof(value));
                control = (Control)(-1);
            }
        }

        #endregion

        #region Constructors

        public InstructionalButton(string description, Control control)
        {
            this.description = description ?? throw new ArgumentNullException(nameof(description));
            this.control = control;
#if FIVEM
            raw = API.GetControlInstructionalButton(2, (int)control, 1);
#elif ALTV
            raw = Alt.Natives.GetControlInstructionalButtonsString(2, (int)control, true);
#elif RAGEMP
            raw = Invoker.Invoke<string>(Natives.GetControlInstructionalButton, 2, (int)control, 1);
#elif RPH
            raw = (string)NativeFunction.CallByHash(0x0499D7B09FC9B407, typeof(string), 2, (int)control, 1);
#elif SHVDN3 || SHVDNC
            raw = Function.Call<string>(Hash.GET_CONTROL_INSTRUCTIONAL_BUTTONS_STRING, 2, (int)control, 1);
#endif
        }
        public InstructionalButton(string description, string raw)
        {
            this.description = description ?? throw new ArgumentNullException(nameof(description));
            control = (Control)(-1);
            this.raw = raw ?? throw new ArgumentNullException(nameof(raw));
        }

        #endregion
    }
}