Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ButtonHintEditorUIComponent.c
Go to the documentation of this file.
2 {
3  protected const int CONDITION_DEVICE = 1;
4  protected const int CONDITION_FOCUS = 2;
5 
6  protected int m_Show;
7 
8  //------------------------------------------------------------------------------------------------
9  protected void RefreshVisibility()
10  {
11  bool show = m_Show == (CONDITION_DEVICE | CONDITION_FOCUS);
12 
13  GetWidget().SetEnabled(show);
14  GetWidget().SetVisible(show);
15  }
16 
17  //------------------------------------------------------------------------------------------------
18  protected void OnMenuFocusGained()
19  {
20  m_Show |= CONDITION_FOCUS;
21 
22  RefreshVisibility();
23  }
24 
25  //------------------------------------------------------------------------------------------------
26  protected void OnMenuFocusLost()
27  {
28  m_Show &= ~CONDITION_FOCUS;
29 
30  RefreshVisibility();
31  }
32 
33  //------------------------------------------------------------------------------------------------
34  protected void OnInputDeviceIsGamepad(bool isGamepad)
35  {
36  if (isGamepad)
37  m_Show |= CONDITION_DEVICE;
38  else
39  m_Show &= ~CONDITION_DEVICE;
40 
41  RefreshVisibility();
42  }
43 
44  //------------------------------------------------------------------------------------------------
45  override protected bool IsUnique()
46  {
47  return false;
48  }
49 
50  //------------------------------------------------------------------------------------------------
51  override void HandlerAttachedScripted(Widget w)
52  {
53  MenuRootBase menu = GetMenu();
54  if (!menu)
55  return;
56 
57  menu.GetOnMenuFocusGained().Insert(OnMenuFocusGained);
58  menu.GetOnMenuFocusLost().Insert(OnMenuFocusLost);
59 
60  GetGame().OnInputDeviceIsGamepadInvoker().Insert(OnInputDeviceIsGamepad);
61 
62  OnMenuFocusGained();
63  OnInputDeviceIsGamepad(!GetGame().GetInputManager().IsUsingMouseAndKeyboard());
64  }
65 
66  //------------------------------------------------------------------------------------------------
67  override void HandlerDeattached(Widget w)
68  {
69  MenuRootBase menu = GetMenu();
70  if (!menu)
71  return;
72 
73  menu.GetOnMenuFocusGained().Remove(OnMenuFocusGained);
74  menu.GetOnMenuFocusLost().Remove(OnMenuFocusLost);
75 
76  GetGame().OnInputDeviceIsGamepadInvoker().Remove(OnInputDeviceIsGamepad);
77  }
78 }
MenuRootSubComponent
Definition: MenuRootSubComponent.c:5
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_ButtonHintEditorUIComponent
Definition: SCR_ButtonHintEditorUIComponent.c:1
GetMenu
SCR_RadialMenu GetMenu()
Definition: SCR_RadialMenuGameModeComponent.c:41
MenuRootBase
Definition: MenuRootBase.c:6
GetInputManager
protected InputManager GetInputManager()
Definition: SCR_BaseManualCameraComponent.c:65
GetWidget
protected Widget GetWidget()
Definition: SCR_VonDisplay.c:155