From d0fd45e220b92093f235f76218d5891c50623265 Mon Sep 17 00:00:00 2001 From: Filip Maciejewski Date: Tue, 5 Oct 2021 18:47:24 +0200 Subject: [PATCH] UI - Infantry speed indictator (#8384) Co-authored-by: jonpas Co-authored-by: PabstMirror --- addons/ui/RscInGameUI.hpp | 17 ++++++++++ addons/ui/UI/speed_indicator/1_ca.paa | Bin 0 -> 1499 bytes addons/ui/UI/speed_indicator/2_ca.paa | Bin 0 -> 1499 bytes addons/ui/UI/speed_indicator/3_ca.paa | Bin 0 -> 1499 bytes addons/ui/UI/speed_indicator/4_ca.paa | Bin 0 -> 1499 bytes addons/ui/XEH_PREP.hpp | 3 ++ addons/ui/XEH_clientInit.sqf | 2 ++ addons/ui/XEH_preInit.sqf | 17 ++++++++-- addons/ui/config.cpp | 3 +- .../ui/functions/fnc_handlePlayerChanged.sqf | 32 ++++++++++++++++++ .../ui/functions/fnc_handleSpeedIndicator.sqf | 28 +++++++++++++++ addons/ui/functions/fnc_onAnimChanged.sqf | 19 +++++++++++ addons/ui/initSettings.sqf | 14 ++++++++ addons/ui/script_component.hpp | 1 + addons/ui/stringtable.xml | 8 +++++ 15 files changed, 141 insertions(+), 3 deletions(-) create mode 100644 addons/ui/RscInGameUI.hpp create mode 100644 addons/ui/UI/speed_indicator/1_ca.paa create mode 100644 addons/ui/UI/speed_indicator/2_ca.paa create mode 100644 addons/ui/UI/speed_indicator/3_ca.paa create mode 100644 addons/ui/UI/speed_indicator/4_ca.paa create mode 100644 addons/ui/functions/fnc_handlePlayerChanged.sqf create mode 100644 addons/ui/functions/fnc_handleSpeedIndicator.sqf create mode 100644 addons/ui/functions/fnc_onAnimChanged.sqf diff --git a/addons/ui/RscInGameUI.hpp b/addons/ui/RscInGameUI.hpp new file mode 100644 index 0000000000..a3e7d2263a --- /dev/null +++ b/addons/ui/RscInGameUI.hpp @@ -0,0 +1,17 @@ +#define SPEED_INDICATOR_W (IGUI_GRID_STANCE_WAbs / 2) +#define SPEED_INDICATOR_H (IGUI_GRID_STANCE_HAbs / 3.5) +#define SPEED_INDICATOR_Y_OFFSET (IGUI_GRID_STANCE_HAbs / 4.25) + +class RscPictureKeepAspect; +class RscInGameUI { + class RscStanceInfo { + controls[] += {QGVAR(speedIndicator)}; + class GVAR(speedIndicator): RscPictureKeepAspect { + onLoad = QUOTE(uiNamespace setVariable [ARR_2(QQGVAR(speedIndicator),_this select 0)]); + x = IGUI_GRID_STANCE_X + IGUI_GRID_STANCE_WAbs / 2 - SPEED_INDICATOR_W / 2; + y = IGUI_GRID_STANCE_Y + IGUI_GRID_STANCE_HAbs - SPEED_INDICATOR_Y_OFFSET; + w = SPEED_INDICATOR_W; + h = SPEED_INDICATOR_H; + }; + }; +}; diff --git a/addons/ui/UI/speed_indicator/1_ca.paa b/addons/ui/UI/speed_indicator/1_ca.paa new file mode 100644 index 0000000000000000000000000000000000000000..bcafc6d09e97b7cff256427c01c0d57e031e2765 GIT binary patch literal 1499 zcmZSm@9ypx;_M#g$il$D@cQ*@DKJ06(HF%34+J2-yQ7aAh|dVbAbzl$o4*5)-2lYx zK#4w9AcHL6z#zcD05W=TgL($fNh+R`SpNTKUb}Ft7qcrGE4O z|MvAC4uJST;84H0k@xnt+}j|2KuBol;PxG+>qeS?(L(^}{|UhORsqK^Fv9CM|Lp(c zmZuDfUq;sY&HR7Z|9=L@zXMQn{bpcfZ;-tKk`E0H2|zb*sPmD-LzD*Lp}@caDP14| zr2wRWVGGGjKsK>_1+;9c@Ww3b%ZtnD;AjM9)0{W_GB-9rvZVtsUjmH=0|g*Sj(rf_ z2=@W)hbJ3QFe$vLZL@RBUkpn&Id8V{-fsL0E+&Af!~tEu0I(>83nGj~SH^MCEX%|# X8Eh;oBO|NyMPO+IO??3&u+#?t$l>SD literal 0 HcmV?d00001 diff --git a/addons/ui/UI/speed_indicator/2_ca.paa b/addons/ui/UI/speed_indicator/2_ca.paa new file mode 100644 index 0000000000000000000000000000000000000000..6ba5b7f2154366f5af85ee8079c047f70bcbf957 GIT binary patch literal 1499 zcmd^9KTE?v6u&DCbt!fU4plj*yMxfR7led@V!%Y41PgAh;^=f1ggVvY7w{_-0)>Kz zW5LO-khKny43$oW$obx-=TPb5Qo#rJa=&{o@9zCIq~loLu5)B%2_aDw?I?U~?IV^z zh#hOsMoeKLKD6xv4*P3ZEfBN~*!+q(DG-9DmrEk(otEr&A|)ZFL5T>a;QAzo0l=4u zV0C@iZ4?o4*E2;>u8jr{N($;Am$D+p-yB53BrUL!>8dcMD0?|$C?-~64AfCvT` zqjF8V3A_*-~zrrvGl+x9-Z>4a!il_zKfzR(-CgtM3aV Csy%@K literal 0 HcmV?d00001 diff --git a/addons/ui/UI/speed_indicator/3_ca.paa b/addons/ui/UI/speed_indicator/3_ca.paa new file mode 100644 index 0000000000000000000000000000000000000000..3e190e88586b166b501ad19ddba22f6e3be4c0b8 GIT binary patch literal 1499 zcmd^9F-s#s6n-OFw2=fMco3BV3rnr67#Y!+>mw4EDa4;txXr=yx`~_iQ zAs}KUf;M)6w6TzEp`;2#*6+<`Jk(A^5FgC!zW2WQc4yxA#z{)0qQ6jDEoO+Q-EJ=$ zf33L0egb2^R9tk~7Z~iXxbCvT`(KQGBn}p`Jv( zr%tQ~rF}$yjNHljJO+E8i06iS_@QE}l933)Q$DkE{hR?r=PjEg6 zeDC%DeYXGA&O_2rdb^|tCGoJO;E45Q{bie0;y-9(k(Nc}GBRF2JN^AIz-8dOO4h{y z+EiPvN^IKL$OLWt+?JLfON>d(b`1xtFY7O5Q;BCreq^tWtTH)8GM+vjy=vd4G9e-B z-Tj`Lkd~_wN5fWDP>BMyF^QQmIb4OxM9d^HbNJ`>#op9Td9J@Lap$@R-q7Yh&M~lX NgWIOBKF_!6djc#uozwsT literal 0 HcmV?d00001 diff --git a/addons/ui/UI/speed_indicator/4_ca.paa b/addons/ui/UI/speed_indicator/4_ca.paa new file mode 100644 index 0000000000000000000000000000000000000000..fc53c16bb5411cd5b5be5f28aa99e9ac70cd4198 GIT binary patch literal 1499 zcmds1&ubGw6rL$r+k<5nVNqz6f&2k_%F#>^HVBFfZp4#lik_PGEC^#jsHe97K`;FS zgoQvrB*%h!@D}LNSSTh?%_$Hazi*~%B!UO^qK`~wAMcy*y?H+-u=RQ^yH>wbD+wV+ zqtTkv@78Wow-D;}+Kq&|#G-yXNp5L;KgHUDVLQObZ;2L>5TyRKSaE%~grBuS#1QTj z2FTsycDxv__PwT4lfP)KRGI_oSsX}{AM62I#X7~ClU{rI&}ll&Ox}4=PPV7i0SDg% z$noL~4{}h_4tQ*GkUL5t0H=Rj1*K;f+Tbn$H5!cZPh|f7|NDLCbM^E6+h2O- zq{@7!n)y#Q${p$QErS^Kv|~HjK|Os%&<_{;;S}{mKi~lRVRKMvx_Sy6FgeNg2nT|E zAcG5PF%F;~cBXLQtuin<$;J*1_r$jj;ez%?BTLEgH)a0*K8_#z|KHAs5=;Jd@kvwI zSPIoW+WdO7c81rL5Y-JMr8%ZP0qesj7-Q+nqN9=;-h1`(@uvlc2Z!p)1&pbg;oTU! zHo+KwAIriYjyO^H=NZ*~bpI+snE5{l2lBJC5x73Qa_&O-#>} zAl}K=R9{jv|DENct + * 1: Old Unit + * + * Return Value: + * None + * + * Example: + * [newbob, oldbob] call ace_ui_fnc_handlePlayerChanged + * + * Public: No + */ +params ["_newUnit", "_oldUnit"]; +TRACE_2("unit changed",_newUnit,_oldUnit); + +if (!isNull _oldUnit) then { + _oldUnit removeEventHandler ["AnimChanged", _oldUnit getVariable [QGVAR(animHandler), -1]]; + _oldUnit setVariable [QGVAR(animHandler), nil]; + TRACE_1("remove old",_oldUnit getVariable QGVAR(animHandler)); +}; + +// Don't add a new EH if the unit respawned +if (_newUnit getVariable [QGVAR(animHandler), -1] == -1) then { + private _animHandler = _newUnit addEventHandler ["AnimChanged", LINKFUNC(onAnimChanged)]; + TRACE_1("add new",_animHandler); + _newUnit setVariable [QGVAR(animHandler), _animHandler]; +}; diff --git a/addons/ui/functions/fnc_handleSpeedIndicator.sqf b/addons/ui/functions/fnc_handleSpeedIndicator.sqf new file mode 100644 index 0000000000..e6b8718b0d --- /dev/null +++ b/addons/ui/functions/fnc_handleSpeedIndicator.sqf @@ -0,0 +1,28 @@ +#include "script_component.hpp" +/* + * Author: veteran29 + * Handles visual changes of the speed indicator. + * + * Arguments: + * Current animation state + * + * Return Value: + * None + * + * Example: + * ["amovpercmtacslowwrfldf_ver2"] call ace_ui_fnc_handleSpeedIndicator + * + * Public: No + */ + +params ["_animState"]; + +if (!GVAR(enableSpeedIndicator)) exitWith {}; + +private _animSpeed = _animState select [9, 3]; +private _isProne = _animState select [5, 3] isEqualTo "pne"; + +private _icon = GVAR(speedIndicatorIconHash) getOrDefault [[_animSpeed, _isProne], ""]; + +private _speedIndicator = uiNamespace getVariable [QGVAR(speedIndicator), controlNull]; +_speedIndicator ctrlSetText _icon; diff --git a/addons/ui/functions/fnc_onAnimChanged.sqf b/addons/ui/functions/fnc_onAnimChanged.sqf new file mode 100644 index 0000000000..d241c30bd4 --- /dev/null +++ b/addons/ui/functions/fnc_onAnimChanged.sqf @@ -0,0 +1,19 @@ +#include "script_component.hpp" +/* + * Author: veteran29 + * Handle player unit animation changes. + * + * Arguments: + * 0: Unit + * 1: Current animation + * + * Return Value: + * None + * + * Example: + * [newbob, "amovpercmtacslowwrfldf_ver2"] call ace_ui_fnc_onAnimChanged + * + * Public: No + */ + +(_this select 1) call FUNC(handleSpeedIndicator); diff --git a/addons/ui/initSettings.sqf b/addons/ui/initSettings.sqf index eebda7e2e4..dade17d3e3 100644 --- a/addons/ui/initSettings.sqf +++ b/addons/ui/initSettings.sqf @@ -7,3 +7,17 @@ if (productVersion select 4 == 'Development') then { true ] call CBA_fnc_addSetting; }; + +[ + QGVAR(enableSpeedIndicator), + "CHECKBOX", + [LSTRING(EnableSpeedIndicator), LSTRING(EnableSpeedIndicator_Description)], + "ACE " + LLSTRING(Category), + true, + true, { + if (!_this) then { + private _speedIndicator = uiNamespace getVariable [QGVAR(speedIndicator), controlNull]; + _speedIndicator ctrlSetText ""; + }; + } +] call CBA_fnc_addSetting; diff --git a/addons/ui/script_component.hpp b/addons/ui/script_component.hpp index d98691e0de..a9899945c7 100644 --- a/addons/ui/script_component.hpp +++ b/addons/ui/script_component.hpp @@ -17,6 +17,7 @@ #include "\z\ace\addons\main\script_macros.hpp" #include "\a3\ui_f\hpp\defineResincl.inc" +#include "\a3\ui_f\hpp\defineCommonGrids.inc" // Basic Elements #define ELEMENTS_BASIC [QGVAR(soldierVehicleWeaponInfo), QGVAR(vehicleRadar), QGVAR(vehicleCompass), QGVAR(commandMenu), QGVAR(groupBar)] diff --git a/addons/ui/stringtable.xml b/addons/ui/stringtable.xml index 73785f8305..21cc6ddd1a 100644 --- a/addons/ui/stringtable.xml +++ b/addons/ui/stringtable.xml @@ -664,5 +664,13 @@ Nelze upravit prvek vynuceného uživatelského rozhraní. No se puede modificar un elemento forzado de la Interfaz del Usuario + + Enable movement speed indicator + Włącz wskaźnik prędkości poruszania + + + Enables movement speed indicator for player character. + Włącza wskaźnik prędkości poruszania się dla postaci gracza. +