Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_JsonApiStructHandler.c
Go to the documentation of this file.
1
5
6
//------------------------------------------------------------------------------------------------
8
class
SCR_JsonApiStructHandler
9
{
10
//------------------------------------------------------------------------------------------------
12
static
void
StoreValue(
JsonApiStruct
json,
string
variableName,
string
value,
EJsonApiStructValueType
type
)
13
{
14
// Check json api struct
15
if
(!json || variableName.IsEmpty() || value.IsEmpty())
16
return
;
17
18
Print
(
string
.Format(
"store: %1 = %2 (%3)"
, variableName, value,
type
));
19
20
// Store valu based on type
21
switch
(
type
)
22
{
23
// Booleans
24
case
EJsonApiStructValueType
.TYPE_BOOL:
25
{
26
bool
bValue =
ToBool
(value);
27
json.StoreBoolean(variableName, bValue);
28
break
;
29
}
30
31
// Integers
32
case
EJsonApiStructValueType
.TYPE_INT:
33
{
34
int
iValue = value.ToInt();
35
json.StoreInteger(variableName, iValue);
36
break
;
37
}
38
39
// Floating decimals
40
case
EJsonApiStructValueType
.TYPE_FLOAT:
41
{
42
int
fValue = value.ToFloat();
43
json.StoreFloat(variableName, fValue);
44
break
;
45
}
46
47
// Strings
48
case
EJsonApiStructValueType
.TYPE_STRING:
49
{
50
json.StoreString(variableName, value);
51
break
;
52
}
53
}
54
}
55
56
//------------------------------------------------------------------------------------------------
57
protected
static
bool
ToBool
(
string
value)
58
{
59
return
value ==
"1"
|| value ==
"true"
;
60
}
61
62
//------------------------------------------------------------------------------------------------
63
static
bool
StringToBool
(
string
str)
64
{
65
switch
(str)
66
{
67
case
"true"
:
return
true
;
68
case
"false"
:
return
false
;
69
case
"1"
:
return
true
;
70
case
"0"
:
return
false
;
71
}
72
73
return
false
;
74
}
75
76
//------------------------------------------------------------------------------------------------
77
static
string
BoolToString
(
bool
boolean
)
78
{
79
if
(
boolean
)
80
return
"1"
;
81
82
return
"0"
;
83
}
84
};
85
86
//------------------------------------------------------------------------------------------------
87
enum
EJsonApiStructValueType
88
{
89
TYPE_BOOL
,
90
TYPE_INT
,
91
TYPE_FLOAT
,
92
TYPE_STRING
,
93
};
94
95
//------------------------------------------------------------------------------------------------
97
class
SCR_CombinedDSConfig
98
{
99
// Consts
100
protected
const
string
DEFAULT_CONFIG_NAME
=
"Server setup"
;
101
102
// Attributes
103
[
Attribute
(
"config"
,
UIWidgets
.EditBox,
"Group tag name for base server configuration"
)]
104
protected
string
m_sCategoryConfig
;
105
106
[
Attribute
(
""
,
UIWidgets
.EditBox,
"Group tag name for generic game settings"
)]
107
protected
string
m_sCategoryGameConfig
;
108
109
[
Attribute
(
""
,
UIWidgets
.EditBox,
"Group tag name for specific game (scenario) properties"
)]
110
protected
string
m_sCategoryGameProperties
;
111
112
// File properties
113
protected
string
m_sConfigName
;
114
115
// Config properties containers
116
protected
ref
SCR_DSConfig
m_DSConfig
=
new
SCR_DSConfig
();
// Config base
117
protected
ref
DSGameConfig
m_DSGameConfig
=
new
DSGameConfig
();
// Generic game settings
118
protected
ref DSGameProperties
m_DSGameProperties
=
new
DSGameProperties();
// Scenario
119
protected
ref array<DSMod>
m_aMods
= {};
120
121
// Unified entries
122
protected
ref array<ref Tuple2<string, ref SCR_WidgetListEntry>>
m_aDSConfigEntries
= {};
// string - tag
123
124
//------------------------------------------------------------------------------------------------
126
void
DefineEntriesMap
(array<ref SCR_WidgetListEntry> entries)
127
{
128
for
(
int
i = 0, count = entries.Count(); i < count; i++)
129
{
130
m_aDSConfigEntries
.Insert(
131
new
Tuple2<string, ref SCR_WidgetListEntry>(
132
entries[i].GetGroupTag(),
133
entries[i]
134
)
135
);
136
}
137
}
138
139
//------------------------------------------------------------------------------------------------
140
// Store value API
141
//------------------------------------------------------------------------------------------------
142
143
//------------------------------------------------------------------------------------------------
145
void
StoreCategoryToJson
(
JsonApiStruct
json,
string
tag)
146
{
147
for
(
int
i = 0, count =
m_aDSConfigEntries
.Count(); i < count; i++)
148
{
149
// Skip different tag
150
if
(
m_aDSConfigEntries
[i].
param1
!= tag)
151
continue
;
152
153
SCR_WidgetListEntry
entry =
m_aDSConfigEntries
[i].param2;
154
155
// Store value
156
SCR_JsonApiStructHandler
.StoreValue(
157
json,
158
entry.
GetPropertyName
(),
159
entry.
ValueAsString
(),
160
entry.
GetType
()
161
);
162
163
/*
164
Print(string.Format(
165
"Save - %1 > %2 : %3",
166
m_aDSConfigEntries[i].param1,
167
entry.GetPropertyName(),
168
entry.ValueAsString()
169
));
170
*/
171
}
172
}
173
174
//------------------------------------------------------------------------------------------------
176
void
StoreFullJson
()
177
{
178
//Print("-------------------------------------");
179
180
for
(
int
i = 0, count =
m_aDSConfigEntries
.Count(); i < count; i++)
181
{
182
SCR_WidgetListEntry
entry =
m_aDSConfigEntries
[i].param2;
183
if
(!entry)
184
continue
;
185
186
// Debug
187
//Print(entry.GetPropertyName() + " : " + entry.ValueAsString());
188
}
189
190
//Print("-------------------------------------");
191
}
192
193
//------------------------------------------------------------------------------------------------
194
// Protected
195
//------------------------------------------------------------------------------------------------
196
197
//------------------------------------------------------------------------------------------------
199
protected
string
DefaultConfigName
()
200
{
201
string
name =
DEFAULT_CONFIG_NAME
;
202
203
// Todo: counting and comparing of config names
204
205
return
name;
206
}
207
};
type
EDamageType type
Definition
SCR_DestructibleTreeV2.c:32
EJsonApiStructValueType
EJsonApiStructValueType
Definition
SCR_JsonApiStructHandler.c:88
TYPE_FLOAT
@ TYPE_FLOAT
Definition
ServerBrowserFiltering.c:638
TYPE_BOOL
@ TYPE_BOOL
Definition
ServerBrowserFiltering.c:636
TYPE_INT
@ TYPE_INT
Definition
ServerBrowserFiltering.c:637
TYPE_STRING
@ TYPE_STRING
Definition
ServerBrowserFiltering.c:639
DSGameConfig
Definition
DSConfig.c:2
JsonApiStruct
base classes for filtering in server browser
Definition
SCR_FeedbackDialogUI.c:3
SCR_CombinedDSConfig
Script class aggregating all dedicated server config part together.
Definition
SCR_JsonApiStructHandler.c:98
SCR_CombinedDSConfig::StoreFullJson
void StoreFullJson()
Store values for all categories.
Definition
SCR_JsonApiStructHandler.c:176
SCR_CombinedDSConfig::m_sCategoryConfig
string m_sCategoryConfig
Definition
SCR_JsonApiStructHandler.c:104
SCR_CombinedDSConfig::m_sCategoryGameProperties
string m_sCategoryGameProperties
Definition
SCR_JsonApiStructHandler.c:110
SCR_CombinedDSConfig::DefaultConfigName
string DefaultConfigName()
Return default config name with number that should be unique to other other configs.
Definition
SCR_JsonApiStructHandler.c:199
SCR_CombinedDSConfig::DefineEntriesMap
void DefineEntriesMap(array< ref SCR_WidgetListEntry > entries)
Pass entries and define entries map.
Definition
SCR_JsonApiStructHandler.c:126
SCR_CombinedDSConfig::m_sConfigName
string m_sConfigName
Definition
SCR_JsonApiStructHandler.c:113
SCR_CombinedDSConfig::DEFAULT_CONFIG_NAME
const string DEFAULT_CONFIG_NAME
Definition
SCR_JsonApiStructHandler.c:100
SCR_CombinedDSConfig::m_DSConfig
ref SCR_DSConfig m_DSConfig
Definition
SCR_JsonApiStructHandler.c:116
SCR_CombinedDSConfig::m_DSGameConfig
ref DSGameConfig m_DSGameConfig
Definition
SCR_JsonApiStructHandler.c:117
SCR_CombinedDSConfig::m_aDSConfigEntries
ref array< ref Tuple2< string, ref SCR_WidgetListEntry > > m_aDSConfigEntries
Definition
SCR_JsonApiStructHandler.c:122
SCR_CombinedDSConfig::m_aMods
ref array< DSMod > m_aMods
Definition
SCR_JsonApiStructHandler.c:119
SCR_CombinedDSConfig::StoreCategoryToJson
void StoreCategoryToJson(JsonApiStruct json, string tag)
Store all values for selected category.
Definition
SCR_JsonApiStructHandler.c:145
SCR_CombinedDSConfig::m_DSGameProperties
ref DSGameProperties m_DSGameProperties
Definition
SCR_JsonApiStructHandler.c:118
SCR_CombinedDSConfig::m_sCategoryGameConfig
string m_sCategoryGameConfig
Definition
SCR_JsonApiStructHandler.c:107
SCR_DSConfig
Definition
SCR_DSConfig.c:6
SCR_JsonApiStructHandler
Handler for json api struct values.
Definition
SCR_JsonApiStructHandler.c:9
SCR_JsonApiStructHandler::BoolToString
static string BoolToString(bool boolean)
Definition
SCR_JsonApiStructHandler.c:77
SCR_JsonApiStructHandler::StringToBool
static bool StringToBool(string str)
Definition
SCR_JsonApiStructHandler.c:63
SCR_JsonApiStructHandler::ToBool
static bool ToBool(string value)
Definition
SCR_JsonApiStructHandler.c:57
SCR_WidgetListEntry
Configurable class for widget.
Definition
SCR_WidgetListEntry.c:116
SCR_WidgetListEntry::ValueAsString
string ValueAsString()
Return value from widget in string format.
SCR_WidgetListEntry::GetType
EJsonApiStructValueType GetType()
Definition
SCR_WidgetListEntry.c:270
SCR_WidgetListEntry::GetPropertyName
string GetPropertyName()
Definition
SCR_WidgetListEntry.c:246
UIWidgets
Definition
attributes.c:40
Print
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
param1
Tuple param1
scripts
Game
UI
Menu
ServerBrowser
ServerHosting
SCR_JsonApiStructHandler.c
Generated by
1.17.0