Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_SelectableTileButtonComponent.c
Go to the documentation of this file.
1 //------------------------------------------------------------------------------------------------
3 {
4  ref ScriptInvoker m_OnChanged = new ScriptInvoker();
5  private bool m_bIsSelected = false;
6  protected bool m_bIsTriggered = true;
7 
8  protected Widget m_wIcon;
9 
10  protected ref Color COLOR_CHECKED_TRUE = UIColors.CONTRAST_COLOR;
11  protected ref Color COLOR_CHECKED_FALSE = UIColors.WHITE_DEFAULT;
12 
13  //------------------------------------------------------------------------------------------------
14  override void HandlerAttached(Widget w)
15  {
16  super.HandlerAttached(w);
17 
18  m_wIcon = m_wRoot.FindAnyWidget("ContentImage");
19  AnimateWidget.Color(m_wBackground, COLOR_BACKGROUND_DEFAULT, m_fAnimationRate);
20  ColorizeCheckWidget();
21  }
22 
23  //------------------------------------------------------------------------------------------------
24  override bool OnClick(Widget w, int x, int y, int button)
25  {
26  super.OnClick(w, x, y, button);
27  if (button != 0)
28  return false;
29 
30  SetSelected(!m_bIsSelected);
31  return false;
32  }
33 
34  //------------------------------------------------------------------------------------------------
35  override bool OnMouseEnter(Widget w, int x, int y)
36  {
37  if (m_bMouseOverToFocus)
38  GetGame().GetWorkspace().SetFocusedWidget(w);
39 
40  PlaySound(m_sSoundHovered);
41 
42  if (GetGame().GetWorkspace().GetFocusedWidget() != w)
43  AnimateWidget.Color(m_wBackground, COLOR_BACKGROUND_HOVERED, m_fAnimationRate);
44 
45  return false;
46  }
47 
48  //------------------------------------------------------------------------------------------------
49  override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
50  {
51  AnimateWidget.Color(m_wBackground, COLOR_BACKGROUND_DEFAULT, m_fAnimationRate);
52  return false;
53  }
54 
55  //------------------------------------------------------------------------------------------------
56  override bool OnFocus(Widget w, int x, int y)
57  {
58  AnimateWidget.Opacity(m_wBackground, 1, m_fAnimationRate);
59  PlaySound(m_sSoundHovered);
60  return false;
61  }
62 
63  //------------------------------------------------------------------------------------------------
64  override bool OnFocusLost(Widget w, int x, int y)
65  {
66  AnimateWidget.Opacity(m_wBackground, 0, m_fAnimationRate);
67  return false;
68  }
69 
70  //------------------------------------------------------------------------------------------------
71  override protected void OnMenuSelect()
72  {
73  if (!m_wRoot.IsEnabled())
74  return;
75 
76  super.OnMenuSelect();
77  ColorizeCheckWidget();
78  }
79 
80  //------------------------------------------------------------------------------------------------
81  override protected void ColorizeWidgets(Color colorBackground, Color colorContent, float speed = -1)
82  {
83  if (speed < 0)
84  speed = m_fAnimationRate;
85  }
86 
87  //------------------------------------------------------------------------------------------------
89  protected void ColorizeCheckWidget()
90  {
91  if (m_bIsSelected)
92  AnimateWidget.Color(m_wIcon, COLOR_BACKGROUND_CLICKED, m_fAnimationRate);
93  else
94  AnimateWidget.Color(m_wIcon, COLOR_CONTENT_DEFAULT, m_fAnimationRate);
95  }
96 
97  //------------------------------------------------------------------------------------------------
98  bool IsSelected()
99  {
100  return m_bIsSelected;
101  }
102 
103  //------------------------------------------------------------------------------------------------
104  void SetSelected(bool selected, bool notify = true)
105  {
106  if (m_bIsSelected == selected)
107  return;
108 
109  m_bIsSelected = selected;
110 
111  ColorizeCheckWidget();
112 
113  if (notify)
114  m_OnChanged.Invoke(this, m_wRoot, m_bIsSelected);
115  }
116 
117  //------------------------------------------------------------------------------------------------
118  void ShowButton()
119  {
120  AnimateWidget.Opacity(m_wRoot, 1, m_fAnimationRate);
121  AnimateWidget.Opacity(m_wBackground, 1, m_fAnimationRate);
122  }
123 
124  //------------------------------------------------------------------------------------------------
125  void HideButton()
126  {
127  AnimateWidget.Opacity(m_wBackground, 0, m_fAnimationRate);
128  if (!m_bIsSelected)
129  AnimateWidget.Opacity(m_wRoot, 0, m_fAnimationRate);
130  }
131 };
m_wIcon
protected ImageWidget m_wIcon
Definition: SCR_InventoryHitZonePointUI.c:374
PlaySound
SCR_ParticleContactComponentClass ScriptComponentClass PlaySound(IEntity owner, SCR_ParticleContactComponentClass prefabData, Contact contact)
Definition: SCR_ParticleContactComponent.c:38
m_wRoot
protected Widget m_wRoot
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:59
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
m_OnChanged
protected ref ScriptInvokerTabViewIndex m_OnChanged
Definition: SCR_TabViewComponent.c:64
SCR_ButtonComponent
Deprecated button component. Still used in many prefabs, so it works, it's just stripped of most of t...
Definition: SCR_ButtonComponent.c:4
UIColors
Definition: Constants.c:16
m_wBackground
protected ImageWidget m_wBackground
Definition: SCR_InventoryHitZonePointUI.c:382
SCR_SelectableTileButtonComponent
Definition: SCR_SelectableTileButtonComponent.c:2