Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_FieldManualPiece_ConfigEntry.c
Go to the documentation of this file.
1[BaseContainerProps(), SCR_BaseContainerLocalizedTitleField("m_sDisplayName", "Config Entry: %1")]
3{
4 [Attribute(uiwidget: UIWidgets.LocaleEditBox)]
5 protected string m_sDisplayName;
6
7 [Attribute(desc: "Config or Entity to parse", params: "conf et")]
9
10 [Attribute(defvalue:"path/to/entry", desc: "in format \"level1/level2/level3/entryName\", entry name is CASE-SENSITIVE for an Entity (see SCR_ConfigHelper.GetChildBaseContainer for more information about the format)")]
11 protected string m_sEntryPath;
12
13 [Attribute(desc: "Use %1 to display the entry's value")]
14 protected string m_sValueFormat;
15
16 [Attribute(defvalue: "{671572B5C56766B3}UI/layouts/Menus/FieldManual/Pieces/FieldManual_Piece_ConfigEntry.layout", uiwidget: UIWidgets.EditBoxWithButton, params: "layout")]
18
19 [Attribute(defvalue: "0", params: "-9 +9", desc: "move a number's decimal by # steps; -1 to the left, +1 to the right: -3 = divided by 1000, 6 = multiplied by one million, etc. Has no effects on other value types.")]
20 protected int m_iDecimalMove;
21
22 [Attribute(defvalue: "-1", params: "-1 5", desc: "decides a number's decimals. -1 = no decimals limit, 0 = rounded")]
23 protected int m_iFixedDecimals;
24
25 protected ref Resource m_Resource;
27
28 //------------------------------------------------------------------------------------------------
29 protected void InitContainerAndPaths()
30 {
31 if (m_ConfigPath.IsEmpty() || m_sEntryPath.IsEmpty())
32 return;
33
35 if (!m_Resource.IsValid())
36 {
37 m_Resource = null;
38 return;
39 }
40
41 m_BaseContainer = SCR_ConfigHelper.GetBaseContainerByPath(m_Resource, m_sEntryPath, true);
42
43 array<string> paths = {};
44 m_sEntryPath = SCR_ConfigHelper.SplitConfigPath(m_sEntryPath, paths, true); // note, m_sEntryPath gets recycled here
45 if (!m_ConfigPath.EndsWith(".et")) // .et entries are case-sensitive -and- .conf ones need ToLower
46 m_sEntryPath.ToLower();
47 }
48
49 //------------------------------------------------------------------------------------------------
50 override void CreateWidget(notnull Widget parent)
51 {
52 Widget createdWidget = GetGame().GetWorkspace().CreateWidgets(m_Layout, parent);
53 if (!createdWidget)
54 return;
55
56 TextWidget descriptionWidget = TextWidget.Cast(createdWidget.FindAnyWidget("Description"));
57 if (descriptionWidget)
58 descriptionWidget.SetText(m_sDisplayName);
59
60 TextWidget valueWidget = TextWidget.Cast(createdWidget.FindAnyWidget("Value"));
61 if (valueWidget)
62 SetConfigValue(valueWidget);
63 }
64
65 //------------------------------------------------------------------------------------------------
66 protected void SetConfigValue(notnull TextWidget valueWidget)
67 {
70
72 {
73 Print("Wrong config entry path | " + FilePath.StripPath(__FILE__) + ":" + __LINE__, LogLevel.WARNING);
74 valueWidget.SetText("-wrong config entry path provided-");
75 return;
76 }
77
78 int index = m_BaseContainer.GetVarIndex(m_sEntryPath);
79 DataVarType dataVarType = m_BaseContainer.GetDataVarType(index);
80
81 if (m_sValueFormat.Trim().IsEmpty())
82 m_sValueFormat = "%1";
83
84 switch (dataVarType)
85 {
86 case DataVarType.BOOLEAN:
87 bool value;
88 m_BaseContainer.Get(m_sEntryPath, value);
89 valueWidget.SetTextFormat(m_sValueFormat, value);
90 break;
91
92 case DataVarType.INTEGER:
93 case DataVarType.SCALAR:
94 float value;
95 m_BaseContainer.Get(m_sEntryPath, value);
97 value /= Math.Pow(10, -m_iDecimalMove);
98
99 valueWidget.SetTextFormat(m_sValueFormat, value.ToString(-1, m_iFixedDecimals));
100 break;
101
102 case DataVarType.STRING:
103 string value;
104 m_BaseContainer.Get(m_sEntryPath, value);
105 valueWidget.SetTextFormat(m_sValueFormat, value);
106 break;
107
108 case DataVarType.VECTOR3:
109 vector value;
110 m_BaseContainer.Get(m_sEntryPath, value);
111 valueWidget.SetTextFormat(m_sValueFormat, value);
112 break;
113
114 default:
115 Print("Missing DataVarType type: " + dataVarType + " | " + FilePath.StripPath(__FILE__) + ":" + __LINE__, LogLevel.WARNING);
116 valueWidget.SetTextFormat(m_sValueFormat, "-");
117 break;
118 }
119
120 if (m_sValueFormat == "%1")
121 m_sValueFormat = string.Empty;
122 }
123}
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
SCR_PlayerCommandingConfigActionPair Managed SCR_BaseContainerLocalizedTitleField("m_sCommandName")
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition Math.c:13
Object holding reference to resource. In destructor release the resource.
Definition Resource.c:25
static string SplitConfigPath(string input, out array< string > output, bool removeLastPart=false)
int m_iDecimalMove
string m_sDisplayName
int m_iFixedDecimals
ResourceName m_Layout
void InitContainerAndPaths()
ref Resource m_Resource
ResourceName m_ConfigPath
override void CreateWidget(notnull Widget parent)
string m_sEntryPath
string m_sValueFormat
BaseContainer m_BaseContainer
void SetConfigValue(notnull TextWidget valueWidget)
DataVarType
Definition DataVarType.c:18
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