Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_DynamicIconComponent.c
Go to the documentation of this file.
1 // Handles setting the icon and glow, assumes to find two ImageWidgets named Icon and Glow
2 // Allows future changes to the hierarchy without losing overrides in children
3 
4 //------------------------------------------------------------------------------------------------
6 {
7  [Attribute(UIConstants.ICONS_IMAGE_SET, UIWidgets.ResourcePickerThumbnail, "Select edds texture or imageset", "edds imageset")]
8  ResourceName m_sIconImageset;
9 
10  [Attribute(UIConstants.ICONS_GLOW_IMAGE_SET, UIWidgets.ResourcePickerThumbnail, "Select edds texture or imageset", "edds imageset")]
11  ResourceName m_sGlowImageset;
12 
13  [Attribute("play")]
14  string m_sImageName;
15 
16  [Attribute("32 32 0")]
17  vector m_sImageSize;
18 
19  ImageWidget m_wIcon;
20  ImageWidget m_wGlow;
21  SizeLayoutWidget m_wSize;
22 
23  //------------------------------------------------------------------------------------------------
24  override void HandlerAttached(Widget w)
25  {
26  super.HandlerAttached(w);
27  m_wIcon = ImageWidget.Cast(w.FindAnyWidget("Icon"));
28  m_wGlow = ImageWidget.Cast(w.FindAnyWidget("Glow"));
29  m_wSize = SizeLayoutWidget.Cast(w.FindAnyWidget("Size"));
30 
31  SetImage(m_sImageName);
32  }
33 
34  //------------------------------------------------------------------------------------------------
35  ImageWidget GetIconWidget()
36  {
37  return m_wIcon;
38  }
39 
40  //------------------------------------------------------------------------------------------------
41  ImageWidget GetGlowWidget()
42  {
43  return m_wGlow;
44  }
45 
46  //------------------------------------------------------------------------------------------------
47  void SetImage(string imageName, ResourceName iconImageSet = string.Empty, ResourceName glowImageSet = string.Empty)
48  {
49  if (!m_wIcon || !m_wGlow)
50  return;
51 
52  if (iconImageSet.IsEmpty())
53  iconImageSet = m_sIconImageset;
54 
55  SetImage_Internal(m_wIcon, iconImageSet, imageName);
56 
57  if (glowImageSet.IsEmpty())
58  glowImageSet = m_sGlowImageset;
59 
60  SetImage_Internal(m_wGlow, glowImageSet, imageName);
61 
62  m_sIconImageset = iconImageSet;
63  m_sGlowImageset = glowImageSet;
64  m_sImageName = imageName;
65 
66  if (m_wSize)
67  {
68  m_wSize.SetWidthOverride(m_sImageSize[0]);
69  m_wSize.SetHeightOverride(m_sImageSize[1]);
70  }
71  }
72 
73  //------------------------------------------------------------------------------------------------
74  protected void SetImage_Internal(ImageWidget image, ResourceName imageSet, string imageName)
75  {
76  if (imageSet.EndsWith("imageset"))
77  image.LoadImageFromSet(0, imageSet, imageName);
78  else
79  image.LoadImageTexture(0, imageSet);
80 
81  image.SetSize(m_sImageSize[0], m_sImageSize[1]);
82  }
83 
84  //------------------------------------------------------------------------------------------------
85  void SetIconColor(Color color)
86  {
87  if (!color || !m_wIcon)
88  return;
89 
90  m_wIcon.SetColor(color);
91  }
92 
93  //------------------------------------------------------------------------------------------------
94  void SetGlowColor(Color color)
95  {
96  if (!color || !m_wIcon)
97  return;
98 
99  m_wGlow.SetColor(color);
100  }
101 
102  //------------------------------------------------------------------------------------------------
103  void SetVisibile(bool visible)
104  {
105  if (m_wIcon)
106  m_wIcon.SetVisible(visible);
107 
108  if (m_wGlow)
109  m_wGlow.SetVisible(visible);
110  }
111 
112  //------------------------------------------------------------------------------------------------
113  // Returns name and imageset
114  string GetIcon(out string imageSet)
115  {
116  if (m_sImageName == string.Empty)
117  return m_sIconImageset;
118  imageSet = m_sIconImageset;
119  return m_sImageName;
120  }
121 
122  //------------------------------------------------------------------------------------------------
123  static SCR_DynamicIconComponent FindComponent(string name, Widget parent, bool searchAllChildren = true)
124  {
126  SCR_WLibComponentBase.GetComponent(SCR_DynamicIconComponent, name, parent, searchAllChildren)
127  );
128  return comp;
129  }
130 }
m_wIcon
protected ImageWidget m_wIcon
Definition: SCR_InventoryHitZonePointUI.c:374
SCR_WLibComponentBase
Base class for all final Reforger interactive elements.
Definition: SCR_WLibComponentBase.c:4
UIConstants
Definition: Constants.c:130
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_DynamicIconComponent
Definition: SCR_DynamicIconComponent.c:5
SCR_ScriptedWidgetComponent
Definition: SCR_ScriptedWidgetComponent.c:7