Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ServerDetailEntry.c
Go to the documentation of this file.
1 // Class for unifiying simple details widget behavior
2 // Widget is displaying label, icons and additional data. Also it's appearance can be change on run to some extend.
3 //------------------------------------------------------------------------------------------------
4 
6 {
7  const string WIDGET_LABEL = "Content";
8  const string WIDGET_ICON = "Icon";
9  const string WIDGET_DATA = "Data";
10 
11  const string WIDGET_BACKGROUND = "Background";
12 
13  [Attribute("true")]
14  protected bool m_bVisibleBackground;
15 
16  [Attribute("true")]
17  protected bool m_bVisibleIcon;
18 
19  [Attribute("true")]
20  protected bool m_bVisibleData;
21 
22  [Attribute()]
23  protected string m_sLabel;
24 
25  [Attribute("{2EFEA2AF1F38E7F0}UI/Textures/Icons/icons_wrapperUI-64.imageset", UIWidgets.ResourceNamePicker)]
26  protected ResourceName m_ImageSetDefault;
27 
28  [Attribute()]
29  protected string m_sImage;
30 
31  protected TextWidget m_wTxtLabel;
32  protected ImageWidget m_wImgIcon;
33  protected TextWidget m_wTxtData;
34 
35  protected ImageWidget m_wImgBackground;
36 
37  //------------------------------------------------------------------------------------------------
38  override void HandlerAttached(Widget w)
39  {
40  super.HandlerAttached(w);
41 
42  // Find widget elements
43  m_wTxtLabel = TextWidget.Cast(w.FindAnyWidget(WIDGET_LABEL));
44  m_wImgIcon = ImageWidget.Cast(w.FindAnyWidget(WIDGET_ICON));
45  m_wTxtData = TextWidget.Cast(w.FindAnyWidget(WIDGET_DATA));
46 
47  m_wImgBackground = ImageWidget.Cast(w.FindAnyWidget(WIDGET_BACKGROUND));
48 
49  // Visual setup
50  VisualSetup();
51  SetIconFromImageSet(m_sImage, m_ImageSetDefault);
52  }
53 
54  //------------------------------------------------------------------------------------------------
55  protected void VisualSetup()
56  {
57  // Background
58  if (m_wImgBackground)
59  {
60  m_wImgBackground.SetVisible(m_bVisibleBackground);
61  }
62 
63  // Icon
64  if (m_wImgIcon)
65  {
66  m_wImgIcon.SetVisible(m_bVisibleIcon);
67  }
68 
69  // Data
70  if (m_wTxtData)
71  {
72  m_wTxtData.SetVisible(m_bVisibleData);
73  }
74 
75  // Label
76  if (m_wTxtLabel && !m_sLabel.IsEmpty())
77  {
78  m_wTxtLabel.SetText(m_sLabel);
79  }
80  }
81 
82  // User API
83  //------------------------------------------------------------------------------------------------
84  void SetLabelText(string text)
85  {
86  if (m_wTxtLabel)
87  m_wTxtLabel.SetText(text);
88  }
89 
90  //------------------------------------------------------------------------------------------------
91  void SetIconFromImageSet(string text, ResourceName imageSet = string.Empty)
92  {
93  if (!imageSet)
94  imageSet = m_ImageSetDefault;
95 
96  if (!imageSet)
97  return;
98 
99  m_sImage = text;
100 
101  if (m_wImgIcon)
102  m_wImgIcon.LoadImageFromSet(0, imageSet, m_sImage);
103  }
104 
105  //------------------------------------------------------------------------------------------------
106  void SetDataText(string text)
107  {
108  if (m_wTxtData)
109  m_wTxtData.SetText(text);
110  }
111 
112  //------------------------------------------------------------------------------------------------
113  void SetElementsVisible(bool label, bool icon, bool data)
114  {
115  if (m_wTxtLabel)
116  m_wTxtLabel.SetVisible(label);
117 
118  if (m_wImgIcon)
119  m_wImgIcon.SetVisible(icon);
120 
121  if (m_wTxtData)
122  m_wTxtData.SetVisible(data);
123 
124  }
125 
126  //------------------------------------------------------------------------------------------------
127  void SetBackroundVisible(bool visible)
128  {
129  if (m_wImgBackground)
130  {
131  m_wImgBackground.SetVisible(visible);
132  }
133  }
134 };
SCR_WLibComponentBase
Base class for all final Reforger interactive elements.
Definition: SCR_WLibComponentBase.c:4
SCR_ServerDetailEntryComponent
Definition: SCR_ServerDetailEntry.c:5
Attribute
typedef Attribute
Post-process effect of scripted camera.
data
Get all prefabs that have the spawner data
Definition: SCR_EntityCatalogManagerComponent.c:305