From 0eccca61747dcd166691b3bc362a0cf70c22b059 Mon Sep 17 00:00:00 2001 From: commy2 Date: Sat, 16 Dec 2017 04:50:17 +0100 Subject: [PATCH] display carried weight in SI and imperial (#5918) --- addons/common/functions/fnc_getWeight.sqf | 7 +++-- addons/movement/ACE_Settings.hpp | 8 ------ addons/movement/CfgEventHandlers.hpp | 1 - addons/movement/XEH_PREP.hpp | 1 - addons/movement/config.cpp | 1 - .../functions/fnc_inventoryDisplayLoad.sqf | 26 ++++++++++++------- 6 files changed, 19 insertions(+), 25 deletions(-) delete mode 100644 addons/movement/ACE_Settings.hpp diff --git a/addons/common/functions/fnc_getWeight.sqf b/addons/common/functions/fnc_getWeight.sqf index 186e10c638..6c3a224582 100644 --- a/addons/common/functions/fnc_getWeight.sqf +++ b/addons/common/functions/fnc_getWeight.sqf @@ -4,7 +4,7 @@ * * Arguments: * 0: The Unit (usually the player) - * 0: Force a return type (0: useImperial setting; 1: Metric; 2: Imperial) + * 1: Force a return type * * Return Value: * The return value @@ -16,10 +16,9 @@ */ #include "script_component.hpp" -params ["_unit", ["_returnFormat", 0, [0]]]; +params ["_unit", ["_useImperial", false, [false, 0]]]; private _virtualLoad = 0; -private _useImperial = (!isNil QEGVAR(movement,useImperial) && {EGVAR(movement,useImperial)}); { _virtualLoad = _virtualLoad + (_x getVariable [QEGVAR(movement,vLoad), 0]); @@ -33,7 +32,7 @@ private _useImperial = (!isNil QEGVAR(movement,useImperial) && {EGVAR(movement,u private _weight = (loadAbs _unit + _virtualLoad) * 0.1; //Return -if ([_useImperial, (_returnFormat == 1)] select (_returnFormat != 0)) then { +if (_useImperial in [true, 1]) then { format ["%1lb", (round (_weight * 100)) / 100] } else { format ["%1kg", (round (_weight * (1/2.2046) * 100)) / 100] diff --git a/addons/movement/ACE_Settings.hpp b/addons/movement/ACE_Settings.hpp deleted file mode 100644 index fdc0bd36b0..0000000000 --- a/addons/movement/ACE_Settings.hpp +++ /dev/null @@ -1,8 +0,0 @@ -class ACE_Settings { - class GVAR(useImperial) { - value = 0; - typeName = "BOOL"; - isClientSettable = 1; - displayName = CSTRING(UseImperial); - }; -}; diff --git a/addons/movement/CfgEventHandlers.hpp b/addons/movement/CfgEventHandlers.hpp index 369f47e1dd..6aee79933c 100644 --- a/addons/movement/CfgEventHandlers.hpp +++ b/addons/movement/CfgEventHandlers.hpp @@ -1,4 +1,3 @@ - class Extended_PreStart_EventHandlers { class ADDON { init = QUOTE(call COMPILE_FILE(XEH_preStart)); diff --git a/addons/movement/XEH_PREP.hpp b/addons/movement/XEH_PREP.hpp index 74074d8f08..ceafa7f5dc 100644 --- a/addons/movement/XEH_PREP.hpp +++ b/addons/movement/XEH_PREP.hpp @@ -1,4 +1,3 @@ - PREP(addLoadToUnitContainer); PREP(canClimb); PREP(climb); diff --git a/addons/movement/config.cpp b/addons/movement/config.cpp index 14a3b8f68d..4979faf819 100644 --- a/addons/movement/config.cpp +++ b/addons/movement/config.cpp @@ -18,4 +18,3 @@ class CfgPatches { #include "CfgFatigue.hpp" #include "CfgMoves.hpp" #include "CfgVehicles.hpp" -#include "ACE_Settings.hpp" diff --git a/addons/movement/functions/fnc_inventoryDisplayLoad.sqf b/addons/movement/functions/fnc_inventoryDisplayLoad.sqf index 88e148fd6a..f7c240f332 100644 --- a/addons/movement/functions/fnc_inventoryDisplayLoad.sqf +++ b/addons/movement/functions/fnc_inventoryDisplayLoad.sqf @@ -13,17 +13,23 @@ * * Public: No */ - #include "script_component.hpp" +#include "script_component.hpp" -disableSerialization; +params ["_display"]; -[{ - disableSerialization; - params ["_dialog"]; +private _fnc_update = { + params ["_display"]; + private _control = _display displayCtrl 111; - if (isNull _dialog) exitWith { - [_this select 1] call CBA_fnc_removePerFrameHandler; - }; + _control ctrlSetText format ["%1 - %2 %3 (%4)", + [ACE_player, false, true] call EFUNC(common,getName), + localize ELSTRING(common,Weight), + [ACE_player] call EFUNC(common,getWeight), + [ACE_player, true] call EFUNC(common,getWeight) + ]; +}; - (_dialog displayCtrl 111) ctrlSetText format ["%1 - %2 %3", [ACE_player, false, true] call EFUNC(common,getName), localize ELSTRING(common,Weight), [ACE_player] call EFUNC(common,getWeight)]; -}, 0, _this select 0] call CBA_fnc_addPerFrameHandler; +_display displayAddEventHandler ["MouseMoving", _fnc_update]; +_display displayAddEventHandler ["MouseHolding", _fnc_update]; + +_display call _fnc_update;