Skip to content

Instantly share code, notes, and snippets.

@nomisum
Created November 6, 2021 13:29
Show Gist options
  • Save nomisum/0427261717b41a7fb71944a286a27bc5 to your computer and use it in GitHub Desktop.
Save nomisum/0427261717b41a7fb71944a286a27bc5 to your computer and use it in GitHub Desktop.
grad_funkspruchlängenmahnanzeige
GRAD_tfarTrainer_fnc_onPress = {
params ["_pressed"];
disableserialization;
private _control = uiNamespace getVariable ["GRAD_tfarTrainerControl", controlNull];
if (!_pressed) then {
if (!isNull _control) then { ctrldelete _control; };
} else {
if (isNull _control) then {
_control = (findDisplay 46) ctrlCreate ["RscText", -1];
_control ctrlSetPosition [
0.85 * safezoneW + safezoneX,
0.895 * safezoneH + safezoneY,
0.15 * safezoneW,
0.005 * safezoneH
];
_control ctrlSetBackgroundColor [1,0,0,1];
_control ctrlCommit 0;
uiNamespace setVariable ["GRAD_tfarTrainerControl", _control];
missionNamespace setVariable ["GRAD_tfarTrainerTime", time];
// hint "created";
[{
params ["_args", "_handle"];
_args params ["_control"];
disableserialization;
if (isNull _control) exitWith { [_handle] call CBA_fnc_removePerFrameHandler; };
private _timePressedStart = missionNamespace getVariable ["GRAD_tfarTrainerTime", time];
private _timeElapsed = time - _timePressedStart;
private _width = linearConversion [0, 5, _timeElapsed, 0, 0.15, true];
_control ctrlSetPosition [
0.85 * safezoneW + safezoneX,
0.895 * safezoneH + safezoneY,
_width * safezoneW,
0.005 * safezoneH
];
private _isEven = (floor (time)) % 2 == 0;
private _color = if (_width < 0.15) then { [0.1,1, 0.1,1] } else { [([0.5,1] select _isEven),0.1,0.1,1] };
_control ctrlSetBackgroundColor _color;
_control ctrlCommit 0;
// hint str _width;
}, 0, [_control]] Call CBA_fnc_addPerFrameHandler;
};
};
};
["talkLength", "OnTangent", {
params ["","","", "", "_pressed"];
[_pressed] call GRAD_tfarTrainer_fnc_onPress;
}, Player] call TFAR_fnc_addEventHandler;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment