Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
HoverButtonComponent.c
Go to the documentation of this file.
1 // Base buttton that changes visuals on being hovered over, but no further functionality
2 
3 //------------------------------------------------------------------------------------------------
4 
5 class HoverButtonComponent : ScriptedWidgetComponent
6 {
7  [Attribute("false", UIWidgets.CheckBox, "")]
8  protected bool m_bColorizeChildren;
9 
10  [Attribute("1 1 1 0", UIWidgets.ColorPicker, "")]
11  protected ref Color m_ColorButtonDefault;
12 
13  [Attribute("1 1 1 1", UIWidgets.ColorPicker, "")]
14  protected ref Color m_ColorButtonHovered;
15 
16  [Attribute("1 1 1 0", UIWidgets.ColorPicker, "")]
17  protected ref Color m_ColorButtonDisabled;
18 
19  [Attribute("1 1 1 1", UIWidgets.ColorPicker, "")]
20  protected ref Color m_ColorChildDefault;
21 
22  [Attribute("0 0 0 1", UIWidgets.ColorPicker, "")]
23  protected ref Color m_ColorChildHovered;
24 
25  [Attribute("0.5 0.5 0.5 1", UIWidgets.ColorPicker, "")]
26  protected ref Color m_ColorChildDisabled;
27 
28  [Attribute("0.2", UIWidgets.EditBox, "")]
29  protected float m_fAnimationLength;
30 
31  [Attribute(SCR_SoundEvent.CLICK, UIWidgets.EditBox, "")]
32  protected string m_sSoundClicked;
33 
34  [Attribute(SCR_SoundEvent.SOUND_FE_BUTTON_HOVER, UIWidgets.EditBox, "")]
35  protected string m_sSoundHovered;
36 
37  protected Widget m_wChild;
38 
39 
40  //------------------------------------------------------------------------------------------------
41  override void HandlerAttached(Widget w)
42  {
43 
44  m_fAnimationLength = 1 / m_fAnimationLength;
45 
46  if (!w.IsEnabled())
47  {
48  w.SetColor(m_ColorButtonDisabled);
49  if (m_wChild)
50  w.SetColor(m_ColorChildDisabled);
51  }
52  else
53  {
54  w.SetColor(m_ColorButtonDefault);
55  if (m_wChild)
56  {
57  AnimateWidget.Color(m_wChild, m_ColorChildDefault, m_fAnimationLength);
58  }
59  }
60  }
61 
62  //------------------------------------------------------------------------------------------------
63  override bool OnClick(Widget w, int x, int y, int button)
64  {
65  SCR_UISoundEntity.SoundEvent(m_sSoundClicked);
66  return false;
67  }
68 
69  //------------------------------------------------------------------------------------------------
70  override bool OnMouseEnter(Widget w, int x, int y)
71  {
72  SCR_UISoundEntity.SoundEvent(m_sSoundHovered);
73  AnimateWidget.Color(w, m_ColorButtonHovered, m_fAnimationLength);
74  if (m_bColorizeChildren && m_wChild)
75  AnimateWidget.Color(m_wChild, m_ColorChildHovered, m_fAnimationLength);
76 
77  return false;
78  }
79 
80  //------------------------------------------------------------------------------------------------
81  override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
82  {
83  AnimateWidget.Color(w, m_ColorButtonDefault, m_fAnimationLength);
84  if (m_bColorizeChildren && m_wChild)
85  AnimateWidget.Color(m_wChild, m_ColorChildDefault, m_fAnimationLength);
86 
87  return false;
88  }
89 };
SCR_UISoundEntity
Definition: SCR_UISoundEntity.c:7
SCR_SoundEvent
Definition: SCR_SoundEvent.c:1
HoverButtonComponent
Definition: HoverButtonComponent.c:5
Attribute
typedef Attribute
Post-process effect of scripted camera.