Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_UIInfo.c
Go to the documentation of this file.
8 {
9  [Attribute(params: "edds imageset", uiwidget: UIWidgets.ResourcePickerThumbnail)]
10  protected ResourceName Icon;
11 
12  [Attribute(desc: "When 'Icon' is an image set, this defines name of the image in the set.")]
13  protected string IconSetName;
14 
15  //------------------------------------------------------------------------------------------------
20  ResourceName GetIconPath()
21  {
22  string ext;
23  FilePath.StripExtension(Icon, ext);
24  if (ext == "imageset")
25  {
26  Print(string.Format("Unable to return texture path, it's an image set '%1'! Use SCR_UIInfo.SetIconTo() instead.", Icon), LogLevel.WARNING);
27  return ResourceName.Empty;
28  }
29  else
30  {
31  return Icon;
32  }
33  }
34 
35  //------------------------------------------------------------------------------------------------
38  string GetIconSetName()
39  {
40  string ext;
41  FilePath.StripExtension(Icon, ext);
42 
43  if (ext == "imageset")
44  return IconSetName;
45  else
46  return "";
47  }
48 
49  //------------------------------------------------------------------------------------------------
52  bool HasIcon()
53  {
54  if (Icon.IsEmpty())
55  return false;
56 
57  //Check if image set name is assigned
58  string ext;
59  FilePath.StripExtension(Icon, ext);
60  if (ext == "imageset")
61  return !GetIconSetName().IsEmpty();
62 
63  return true;
64  }
65 
66  //------------------------------------------------------------------------------------------------
72  bool SetIconTo(ImageWidget imageWidget)
73  {
74  if (!imageWidget || Icon.IsEmpty())
75  return false;
76 
77  string ext;
78  FilePath.StripExtension(Icon, ext);
79  if (ext == "imageset")
80  imageWidget.LoadImageFromSet(0, Icon, GetIconSetName());
81  else
82  imageWidget.LoadImageTexture(0, GetIconPath());
83 
84  return true;
85  }
86 
87  //------------------------------------------------------------------------------------------------
91  override void Log(string prefix = string.Empty, LogLevel logLevel = LogLevel.VERBOSE)
92  {
93  Print(string.Format(prefix + "%1: \"%2\", \"%3\", \"%4\"", Type(), Name, Description, Icon), logLevel);
94  }
95 
96  //------------------------------------------------------------------------------------------------
101  static SCR_UIInfo GetInfo(BaseContainer source, string varName)
102  {
103  BaseContainer infoSource = source.GetObject(varName);
104  if (infoSource)
105  return SCR_UIInfo.Cast(BaseContainerTools.CreateInstanceFromContainer(infoSource));
106  else
107  return null;
108  }
109 
110  //------------------------------------------------------------------------------------------------
114  static SCR_UIInfo CreateInfo(UIInfo source)
115  {
116  if (!source)
117  return null;
118 
119  SCR_UIInfo info = new SCR_UIInfo();
120  info.Name = source.GetName();
121  info.Description = source.GetDescription();
122  info.Icon = source.GetIconPath();
123  return info;
124  }
125 
126  //------------------------------------------------------------------------------------------------
133  static SCR_UIInfo CreateInfo(LocalizedString name, LocalizedString description = LocalizedString.Empty, ResourceName icon = ResourceName.Empty, string iconSetName = string.Empty)
134  {
135  SCR_UIInfo info = new SCR_UIInfo();
136  info.Name = name;
137  info.Description = description;
138  info.Icon = icon;
139  info.IconSetName = iconSetName;
140  return info;
141  }
142 
143  //------------------------------------------------------------------------------------------------
147  static SCR_UIInfo CreatePlaceholderInfo(typename type)
148  {
149  SCR_UIInfo info = SCR_UIInfo.Cast(type.Spawn());
150  info.Name = string.Format("ERROR: Missing info for %1", type);
151  return info;
152  }
153 
154  //------------------------------------------------------------------------------------------------
155  //--- Protected, to be overridden and/or made public by inherited classes
156  protected override void CopyFrom(SCR_UIName source)
157  {
158  SCR_UIInfo sourceInfo = SCR_UIInfo.Cast(source);
159  if (sourceInfo)
160  {
161  Icon = sourceInfo.Icon;
162  IconSetName = sourceInfo.IconSetName;
163  }
164 
165  super.CopyFrom(source);
166  }
167 }
SCR_UIName
Definition: SCR_UIName.c:5
UIInfo
UIInfo - declare object, allows to define UI elements.
Definition: UIInfo.c:13
SCR_BaseContainerLocalizedTitleField
SCR_TabViewComponent SCR_ScriptedWidgetComponent SCR_BaseContainerLocalizedTitleField("m_sTabButtonContent")
Definition: SCR_TabViewComponent.c:963
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_UIInfo
Definition: SCR_UIInfo.c:7
type
EDamageType type
Definition: SCR_DestructibleTreeV2.c:32
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
LocalizedString
Definition: LocalizedString.c:21
SCR_UIDescription
Definition: SCR_UIDescription.c:5
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