Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AttributeButtonUIComponent.c
Go to the documentation of this file.
1 class SCR_AttributeButtonUIComponent: ScriptedWidgetComponent
2 {
3  protected SCR_ButtonBoxAttributeUIComponent m_AttributeUIComponent;
4 
5  protected string m_sButtonDescription;
6 
7  protected bool m_bIsFocused;
8  protected bool m_bListeningToMouseLeft;
9  protected bool m_FocusUpdateBlocked;
10 
11  protected const int MOUSE_LEFT_REMOVE_DESCRIPTION_DELAY = 50;
12 
20  void ButtonDescriptionInit(SCR_ButtonBoxAttributeUIComponent attributeUIComponent, SCR_ButtonBaseComponent button, string buttonDescription, string buttonName = string.Empty)
21  {
22  m_AttributeUIComponent = attributeUIComponent;
23 
24  if (!buttonDescription.IsEmpty())
25  m_sButtonDescription = buttonDescription;
26  else
27  m_sButtonDescription = buttonName;
28 
29  button.m_OnShowBorder.Insert(OnButtonFocus);
30  }
31 
32  protected void OnButtonFocus(SCR_ButtonBaseComponent button, bool value)
33  {
34  if (!value)
35  return;
36  }
37 
38  override bool OnMouseEnter(Widget w, int x, int y)
39  {
40  m_bIsFocused = true;
41  if (!m_AttributeUIComponent)
42  return false;
43 
44  if (!m_AttributeUIComponent.GetIsFocused())
45  return false;
46 
47  m_AttributeUIComponent.ShowButtonDescription(this, true, m_sButtonDescription);
48  return false;
49  }
50 
51  override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
52  {
53  m_bIsFocused = false;
54 
55  if (!m_bListeningToMouseLeft)
56  {
57  m_bListeningToMouseLeft = true;
58  GetGame().GetCallqueue().CallLater(OnMouseLeaveDelay, MOUSE_LEFT_REMOVE_DESCRIPTION_DELAY);
59  }
60 
61  return false;
62  }
63 
64  protected void OnMouseLeaveDelay()
65  {
66  m_bListeningToMouseLeft = false;
67 
68  if (m_bIsFocused)
69  return;
70 
71  if (!m_AttributeUIComponent)
72  return;
73 
74  m_AttributeUIComponent.ShowButtonDescription(this, false);
75  }
76 };
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_AttributeButtonUIComponent
Definition: SCR_AttributeButtonUIComponent.c:1
SCR_ButtonBaseComponent
Base class for any button, regardless its own content.
Definition: SCR_ButtonBaseComponent.c:3
SCR_ButtonBoxAttributeUIComponent
Definition: SCR_ButtonBoxAttributeUIComponent.c:3