fn_getSettings.sqf 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. Name: cTab_fnc_getSettings
  3. Author(s):
  4. Gundy
  5. Description:
  6. Read cTab settings
  7. Parameters:
  8. 0: STRING - Name of uiNamespace display / dialog variable
  9. (Optional)
  10. 1: STRING - Name of individual property to read
  11. Returns:
  12. (If only parameter 0 is specified)
  13. ARRAY - All property pairs for that display / dialog are returned, like so: [["propertyName1",propertyValue1],["propertyName2",propertyValue2]]
  14. If the uiNamespace variable cannot be found in cTabDisplayPropertyGroups, nil is returned.
  15. (If parameter 1 is specified)
  16. ANY - Value of individual property, nil if it does not exist
  17. Example:
  18. // Return all settings for Tablet
  19. ["cTab_Tablet_dlg"] call cTab_fnc_getSettings;
  20. // Return available map types for Tablet
  21. ["cTab_Tablet_dlg","mapTypes"] call cTab_fnc_getSettings;
  22. */
  23. private ["_propertyGroupName","_commonProperties","_groupProperties","_combinedProperties","_property","_value"];
  24. _propertyGroupName = [cTabDisplayPropertyGroups,_this select 0] call cTab_fnc_getFromPairs;
  25. // Exit with nil if uiNamespace variable cannot be found in cTabDisplayPropertyGroups
  26. if (isNil "_propertyGroupName") exitWith {nil};
  27. // Fetch common and interface group specific property pairs
  28. _commonProperties = [cTabSettings,"COMMON"] call cTab_fnc_getFromPairs;
  29. _groupProperties = [cTabSettings,_propertyGroupName] call cTab_fnc_getFromPairs;
  30. if (isNil "_groupProperties") then {_groupProperties = [];};
  31. // Return value of requested property
  32. _property = _this select 1;
  33. if (count _this == 2) exitWith {
  34. _value = [_groupProperties,_property] call cTab_fnc_getFromPairs;
  35. if (isNil "_value") then {
  36. _value = [_commonProperties,_property] call cTab_fnc_getFromPairs;
  37. };
  38. if (isNil "_value") then {nil} else {_value}
  39. };
  40. // Return list of all property pairs
  41. _combinedProperties = [] + _commonProperties;
  42. {
  43. [_combinedProperties,_x select 0,_x select 1] call BIS_fnc_setToPairs;
  44. } forEach _groupProperties;
  45. _combinedProperties