Last active
June 9, 2018 20:42
-
-
Save commy2/50503a6032d88f4a0641b5c4e57813fa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// by commy2 | |
private _display = uiNamespace getVariable ["commy_fpsCounter", displayNull]; | |
if (!isNull _display) exitWith { | |
"commy_fpsCounter" cutText ["", "PLAIN"]; | |
false | |
}; | |
// canvas | |
"commy_fpsCounter" cutRsc ["RscTitleDisplayEmpty", "PLAIN", 0, false]; | |
private _display = uiNamespace getVariable "RscTitleDisplayEmpty"; | |
uiNamespace setVariable ["commy_fpsCounter", _display]; | |
private _vignette = _display displayCtrl 1202; | |
_vignette ctrlShow false; | |
// fps counter control | |
private _counter = _display ctrlCreate ["RscStructuredText", -1]; | |
_display setVariable ["commy_fpsCounter", _counter]; | |
private _size = safezoneW/10; | |
private _width = _size; | |
private _height = _size/2 * (getResolution#4); | |
private _left = safezoneX; | |
private _top = safezoneY; | |
_counter ctrlSetPosition [_left, _top, _width, _height]; | |
_counter ctrlCommit 0; | |
_counter setVariable ["commy_timeout", diag_tickTime]; | |
// draw script | |
private _script = _display ctrlCreate ["RscMapControl", -1]; | |
_script ctrlSetPosition [0,0,0,0]; | |
_script ctrlCommit 0; | |
_script ctrlAddEventHandler ["Draw", { | |
params ["_script"]; | |
private _counter = ctrlParent _script getVariable "commy_fpsCounter"; | |
if (diag_tickTime < _counter getVariable "commy_timeout") exitWith {}; | |
_counter setVariable ["commy_timeout", diag_tickTime + 1/3]; | |
private _fps = floor diag_fps; | |
_counter ctrlSetStructuredText parseText format ["<t size='%1'>%2</t>", 2 * 0.85/(getResolution#5), _fps]; | |
if (_fps < 10) exitWith { | |
_counter ctrlSetTextColor [1,0,0,0.8]; | |
}; | |
if (_fps < 20) exitWith { | |
_counter ctrlSetTextColor [1,1,0,0.8]; | |
}; | |
_counter ctrlSetTextColor [0,1,0,0.8]; | |
}]; | |
true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment