This repository was archived by the owner on Jan 28, 2019. It is now read-only.
forked from citizenfx/NativeUI
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathInstructionalButton.cs
56 lines (47 loc) · 1.85 KB
/
InstructionalButton.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using static CitizenFX.Core.Native.API;
namespace NativeUI
{
public class InstructionalButton
{
public string Text { get; set; }
public UIMenuItem ItemBind { get; private set; }
private readonly string _buttonString;
private readonly CitizenFX.Core.Control _buttonControl;
private readonly bool _usingControls;
/// <summary>
/// Add a dynamic button to the instructional buttons array.
/// Changes whether the controller is being used and changes depending on keybinds.
/// </summary>
/// <param name="control">CitizenFX.Core.Control that gets converted into a button.</param>
/// <param name="text">Help text that goes with the button.</param>
public InstructionalButton(CitizenFX.Core.Control control, string text)
{
Text = text;
_buttonControl = control;
_usingControls = true;
}
/// <summary>
/// Adds a keyboard button to the instructional buttons array.
/// </summary>
/// <param name="keystring">Custom keyboard button, like "I", or "O", or "F5".</param>
/// <param name="text">Help text that goes with the button.</param>
public InstructionalButton(string keystring, string text)
{
Text = text;
_buttonString = keystring;
_usingControls = false;
}
/// <summary>
/// Bind this button to an item, so it's only shown when that item is selected.
/// </summary>
/// <param name="item">Item to bind to.</param>
public void BindToItem(UIMenuItem item)
{
ItemBind = item;
}
public string GetButtonId()
{
return _usingControls ? GetControlInstructionalButton(2, (int)_buttonControl, 0) : "t_" + _buttonString;
}
}
}