Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Attributes.c
Go to the documentation of this file.
1 
10 class SCR_BaseContainerStaticTitleField : BaseContainerCustomTitle
11 {
12  protected string m_sCustomTitle;
13 
14  //------------------------------------------------------------------------------------------------
15  void SCR_BaseContainerStaticTitleField(string customTitle = "")
16  {
17  customTitle.Trim();
18  m_sCustomTitle = customTitle;
19  }
20 
21  //------------------------------------------------------------------------------------------------
22  override bool _WB_GetCustomTitle(BaseContainer source, out string title)
23  {
24  // if (m_sCustomTitle.IsEmpty())
25  // return false;
26 
27  title = m_sCustomTitle;
28  return true;
29  }
30 };
31 
43 class SCR_BaseContainerCustomTitleField : BaseContainerCustomTitle
44 {
45  protected string m_sPropertyName;
46  protected string m_sFormat;
47 
48  //------------------------------------------------------------------------------------------------
49  void SCR_BaseContainerCustomTitleField(string propertyName, string format = "%1")
50  {
51  m_sPropertyName = propertyName;
52  m_sFormat = format;
53  }
54 
55  //------------------------------------------------------------------------------------------------
56  override bool _WB_GetCustomTitle(BaseContainer source, out string title)
57  {
58  if (!source.Get(m_sPropertyName, title))
59  return false;
60 
61  title = string.Format(m_sFormat, title);
62  return true;
63  }
64 };
65 
75 class SCR_BaseContainerCustomTitleFields : BaseContainerCustomTitle
76 {
77  protected ref array<string> m_aPropertyNames;
78  protected string m_sFormat;
79 
80  //------------------------------------------------------------------------------------------------
81  void SCR_BaseContainerCustomTitleFields(array<string> propertyNames, string format = "%1")
82  {
83  m_aPropertyNames = propertyNames;
84  m_sFormat = format;
85  }
86 
87  //------------------------------------------------------------------------------------------------
88  override bool _WB_GetCustomTitle(BaseContainer source, out string title)
89  {
90  if (!m_aPropertyNames)
91  {
92  title = m_sFormat;
93  return false;
94  }
95 
96  int count = m_aPropertyNames.Count();
97  array<string> arguments = {};
98  arguments.Resize(count); // needed here
99 
100  for (int i = 0; i < count; i++)
101  {
102  title = "<°))))-<";
103  if (!source.Get(m_aPropertyNames[i], title) || title == "<°))))-<")
104  {
105  ResourceName tempResourceName;
106  if (source.Get(m_aPropertyNames[i], tempResourceName))
107  title = FilePath.StripPath(tempResourceName);
108  else
109  title = "x";
110  }
111 
112  arguments[i] = title;
113  }
114 
115  title = SCR_StringHelper.Format(m_sFormat, arguments);
116 
117  return true;
118  }
119 };
120 
130 class SCR_BaseContainerLocalizedTitleField : BaseContainerCustomTitle
131 {
132  protected string m_sPropertyName;
133  protected string m_sFormat;
134 
135  //------------------------------------------------------------------------------------------------
136  void SCR_BaseContainerLocalizedTitleField(string propertyName, string format = "%1")
137  {
138  m_sPropertyName = propertyName;
139  m_sFormat = format;
140  }
141 
142  //------------------------------------------------------------------------------------------------
143  override bool _WB_GetCustomTitle(BaseContainer source, out string title)
144  {
145  if (!source.Get(m_sPropertyName, title))
146  return false;
147 
148  title = string.Format(m_sFormat, WidgetManager.Translate(title));
149  return true;
150  }
151 };
152 
162 class SCR_BaseContainerLocalizedTitleFields : BaseContainerCustomTitle
163 {
164  protected ref array<string> m_aPropertyNames;
165  protected string m_sFormat;
166 
167  //------------------------------------------------------------------------------------------------
168  void SCR_BaseContainerMultipleParametersTitleField(array<string> propertyNames, string format = "%1")
169  {
170  m_aPropertyNames = propertyNames;
171  m_sFormat = format;
172  }
173 
174  //------------------------------------------------------------------------------------------------
175  override bool _WB_GetCustomTitle(BaseContainer source, out string title)
176  {
177  if (!m_aPropertyNames)
178  {
179  title = m_sFormat;
180  return false;
181  }
182 
183  int count = m_aPropertyNames.Count();
184  array<string> arguments = {};
185  arguments.Resize(count); // needed here
186 
187  for (int i = 0; i < count; i++)
188  {
189  title = "<°))))-<"; // looks fishy hey?
190  if (!source.Get(m_aPropertyNames[i], title) || title == "<°))))-<")
191  {
192  ResourceName tempResourceName;
193  if (source.Get(m_aPropertyNames[i], tempResourceName) && title != "<°))))-<")
194  title = FilePath.StripPath(tempResourceName);
195  else
196  title = "x";
197  }
198 
199  arguments[i] = title;
200  }
201 
202  title = SCR_StringHelper.Translate(m_sFormat, arguments);
203 
204  return true;
205  }
206 };
218 class SCR_BaseContainerResourceTitleField : BaseContainerCustomTitle
219 {
220  protected string m_sPropertyName;
221  protected string m_sFormat;
222 
223  //------------------------------------------------------------------------------------------------
224  void SCR_BaseContainerResourceTitleField(string propertyName, string format = "%1")
225  {
226  m_sPropertyName = propertyName;
227  m_sFormat = format;
228  }
229 
230  //------------------------------------------------------------------------------------------------
231  override bool _WB_GetCustomTitle(BaseContainer source, out string title)
232  {
233  ResourceName resourceName;
234  if (!source.Get(m_sPropertyName, resourceName))
235  return false;
236 
237  title = string.Format(m_sFormat, FilePath.StripPath(resourceName));
238  return true;
239  }
240 };
241 
253 class SCR_BaseContainerCustomTitleEnum : BaseContainerCustomTitle
254 {
255  protected typename m_EnumType;
256  protected string m_PropertyName;
257  protected string m_sFormat;
258 
259  //------------------------------------------------------------------------------------------------
260  void SCR_BaseContainerCustomTitleEnum(typename enumType, string propertyName, string format = "%1")
261  {
262  m_EnumType = enumType;
263  m_PropertyName = propertyName;
264  m_sFormat = format;
265  }
266 
267  //------------------------------------------------------------------------------------------------
268  override bool _WB_GetCustomTitle(BaseContainer source, out string title)
269  {
270  int enumValue;
271  if (!source.Get(m_PropertyName, enumValue))
272  {
273  return false;
274  }
275 
276  title = string.Format(m_sFormat, typename.EnumToString(m_EnumType, enumValue));
277  return true;
278  }
279 };
280 
295 class BaseContainerCustomEnumWithValue : BaseContainerCustomTitle
296 {
297  protected typename m_EnumType;
298  protected string m_sEnumName;
299  protected string m_sValueName;
300  protected string m_sDefaultValue;
301  protected string m_sFormat;
302 
303  //------------------------------------------------------------------------------------------------
304  void BaseContainerCustomEnumWithValue(typename enumType, string enumName, string valueName, string defaultValue, string format = "%1: %2")
305  {
306  m_EnumType = enumType;
307  m_sEnumName = enumName;
308  m_sValueName = valueName;
309  m_sDefaultValue = defaultValue;
310  m_sFormat = format;
311  }
312 
313  //------------------------------------------------------------------------------------------------
314  override bool _WB_GetCustomTitle(BaseContainer source, out string title)
315  {
316  int enumValue;
317  if (!source.Get(m_sEnumName, enumValue))
318  return false;
319 
320  string value;
321  if (!source.Get(m_sValueName, value))
322  return false;
323 
324  //~ No value found so use default
325  if (value.IsEmpty())
326  value = m_sDefaultValue;
327 
328  title = string.Format(m_sFormat, typename.EnumToString(m_EnumType, enumValue), value);
329  return true;
330  }
331 };
332 
344 class SCR_BaseContainerCustomTitleFlags : BaseContainerCustomTitle
345 {
346  protected typename m_EnumType;
347  protected string m_PropertyName;
348  protected string m_sFormat;
349 
350  //------------------------------------------------------------------------------------------------
351  void SCR_BaseContainerCustomTitleFlags(typename enumType, string propertyName, string format = "%1")
352  {
353  m_EnumType = enumType;
354  m_PropertyName = propertyName;
355  m_sFormat = format;
356  }
357 
358  //------------------------------------------------------------------------------------------------
359  override bool _WB_GetCustomTitle(BaseContainer source, out string title)
360  {
361  int enumValue;
362  if (!source.Get(m_PropertyName, enumValue))
363  return false;
364 
365  array<int> values = {};
366  string enumName;
367  for (int i = 0, count = SCR_Enum.BitToIntArray(enumValue, values); i < count; i++)
368  {
369  if (i > 0)
370  enumName += " | ";
371 
372  enumName += typename.EnumToString(m_EnumType, values[i]);
373  }
374 
375  title = string.Format(m_sFormat, enumName);
376  return true;
377  }
378 };
379 
391 class SCR_BaseContainerCustomTitleResourceName : BaseContainerCustomTitle
392 {
393  protected string m_sPropertyName;
394  protected bool m_bFileNameOnly;
395  protected string m_sFormat;
396 
397  //------------------------------------------------------------------------------------------------
398  void SCR_BaseContainerCustomTitleResourceName(string propertyName, bool fileNameOnly = false, string format = "%1")
399  {
400  m_sPropertyName = propertyName;
401  m_bFileNameOnly = fileNameOnly;
402  m_sFormat = format;
403  }
404 
405  //------------------------------------------------------------------------------------------------
406  override bool _WB_GetCustomTitle(BaseContainer source, out string title)
407  {
408  ResourceName path;
409  if (!source.Get(m_sPropertyName, path))
410  return false;
411 
412  title = path.GetPath();
413  if (m_bFileNameOnly)
414  title = string.Format(m_sFormat, FilePath.StripPath(title));
415 
416  return true;
417  }
418 };
419 
431 class SCR_BaseContainerCustomTitleObject : BaseContainerCustomTitle
432 {
433  protected string m_sPropertyName;
434  protected string m_sFormat;
435 
436  //------------------------------------------------------------------------------------------------
437  void SCR_BaseContainerCustomTitleObject(string propertyName, string format = "%1")
438  {
439  m_sPropertyName = propertyName;
440  m_sFormat = format;
441  }
442 
443  //------------------------------------------------------------------------------------------------
444  override bool _WB_GetCustomTitle(BaseContainer source, out string title)
445  {
446  BaseContainer object = source.GetObject(m_sPropertyName);
447  if (!object)
448  return false;
449 
450  title = string.Format(m_sFormat, object.GetClassName());
451  return true;
452  }
453 };
454 
464 class BaseContainerCustomStringTitleField : BaseContainerCustomTitle
465 {
466  string m_Title;
467 
468  //------------------------------------------------------------------------------------------------
469  void BaseContainerCustomStringTitleField(string title)
470  {
471  m_Title = title;
472  }
473 
474  //------------------------------------------------------------------------------------------------
475  override bool _WB_GetCustomTitle(BaseContainer source, out string title)
476  {
477  title = m_Title;
478  return !title.IsEmpty();
479  }
480 };
481 
493 class BaseContainerCustomDoubleTitleField : BaseContainerCustomTitle
494 {
495  protected string m_sPropertyName1;
496  protected string m_sPropertyName2;
497  protected string m_sFormat;
498 
499  //------------------------------------------------------------------------------------------------
500  void BaseContainerCustomDoubleTitleField(string propertyName1, string propertyName2, string format = "%1: %2")
501  {
502  m_sPropertyName1 = propertyName1;
503  m_sPropertyName2 = propertyName2;
504  m_sFormat = format;
505  }
506 
507  //------------------------------------------------------------------------------------------------
508  override bool _WB_GetCustomTitle(BaseContainer source, out string title)
509  {
510  string title1, title2;
511 
512  if (!source.Get(m_sPropertyName1, title1))
513  return false;
514 
515  if (!source.Get(m_sPropertyName2, title2))
516  return false;
517 
518  title = string.Format(m_sFormat, title1, title2);
519  return true;
520  }
521 };
522 
538 class BaseContainerCustomDoubleCheckTitleField : BaseContainerCustomTitle
539 {
540  protected string m_sCheckVar;
541  protected string m_sPropertyName;
542  protected string m_sFormatTrue;
543  protected string m_sFormatFalse;
544  protected string m_sCheckVarEqual;
545 
546  //------------------------------------------------------------------------------------------------
547  void BaseContainerCustomDoubleCheckTitleField(string checkVar, string propertyName, string checkVarEqual = "1", string formatTrue = "%1", string formatFalse = "EXAMPLE FORMAT - %1")
548  {
549  m_sCheckVar = checkVar;
550  m_sPropertyName = propertyName;
551  m_sFormatTrue = formatTrue;
552  m_sFormatFalse = formatFalse;
553  m_sCheckVarEqual = checkVarEqual;
554  }
555 
556  //------------------------------------------------------------------------------------------------
557  override bool _WB_GetCustomTitle(BaseContainer source, out string title)
558  {
559  string checkVar, titleName;
560 
561  if (!source.Get(m_sCheckVar, checkVar))
562  return false;
563 
564  if (!source.Get(m_sPropertyName, titleName))
565  return false;
566 
567  if (checkVar == m_sCheckVarEqual)
568  title = string.Format(m_sFormatTrue, titleName);
569  else
570  title = string.Format(m_sFormatFalse, titleName);
571 
572  return true;
573  }
574 };
575 
592 {
593  protected string m_sCheckVar;
594  protected string m_sPropertyName;
595  protected string m_sFormatTrue;
596  protected string m_sFormatFalse;
597  protected float m_iCheckVarEqual;
598  protected bool m_bFileNameOnly;
599 
600  //------------------------------------------------------------------------------------------------
601  void BaseContainerCustomDoubleCheckIntResourceNameTitleField(string checkVar, string propertyName, int checkVarEqual, string formatTrue = "%1", string formatFalse = "EXAMPLE FORMAT - %1", bool fileNameOnly = true)
602  {
603  m_sCheckVar = checkVar;
604  m_sPropertyName = propertyName;
605  m_sFormatTrue = formatTrue;
606  m_sFormatFalse = formatFalse;
607  m_iCheckVarEqual = checkVarEqual;
608  m_bFileNameOnly = fileNameOnly;
609  }
610 
611  //------------------------------------------------------------------------------------------------
612  override bool _WB_GetCustomTitle(BaseContainer source, out string title)
613  {
614  int checkVar;
615  string pathString;
616 
617  if (!source.Get(m_sCheckVar, checkVar))
618  return false;
619 
620  ResourceName path;
621  if (!source.Get(m_sPropertyName, path))
622  return false;
623 
624  if (path.IsEmpty())
625  pathString = "NO PREFAB";
626  else
627  pathString = path.GetPath();
628 
629  if (checkVar == m_iCheckVarEqual)
630  {
631  if (!m_bFileNameOnly || path.IsEmpty())
632  title = string.Format(m_sFormatTrue, pathString);
633  else
634  title = string.Format(m_sFormatTrue, FilePath.StripPath(pathString));
635  }
636  else
637  {
638  if (!m_bFileNameOnly || path.IsEmpty())
639  title = string.Format(m_sFormatFalse, pathString);
640  else
641  title = string.Format(m_sFormatFalse, FilePath.StripPath(pathString));
642  }
643 
644  return true;
645  }
646 };
647 
659 class BaseContainerCustomCheckIntTitleField : BaseContainerCustomTitle
660 {
661  protected string m_sCheckVar;
662  protected string m_sConditionTrueText;
663  protected string m_sConditionFalseText;
664  protected int m_iCheckVarEqual;
665 
666  //------------------------------------------------------------------------------------------------
667  void BaseContainerCustomCheckIntTitleField(string checkVar, string conditionTrueText, string conditionFalseText, int checkVarEqual)
668  {
669  m_sCheckVar = checkVar;
670  m_sConditionTrueText = conditionTrueText;
671  m_sConditionFalseText = conditionFalseText;
672  m_iCheckVarEqual = checkVarEqual;
673  }
674 
675  //------------------------------------------------------------------------------------------------
676  override bool _WB_GetCustomTitle(BaseContainer source, out string title)
677  {
678  int checkVar;
679 
680  if (!source.Get(m_sCheckVar, checkVar))
681  return false;
682 
683  if (checkVar == m_iCheckVarEqual)
684  title = m_sConditionTrueText;
685  else
686  title = m_sConditionFalseText;
687 
688  return true;
689  }
690 };
691 
706 class BaseContainerCustomCheckIntWithFlagTitleField : BaseContainerCustomTitle
707 {
708  protected typename m_FlagEnumType;
709  protected string m_sFlagName;
710  protected string m_sFlagDivider;
711  protected string m_sCheckVar;
712  protected string m_sConditionTrueText;
713  protected string m_sConditionFalseText;
714  protected int m_iCheckVarEqual;
715 
716  //------------------------------------------------------------------------------------------------
717  void BaseContainerCustomCheckIntWithFlagTitleField(typename flagEnumType, string flagName, string checkVar, int checkVarEqual, string conditionTrueText = "DEFAULT TRUE - %1", string conditionFalseText = "DEFAULT FALSE - %2", string flagDivider = " & ")
718  {
719  m_FlagEnumType = flagEnumType;
720  m_sFlagName = flagName;
721  m_sFlagDivider = flagDivider;
722  m_sCheckVar = checkVar;
723  m_sConditionTrueText = conditionTrueText;
724  m_sConditionFalseText = conditionFalseText;
725  m_iCheckVarEqual = checkVarEqual;
726  }
727 
728  //------------------------------------------------------------------------------------------------
729  override bool _WB_GetCustomTitle(BaseContainer source, out string title)
730  {
731  int checkVar;
732 
733  if (!source.Get(m_sCheckVar, checkVar))
734  return false;
735 
736  if (checkVar == m_iCheckVarEqual)
737  {
738  title = m_sConditionTrueText;
739  }
740  else
741  {
742  title = m_sConditionFalseText;
743  return true;
744  }
745 
746  string enumName = "NONE";
747 
748  int enumValue;
749  if (source.Get(m_sFlagName, enumValue))
750  {
751  array<int> values = {};
752  for (int i = 0, count = SCR_Enum.BitToIntArray(enumValue, values); i < count; i++)
753  {
754  if (i == 0)
755  enumName = string.Empty;
756 
757  if (i > 0)
758  enumName += m_sFlagDivider;
759 
760  enumName += typename.EnumToString(m_FlagEnumType, values[i]);
761  }
762  }
763 
764  //~ Add flags
765  title = title.Format(title, enumName);
766 
767  return true;
768  }
769 }
770 
782 class SCR_BaseContainerCustomTitleUIInfo : BaseContainerCustomTitle
783 {
784  protected string m_sPropertyName;
785  protected string m_sFormat;
786 
787  //------------------------------------------------------------------------------------------------
788  void SCR_BaseContainerCustomTitleUIInfo(string propertyName, string format = "%1")
789  {
790  m_sPropertyName = propertyName;
791  m_sFormat = format;
792  }
793 
794  //------------------------------------------------------------------------------------------------
795  override bool _WB_GetCustomTitle(BaseContainer source, out string title)
796  {
797  BaseContainer info = source.GetObject(m_sPropertyName);
798  if (!info || !info.Get("Name", title))
799  return false;
800 
801  title = string.Format(m_sFormat, WidgetManager.Translate(title));
802  return true;
803  }
804 };
BaseContainerCustomDoubleCheckIntResourceNameTitleField
Attribute for setting a custom format if the given checkVar is equal to checkVarEqual....
Definition: Attributes.c:591
BaseContainerCustomDoubleCheckTitleField
Attribute for setting a custom format if the given checkVar is equal to checkVarEqual....
Definition: Attributes.c:538
SCR_Enum
Definition: SCR_Enum.c:1
SCR_BaseContainerStaticTitleField
Attribute to manually set a static title.
Definition: Attributes.c:10
SCR_BaseContainerLocalizedTitleField
Attribute to manually set a LOCALIZED (translated) title.
Definition: Attributes.c:130
BaseContainerCustomCheckIntWithFlagTitleField
Attribute for setting a custom format if the given checkVar is equal to checkVarEqual with showing fl...
Definition: Attributes.c:706
SCR_StringHelper
Definition: SCR_StringHelper.c:1
_WB_GetCustomTitle
override bool _WB_GetCustomTitle(BaseContainer source, out string title)
Definition: Attributes.c:795
SCR_BaseContainerCustomTitleEnum
Attribute for setting any enum property as custom title.
Definition: Attributes.c:253
SCR_BaseContainerCustomTitleFields
allow to define multiple fields - up to 9 elements
Definition: Attributes.c:75
m_sFormat
protected string m_sFormat
Definition: Attributes.c:785
SCR_BaseContainerCustomTitleField
Attribute for setting any string property as custom title.
Definition: Attributes.c:43
SCR_BaseContainerCustomTitleFlags
Attribute for setting any flags enum property as custom title.
Definition: Attributes.c:344
BaseContainerCustomStringTitleField
Attribute for setting a custom string as title.
Definition: Attributes.c:464
BaseContainerCustomCheckIntTitleField
Attribute for setting a custom format if the given checkVar is equal to checkVarEqual....
Definition: Attributes.c:659
SCR_BaseContainerCustomTitleObject
Attribute for setting any object classname property as custom title.
Definition: Attributes.c:431
BaseContainerCustomDoubleTitleField
Attribute for setting two string property as custom title.
Definition: Attributes.c:493
SCR_BaseContainerLocalizedTitleFields
allow to define multiple fields - up to 9 elements
Definition: Attributes.c:162
SCR_BaseContainerResourceTitleField
Attribute to use a ResourceName filename.
Definition: Attributes.c:218
m_sPropertyName
BaseContainerCustomCheckIntWithFlagTitleField m_sPropertyName
Attribute for setting UIInfo's name property as (Localized) custom title.
SCR_BaseContainerCustomTitleUIInfo
void SCR_BaseContainerCustomTitleUIInfo(string propertyName, string format="%1")
Definition: Attributes.c:788
SCR_BaseContainerCustomTitleResourceName
Attribute for setting any ResourceName path property as custom title.
Definition: Attributes.c:391
BaseContainerCustomEnumWithValue
Attribute for setting any enum property as custom title with an aditional varriable....
Definition: Attributes.c:295