Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_SimpleMessageComponent.c
Go to the documentation of this file.
1 class SCR_SimpleMessageComponent : ScriptedWidgetComponent
2 {
3  [Attribute()]
4  protected string m_sImageWidgetName;
5 
6  [Attribute()]
7  protected string m_sTitleWidgetName;
8 
9  [Attribute()]
10  protected string m_sDescriptionWidgetName;
11 
12  [Attribute("Loading")]
13  protected string m_sLoadingName;
14 
15  [Attribute()]
16  protected string m_sDefaultPreset;
17 
18  [Attribute()]
19  ref SCR_SimpleMessagePresets m_aContentPresets;
20 
21  protected ImageWidget m_wImage;
22  protected TextWidget m_wTitle;
23  protected TextWidget m_wDescription;
24  protected Widget m_wLoading;
25 
26  protected Widget m_wRoot;
27 
28  //----------------------------------------------------------------------------------
29  protected override void HandlerAttached(Widget w)
30  {
31  m_wRoot = w;
32 
33  if (!m_sImageWidgetName.IsEmpty())
34  m_wImage = ImageWidget.Cast(w.FindAnyWidget(m_sImageWidgetName));
35 
36  if (!m_sTitleWidgetName.IsEmpty())
37  m_wTitle = TextWidget.Cast(w.FindAnyWidget(m_sTitleWidgetName));
38 
39  if (!m_sDescriptionWidgetName.IsEmpty())
40  m_wDescription = TextWidget.Cast(w.FindAnyWidget(m_sDescriptionWidgetName));
41 
42  if (!m_sLoadingName.IsEmpty())
43  m_wLoading = w.FindAnyWidget(m_sLoadingName);
44 
45  SetContentFromPreset(m_sDefaultPreset);
46  }
47 
48  //----------------------------------------------------------------------------------
53  void SetContentFromPreset(string presetTag)
54  {
55  if (!m_aContentPresets || presetTag.IsEmpty())
56  return;
57 
58  SCR_SimpleMessagePreset preset = m_aContentPresets.GetPreset(presetTag);
59 
60  if (!preset)
61  return;
62 
63  if (!preset.m_UIInfo)
64  return;
65 
66  SetContentFromPreset(preset.m_UIInfo);
67  }
68 
69  //----------------------------------------------------------------------------------
71  protected void SetContentFromPreset(SCR_SimpleMessageUIInfo uiInfo)
72  {
73  array<Widget> mainWidgets = {m_wImage, m_wTitle, m_wDescription};
74  bool loading = uiInfo.GetDisplayLoading();
75  foreach (Widget w : mainWidgets)
76  {
77  if (w)
78  w.SetVisible(!loading);
79  }
80 
81  if (m_wLoading)
82  m_wLoading.SetVisible(loading);
83 
84  if (loading)
85  {
86  if (m_wLoading)
87  {
88  SCR_LoadingOverlay loadingComp = SCR_LoadingOverlay.Cast(m_wLoading.FindHandler(SCR_LoadingOverlay));
89  if (loadingComp)
90  {
91  if (!uiInfo.GetName().IsEmpty())
92  loadingComp.SetText(uiInfo.GetName());
93  else if (!uiInfo.GetDescription().IsEmpty())
94  loadingComp.SetText(uiInfo.GetDescription());
95  }
96  }
97  }
98  else
99  {
100  if (m_wImage)
101  {
102  if (uiInfo.HasIcon())
103  {
104  m_wImage.SetColor(uiInfo.GetImageColor());
105  uiInfo.SetIconTo(m_wImage);
106  m_wImage.SetVisible(true);
107  }
108  else
109  {
110  m_wImage.SetVisible(false);
111  }
112  }
113 
114  if (m_wTitle)
115  {
116  if (!uiInfo.GetName().IsEmpty())
117  {
118  uiInfo.SetNameTo(m_wTitle);
119  m_wTitle.SetVisible(true);
120  }
121  else
122  {
123  m_wTitle.SetVisible(false);
124  }
125  }
126 
127  if (m_wDescription)
128  {
129  if (!uiInfo.GetName().IsEmpty())
130  {
131  uiInfo.SetDescriptionTo(m_wDescription);
132  m_wDescription.SetVisible(true);
133  }
134  else
135  {
136  m_wDescription.SetVisible(false);
137  }
138  }
139  }
140  }
141 
142  //----------------------------------------------------------------------------------
143  Widget GetRootWidget()
144  {
145  return m_wRoot;
146  }
147 
148  //----------------------------------------------------------------------------------
149  void SetVisible(bool visible)
150  {
151  if (m_wRoot)
152  m_wRoot.SetVisible(visible);
153  }
154 };
155 
157 class SCR_SimpleMessagePreset : Managed
158 {
159  [Attribute(desc: "The ID of the Preset used to set the correct visual information")]
160  string m_sTag;
161 
162  [Attribute()]
163  ref SCR_SimpleMessageUIInfo m_UIInfo;
164 };
165 
166 [BaseContainerProps(configRoot: true)]
168 {
169  [Attribute()]
170  ref array<ref SCR_SimpleMessagePreset> m_aPresets;
171 
172  //----------------------------------------------------------------------------------
173  SCR_SimpleMessagePreset GetPreset(string tag)
174  {
175  foreach (SCR_SimpleMessagePreset preset : m_aPresets)
176  {
177  if (preset.m_sTag == tag)
178  return preset;
179  }
180 
181  Print(string.Format("SCR_SimpleMessagePresets: preset not found: %1", tag), LogLevel.ERROR);
182  return null;
183  }
184 };
m_wRoot
protected Widget m_wRoot
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:59
SCR_SimpleMessageUIInfo
Definition: SCR_SimpleMessageUIInfo.c:2
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
SCR_LoadingOverlay
Definition: SCR_LoadingOverlay.c:49
BaseContainerCustomTitleField
class SCR_KeyBindingFilter BaseContainerCustomTitleField("m_sBindString")
Definition: SCR_KeyBindingMenuConfig.c:113
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_SimpleMessagePresets
Definition: SCR_SimpleMessageComponent.c:167
m_aPresets
ref array< ref SCR_ScriptedWidgetTooltipPreset > m_aPresets
Definition: SCR_ScriptedWidgetTooltip.c:407
m_sImageWidgetName
protected string m_sImageWidgetName
Definition: SCR_EntityTooltipEditorUIComponent.c:3
m_wImage
protected ImageWidget m_wImage
Definition: SCR_BackendImageComponent.c:248
SCR_SimpleMessageComponent
Definition: SCR_SimpleMessageComponent.c:1
SCR_SimpleMessagePreset
Definition: SCR_SimpleMessageComponent.c:157
m_wLoading
protected Widget m_wLoading
Definition: SCR_ServerBrowserEntryComponent.c:40
BaseContainerProps
SCR_AIGoalReaction_Follow BaseContainerProps
Handles insects that are supposed to be spawned around selected prefabs defined in prefab names array...
Definition: SCR_AIGoalReaction.c:468