Skip to content

Commit 2723f1b

Browse files
authored
Merge pull request #1823 from OverlordZorn/getCfgDataHashmap-toLoweransi
Common - Add parameter to fnc_getCfgDataHashmap: _toLower
2 parents 1b8e1c3 + 17a093d commit 2723f1b

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

addons/common/fnc_getCfgDataHashmap.sqf

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Function: CBA_fnc_getCfgDataHashmap
44
55
Description:
66
This function extracts all config properties of a class and returns them as a Hashmap with the properties as keys (string).
7-
7+
88
The following Values will be converted:
99
Boolean as String ("true", "false") will be converted to boolean data-type.
1010
@@ -15,6 +15,7 @@ Parameters:
1515
_condition - Condition for configProperties (optional, default: "true") <STRING>
1616
_inherit - include inherited properties (optional, default: true) <BOOL>
1717
_convert - convert certain values - see above (optional, default: true) <BOOL>
18+
_toLower - applies toLowerANSI to keys of hashmap (optional, default: false) <BOOL>
1819
1920
Returns:
2021
properties <HASHMAP> (or <NIL> if _cfg is invalid)
@@ -33,7 +34,8 @@ params [
3334
["_cfg", configNull, [configNull]],
3435
["_condition", "true", [""]],
3536
["_inherit", true, [true]],
36-
["_convert", true, [true]]
37+
["_convert", true, [true]],
38+
["_toLower", false, [true]]
3739
];
3840

3941
if !(isClass _cfg || { isNull _cfg } ) exitWith { nil };
@@ -75,15 +77,15 @@ private _convertCall = [
7577

7678

7779
{
78-
private _config = _x;
79-
80-
private _value = _x call BIS_fnc_getCfgData call _convertCall;
80+
private _cfg = _x;
81+
private _key = if (_toLower) then { toLowerANSI configName _cfg } else { configName _cfg };
82+
private _value = _cfg call BIS_fnc_getCfgData call _convertCall;
8183

8284
_returnHashMap set [
83-
configName _x,
85+
_key,
8486
_value
8587
];
86-
88+
8789
} forEach _properties;
8890

8991
_returnHashMap // return

0 commit comments

Comments
 (0)