Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_WidgetListEntry.c
Go to the documentation of this file.
5
6//-------------------------------------------------------------------------------------------
7// Custom titles
8//-------------------------------------------------------------------------------------------
9
10//------------------------------------------------------------------------------------------------
12{
13 //------------------------------------------------------------------------------------------------
14 override bool _WB_GetCustomTitle(BaseContainer source, out string title)
15 {
16 // Group tag string
17 string groupTag = "";
18 source.Get("m_sGroupTag", groupTag);
19
20 // Name string
21 string name = "";
22 source.Get("m_sPropertyName", name);
23
24 // Class tag
25 string classTag = "";
26 source.Get("m_sClassTag", classTag);
27
28 // Setup title string
29 title = "";
30
31 if (!groupTag.IsEmpty())
32 title += groupTag + ": ";
33
34 if (!name.IsEmpty())
35 title += name;
36 else
37 title += "!!!";
38
39 if (!classTag.IsEmpty())
40 title += string.Format("(%1)", classTag);
41
42 return true;
43 }
44};
45
46//------------------------------------------------------------------------------------------------
49{
50 protected string m_Label;
51 protected string m_PropertyName;
52
53 //------------------------------------------------------------------------------------------------
54 override bool _WB_GetCustomTitle(BaseContainer source, out string title)
55 {
56 // Group tag string
57 string label = "";
58 source.Get("m_Label", label);
59
60 // Name string
61 string property = "";
62 source.Get("m_PropertyName", property);
63
64 // Setup title string
65 title = label + ": " + property;
66
67 return true;
68 }
69};
70
71//-------------------------------------------------------------------------------------------
74class SCR_LocalizedProperty
75{
76 [Attribute("")]
77 string m_sLabel;
78
79 [Attribute("")]
80 string m_sPropertyName;
81
82 void SCR_LocalizedProperty(string label, string propertyName)
83 {
84 if (m_sLabel.IsEmpty())
85 m_sLabel = label;
86
87 if (m_sPropertyName.IsEmpty())
88 m_sPropertyName = propertyName;
89 }
90};
91
92//-------------------------------------------------------------------------------------------
95class SCR_LocalizedPropertyExtended : SCR_LocalizedProperty
96{
97 [Attribute()]
98 ref array<string> m_aInfo;
99
100 void SCR_LocalizedPropertyExtended(string label, string propertyName, array<string> info)
101 {
102 m_sLabel = label;
103 m_sPropertyName = propertyName;
104 m_aInfo = info;
105 }
106};
107
108//-------------------------------------------------------------------------------------------
109// Widget entries
110//-------------------------------------------------------------------------------------------
111
112//-------------------------------------------------------------------------------------------
116{
117 protected const ResourceName ENTRY_DEFINITIONS = "{A6EFD45A3A38965C}Configs/JsonConfigList/JsonConfigListDefinition.conf";
118
119 const string INVALID_VALUE = "-invalid-";
120
121 [Attribute("{0022F0B45ADBC5AC}UI/layouts/WidgetLibrary/EditBox/WLib_EditBox.layout", UIWidgets.ResourceNamePicker, "What kind of widget should be generated for this value", "layout")]
123
124 [Attribute("1")]
125 protected bool m_bShow;
126
127 [Attribute("", UIWidgets.EditBox, "Text for label")]
128 protected string m_sLabel;
129
130 [Attribute("", UIWidgets.EditBox, "Name of property that in json file")]
131 protected string m_sPropertyName;
132
133 [Attribute("", UIWidgets.EditBox, "Name of property that in json file")]
134 protected string m_sGroupTag;
135
136 [Attribute("", UIWidgets.EditBox, "Fallback value that will be prefilled at start")]
137 protected string m_sDefaultValue;
138
139 [Attribute("1")]
140 protected bool m_bRequired;
141
142 [Attribute("1")]
143 protected bool m_bInteractive;
144
147 protected string m_sClassTag;
148
150
151 protected bool m_bValidInput = true;
152
153 //-------------------------------------------------------------------------------------------
154 void CreateWidget(Widget parent)
155 {
156 // Create widget
157 Widget w = GetGame().GetWorkspace().CreateWidgets(m_sEntryLayout, parent);
158 m_EntryRoot = w;
159
160 // Setup component
163 return;
164
166 m_ChangeableComponent.UseLabel(!m_sLabel.IsEmpty());
167
170
171 w.SetVisible(m_bShow);
172 }
173
174 //-------------------------------------------------------------------------------------------
176
177 //-------------------------------------------------------------------------------------------
179 protected void SetupHandlers();
180
181 //-------------------------------------------------------------------------------------------
184
185 //-------------------------------------------------------------------------------------------
186 void SetValue(string str){}
187
188 //-------------------------------------------------------------------------------------------
191 {
192 if (CanSkip())
193 return true;
194
195 m_bValidInput = true;
196
197 return m_bValidInput;
198 }
199
200 //-------------------------------------------------------------------------------------------
202 protected bool CanSkip()
203 {
204 return ValueAsString().IsEmpty() && !m_bRequired;
205 }
206
207 //-------------------------------------------------------------------------------------------
209 void SetInteractive(bool interactive)
210 {
212 return;
213
214 m_ChangeableComponent.SetEnabled(interactive, false);
215 }
216
217 //-------------------------------------------------------------------------------------------
218 // Get and Set
219 //-------------------------------------------------------------------------------------------
220
221 //-------------------------------------------------------------------------------------------
223 {
224 return m_sEntryLayout;
225 }
226
227 //-------------------------------------------------------------------------------------------
232
233 //-------------------------------------------------------------------------------------------
234 string GetLabel()
235 {
236 return m_sLabel;
237 }
238
239 //-------------------------------------------------------------------------------------------
240 void SetLabel(string label)
241 {
242 m_sLabel = label;
243 }
244
245 //-------------------------------------------------------------------------------------------
247 {
248 return m_sPropertyName;
249 }
250
251 //-------------------------------------------------------------------------------------------
252 void SetPropertyName(string propertyName)
253 {
254 m_sPropertyName = propertyName;
255 }
256
257 //-------------------------------------------------------------------------------------------
258 string GetGroupTag()
259 {
260 return m_sGroupTag;
261 }
262
263 //-------------------------------------------------------------------------------------------
264 void SetGroupTag(string tag)
265 {
266 m_sGroupTag = tag;
267 }
268
269 //-------------------------------------------------------------------------------------------
271 {
272 return m_iType;
273 }
274
275 //-------------------------------------------------------------------------------------------
277 {
278 return m_EntryRoot;
279 }
280
281 //-------------------------------------------------------------------------------------------
283 {
284 return m_bValidInput;
285 }
286
287 //-------------------------------------------------------------------------------------------
289 {
290 return m_bShow;
291 }
292
293 //-------------------------------------------------------------------------------------------
294 void SetVisible(bool show)
295 {
296 m_bShow = show;
297 m_EntryRoot.SetVisible(m_bShow);
298 }
299
300 //-------------------------------------------------------------------------------------------
302 {
303 Resource rsc = BaseContainerTools.LoadContainer(presetsResourceName);
304 if (!rsc)
305 return null;
306
307 BaseContainer container = rsc.GetResource().ToBaseContainer();
308
309 return SCR_ConfigListEntries.Cast(BaseContainerTools.CreateInstanceFromContainer(container));
310 }
311};
312
313//-------------------------------------------------------------------------------------------
314[BaseContainerProps(configRoot: true)]
316{
317 [Attribute("", UIWidgets.EditBox, "Group tag for fast recognition")]
318 protected string m_sTag;
319
320 [Attribute()]
321 protected ref array<ref SCR_WidgetListEntry> m_aEntries;
322
323 //-------------------------------------------------------------------------------------------
324 string GetTag()
325 {
326 return m_sTag;
327 }
328};
329
330
331//-------------------------------------------------------------------------------------------
336{
337 [Attribute("", UIWidgets.EditBox, "Group tag for fast recognition")]
338 protected string m_sMessage;
339
341
342 //-------------------------------------------------------------------------------------------
343 override void CreateWidget(Widget parent)
344 {
345 // Create widget
346 Widget w = GetGame().GetWorkspace().CreateWidgets(m_sEntryLayout, parent);
347
348 // Show
349 w.SetVisible(m_bShow);
350 if (!m_bShow)
351 return;
352
353 m_EntryRoot = w;
354
356 m_SimpleEntry.SetMessages(m_sLabel, m_sMessage);
357 }
358
359 //-------------------------------------------------------------------------------------------
361 override void SetValue(string str)
362 {
363 m_sMessage = str;
364 m_SimpleEntry.SetMessages(m_sLabel, m_sMessage);
365 }
366
367 //-------------------------------------------------------------------------------------------
369 override string ValueAsString()
370 {
371 return m_sMessage;
372 }
373}
374
375//-------------------------------------------------------------------------------------------
377[BaseContainerProps(configRoot: true)]
378class SCR_WidgetListEntryLabel : SCR_WidgetListEntry
380 [Attribute("8")]
381 protected float m_iOffsetTop;
382
383 [Attribute("8")]
384 protected float m_iOffsetBottom;
385
386 [Attribute("8")]
387 protected float m_iLeftBottom;
388
389 //-------------------------------------------------------------------------------------------
390 override void CreateWidget(Widget parent)
391 {
392
393 TextWidget wText = TextWidget.Cast(GetGame().GetWorkspace().CreateWidgets(m_sEntryLayout, parent));
394 if (!wText)
395 return;
396
397 wText.SetText(m_sLabel);
398 VerticalLayoutSlot.SetPadding(wText, m_iLeftBottom, m_iOffsetTop, 0, m_iOffsetBottom);
399
400 m_sClassTag = "label";
401
402 m_EntryRoot = wText;
403
404 // Show
405 wText.SetVisible(m_bShow);
406 }
407};
408
409//-------------------------------------------------------------------------------------------
410//! Configurable widget list entry for various value that can be typed - numbers, strings, references
413{
414 [Attribute(EJsonApiStructValueType.TYPE_STRING.ToString(), uiwidget: UIWidgets.ComboBox, enums: SCR_Enum.GetList(EJsonApiStructValueType))]
416
417 [Attribute("100")]
418 protected int m_CharLimit;
419
420 [Attribute("5", UIWidgets.EditBox, "In how many seconds should editbox error should be cleared after focus")]
421 protected int m_fClearErrorTimes;
422
423 [Attribute()]
425
426 [Attribute("...")]
427 protected string m_sPlaceholderText;
428
429 [Attribute("0", desc: "When false - there will be used warning text below as default. Otherwise there might be hardcoded strings in format messages.")]
430 protected bool m_bUseFormatWarning;
431
432 [Attribute("")]
433 protected string m_sWarningText;
434
435 [Attribute("")]
436 protected string m_sObfuscation;
437
438 [Attribute("")]
439 protected string m_sCharBlackList;
440
441 [Attribute("0")]
443
444 [Attribute("0")]
445 protected bool m_bShowWriteIcon;
446
447 [Attribute("-1", desc: "Height -1 keep editbox single line. Changing height will override current height")]
448 protected float m_fCustomHeight;
449
452
453 // It's a bad idea to store this on the Widget itself!
454 // Also, we need to be able to freely change it without triggering the Edit Box's OnChange invoker by calling SetText()
455 protected string m_sCurrentValue;
456
457 //-------------------------------------------------------------------------------------------
458 override protected void SetupHandlers()
459 {
462
463 if (!m_EditBox)
464 return;
465
466 m_Filter = EditBoxFilterComponent.Cast(m_EditBox.m_wEditBox.FindHandler(EditBoxFilterComponent));
467
469 m_sClassTag = "edit";
470
471 // Editbox setup
473 m_EditBox.m_OnTextChange.Insert(OnEditBoxTextChange);
474
475 m_EditBox.SetPlaceholderText(m_sPlaceholderText);
476 m_EditBox.ShowWriteIcon(m_bShowWriteIcon);
477
478 // Label and size setup
479 //m_EditBox.SetLabel(m_sLabel);
480 bool useLabel = !m_sLabel.IsEmpty();
481
482 if (m_fCustomHeight > 0)
483 {
484 if (useLabel)
485 m_EditBox.SetSizeWithLabel(m_fCustomHeight);
486 else
487 m_EditBox.SetSizeWithoutLabel(m_fCustomHeight);
488 }
489
490 //m_EditBox.UseLabel(useLabel);
491
492 // Hint setup
493 if (m_EditBox.GetHint())
494 m_EditBox.GetHint().SetMessage(m_sWarningText);
495
496 EditBoxWidget editBox = EditBoxWidget.Cast(m_EditBox.GetEditBoxWidget());
497 if (editBox)
498 editBox.SetObfuscationChar(m_sObfuscation);
499
500 if (m_FormatCheck)
501 {
502 m_EditBox.m_OnWriteModeLeave.Insert(OnEditModeLeave);
503
504 if (m_Filter)
505 {
506 m_FormatCheck.SetEditBoxFilter(m_Filter);
507
508 // Call character list settings next frame to ensure list is properly override default values
509 GetGame().GetCallqueue().CallLater(SetCharLists);
510 }
511 }
512
513 // Number specific setup
514 if (m_iType == EJsonApiStructValueType.TYPE_INT || m_iType == EJsonApiStructValueType.TYPE_FLOAT)
515 {
516 if (m_Filter)
517 {
518 m_Filter.SetNumbers(true);
519 m_Filter.SetPunctuation(m_iType == EJsonApiStructValueType.TYPE_FLOAT);
520 m_Filter.SetASCIIchars(false);
521 m_Filter.SetUTFMultibyte(false);
522 }
523 }
524
525 // Limit
526 if (m_Filter)
527 {
528 m_Filter.SetCharacterLimit(m_CharLimit);
529 m_Filter.m_OnInvalidInput.Insert(OnInvalidInput);
530 m_Filter.m_OnTextTooLong.Insert(OnInvalidInput);
531
533 {
534 m_Filter.SetNumbers(false);
535 m_Filter.SetPunctuation(false);
536 m_Filter.SetASCIIchars(false);
537 m_Filter.SetUTFMultibyte(false);
538 m_Filter.SetCharWhiteList(m_sCharBlackList);
539 }
540 else
541 m_Filter.SetCharBlacklist(m_sCharBlackList);
542 }
543 }
544
545 //-------------------------------------------------------------------------------------------
546 override void RemoveWidget()
547 {
548 if (m_EditBox)
549 m_EditBox.m_OnWriteModeLeave.Remove(OnEditModeLeave);
550 }
551
552 //-------------------------------------------------------------------------------------------
553 protected void SetCharLists()
554 {
556 m_Filter.SetCharWhiteList(m_sCharBlackList);
557 else
558 m_Filter.SetCharBlacklist(m_sCharBlackList);
559 }
560
561 //-------------------------------------------------------------------------------------------
562 protected void OnEditBoxTextChange(string text)
563 {
564 m_sCurrentValue = text;
565 }
566
567 //-------------------------------------------------------------------------------------------
568 override string ValueAsString()
569 {
570 if (!m_EditBox)
571 return INVALID_VALUE;
572
573 return m_sCurrentValue;
574 }
575
576 //-------------------------------------------------------------------------------------------
577 override void SetValue(string str)
578 {
579 m_sCurrentValue = str;
581 }
582
583 //-------------------------------------------------------------------------------------------
584 protected void UpdateEditBoxText()
585 {
586 if (m_EditBox)
587 m_EditBox.SetValue(m_sCurrentValue);
588 }
589
590 //-------------------------------------------------------------------------------------------
591 override bool CheckValidity()
592 {
593 if (CanSkip())
594 return true;
595
597 return m_bValidInput;
598 }
599
600 //-------------------------------------------------------------------------------------------
601 protected void OnEditModeLeave(string text)
602 {
604 }
605
606 //-------------------------------------------------------------------------------------------
608 void CheckEditBoxValidity(SCR_EditBoxComponent editBox, string value)
609 {
610 if (!m_FormatCheck)
611 {
612 m_bValidInput = true;
613 return;
614 }
615
616 m_bValidInput = m_FormatCheck.IsFormatValid(value);
617
618 // Invalid
619 if (m_Filter && !m_bValidInput)
620 {
621 // Call in next frame to make sure this invoke happens after editbox change
622 // Change clears invalid input
623 GetGame().GetCallqueue().CallLater(InvokeInvalidInput);
624 }
625
626 // Setup error
628 {
629 SCR_WidgetHintComponent hint = m_EditBox.GetHint();
630
631 if (hint)
632 hint.SetMessage(m_FormatCheck.GetFormatMessage());
633 }
634 }
635
636 //-------------------------------------------------------------------------------------------
637 protected void InvokeInvalidInput()
638 {
639 m_Filter.m_OnInvalidInput.Invoke();
640 }
641
642 //-------------------------------------------------------------------------------------------
643 protected void OnInvalidInput()
644 {
645 // Call later to clear out invalid input
646 if (m_bValidInput)
647 GetGame().GetCallqueue().CallLater(ClearInvalidInput, m_fClearErrorTimes * 1000);
648 }
649
650 //-------------------------------------------------------------------------------------------
652 {
653 if (m_EditBox)
654 m_EditBox.ClearInvalidInput();
655 }
656
657 //-------------------------------------------------------------------------------------------
662
663 //-------------------------------------------------------------------------------------------
668
669 //-------------------------------------------------------------------------------------------
670 void SetWarningText(string warning)
671 {
672 if (!m_EditBox)
673 return;
674
675 if (m_EditBox.GetHint())
676 m_EditBox.GetHint().SetMessage(warning);
677 }
679
680//-------------------------------------------------------------------------------------------
684{
685 protected SCR_WidgetEditFormatIP m_IPCheck;
686
687 //-------------------------------------------------------------------------------------------
688 override protected void SetupHandlers()
689 {
690 super.SetupHandlers();
691 m_IPCheck = SCR_WidgetEditFormatIP.Cast(m_FormatCheck);
692 }
693
694 //-------------------------------------------------------------------------------------------
695 override bool CheckValidity()
696 {
697 super.CheckValidity();
698
699 // Private IP
700 if (m_IPCheck)
701 {
702 if (m_IPCheck.IsPrivate())
703 m_EditBox.ShowHint(true);
704 }
705
706 return m_bValidInput;
707 }
708}
709
710//-------------------------------------------------------------------------------------------
713class SCR_WidgetListEntryCheckBox : SCR_WidgetListEntry
714{
715 [Attribute("")]
716 protected string m_sPositive;
717
718 [Attribute("")]
719 protected string m_sNegative;
720
721 protected SCR_CheckboxComponent m_Checkbox;
722
723 //-------------------------------------------------------------------------------------------
724 override protected void SetupHandlers()
725 {
726 if (m_ChangeableComponent)
727 m_Checkbox = SCR_CheckboxComponent.Cast(m_ChangeableComponent);
728
729 m_iType = EJsonApiStructValueType.TYPE_BOOL;
730 m_sClassTag = "check box";
731
732 // Checkbox value setup
733 if (!m_sNegative.IsEmpty() && m_Checkbox.m_aSelectionElements[0])
734 {
735 SCR_ButtonTextComponent textComp = SCR_ButtonTextComponent.Cast(m_Checkbox.m_aSelectionElements[0]);
736 if (textComp)
737 textComp.SetText(m_sNegative);
738 }
739
740 if (!m_sPositive.IsEmpty() && m_Checkbox.m_aSelectionElements[1])
741 {
742 SCR_ButtonTextComponent textComp = SCR_ButtonTextComponent.Cast(m_Checkbox.m_aSelectionElements[1]);
743 if (textComp)
744 textComp.SetText(m_sPositive);
745 }
746
747 m_Checkbox.SetChecked(SCR_JsonApiStructHandler.StringToBool(m_sDefaultValue), false, false);
748 }
749
750 //-------------------------------------------------------------------------------------------
751 override void SetValue(string str)
752 {
753 if (!m_Checkbox)
754 return;
755
756 bool checked = SCR_JsonApiStructHandler.StringToBool(str);
757 m_Checkbox.SetChecked(checked);
758 }
759
760 //-------------------------------------------------------------------------------------------
761 override string ValueAsString()
762 {
763 if (!m_Checkbox)
764 return INVALID_VALUE;
765
766 return m_Checkbox.IsChecked().ToString();
767 }
768
769 //-------------------------------------------------------------------------------------------
770 SCR_CheckboxComponent GetCheckbox()
771 {
772 return m_Checkbox;
773 }
774};
775
776//-------------------------------------------------------------------------------------------
780{
781 [Attribute()]
782 protected ref array<ref SCR_LocalizedProperty> m_aOptions;
783
785
786 //-------------------------------------------------------------------------------------------
787 override protected void SetupHandlers()
788 {
791
792 if (!m_Selection)
793 return;
794
795 // Fill values
796 for (int i = 0, count = m_aOptions.Count(); i < count; i++)
797 {
798 m_Selection.AddItem(m_aOptions[i].m_sLabel);
799 }
800
801 // Select default value
802 if (!m_sDefaultValue.IsEmpty())
803 SelectOption(m_sDefaultValue.ToInt());
804 }
805
806 //-------------------------------------------------------------------------------------------
807 override string ValueAsString()
808 {
809 if (!m_Selection)
810 return INVALID_VALUE;
811
812 int id = m_Selection.m_iSelectedItem;
813
814 #ifdef SB_DEBUG
815 Print("option Id: " + id + "/" + m_aOptions.Count());
816 #endif
817
818 if (id == -1 || id >= m_aOptions.Count())
819 return INVALID_VALUE;
820
821 if (m_aOptions[id] == null)
822 return INVALID_VALUE;
823
824 return m_aOptions[id].m_sPropertyName;
825 }
826
827 //-------------------------------------------------------------------------------------------
830 {
831 if (!m_Selection)
832 return -1;
833
834 return m_Selection.m_iSelectedItem;
835 }
836
837 //-------------------------------------------------------------------------------------------
838 // API
839 //-------------------------------------------------------------------------------------------
840
841 //-------------------------------------------------------------------------------------------\
842 void SelectOption(int id)
843 {
844 if (m_Selection)
846 }
847
848 //-------------------------------------------------------------------------------------------
851 {
852 int id = -1;
853
854 if (m_Selection)
855 id = m_Selection.GetCurrentIndex();
856
857 if (id == -1)
858 return null;
859
860 return m_aOptions[id];
861 }
862
863 //-------------------------------------------------------------------------------------------
865 void SetOptions(array<ref SCR_LocalizedProperty> options)
866 {
867 m_aOptions = options;
868
869 // Update values
870 if (!m_Selection)
871 return;
872
873 m_Selection.ClearAll();
874
875 for (int i = 0, count = m_aOptions.Count(); i < count; i++)
876 {
877 m_Selection.AddItem(m_aOptions[i].m_sLabel);
878 }
879 }
880
881 //-------------------------------------------------------------------------------------------
886
887 //-------------------------------------------------------------------------------------------
888 void GetOptions(out array<ref SCR_LocalizedProperty> options)
889 {
890 for (int i = 0, count = m_aOptions.Count(); i < count; i++)
891 {
892 options.Insert(m_aOptions[i]);
893 }
894 }
895};
896
897//-------------------------------------------------------------------------------------------
901{
902 [Attribute("1")]
903 protected bool m_bCycle;
904
906
907 //-------------------------------------------------------------------------------------------
908 override protected void SetupHandlers()
909 {
910 super.SetupHandlers();
912
913 if (!m_SpinBox)
914 return;
915
916 m_SpinBox.SetCycleMode(m_bCycle);
917 }
918
919 //-------------------------------------------------------------------------------------------
920 override void SetValue(string str)
921 {
922 if (m_SpinBox)
923 m_SpinBox.SetCurrentItem(str.ToInt());
924 }
925
926 //-------------------------------------------------------------------------------------------
928 {
929 return m_SpinBox;
930 }
931}
932
933//-------------------------------------------------------------------------------------------
935class SCR_WidgetListEntryBoolSpinBox : SCR_WidgetListEntrySpinBox
936{
937 [Attribute("0", desc: "Revert item reading order*")]
938 protected bool m_bReversed;
939
940 //-------------------------------------------------------------------------------------------
941 override protected void SetupHandlers()
942 {
943 if (m_ChangeableComponent)
944 m_Selection = SCR_SelectionWidgetComponent.Cast(m_ChangeableComponent);
945
946 if (!m_Selection)
947 return;
948
949 // Fill values
950 if (m_bReversed)
951 {
952 for (int i = m_aOptions.Count() - 1; i >= 0; i--)
953 {
954 m_Selection.AddItem(m_aOptions[i].m_sLabel);
955 }
956 }
957 else
958 {
959 for (int i = 0, count = m_aOptions.Count(); i < count; i++)
960 {
961 m_Selection.AddItem(m_aOptions[i].m_sLabel);
962 }
963 }
964
965 // Select default value
966 if (!m_sDefaultValue.IsEmpty())
967 SelectOption(m_sDefaultValue.ToInt());
968
969 // Spinbox
970 m_SpinBox = SCR_SpinBoxComponent.Cast(m_Selection);
971
972 if (!m_SpinBox)
973 return;
974
976 }
977
978 //-------------------------------------------------------------------------------------------
979 override void SetValue(string str)
980 {
981 int value = str.ToInt();
982 if (m_bReversed)
983 {
984 if (value == 0)
985 value = 1;
986 else if (value == 1)
987 value = 0;
988 }
989
990 if (m_SpinBox)
992 }
993}
994
995//-------------------------------------------------------------------------------------------
998class SCR_WidgetListEntrySlider : SCR_WidgetListEntry
999{
1000 [Attribute()]
1001 protected float m_fMin;
1002
1003 [Attribute()]
1004 protected float m_fMax;
1005
1006 [Attribute("0.05")]
1007 protected float m_fStep;
1008
1009 [Attribute("%1")]
1010 protected string m_sFormatText;
1011
1012 protected SCR_SliderComponent m_Slider;
1013
1014 //-------------------------------------------------------------------------------------------
1015 override protected void SetupHandlers()
1016 {
1017 if (m_ChangeableComponent)
1018 m_Slider = SCR_SliderComponent.Cast(m_ChangeableComponent);
1019
1020 m_Slider.SetMin(m_fMin);
1021 m_Slider.SetMax(m_fMax);
1022 m_Slider.SetStep(m_fStep);
1023 m_Slider.SetFormatText(m_sFormatText);
1024
1025 m_Slider.SetValue(m_sDefaultValue.ToFloat());
1026 }
1027
1028 //-------------------------------------------------------------------------------------------
1029 override void SetValue(string str)
1030 {
1031 if (!m_Slider)
1032 return;
1033
1034 m_Slider.SetValue(str.ToFloat());
1035 }
1036
1037 //-------------------------------------------------------------------------------------------
1038 override string ValueAsString()
1039 {
1040 if (!m_Slider)
1041 return INVALID_VALUE;
1042
1043 return m_Slider.GetValue().ToString();
1044 }
1045
1046 //-------------------------------------------------------------------------------------------
1047 void SetRange(float min, float max)
1048 {
1049 m_Slider.SetMin(min);
1050 m_Slider.SetMax(max);
1051 }
1052};
AddonBuildInfoTool id
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_BaseEditorAttributeEntryUIInfo m_fMin
float m_fStep
UI layouts Menus CleanSweep CleanSweepAreaSelection layout
void SetRange(float range)
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
SCR_WidgetListEntryEditBox BaseContainerProps
SCR_SpinBoxComponent m_SpinBox
bool m_bCycle
Object holding reference to resource. In destructor release the resource.
Definition Resource.c:25
Base class for all widgets that can change their internal state as editbox or spinbox.
Variable that is using localized label.
Displays label and value name for variable with localization.
override bool _WB_GetCustomTitle(BaseContainer source, out string title)
int AddItem(string item, bool last=false, Managed data=null)
bool SetCurrentItem(int i, bool playSound=false, bool animate=false)
void SetFormatText(string text)
void SetValue(float value)
override bool SetCurrentItem(int i, bool playSound=false, bool animate=false)
void SetCycleMode(bool cycle)
void SetMessage(string message)
Configurable widget list entry for various value that can be typed - numbers, strings,...
string m_sCharBlackList
void SetupHandlers()
void ClearInvalidInput()
void SetCharLists()
EditBoxFilterComponent m_Filter
SCR_EditBoxComponent m_EditBox
override void SetValue(string str)
override void RemoveWidget()
void OnEditModeLeave(string text)
bool m_bBlacklistIsWhiteList
SCR_EditBoxComponent GetEditBoxComponent()
void OnInvalidInput()
void UpdateEditBoxText()
EJsonApiStructValueType m_iEditType
string m_sCurrentValue
void OnEditBoxTextChange(string text)
string m_sWarningText
int m_CharLimit
bool m_bShowWriteIcon
SCR_WidgetEditFormat GetFormatCheck()
string m_sObfuscation
string m_sPlaceholderText
void InvokeInvalidInput()
void CheckEditBoxValidity(SCR_EditBoxComponent editBox, string value)
Check if input is right, otherwise show warning.
void SetWarningText(string warning)
float m_fCustomHeight
int m_fClearErrorTimes
bool m_bUseFormatWarning
override string ValueAsString()
override bool CheckValidity()
ref SCR_WidgetEditFormat m_FormatCheck
IP specific entry.
SCR_WidgetEditFormatIP m_IPCheck
void SetupHandlers()
override bool CheckValidity()
ref array< ref SCR_WidgetListEntry > m_aEntries
string GetTag()
string m_sTag
Configurable class for widget.
Widget GetEntryRoot()
void CreateWidget(Widget parent)
static SCR_ConfigListEntries GetEntriesDefinitions(ResourceName presetsResourceName)
string m_sDefaultValue
void SetupHandlers()
Empty function to override to assing custom handlers.
void SetLabel(string label)
string GetGroupTag()
ResourceName GetEntryLayout()
void SetGroupTag(string tag)
const string INVALID_VALUE
bool GetVisible()
void RemoveWidget()
ResourceName m_sEntryLayout
SCR_ChangeableComponentBase m_ChangeableComponent
string ValueAsString()
Return value from widget in string format.
void SetEntryLayout(ResourceName layout)
void SetInteractive(bool interactive)
Can value be interacted - set handler enabled.
EJsonApiStructValueType GetType()
string m_sGroupTag
bool CanSkip()
Can skip return true if input is empty and value is not required.
Widget m_EntryRoot
EJsonApiStructValueType m_iType
bool m_bInteractive
string m_sPropertyName
void SetValue(string str)
string m_sClassTag
string GetLabel()
void SetPropertyName(string propertyName)
bool CheckValidity()
Default validity for majority of inputs will be true.
const ResourceName ENTRY_DEFINITIONS
bool m_bValidInput
void SetVisible(bool show)
string GetPropertyName()
string m_sLabel
bool m_bRequired
bool m_bShow
bool IsInputValid()
string m_sMessage
override void SetValue(string str)
Apply value to message.
override string ValueAsString()
Return message.
override void CreateWidget(Widget parent)
SCR_SimpleEntryComponent m_SimpleEntry
Configurable widget list entry list selection.
override string ValueAsString()
SCR_SelectionWidgetComponent GetSelectionComponent()
ref array< ref SCR_LocalizedProperty > m_aOptions
void SetupHandlers()
int ValueId()
Get selected value as id.
void GetOptions(out array< ref SCR_LocalizedProperty > options)
SCR_LocalizedProperty GetSelectedOption()
Return current selected option as full localized property.
void SetOptions(array< ref SCR_LocalizedProperty > options)
Fill list with options.
SCR_SelectionWidgetComponent m_Selection
Configurable widget list entry selection specific for spinbox.
bool m_bCycle
override void SetValue(string str)
SCR_SpinBoxComponent m_SpinBox
void SetupHandlers()
SCR_SpinBoxComponent GetSpinBox()
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
SCR_FieldOfViewSettings Attribute