9 [
Attribute(
params:
"edds imageset", uiwidget: UIWidgets.ResourcePickerThumbnail)]
10 protected ResourceName Icon;
12 [
Attribute(
desc:
"When 'Icon' is an image set, this defines name of the image in the set.")]
13 protected string IconSetName;
20 ResourceName GetIconPath()
23 FilePath.StripExtension(Icon, ext);
24 if (ext ==
"imageset")
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;
38 string GetIconSetName()
41 FilePath.StripExtension(Icon, ext);
43 if (ext ==
"imageset")
59 FilePath.StripExtension(Icon, ext);
60 if (ext ==
"imageset")
61 return !GetIconSetName().IsEmpty();
72 bool SetIconTo(ImageWidget imageWidget)
74 if (!imageWidget || Icon.IsEmpty())
78 FilePath.StripExtension(Icon, ext);
79 if (ext ==
"imageset")
80 imageWidget.LoadImageFromSet(0, Icon, GetIconSetName());
82 imageWidget.LoadImageTexture(0, GetIconPath());
91 override void Log(
string prefix =
string.Empty, LogLevel logLevel = LogLevel.VERBOSE)
93 Print(
string.Format(prefix +
"%1: \"%2\", \"%3\", \"%4\"", Type(), Name, Description, Icon), logLevel);
101 static SCR_UIInfo GetInfo(BaseContainer source,
string varName)
103 BaseContainer infoSource = source.GetObject(varName);
105 return SCR_UIInfo.Cast(BaseContainerTools.CreateInstanceFromContainer(infoSource));
120 info.Name = source.GetName();
121 info.Description = source.GetDescription();
122 info.Icon = source.GetIconPath();
137 info.Description = description;
139 info.IconSetName = iconSetName;
150 info.Name =
string.Format(
"ERROR: Missing info for %1",
type);
156 protected override void CopyFrom(
SCR_UIName source)
161 Icon = sourceInfo.Icon;
162 IconSetName = sourceInfo.IconSetName;
165 super.CopyFrom(source);