Add fade nametags towards screen border (#4316)

* Fade nametags towards screen border

* Use distance2D instead of vector commands

* Don't calculate fade when off screen

* Made fade on border optional
This commit is contained in:
BaerMitUmlaut 2016-09-04 20:50:12 +02:00 committed by Glowbal
parent b0fa1a32d9
commit 8a47d7a9b6
4 changed files with 27 additions and 3 deletions

View File

@ -12,7 +12,7 @@ class ACE_Settings {
isClientSettable = 1;
displayName = CSTRING(ShowPlayerNames);
description = CSTRING(ShowPlayerNames_Desc);
values[] = {ECSTRING(common,Disabled), ECSTRING(common,Enabled), CSTRING(OnlyCursor), CSTRING(OnlyKeypress), CSTRING(OnlyCursorAndKeypress)};
values[] = {ECSTRING(common,Disabled), ECSTRING(common,Enabled), CSTRING(OnlyCursor), CSTRING(OnlyKeypress), CSTRING(OnlyCursorAndKeypress), CSTRING(FadeOnBorder)};
category = CSTRING(Module_DisplayName);
};
class GVAR(showPlayerRanks) {

View File

@ -28,6 +28,10 @@ class CfgVehicles {
name = CSTRING(ForceShow);
value = 1;
};
class ForceShowFadeOnBorder {
name = CSTRING(FadeOnBorder);
value = 5;
};
class ForceShowOnlyCursor {
name = CSTRING(ForceShowOnlyCursor);
value = 2;

View File

@ -57,6 +57,11 @@ switch (GVAR(showPlayerNames)) do {
_enabledTagsNearby = (GVAR(showSoundWaves) == 2);
_enabledTagsCursor = _onKeyPressAlphaMax > 0;
};
case 5: {
// Fade on border
_enabledTagsNearby = true;
_enabledTagsCursor = false;
};
};
private _ambientBrightness = ((([] call EFUNC(common,ambientBrightness)) + ([0, 0.4] select ((currentVisionMode ace_player) != 0))) min 1) max 0;
@ -132,7 +137,18 @@ if (_enabledTagsNearby) then {
if !(isNull _target) then {
private _relPos = (visiblePositionASL _target) vectorDiff _camPosASL;
private _distance = vectorMagnitude _relPos;
private _projDist = _relPos vectorDistance (_vecy vectorMultiply (_relPos vectorDotProduct _vecy));
// Fade on border
private _centerOffsetFactor = 1;
if (GVAR(showPlayerNames) == 5) then {
private _screenPos = worldToScreen (_target modelToWorld (_target selectionPosition "head"));
if !(_screenPos isEqualTo []) then {
// Distance from center / half of screen width
_centerOffsetFactor = 1 - ((_screenPos distance2D [0.5, 0.5]) / (safezoneW / 3));
} else {
_centerOffsetFactor = 0;
};
};
private _drawSoundwave = (GVAR(showSoundWaves) > 0) && {[_target] call FUNC(isSpeaking)};
private _alphaMax = _onKeyPressAlphaMax;
@ -146,7 +162,7 @@ if (_enabledTagsNearby) then {
// - decreases when _distance > _maxDistance
// - increases when the unit is speaking
// - it's clamped by the value of _onKeyPressAlphaMax unless soundwaves are forced on and the unit is talking
private _alpha = (((1 + ([0, 0.2] select _drawSoundwave) - 0.2 * (_distance - _maxDistance)) min 1) * GVAR(playerNamesMaxAlpha)) min _alphaMax;
private _alpha = (((1 + ([0, 0.2] select _drawSoundwave) - 0.2 * (_distance - _maxDistance)) min 1) * GVAR(playerNamesMaxAlpha) * _centerOffsetFactor) min _alphaMax;
if (_alpha > 0) then {
[ACE_player, _target, _alpha, _distance * 0.026, _drawName, _drawRank, _drawSoundwave] call FUNC(drawNameTagIcon);

View File

@ -396,5 +396,9 @@
<Russian>Масштабирование размера текста и иконок</Russian>
<Italian>Proporzione Dimensioni Testo ed Icone</Italian>
</Key>
<Key ID="STR_ACE_NameTags_FadeOnBorder">
<English>Fade on screen border</English>
<German>Am Bildschirmrand ausblenden</German>
</Key>
</Package>
</Project>