UI - Infantry speed indictator (#8384)

Co-authored-by: jonpas <jonpas33@gmail.com>
Co-authored-by: PabstMirror <pabstmirror@gmail.com>
This commit is contained in:
Filip Maciejewski 2021-10-05 18:47:24 +02:00 committed by GitHub
parent 2134f6e837
commit d0fd45e220
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 141 additions and 3 deletions

17
addons/ui/RscInGameUI.hpp Normal file
View File

@ -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;
};
};
};

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,5 +1,8 @@
PREP(compileConfigUI); PREP(compileConfigUI);
PREP(handlePlayerChanged);
PREP(handleSpeedIndicator);
PREP(moduleInit); PREP(moduleInit);
PREP(onAnimChanged);
PREP(setAdvancedElement); PREP(setAdvancedElement);
PREP(setElements); PREP(setElements);
PREP(setElementVisibility); PREP(setElementVisibility);

View File

@ -50,3 +50,5 @@ GVAR(elementsSet) = call CBA_fnc_createNamespace;
}; };
}] call CBA_fnc_addEventHandler; }] call CBA_fnc_addEventHandler;
}] call CBA_fnc_addEventHandler; }] call CBA_fnc_addEventHandler;
["unit", FUNC(handlePlayerChanged), true] call CBA_fnc_addPlayerEventHandler;

View File

@ -6,8 +6,21 @@ PREP_RECOMPILE_START;
#include "XEH_PREP.hpp" #include "XEH_PREP.hpp"
PREP_RECOMPILE_END; PREP_RECOMPILE_END;
GVAR(interfaceInitialized) = false;
#include "initSettings.sqf" #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; ADDON = true;

View File

@ -8,7 +8,7 @@ class CfgPatches {
requiredVersion = REQUIRED_VERSION; requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_common"}; requiredAddons[] = {"ace_common"};
author = ECSTRING(common,ACETeam); author = ECSTRING(common,ACETeam);
authors[] = {"VKing", "Jonpas"}; authors[] = {"VKing", "Jonpas", "veteran29"};
url = ECSTRING(main,URL); url = ECSTRING(main,URL);
VERSION_CONFIG; VERSION_CONFIG;
}; };
@ -20,4 +20,5 @@ class CfgPatches {
#include "ACE_UI.hpp" #include "ACE_UI.hpp"
#include "RscChat.hpp" #include "RscChat.hpp"
#include "RscInGameUI.hpp"
#include "RscVignette.hpp" #include "RscVignette.hpp"

View File

@ -0,0 +1,32 @@
#include "script_component.hpp"
/*
* Author: veteran29
* Handles switching units.
*
* Arguments:
* 0: New Unit <OBJECT>
* 1: Old Unit <OBJECT>
*
* 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];
};

View File

@ -0,0 +1,28 @@
#include "script_component.hpp"
/*
* Author: veteran29
* Handles visual changes of the speed indicator.
*
* Arguments:
* Current animation state <STRING>
*
* 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;

View File

@ -0,0 +1,19 @@
#include "script_component.hpp"
/*
* Author: veteran29
* Handle player unit animation changes.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Current animation <STRING>
*
* Return Value:
* None
*
* Example:
* [newbob, "amovpercmtacslowwrfldf_ver2"] call ace_ui_fnc_onAnimChanged
*
* Public: No
*/
(_this select 1) call FUNC(handleSpeedIndicator);

View File

@ -7,3 +7,17 @@ if (productVersion select 4 == 'Development') then {
true true
] call CBA_fnc_addSetting; ] 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;

View File

@ -17,6 +17,7 @@
#include "\z\ace\addons\main\script_macros.hpp" #include "\z\ace\addons\main\script_macros.hpp"
#include "\a3\ui_f\hpp\defineResincl.inc" #include "\a3\ui_f\hpp\defineResincl.inc"
#include "\a3\ui_f\hpp\defineCommonGrids.inc"
// Basic Elements // Basic Elements
#define ELEMENTS_BASIC [QGVAR(soldierVehicleWeaponInfo), QGVAR(vehicleRadar), QGVAR(vehicleCompass), QGVAR(commandMenu), QGVAR(groupBar)] #define ELEMENTS_BASIC [QGVAR(soldierVehicleWeaponInfo), QGVAR(vehicleRadar), QGVAR(vehicleCompass), QGVAR(commandMenu), QGVAR(groupBar)]

View File

@ -664,5 +664,13 @@
<Czech>Nelze upravit prvek vynuceného uživatelského rozhraní.</Czech> <Czech>Nelze upravit prvek vynuceného uživatelského rozhraní.</Czech>
<Spanish>No se puede modificar un elemento forzado de la Interfaz del Usuario</Spanish> <Spanish>No se puede modificar un elemento forzado de la Interfaz del Usuario</Spanish>
</Key> </Key>
<Key ID="STR_ACE_UI_EnableSpeedIndicator">
<English>Enable movement speed indicator</English>
<Polish>Włącz wskaźnik prędkości poruszania</Polish>
</Key>
<Key ID="STR_ACE_UI_EnableSpeedIndicator_Description">
<English>Enables movement speed indicator for player character.</English>
<Polish>Włącza wskaźnik prędkości poruszania się dla postaci gracza.</Polish>
</Key>
</Package> </Package>
</Project> </Project>