ACE3/addons/advanced_fatigue/functions/fnc_handleStaminaBar.sqf
Blutze 30b4f3edf0 Advanced Fatigue - Solid stamina bar option (#6911)
* Translation Entries (EN+DE)

* Add setting

* Obey setting in handler

* Add setting to movedToSQF list

* Replace elegant else-if with clunky SQF

* Revert adding solidStaminaBar to movedToSqf list

* Remove unnecessary fade applications

* Invert solid/fade setting for better translation

* Change translations to "fade"

* Invert fade/solid logic

* Dont unfade when disabled overall

* Dont unfade with AF disabled; fix old bug
2019-12-07 15:23:04 -06:00

52 lines
1.6 KiB
Plaintext

#include "script_component.hpp"
/*
* Author: BaerMitUmlaut
* Handles visual changes of the stamina bar.
*
* Arguments:
* Percent of stamina remaining <NUMBER>
*
* Return Value:
* None
*
* Example:
* [0.5] call ace_advanced_fatigue_fnc_handleStaminaBar
*
* Public: No
*/
params ["_stamina"];
private _staminaBarContainer = uiNamespace getVariable [QGVAR(staminaBarContainer), controlNull];
// - Size ---------------------------------------------------------------------
// Shrink the container to cut off the image (other wise it would just get stretched)
private _posAndSize = ctrlPosition _staminaBarContainer;
_posAndSize set [2, _stamina * GVAR(staminaBarWidth)];
_staminaBarContainer ctrlSetPosition _posAndSize;
// - Opacity ------------------------------------------------------------------
if (GVAR(fadeStaminaBar)) then {
if (_stamina >= 0.8) then {
_staminaBarContainer ctrlSetFade (0.9 + 0.1 * (_stamina - 0.8) / 0.2);
} else {
_staminaBarContainer ctrlSetFade (0.9 * _stamina / 0.8);
};
};
// - Color --------------------------------------------------------------------
// 1.0 - 0.8: White
// 0.6 - 0.4: Orange
// 0.4 - 0.2: Red
private _color = [1, 1, 1];
if (_stamina < 0.6) then {
if (_stamina < 0.4) then {
_color = [1, 0, 0] vectorAdd ([0, 0.65, 0] vectorMultiply ((_stamina - 0.2) / 0.2));
} else {
_color = [1, 0.65, 0] vectorAdd ([0, 0.35, 1] vectorMultiply ((_stamina - 0.4) / 0.2));
};
};
_color pushBack 1;
(_staminaBarContainer controlsGroupCtrl 10) ctrlSetTextColor _color;
_staminaBarContainer ctrlCommit 1;