Improved side handling in unit tree

This commit is contained in:
SilentSpike 2015-07-21 21:21:46 +01:00
parent ec58c0061a
commit 53dc519336

View File

@ -266,7 +266,7 @@ switch (toLower _mode) do {
}; };
case "onunitsupdate": { case "onunitsupdate": {
_args params ["_tree"]; _args params ["_tree"];
private ["_curSelData","_cachedGrps","_grp","_sNode","_gNode","_uNode"]; private ["_curSelData","_cachedGrps","_cachedSides","_grp","_side","_sNode","_gNode","_uNode"];
// Cache current selection // Cache current selection
_curSelData = _tree tvData (tvCurSel _tree); _curSelData = _tree tvData (tvCurSel _tree);
@ -274,20 +274,24 @@ switch (toLower _mode) do {
// Clear the tree // Clear the tree
tvClear _tree; tvClear _tree;
// Add side nodes
{
_tree tvAdd [[], _x];
_tree tvExpand [_forEachIndex];
} forEach ["West","East","Resistance","Civilian","Unknown"];
// Update the tree from the unit list // Update the tree from the unit list
_cachedGrps = []; _cachedGrps = [];
_cachedSides = [];
{ {
_grp = group _x; _grp = group _x;
_side = WFSideText side _grp;
// Use correct side node // Use correct side node
_sNode = [west,east,resistance,civilian] find (side _grp); if !(_side in _cachedSides) then {
if (_sNode == -1) then { _sNode = 4 }; // Add side node
_sNode = _tree tvAdd [[], _side];
_cachedSides pushBack _side;
_cachedSides pushBack _sNode;
} else {
// If side already processed, use existing node
_sNode = _cachedSides select ((_cachedSides find _side) + 1);
};
// Use correct group node // Use correct group node
if !(_grp in _cachedGrps) then { if !(_grp in _cachedGrps) then {
@ -313,7 +317,14 @@ switch (toLower _mode) do {
_tree tvExpand [_sNode,_gNode]; _tree tvExpand [_sNode,_gNode];
} forEach GVAR(unitList); } forEach GVAR(unitList);
{ _tree tvSort [[_x], false]; } forEach [0,1,2,3,4]; {
if (typeName _x == "SCALAR") then {
_tree tvSort [[_x],false];
_tree tvExpand [_x];
};
} forEach _cachedSides;
_tree tvSort [[],false];
}; };
// Map events // Map events
case "onmapdblclick": { case "onmapdblclick": {