From ea4a159cd228ca2866580dcda4b45a3acd585b55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20E=C4=9Fitmen?= Date: Fri, 5 May 2017 23:02:59 +0400 Subject: [PATCH] Add Paradrop Time Coefficient Setting (#5116) * Add coef * Show cargo paradrop time in menu * Unary command, not a function call * If drop time is 0 don't show a progress bar * Add the setting to cargo's editor module * Swap values * Remove extra comma * Move unload message to paradrop event This way the message will show up on all paradrops, not just immidiate ones. --- addons/cargo/ACE_Settings.hpp | 7 +++++++ addons/cargo/CfgVehicles.hpp | 6 ++++++ addons/cargo/functions/fnc_moduleSettings.sqf | 1 + addons/cargo/functions/fnc_onMenuOpen.sqf | 8 +++++++- addons/cargo/functions/fnc_paradropItem.sqf | 9 +++++++++ addons/cargo/functions/fnc_startUnload.sqf | 9 +++++++-- addons/cargo/stringtable.xml | 6 ++++++ 7 files changed, 43 insertions(+), 3 deletions(-) diff --git a/addons/cargo/ACE_Settings.hpp b/addons/cargo/ACE_Settings.hpp index 574000155e..595de28459 100644 --- a/addons/cargo/ACE_Settings.hpp +++ b/addons/cargo/ACE_Settings.hpp @@ -6,4 +6,11 @@ class ACE_Settings { value = 1; category = ECSTRING(OptionsMenu,CategoryLogistics); }; + class GVAR(paradropTimeCoefficent) { + displayName = CSTRING(paradropTimeCoefficent); + description = CSTRING(paradropTimeCoefficent_description); + typeName = "SCALAR"; + value = 2.5; + category = ECSTRING(OptionsMenu,CategoryLogistics); + }; }; diff --git a/addons/cargo/CfgVehicles.hpp b/addons/cargo/CfgVehicles.hpp index a89375e4a0..4c4647581e 100644 --- a/addons/cargo/CfgVehicles.hpp +++ b/addons/cargo/CfgVehicles.hpp @@ -26,6 +26,12 @@ class CfgVehicles { typeName = "BOOL"; defaultValue = 1; }; + class paradropTimeCoefficent { + displayName = CSTRING(paradropTimeCoefficent); + description = CSTRING(paradropTimeCoefficent_description); + typeName = "SCALAR"; + defaultValue = 2.5; + }; }; class ModuleDescription { diff --git a/addons/cargo/functions/fnc_moduleSettings.sqf b/addons/cargo/functions/fnc_moduleSettings.sqf index 0374152a5a..b7af19c76a 100644 --- a/addons/cargo/functions/fnc_moduleSettings.sqf +++ b/addons/cargo/functions/fnc_moduleSettings.sqf @@ -24,5 +24,6 @@ params ["_logic", "", "_activated"]; if (!_activated) exitWith {}; [_logic, QGVAR(enable), "enable"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(paradropTimeCoefficent), "paradropTimeCoefficent"] call EFUNC(common,readSettingFromModule); INFO("Cargo Module Initialized."); diff --git a/addons/cargo/functions/fnc_onMenuOpen.sqf b/addons/cargo/functions/fnc_onMenuOpen.sqf index 852729e529..8b3847993d 100644 --- a/addons/cargo/functions/fnc_onMenuOpen.sqf +++ b/addons/cargo/functions/fnc_onMenuOpen.sqf @@ -44,7 +44,13 @@ if (GVAR(interactionParadrop)) then { lbClear _ctrl; { private _class = if (_x isEqualType "") then {_x} else {typeOf _x}; - _ctrl lbAdd (getText(configfile >> "CfgVehicles" >> _class >> "displayName")); + private _displayName = getText (configfile >> "CfgVehicles" >> _class >> "displayName"); + if (GVAR(interactionParadrop)) then { + _ctrl lbAdd format ["%1 (%2s)", _displayName, GVAR(paradropTimeCoefficent) * ([_class] call FUNC(getSizeItem))]; + } else { + _ctrl lbAdd _displayName; + }; + true } count _loaded; diff --git a/addons/cargo/functions/fnc_paradropItem.sqf b/addons/cargo/functions/fnc_paradropItem.sqf index 2eb59fee1d..4c34e61e4e 100644 --- a/addons/cargo/functions/fnc_paradropItem.sqf +++ b/addons/cargo/functions/fnc_paradropItem.sqf @@ -90,6 +90,15 @@ _itemObject setVelocity ((velocity _vehicle) vectorAdd ((vectorNormalized (vecto }, 1, [_itemObject]] call CBA_fnc_addPerFrameHandler; +[ + [ + LSTRING(UnloadedItem), + getText (configFile >> "CfgVehicles" >> typeOf _itemObject >> "displayName"), + getText (configFile >> "CfgVehicles" >> typeOf _vehicle >> "displayName") + ], + 3 +] call EFUNC(common,displayTextStructured); + // Invoke listenable event ["ace_cargoUnloaded", [_item, _vehicle, "paradrop"]] call CBA_fnc_globalEvent; diff --git a/addons/cargo/functions/fnc_startUnload.sqf b/addons/cargo/functions/fnc_startUnload.sqf index 8631449b9e..27ebe9e952 100644 --- a/addons/cargo/functions/fnc_startUnload.sqf +++ b/addons/cargo/functions/fnc_startUnload.sqf @@ -28,13 +28,18 @@ private _ctrl = _display displayCtrl 100; private _selected = (lbCurSel _ctrl) max 0; if (count _loaded <= _selected) exitWith {}; -private _item = _loaded select _selected; //This can be an object or a classname string +private _item = _loaded select _selected; // This can be an object or a classname string if (GVAR(interactionParadrop)) exitWith { + // If drop time is 0 don't show a progress bar + if (GVAR(paradropTimeCoefficent) == 0) exitWith { + [QGVAR(paradropItem), [_item, GVAR(interactionVehicle)]] call CBA_fnc_localEvent; + }; + // Start progress bar - paradrop private _size = [_item] call FUNC(getSizeItem); [ - 2.5 * _size, + GVAR(paradropTimeCoefficent) * _size, [_item, GVAR(interactionVehicle), ACE_player], { (_this select 0) params ["_item", "_target", "_player"]; diff --git a/addons/cargo/stringtable.xml b/addons/cargo/stringtable.xml index c85d99b7f8..c10f293268 100644 --- a/addons/cargo/stringtable.xml +++ b/addons/cargo/stringtable.xml @@ -253,5 +253,11 @@ 기체가 수평이 아닙니다 Rétablir l'assiette + + Paradrop Time Coffecient + + + Modifier for how long it takes to paradrop a cargo item. +