Skip to content

Instantly share code, notes, and snippets.

@ConnorAU
Created January 29, 2020 21:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ConnorAU/77f9f50363f5d47ddf4f4ac9a7c7b7c6 to your computer and use it in GitHub Desktop.
Save ConnorAU/77f9f50363f5d47ddf4f4ac9a7c7b7c6 to your computer and use it in GitHub Desktop.
Generate a config of all display events in the arma 3 config file
/*──────────────────────────────────────────────────────┐
β”‚ Author: Connor β”‚
β”‚ Steam: https://steamcommunity.com/id/_connor β”‚
β”‚ Github: https://github.com/ConnorAU β”‚
β”‚ β”‚
β”‚ Please do not modify or remove this comment block β”‚
└──────────────────────────────────────────────────────*/
private _timeStartTick = diag_ticktime;
diag_log 'export start';
getTabs = {
_t = " ";
_a = [];
_a resize tab;
_a apply {""} joinstring _t;
};
tab = 0;
events = [
"onLoad",
"onUnload",
"onChildDestroyed",
"onMouseEnter",
"onMouseExit",
"onSetFocus",
"onKillFocus",
"onTimer",
"onKeyDown",
"onKeyUp",
"onChar",
"onIMEChar",
"onIMEComposition",
"onJoystickButton",
"onMouseButtonDown",
"onMouseButtonUp",
"onMouseButtonClick",
"onMouseButtonDblClick",
"onMouseMoving",
"onMouseHolding",
"onMouseZChanged",
"onCanDestroy",
"onDestroy",
"onButtonClick",
"onButtonDblClick",
"onButtonDown",
"onButtonUp",
"onLBSelChanged",
"onLBListSelChanged",
"onLBDblClick",
"onLBDrag",
"onLBDragging",
"onLBDrop",
"onTreeSelChanged",
"onTreeLButtonDown",
"onTreeDblClick",
"onTreeExpanded",
"onTreeCollapsed",
"onTreeMouseMove",
"onTreeMouseHold",
"onTreeMouseExit",
"onChecked",
"onCheckedChanged",
"onCheckBoxesSelChanged",
"onToolBoxSelChanged",
"onHTMLLink",
"onSliderPosChanged",
"onObjectMoved",
"onMenuSelected",
"onDraw",
"onVideoStopped"
] apply {tolower _x};
private _sortClasses = {
private _cfg = param [0,confignull];
private _out = [false,configname _cfg,[],[]];
_out set [2,[_cfg] call _sortProperties];
{
private _feOut = [false,configname _x,[],[]];
_feOut set [2,[_x] call _sortProperties];
{
private _fe2Out = [_x] call _sortClasses;
if (
count(_fe2Out select 2) > 0 OR
count(_fe2Out select 3) > 0
) then {_fe2Out set [0,true]};
if (_fe2Out select 0) then {
_feOut set [3,(_feOut select 3)+[_fe2Out]];
};
} foreach ('true' configclasses _x);
if (
count(_feOut select 2) > 0 OR
count(_feOut select 3) > 0
) then {_feOut set [0,true]};
if (_feOut select 0) then {
_out set [3,(_out select 3)+[_feOut]];
};
} foreach ('true' configclasses _cfg);
if (
count(_out select 2) > 0 OR
count(_out select 3) > 0
) then {_out set [0,true]};
_out
};
private _sortProperties = {
private _cfg = param [0,confignull];
private _out = [];
{
_name = configname _x;
_value = [_x] call BIS_fnc_getCfgData;
if !(_value isEqualTo "") then {
_out pushback [_name,_value];
};
}foreach configProperties[_cfg,'!isClass _x && {(tolower configName _x) in events}',true];
_out
};
private _makeName = {
params ['_name','_value'];
private _isArray = _value isEqualType [];
_value = switch true do {
case (_value isequaltype ''):{str _value};
case _isArray:{_value call _formatArray};
default{_value};
};
format['%4%1%2=%3;',_name,if _isArray then {'[]'} else {''},_value,call getTabs];
};
private _formatArray = {
private _out = [];
if (_this isEqualType []) then {
{
_out pushback (
switch true do {
case (_x isequaltype ""): {str _x};
case (_x isequaltype []): {_x call _formatArray};
default {_x};
}
);
} foreach _this;
} else {
_out pushback _this
};
["{",_out joinstring ",","}"] joinstring ""
};
private _buildCfg = {
params ['','_name','_prop','_subCfg'];
private _out = [];
tab = tab + 1;
_out pushback format['%2class %1 {',_name,call getTabs];
tab = tab + 1;
{_out pushback (_x call _makeName)} foreach _prop;
tab = tab - 1;
{_out append (_x call _buildCfg)} foreach (_subCfg select {_x param [0,false]});
_out pushback format["%1};",call getTabs];
tab = tab - 1;
_out
};
_cfgList = [configFile] call _sortClasses;
_cfgList set [1,"DEV"];
out = _cfgList call _buildCfg;
//copyToClipboard (out joinstring '');
"ExportConfigFile" callExtension ["WriteLine",[out joinstring endl]];
diag_log format['export end: %1 seconds',diag_ticktime - _timeStartTick];
"scp" servercommand "#shutdown";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment