Atom_Monky 14 Posted April 15, 2020 Hi i wanted to ask how can i make a tree view list of objects like it is in the enden editor. what i currently found is snippets from other posts: h = [] spawn { disableSerialization; _display = findDisplay 46 createDisplay "RscDisplayEmpty"; _mod = _display ctrlCreate [ "RscCombo", 100 ]; _mod ctrlSetPosition[ 0, - 0.06, 1, 0.05 ]; _mod ctrlCommit 0; { _mod lbAdd format["Mod: %1",_x] } forEach ["Name 1","Name 2","Name 3"]; _mod lbSetCurSel 0; _tree = _display ctrlCreate [ "ctrlTree", 101 ]; _tree ctrlSetPosition[ 0, 0, 1, 1 ]; _tree ctrlCommit 0; tvClear _tree; _classes = 'true' configClasses (configFile >> 'CfgVehicles'); for '_i' from 0 to 10 do { _tree tvAdd [[], configName selectRandom _classes]; for '_j' from 0 to 10 do { _tree tvAdd [[_i], configName selectRandom _classes]; for '_k' from 0 to 10 do { _tree tvAdd [[_i, _j], configName selectRandom _classes]; }; }; }; }; can someone help me to ghet a list of all the mods and then only get the objects form the selected mod? thanks for your time Share this post Link to post Share on other sites
Larrow 2817 Posted April 16, 2020 (edited) Just something quickly cobbled together Spoiler h = [] spawn { disableSerialization; TAG_CfgWeaponTypes = [ ]; TAG_patches = []; { TAG_patches pushBack [ getText( _x >> "name" ), configName _x ]; }forEach( "isText( _x >> 'name' )" configClasses( configFile >> "CfgPatches" )); TAG_patches sort true; TAG_data = []; TAG_data resize count TAG_patches; { _childClass = _x; _index = TAG_patches findIf{ _x select 1 == getText( _childClass >> "addonRootClass" ) }; if ( _index > -1 ) then { if ( isNil{ TAG_data select _index } ) then { TAG_data set[ _index, [ [], [] ] ]; }; { if ( isClass( configFile >> "CfgVehicles" >> _x ) && { getNumber( configFile >> "CfgVehicles" >> _x >> "scope" ) isEqualTo 2 } ) then { ( TAG_data select _index select 0 ) pushBack _x; }; if ( isClass( configFile >> "CfgWeapons" >> _x ) && { getNumber( configFile >> "CfgWeapons" >> _x >> "scope" ) isEqualTo 2 } ) then { ( TAG_data select _index select 1 ) pushBack _x; }; }forEach ( getArray( _x >> "units" ) + getArray( _x >> "weapons" )); }; }forEach( "isText( _x >> 'addonRootClass' ) && ( isArray( _x >> 'units' ) || isArray( _x >> 'weapons' ) ) " configClasses( configFile >> "CfgPatches" )); { if ( isNil "_x" || { _x isEqualTo [[],[]] } ) then { TAG_patches set[ _forEachIndex, objNull ]; TAG_data set[ _forEachIndex, objNull ]; }; }forEach TAG_data; TAG_patches = TAG_patches - [ objNull ]; TAG_data = TAG_data - [ objNull ]; _display = findDisplay 46 createDisplay "RscDisplayEmpty"; _backGround = _display ctrlCreate[ "ctrlStaticPicture", -1 ]; _backGround ctrlSetPosition[ 0, 0, 1, 1 ]; _backGround ctrlSetText "#(argb,8,8,3)color(0.35,0.35,0.35,1)"; _backGround ctrlCommit 0; _mod = _display ctrlCreate[ "RscCombo", 100 ]; _mod ctrlSetPosition[ 0, -0.07, 1, 0.07 ]; _mod ctrlCommit 0; _tree = _display ctrlCreate [ "ctrlTree", 101 ]; _tree ctrlSetPosition[ 0, 0, 0.5, 1 ]; _tree ctrlCommit 0; _image = _display ctrlCreate [ "ctrlStaticPictureKeepAspect", 102 ]; _image ctrlSetPosition[ 0.5, 0, 0.5, 0.5 ]; _image ctrlCommit 0; { _index = _mod lbAdd ( _x select 0 ); _mod lbSetTextRight[ _index, ( _x select 1 ) ]; _mod lbSetColorRight[ _index, [ 1, 0, 0, 1 ] ]; }forEach TAG_patches; _mod ctrlAddEventHandler[ "LBSelChanged", { params[ "_mod", "_index" ]; _tree = ctrlParent _mod displayCtrl 101; tvClear _tree; _image = ctrlParent _mod displayCtrl 102; _image ctrlSetText "#(argb,8,8,3)color(0,0,0,1)"; _fnc_tvFindVehiclesCategory = { params[ "_item", "_path" ]; _itemCat = if ( isText( configFile >> "CfgVehicles" >> _x >> "editorCategory" ) ) then { _cat = getText( configFile >> "CfgVehicles" >> _x >> "editorCategory" ); getText( configFile >> "CfgEditorCategories" >> _cat >> "displayName" ); }else{ getText( configFile >> "CfgEditorCategories" >> "EdCat_Default" >> "displayName" ); }; _itemSubCat = if ( isText( configFile >> "CfgVehicles" >> _x >> "editorSubcategory" ) ) then { _cat = getText( configFile >> "CfgVehicles" >> _x >> "editorSubcategory" ); getText( configFile >> "CfgEditorSubcategories" >> _cat >> "displayName" ); }else{ getText( configFile >> "CfgEditorSubcategories" >> "EdSubcat_Default" >> "displayName" ); }; { _found = for "_i" from 0 to ( _tree tvCount _path ) do { if ( _tree tvText ( _path + [ _i ] ) == _x ) exitWith { _path = _path + [ _i ]; true }; }; if ( isNil "_found" ) then { private _index = _tree tvAdd[ _path, _x ]; _path = _path + [ _index ]; }; }forEach [ _itemCat, _itemSubCat ]; _path }; if !( TAG_data select _index select 0 isEqualTo [] ) then { _vehiclesPath = [ _tree tvAdd[ [], "CfgVehicles" ] ]; { _path = [ _x, _vehiclesPath ] call _fnc_tvFindVehiclesCategory; private _index = _tree tvAdd [ _path, getText( configFile >> "CfgVehicles" >> _x >> "displayName" ) ]; _tree tvSetData[ _path + [ _index ], getText( configFile >> "CfgVehicles" >> _x >> "editorPreview" ) ]; if ( isText( configFile >> "CfgVehicles" >> _x >> "DLC" ) ) then { _dlc = getText( configFile >> "CfgVehicles" >> _x >> "DLC" ); _picture = getText( configFile >> "CfgMods" >> _dlc >> "logSmall" ); if ( _picture != "" ) then { _tree tvSetPicture[ _path + [ _index ], _picture ]; }; }; }forEach ( TAG_data select _index select 0 ); }; _fnc_tvFindWeaponsCategory = { params[ "_item", "_path" ]; _itemCats = _item call BIS_fnc_itemType; { _found = for "_i" from 0 to ( _tree tvCount _path ) do { if ( _tree tvText ( _path + [ _i ] ) == _x ) exitWith { _path = _path + [ _i ]; true }; }; if ( isNil "_found" ) then { private _index = _tree tvAdd[ _path, _x ]; _path = _path + [ _index ]; }; }forEach _itemCats; _path }; if !( TAG_data select _index select 1 isEqualTo [] ) then { _weaponsPath = [ _tree tvAdd[ [], "CfgWeapons" ] ]; { _path = [ _x, _weaponsPath ] call _fnc_tvFindWeaponsCategory; _index = _tree tvAdd [ _path, getText( configFile >> "CfgWeapons" >> _x >> "displayName" ) ]; _tree tvSetData[ ( _path + [ _index ] ), getText( configFile >> "CfgWeapons" >> _x >> "picture" ) ]; }forEach ( TAG_data select _index select 1 ); }; }]; _tree ctrlAddEventHandler[ "TreeSelChanged", { params[ "_tree", "_path" ]; _image = ctrlParent _tree displayCtrl 102; _image ctrlSetText ( _tree tvData _path ); }]; _mod lbSetCurSel 0; }; Just run from the debug console in a mission preview. Should give you something to work from. Edited April 17, 2020 by Larrow Updated to split into editor categories 1 Share this post Link to post Share on other sites