{"name":"BIS_fnc_configViewer","title":"BIS fnc configViewer","type":"function","url":"https://community.bistudio.com/wiki/BIS_fnc_configViewer","revid":348118,"updated":"2023-11-08T11:32:17Z","groups":["Diagnostic"],"status":"ok","games":{"arma2oa":"1.50","tkoh":"1.00","arma3":"0.50"},"since":"arma2oa 1.50","arma3_since":"0.50","description":"Opens the Splendid™ Config Viewer.","syntaxes":[{"syntax":"[parent, cfg, showOk, onSelect, onAdd, header] call BIS_fnc_configViewer","params":[{"name":"parent","type":"Display","optional":true,"default":"mission display","description":"parent display","type_expr":"Display","text":"parent: Display - (Optional, default mission display) parent display"},{"name":"cfg","type":"Config","optional":true,"default":"all configs","description":"root config","type_expr":"Config","text":"cfg: Config - (Optional, default all configs) root config"},{"name":"showOk","type":"Boolean","optional":true,"default":"false","description":"true to display OK button. Script will then wait until viewer is closed and return selected class and param","type_expr":"Boolean","text":"showOk: Boolean - (Optional, default false) true to display OK button. Script will then wait until viewer is closed and return selected class and param"},{"name":"onSelect","type":"Code","optional":true,"default":"{}","description":"executed upon selecting a class. **Must return String**, which will be shown as structured text instead of params. Currently evaluated config is passed in the `_this` variable.","type_expr":"Code","text":"onSelect: Code - (Optional, default {}) executed upon selecting a class. **Must return String**, which will be shown as structured text instead of params. Currently evaluated config is passed in the `_this` variable."},{"name":"onAdd","type":"Code","optional":true,"default":"{}","description":"executed upon adding a class to list. Returned value (STRING) is item text. Empty string will skip the item. Currently evaluated config is passed in the `_this` variable.","type_expr":"Code","text":"onAdd: Code - (Optional, default {}) executed upon adding a class to list. Returned value (STRING) is item text. Empty string will skip the item. Currently evaluated config is passed in the `_this` variable."},{"name":"header","type":"String","optional":true,"default":"\"%1\"","description":"custom header. Use %1 to refer to original name (\"Splendid Config Viewer\")","type_expr":"String","text":"header: String - (Optional, default \"%1\") custom header. Use %1 to refer to original name (\"Splendid Config Viewer\")"}],"returns":{"type":"Array","type_expr":"Array","description":"- When OK button is not displayed, empty array is returned - Else, an array of currently selected entries in format [class (Config), param (String)] is returned.","text":"Array\n\n- When OK button is not displayed, empty array is returned\n- Else, an array of currently selected entries in format [class (Config), param (String)] is returned."}}],"examples":[{"code":["call BIS_fnc_configViewer;"]},{"text":"```sqf\nprivate _return = [\n    nil,\n    configFile >> \"CfgWeapons\",\n    true,\n    nil,\n    {\n        params [\"_cfg\"];\n        if (\n            getNumber(_cfg >> \"scope\") == 2 &&\n            { // Layzy evaluation\n                getNumber(_cfg >> \"type\") in [1,2,4] && // primary, secondary, handgun weapons\n                { !isClass (_cfg >> \"LinkedItems\") or getText(_cfg >> \"baseWeapon\") == configName _cfg } // only base weapons, no accessories\n            }\n        ) exitWith {\n            [_cfg] call BIS_fnc_displayName; // add the weapon with its displayname\n        };\n        \"\" // don't add\n    },\n    \"Select Weapon\"\n] call BIS_fnc_configViewer;\n_cfgSelected = _return param [0, configNull];\nsystemChat str [configName _cfgSelected, _cfgSelected];\n```","code":["private _return = [\n\tnil,\n\tconfigFile >> \"CfgWeapons\",\n\ttrue,\n\tnil,\n\t{\n\t\tparams [\"_cfg\"];\n\t\tif (\n\t\t\tgetNumber(_cfg >> \"scope\") == 2 &&\n\t\t\t{ // Layzy evaluation\n\t\t\t\tgetNumber(_cfg >> \"type\") in [1,2,4] && // primary, secondary, handgun weapons\n\t\t\t\t{ !isClass (_cfg >> \"LinkedItems\") or getText(_cfg >> \"baseWeapon\") == configName _cfg } // only base weapons, no accessories\n\t\t\t}\n\t\t) exitWith {\n\t\t\t[_cfg] call BIS_fnc_displayName; // add the weapon with its displayname\n\t\t};\n\t\t\"\" // don't add\n\t},\n\t\"Select Weapon\"\n] call BIS_fnc_configViewer;\n_cfgSelected = _return param [0, configNull];\nsystemChat str [configName _cfgSelected, _cfgSelected];"]}],"see_also":["BIS_fnc_animViewer","BIS_fnc_help"]}