Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_UIInfo.c
Go to the documentation of this file.
1
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 //------------------------------------------------------------------------------------------------
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
36 //------------------------------------------------------------------------------------------------
38 {
39 return Icon;
40 }
41
42 //------------------------------------------------------------------------------------------------
48 {
49 string ext;
50 FilePath.StripExtension(Icon, ext);
51 if (ext == "imageset")
52 {
53 return Icon;
54 }
55 else
56 {
57 Print(string.Format("Unable to return ImageSet path, it's a Texture '%1'! Use SCR_UIInfo.SetIconTo() instead.", Icon), LogLevel.WARNING);
58 return ResourceName.Empty;
59 }
60 }
61
62 //------------------------------------------------------------------------------------------------
66 {
67 string ext;
68 FilePath.StripExtension(Icon, ext);
69
70 if (ext == "imageset")
71 return IconSetName;
72 else
73 return "";
74 }
75
76 //------------------------------------------------------------------------------------------------
79 bool HasIcon()
80 {
81 if (Icon.IsEmpty())
82 return false;
83
84 //Check if image set name is assigned
85 string ext;
86 FilePath.StripExtension(Icon, ext);
87 if (ext == "imageset")
88 return !GetIconSetName().IsEmpty();
89
90 return true;
91 }
92
93//---- REFACTOR NOTE START: This code will need to be refactored as current implementation is not conforming to the standards ----
94// This class is meant to hold data, not manipulate widgets! Such methods should be in SCR_WidgetTools or SCR_WidgetHelper
95
96 //------------------------------------------------------------------------------------------------
102 bool SetIconTo(ImageWidget imageWidget)
103 {
104 if (!imageWidget || Icon.IsEmpty())
105 return false;
106
107 string ext;
108 FilePath.StripExtension(Icon, ext);
109 if (ext == "imageset")
110 imageWidget.LoadImageFromSet(0, Icon, GetIconSetName());
111 else
112 imageWidget.LoadImageTexture(0, GetIconPath());
113
114 return true;
115 }
116
117//---- REFACTOR NOTE END ----
118
119 //------------------------------------------------------------------------------------------------
123 override void Log(string prefix = string.Empty, LogLevel logLevel = LogLevel.VERBOSE)
124 {
125 Print(string.Format(prefix + "%1: \"%2\", \"%3\", \"%4\"", Type(), Name, Description, Icon), logLevel);
126 }
127
128 //------------------------------------------------------------------------------------------------
133 static SCR_UIInfo GetInfo(BaseContainer source, string varName)
134 {
135 BaseContainer infoSource = source.GetObject(varName);
136 if (infoSource)
137 return SCR_UIInfo.Cast(BaseContainerTools.CreateInstanceFromContainer(infoSource));
138 else
139 return null;
140 }
141
142 //------------------------------------------------------------------------------------------------
147 {
148 if (!source)
149 return null;
150
151 SCR_UIInfo info = new SCR_UIInfo();
152 info.Name = source.GetName();
153 info.Description = source.GetDescription();
154 info.Icon = source.GetIconPath();
155 return info;
156 }
157
158 //------------------------------------------------------------------------------------------------
165 static SCR_UIInfo CreateInfo(LocalizedString name, LocalizedString description = LocalizedString.Empty, ResourceName icon = ResourceName.Empty, string iconSetName = string.Empty)
166 {
167 SCR_UIInfo info = new SCR_UIInfo();
168 info.Name = name;
169 info.Description = description;
170 info.Icon = icon;
171 info.IconSetName = iconSetName;
172 return info;
173 }
174
175 //------------------------------------------------------------------------------------------------
180 {
181 SCR_UIInfo info = SCR_UIInfo.Cast(type.Spawn());
182 info.Name = string.Format("ERROR: Missing info for %1", type);
183 return info;
184 }
185
186 //------------------------------------------------------------------------------------------------
187 //--- Protected, to be overridden and/or made public by inherited classes
188 protected override void CopyFrom(SCR_UIName source)
189 {
190 SCR_UIInfo sourceInfo = SCR_UIInfo.Cast(source);
191 if (sourceInfo)
192 {
193 Icon = sourceInfo.Icon;
194 IconSetName = sourceInfo.IconSetName;
195 }
196
197 super.CopyFrom(source);
198 }
199}
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
EDamageType type
SCR_PlayerCommandingConfigActionPair Managed SCR_BaseContainerLocalizedTitleField("m_sCommandName")
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
int Type
LocalizedString Description
ResourceName GetIcon()
Definition SCR_UIInfo.c:37
string IconSetName
Definition SCR_UIInfo.c:13
string GetIconSetName()
Definition SCR_UIInfo.c:65
static SCR_UIInfo CreatePlaceholderInfo(typename type)
Definition SCR_UIInfo.c:179
bool HasIcon()
Definition SCR_UIInfo.c:79
static SCR_UIInfo CreateInfo(UIInfo source)
Definition SCR_UIInfo.c:146
bool SetIconTo(ImageWidget imageWidget)
Definition SCR_UIInfo.c:102
override void Log(string prefix=string.Empty, LogLevel logLevel=LogLevel.VERBOSE)
Definition SCR_UIInfo.c:123
ResourceName GetIconPath()
Definition SCR_UIInfo.c:20
ResourceName Icon
Definition SCR_UIInfo.c:10
override void CopyFrom(SCR_UIName source)
Definition SCR_UIInfo.c:188
static SCR_UIInfo GetInfo(BaseContainer source, string varName)
Definition SCR_UIInfo.c:133
ResourceName GetImageSetPath()
Definition SCR_UIInfo.c:47
static SCR_UIInfo CreateInfo(LocalizedString name, LocalizedString description=LocalizedString.Empty, ResourceName icon=ResourceName.Empty, string iconSetName=string.Empty)
Definition SCR_UIInfo.c:165
LocalizedString Name
Definition SCR_UIName.c:8
UIInfo - allows to define UI elements.
Definition UIInfo.c:14
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
SCR_FieldOfViewSettings Attribute