Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
HotAction.cs
Go to the documentation of this file.
1using Newtonsoft.Json;
2using UnityEngine;
3
4public class HotAction : HotItem
5{
6 [JsonProperty]
7 public int _bgColor;
8
9 [JsonProperty]
10 public string text;
11
13 {
14 get
15 {
17 }
18 set
19 {
20 _bgColor = IntColor.ToInt(ref value);
21 }
22 }
23
24 public override Color SpriteColor
25 {
26 get
27 {
28 if (!CanChangeIconColor || _bgColor == 0)
29 {
30 return base.SpriteColor;
31 }
32 return bgColor;
33 }
34 }
35
36 public virtual string Id => "";
37
38 public virtual bool CanChangeIconColor => false;
39
40 public virtual bool CanName => true;
41
42 public override string Name => text.IsEmpty(("hotAction" + Id).lang());
43
44 public override string pathSprite => "icon_hot" + Id;
45
46 public override void OnClick(ButtonHotItem b, Hotbar h)
47 {
49 {
50 SE.Beep();
51 }
52 else
53 {
54 Perform();
55 }
56 }
57
58 public virtual void Perform()
59 {
60 }
61
62 public override void OnShowContextMenu(UIContextMenu m)
63 {
64 base.OnShowContextMenu(m);
65 if (CanName)
66 {
67 m.AddButton("changeName", delegate
68 {
69 Dialog.InputName("dialogChangeName", text.IsEmpty(""), delegate(bool cancel, string t)
70 {
71 if (!cancel)
72 {
73 text = t;
74 }
75 });
76 });
77 }
79 {
80 return;
81 }
82 m.AddButton("actChangeColor", delegate
83 {
84 if (_bgColor == 0)
85 {
86 bgColor = Color.white;
87 }
88 EClass.ui.AddLayer<LayerColorPicker>().SetColor(bgColor, Color.white, delegate(PickerState state, Color _c)
89 {
90 bgColor = _c;
91 button.icon.color = _c;
92 });
93 });
94 }
95}
PickerState
Definition: PickerState.cs:2
Definition: Dialog.cs:7
static Dialog InputName(string langDetail, string text, Action< bool, string > onClose, InputType inputType=InputType.Default)
Definition: Dialog.cs:528
Definition: EClass.cs:5
static Player player
Definition: EClass.cs:12
static UI ui
Definition: EClass.cs:16
virtual string Id
Definition: HotAction.cs:36
override void OnShowContextMenu(UIContextMenu m)
Definition: HotAction.cs:62
override string Name
Definition: HotAction.cs:42
int _bgColor
Definition: HotAction.cs:7
override Color SpriteColor
Definition: HotAction.cs:25
virtual bool CanChangeIconColor
Definition: HotAction.cs:38
override void OnClick(ButtonHotItem b, Hotbar h)
Definition: HotAction.cs:46
virtual void Perform()
Definition: HotAction.cs:58
virtual bool CanName
Definition: HotAction.cs:40
Color bgColor
Definition: HotAction.cs:13
string text
Definition: HotAction.cs:10
override string pathSprite
Definition: HotAction.cs:44
Definition: Hotbar.cs:5
static int ToInt(ref Color c)
Definition: IntColor.cs:24
static Color32 FromInt(int i)
Definition: IntColor.cs:15
bool CanAcceptInput()
Definition: Player.cs:2212
void AddButton(Func< string > funcText, UnityAction action=null)