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 0000000000..bcafc6d09e Binary files /dev/null and b/addons/ui/UI/speed_indicator/1_ca.paa differ 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 0000000000..6ba5b7f215 Binary files /dev/null and b/addons/ui/UI/speed_indicator/2_ca.paa differ 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 0000000000..3e190e8858 Binary files /dev/null and b/addons/ui/UI/speed_indicator/3_ca.paa differ 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 0000000000..fc53c16bb5 Binary files /dev/null and b/addons/ui/UI/speed_indicator/4_ca.paa differ diff --git a/addons/ui/XEH_PREP.hpp b/addons/ui/XEH_PREP.hpp index a927a8ad2d..f7edabcc3f 100644 --- a/addons/ui/XEH_PREP.hpp +++ b/addons/ui/XEH_PREP.hpp @@ -1,5 +1,8 @@ PREP(compileConfigUI); +PREP(handlePlayerChanged); +PREP(handleSpeedIndicator); PREP(moduleInit); +PREP(onAnimChanged); PREP(setAdvancedElement); PREP(setElements); PREP(setElementVisibility); diff --git a/addons/ui/XEH_clientInit.sqf b/addons/ui/XEH_clientInit.sqf index dfef530fcf..d0a3ab497c 100644 --- a/addons/ui/XEH_clientInit.sqf +++ b/addons/ui/XEH_clientInit.sqf @@ -50,3 +50,5 @@ GVAR(elementsSet) = call CBA_fnc_createNamespace; }; }] call CBA_fnc_addEventHandler; }] call CBA_fnc_addEventHandler; + +["unit", FUNC(handlePlayerChanged), true] call CBA_fnc_addPlayerEventHandler; diff --git a/addons/ui/XEH_preInit.sqf b/addons/ui/XEH_preInit.sqf index 8fe8c38b0d..9f2cfd9824 100644 --- a/addons/ui/XEH_preInit.sqf +++ b/addons/ui/XEH_preInit.sqf @@ -6,8 +6,21 @@ PREP_RECOMPILE_START; #include "XEH_PREP.hpp" PREP_RECOMPILE_END; -GVAR(interfaceInitialized) = false; - #include "initSettings.sqf" +GVAR(interfaceInitialized) = false; + +GVAR(speedIndicatorIconHash) = createHashMapFromArray [ + // Standing/Crouched + [["wlk", false], QPATHTOF(ui\speed_indicator\1_ca.paa)], + [["tac", false], QPATHTOF(ui\speed_indicator\2_ca.paa)], + [["run", false], QPATHTOF(ui\speed_indicator\3_ca.paa)], + [["eva", false], QPATHTOF(ui\speed_indicator\4_ca.paa)], + // Prone + [["wlk", true], QPATHTOF(ui\speed_indicator\1_ca.paa)], + [["run", true], QPATHTOF(ui\speed_indicator\2_ca.paa)], + [["spr", true], QPATHTOF(ui\speed_indicator\3_ca.paa)], + [["eva", true], QPATHTOF(ui\speed_indicator\4_ca.paa)] +]; + ADDON = true; diff --git a/addons/ui/config.cpp b/addons/ui/config.cpp index d480a5f33b..6dfeba4cfb 100644 --- a/addons/ui/config.cpp +++ b/addons/ui/config.cpp @@ -8,7 +8,7 @@ class CfgPatches { requiredVersion = REQUIRED_VERSION; requiredAddons[] = {"ace_common"}; author = ECSTRING(common,ACETeam); - authors[] = {"VKing", "Jonpas"}; + authors[] = {"VKing", "Jonpas", "veteran29"}; url = ECSTRING(main,URL); VERSION_CONFIG; }; @@ -20,4 +20,5 @@ class CfgPatches { #include "ACE_UI.hpp" #include "RscChat.hpp" +#include "RscInGameUI.hpp" #include "RscVignette.hpp" diff --git a/addons/ui/functions/fnc_handlePlayerChanged.sqf b/addons/ui/functions/fnc_handlePlayerChanged.sqf new file mode 100644 index 0000000000..1abc39efcb --- /dev/null +++ b/addons/ui/functions/fnc_handlePlayerChanged.sqf @@ -0,0 +1,32 @@ +#include "script_component.hpp" +/* + * Author: veteran29 + * Handles switching units. + * + * Arguments: + * 0: New Unit + * 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. +