Skip to content

Commit

Permalink
Minor performance tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
diwako committed Feb 4, 2019
1 parent eac384a commit 1463f9e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
6 changes: 2 additions & 4 deletions mod/functions/fn_compass.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ diwako_dui_compass_pfHandle = [{
_dirCtrl ctrlSetText "";
};


private _usedCtrls = [];
private _ctrls = _ctrlGrp getVariable ["diwako_dui_ctrlArr",[]];
private _playerDir = getDir _player;
Expand All @@ -63,12 +62,11 @@ diwako_dui_compass_pfHandle = [{
_usedCtrls pushBack ([_x, _display, _dir, _playerDir, _player, _ctrlGrp] call diwako_dui_fnc_displayUnitOnCompass);
} forEach _grp;

private _unusedCtrls = _ctrls - _usedCtrls;
{
ctrlDelete _x;
} forEach _unusedCtrls;
} forEach (_ctrls - _usedCtrls);

(_display displayCtrl IDC_COMPASS_CTRLGRP) setVariable ["diwako_dui_ctrlArr",_usedCtrls];
_ctrlGrp setVariable ["diwako_dui_ctrlArr",_usedCtrls];

if !(isNil "diwako_dui_custom_code") then {
/*
Expand Down
10 changes: 4 additions & 6 deletions mod/functions/fn_displayUnitOnCompass.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ if (diwako_dui_enable_occlusion && {_fade > 0}) then {
};
};

private _ctrl = _ctrlGrp getVariable [("diwako_dui_ctrl_unit_" + str _unitID), controlNull];
private _ctrl = _ctrlGrp getVariable [format ["diwako_dui_ctrl_unit_%1", _unitID], controlNull];

if (_fade <= 0) exitWith {
if (isNull _ctrl) exitWith {controlNull};
Expand All @@ -65,7 +65,7 @@ private _divisor = linearConversion [35,50,_circleRange,2.25,2.75,false] / diwak

if (isNull _ctrl) then {
_ctrl = _display ctrlCreate ["RscPicture", -1, _ctrlGrp];
_ctrlGrp setVariable [("diwako_dui_ctrl_unit_" + str _unitID), _ctrl];
_ctrlGrp setVariable [format ["diwako_dui_ctrl_unit_%1", _unitID], _ctrl];

private _ctrlArr = _ctrlGrp getVariable ["ctrl_diw_ctrlArr", nil];
if (isNil "_ctrlArr") then {
Expand All @@ -76,19 +76,17 @@ if (isNull _ctrl) then {
};

ctrlPosition _ctrlGrp params ["_left", "_top", "_width", "_height"];
private _center = [_left + _width/2, _top + _height/2];
private _dist = _distance / linearConversion [15,50,_circleRange,40,145,false];
private _iconScale = diwako_dui_compass_icon_scale;
private _newWidth = (44 * pixelW) /_divisor * _iconScale;
private _newHeight = (44 * pixelH) /_divisor * _iconScale;
private _ctrlPos = [

_ctrl ctrlSetPosition [
_width/2 + _width * (sin _relDir * _dist) - _newWidth/2,
_height/2 - _height * (cos _relDir * _dist) - _newHeight/2,
_newWidth,
_newHeight
];

_ctrl ctrlSetPosition _ctrlPos;
_ctrl ctrlSetAngle [_dir,0.5,0.5,false];
_ctrl ctrlCommit 0;

Expand Down

0 comments on commit 1463f9e

Please sign in to comment.