Improve overhead reduction

This commit is contained in:
SilentSpike 2015-07-19 23:03:40 +01:00
parent e09342b7ea
commit 08d5a8364f
4 changed files with 20 additions and 23 deletions

View File

@ -23,7 +23,7 @@ params ["_display"];
if (isNull _display) exitWith { [_this select 1] call CBA_fnc_removePerFrameHandler; };
// Reduce overhead when compass is hidden
if !(GVAR(showComp) && GVAR(showInterface)) exitWith {};
if !(ctrlShown (_display displayCtrl IDC_COMP)) exitWith {};
private ["_compass","_NE","_ES","_SW","_WN","_compassW","_degree","_heading","_offset","_positions","_sequence"];

View File

@ -274,17 +274,14 @@ switch (toLower _mode) do {
};
};
case "onunitsupdate": {
_args params ["_display"];
private ["_ctrl","_curSelData","_cachedGrps","_grp","_node","_side","_index"];
// Fetch tree
_ctrl = _display displayCtrl IDC_UNIT;
_args params ["_tree"];
private ["_curSelData","_cachedGrps","_grp","_node","_side","_index"];
// Cache current selection
_curSelData = _ctrl tvData (tvCurSel _ctrl);
_curSelData = _tree tvData (tvCurSel _tree);
// Clear the tree
tvClear _ctrl;
tvClear _tree;
// Update the tree from the unit list
_cachedGrps = [];
@ -294,31 +291,31 @@ switch (toLower _mode) do {
// If group already exists, find existing node
if !(_grp in _cachedGrps) then {
_side = [west,east,resistance,civilian,sideLogic] find (side _grp);
_node = _ctrl tvCount [];
_node = _tree tvCount [];
_ctrl tvAdd [[], groupID _grp];
_ctrl tvSetValue [[_node], _side];
_tree tvAdd [[], groupID _grp];
_tree tvSetValue [[_node], _side];
_cachedGrps pushBack _grp;
} else {
_node = _cachedGrps find _grp;
};
_index = _ctrl tvCount [_node];
_index = _tree tvCount [_node];
_ctrl tvAdd [[_node], name _x];
_ctrl tvSetData [[_node,_index], netID _x];
_tree tvAdd [[_node], name _x];
_tree tvSetData [[_node,_index], netID _x];
// Preserve the previous selection
if (_curSelData == (_ctrl tvData [_node,_index])) then {
_ctrl tvSetCurSel [_node,_index];
if (_curSelData == (_tree tvData [_node,_index])) then {
_tree tvSetCurSel [_node,_index];
};
_ctrl tvSort [[_node],false];
_ctrl tvExpand [_node];
_tree tvSort [[_node],false];
_tree tvExpand [_node];
} forEach GVAR(unitList);
// Sort group nodes by side
_ctrl tvSortByValue [[],false];
_tree tvSortByValue [[],false];
};
};

View File

@ -31,9 +31,10 @@ GVAR(camera) camSetFov -(linearConversion [0.1,2,GVAR(camZoom),-2,-0.1,true]);
GVAR(camera) camCommit 0;
// Reduce overhead when toolbar is hidden
if !(GVAR(showTool) && GVAR(showInterface)) exitWith {};
if !(ctrlShown (_display displayCtrl IDC_TOOL)) exitWith {};
private ["_name","_focus","_fov","_speed","_mode","_time","_toolbar"];
_toolbar = _display displayCtrl IDC_TOOL;
// Find all tool values
if (GVAR(camMode) == 0) then {
@ -52,7 +53,6 @@ _mode = ["FREE","FIRST","THIRD"] select GVAR(camMode);
_time = [daytime,"HH:MM"] call BIS_fnc_timeToString;
// Update the UI tools
_toolbar = _display displayCtrl IDC_TOOL;
(_toolbar controlsGroupCtrl IDC_TOOL_CLOCK) ctrlSetText _time;
(_toolbar controlsGroupCtrl IDC_TOOL_FOCUS) ctrlSetText _focus;
(_toolbar controlsGroupCtrl IDC_TOOL_FOV) ctrlSetText _fov;

View File

@ -32,7 +32,7 @@ if !(GVAR(camUnit) in GVAR(unitList)) then {
};
// Reduce overhead when unit tree is hidden
if (GVAR(showUnit) && GVAR(showInterface)) then {
if (ctrlShown (_display displayCtrl IDC_UNIT)) then {
// Reduce overhead by spreading across frames
[FUNC(handleInterface),["onUnitsUpdate",[_display]],1] call EFUNC(common,waitAndExecute);
[FUNC(handleInterface),["onUnitsUpdate",[_display displayCtrl IDC_UNIT]],1] call EFUNC(common,waitAndExecute);
};