Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_MenuTileComponent.c
Go to the documentation of this file.
1 class SCR_MenuTileComponent : ScriptedWidgetComponent
2 {
3  [Attribute("")]
4  protected string m_sTitle;
5 
6  [Attribute("")]
7  protected string m_sDescription;
8 
9  [Attribute("0.2")]
10  protected float m_fAnimationTime;
11 
12  [Attribute("{C58FCC06AF13075B}UI/Textures/MissionLoadingScreens/placeholder_1.edds", UIWidgets.ResourceNamePicker, "","edds")]
13  protected ResourceName m_sImageDefault;
14 
15  [Attribute("{C58FCC06AF13075B}UI/Textures/MissionLoadingScreens/placeholder_1.edds", UIWidgets.ResourceNamePicker, "","edds")]
16  protected ResourceName m_sImageSelected;
17 
18  [Attribute("", UIWidgets.ResourceNamePicker, "", "")]
19  protected ResourceName m_sIconTexture;
20 
21  [Attribute()]
22  protected string m_sIconImage;
23 
24  [Attribute("-1", UIWidgets.SearchComboBox, "", "", ParamEnumArray.FromEnum(ChimeraMenuPreset))]
25  ChimeraMenuPreset m_eMenuPreset;
26 
27  [Attribute("Title")]
28  protected LocalizedString m_sTitleName;
29 
30  [Attribute("Description")]
31  protected LocalizedString m_sDescriptionName;
32 
33  [Attribute("ImageDefault")]
34  protected string m_sDefaultWidgetName;
35 
36  [Attribute("ImageSelected")]
37  protected string m_sSelectedWidgetName;
38 
39  [Attribute("Icon")]
40  protected string m_sIconImageName;
41 
42  protected Widget m_wRoot;
43  protected ImageWidget m_wImageDefault;
44  protected ImageWidget m_wImageSelected;
45  protected ImageWidget m_wIcon;
46  protected TextWidget m_wTitle;
47  protected TextWidget m_wDescription;
48  protected float m_fAnimationRate = 10000;
49 
50  ref ScriptInvoker m_OnFocused = new ScriptInvoker();
51  ref ScriptInvoker m_OnFocusLost = new ScriptInvoker();
52  ref ScriptInvoker m_OnClicked = new ScriptInvoker();
53 
54  //------------------------------------------------------------------------------------------------
55  override void HandlerAttached(Widget w)
56  {
57  m_wRoot = w;
58  m_wImageDefault = ImageWidget.Cast(w.FindAnyWidget(m_sDefaultWidgetName));
59  m_wImageSelected = ImageWidget.Cast(w.FindAnyWidget(m_sSelectedWidgetName));
60  m_wIcon = ImageWidget.Cast(w.FindAnyWidget(m_sIconImageName));
61  m_wTitle = TextWidget.Cast(w.FindAnyWidget(m_sTitleName));
62  m_wDescription = TextWidget.Cast(w.FindAnyWidget(m_sDescriptionName));
63 
64  SetOrHideImage(m_wImageDefault, m_sImageDefault, string.Empty);
65  SetOrHideImage(m_wImageSelected, m_sImageSelected, string.Empty);
66  SetOrHideImage(m_wIcon, m_sIconTexture, m_sIconImage);
67 
68  if (m_wImageSelected)
69  m_wImageSelected.SetOpacity(0);
70 
71  if (m_wDescription)
72  {
73  m_wDescription.SetText(m_sDescription);
74  m_wDescription.SetOpacity(0);
75  }
76 
77  if (m_wTitle)
78  m_wTitle.SetText(m_sTitle);
79 
80  GetGame().GetCallqueue().CallLater(SetAnimationRate, SCR_WLibComponentBase.START_ANIMATION_PERIOD);
81  }
82 
83  //------------------------------------------------------------------------------------------------
84  protected void SetOrHideImage(ImageWidget widget, string texture, string image)
85  {
86  if (!widget)
87  return;
88 
89  bool success = SCR_WLibComponentBase.SetTexture(widget, texture, image);
90  widget.GetParent().SetVisible(success); // Hide parent widget, because it's a scale widget
91  }
92 
93  //------------------------------------------------------------------------------------------------
94  private void SetAnimationRate()
95  {
96  if (m_fAnimationTime <= 0)
97  m_fAnimationRate = 1000;
98  else
99  m_fAnimationRate = 1 / m_fAnimationTime;
100  }
101 
102  //------------------------------------------------------------------------------------------------
103  override bool OnFocus(Widget w, int x, int y)
104  {
105  AnimateWidget.Opacity(m_wDescription, 1, m_fAnimationRate);
106  AnimateWidget.Opacity(m_wImageSelected, 1, m_fAnimationRate);
107  m_OnFocused.Invoke(this);
108  return false;
109  }
110 
111  //------------------------------------------------------------------------------------------------
112  override bool OnFocusLost(Widget w, int x, int y)
113  {
114  AnimateWidget.Opacity(m_wDescription, 0, m_fAnimationRate);
115  AnimateWidget.Opacity(m_wImageSelected, 0, m_fAnimationRate);
116  m_OnFocusLost.Invoke(this);
117  return false;
118  }
119 
120  //------------------------------------------------------------------------------------------------
121  override bool OnClick(Widget w, int x, int y, int button)
122  {
123  m_OnClicked.Invoke(this);
124  return false;
125  }
126 
127  //------------------------------------------------------------------------------------------------
129  Widget GetRootWidget()
130  {
131  return m_wRoot;
132  }
133 }
SCR_MenuTileComponent
Definition: SCR_MenuTileComponent.c:1
m_wIcon
protected ImageWidget m_wIcon
Definition: SCR_InventoryHitZonePointUI.c:374
m_wRoot
protected Widget m_wRoot
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:59
SCR_WLibComponentBase
Base class for all final Reforger interactive elements.
Definition: SCR_WLibComponentBase.c:4
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
m_OnFocusLost
ref ScriptInvoker m_OnFocusLost
Definition: SCR_ModularButtonComponent.c:64
Attribute
typedef Attribute
Post-process effect of scripted camera.
m_sDescription
string m_sDescription
Definition: SCR_FlashlightComponent.c:3
ChimeraMenuPreset
ChimeraMenuPreset
Menu presets.
Definition: ChimeraMenuBase.c:3
LocalizedString
Definition: LocalizedString.c:21
m_OnClicked
ref ScriptInvoker m_OnClicked
Definition: SCR_ModularButtonComponent.c:60