diff --git a/addons/cargo/functions/fnc_startUnload.sqf b/addons/cargo/functions/fnc_startUnload.sqf index cf00327dcc..2b4c4229c7 100644 --- a/addons/cargo/functions/fnc_startUnload.sqf +++ b/addons/cargo/functions/fnc_startUnload.sqf @@ -60,7 +60,8 @@ if (GVAR(interactionParadrop)) exitWith { if ((speed _target) < -5) exitWith {false}; // check reverse true }, - ["isNotSwimming", "isNotInside"] + ["isNotSwimming", "isNotInside"], + false ] call EFUNC(common,progressBar); }; diff --git a/addons/common/HintConfig.hpp b/addons/common/HintConfig.hpp index 72fd7f6233..c299bee8df 100644 --- a/addons/common/HintConfig.hpp +++ b/addons/common/HintConfig.hpp @@ -10,6 +10,11 @@ class GVAR(debug_structuredText): ctrlStructuredText { }; class RscTitles { + class GVAR(ProgressBar_Display): GVAR(ProgressBar_Dialog) { + duration = 1e11; // forever, essentially + fadeIn = 0; + fadeOut = 0; + }; class GVAR(watchVariableUI) { idd = -1; onLoad = QUOTE(with uiNameSpace do {GVAR(watchVariableUI) = _this select 0};); diff --git a/addons/common/functions/fnc_progressBar.sqf b/addons/common/functions/fnc_progressBar.sqf index 20c1283da4..9b5519c232 100644 --- a/addons/common/functions/fnc_progressBar.sqf +++ b/addons/common/functions/fnc_progressBar.sqf @@ -1,4 +1,5 @@ #include "..\script_component.hpp" +#include "\a3\ui_f\hpp\defineDIKCodes.inc" /* * Author: commy2, Glowbal, PabstMirror * Draw progress bar and execute given function if succesful. @@ -9,9 +10,10 @@ * 1: Arguments, passed to condition, fail and finish * 2: On Finish: Code called or STRING raised as event. * 3: On Failure: Code called or STRING raised as event. - * 4: (Optional) Localized Title - * 5: Code to check each frame (Optional) - * 6: Exceptions for checking EFUNC(common,canInteractWith) (Optional) + * 4: Localized Title (default: "") + * 5: Code to check each frame (default: {true}) + * 6: Exceptions for checking ace_common_fnc_canInteractWith (default: []) + * 7: Create progress bar as dialog, this blocks user input (default: true) * * Return Value: * None @@ -22,13 +24,17 @@ * Public: Yes */ -params ["_totalTime", "_args", "_onFinish", "_onFail", ["_localizedTitle", ""], ["_condition", {true}], ["_exceptions", []]]; +params ["_totalTime", "_args", "_onFinish", "_onFail", ["_localizedTitle", ""], ["_condition", {true}], ["_exceptions", []], ["_dialog", true]]; private _player = ACE_player; //Open Dialog and set the title closeDialog 0; -createDialog QGVAR(ProgressBar_Dialog); +if (_dialog) then { + createDialog QGVAR(ProgressBar_Dialog); +} else { + QGVAR(progressBarDisplay) cutRsc [QGVAR(ProgressBar_Display), "PLAIN"]; +}; private _display = uiNamespace getVariable QGVAR(dlgProgress); @@ -36,8 +42,16 @@ private _display = uiNamespace getVariable QGVAR(dlgProgress); _display call (uiNamespace getVariable "CBA_events_fnc_initDisplayCurator"); // Hide cursor by using custom transparent cursor -private _map = _display displayCtrl 101; -_map ctrlMapCursor ["", QGVAR(blank)]; +if (_dialog) then { + private _map = _display displayCtrl 101; + _map ctrlMapCursor ["", QGVAR(blank)]; +} else { // Add key handler for ESC to cancel + [DIK_ESCAPE, [false, false, false], { + QGVAR(progressBarDisplay) cutText ["", "PLAIN"]; + [QGVAR(progressBarKeyHandler), "keydown"] call CBA_fnc_removeKeyHandler; + true + }, "keydown", QGVAR(progressBarKeyHandler)] call CBA_fnc_addKeyHandler; +}; (uiNamespace getVariable QGVAR(ctrlProgressBarTitle)) ctrlSetText _localizedTitle; @@ -53,7 +67,7 @@ _ctrlPos set [1, ((0 + 29 * GVAR(settingProgressBarLocation)) * ((((safezoneW / (uiNamespace getVariable QGVAR(ctrlProgressBarTitle)) ctrlCommit 0; [{ - (_this select 0) params ["_args", "_onFinish", "_onFail", "_condition", "_player", "_startTime", "_totalTime", "_exceptions", "_title"]; + (_this select 0) params ["_args", "_onFinish", "_onFail", "_condition", "_player", "_startTime", "_totalTime", "_exceptions", "_title", "_dialog"]; private _elapsedTime = CBA_missionTime - _startTime; private _errorCode = -1; @@ -71,8 +85,12 @@ _ctrlPos set [1, ((0 + 29 * GVAR(settingProgressBarLocation)) * ((((safezoneW / if !([_player, objNull, _exceptions] call EFUNC(common,canInteractWith)) then { _errorCode = 4; } else { - if (_elapsedTime >= _totalTime) then { - _errorCode = 0; + if (!_dialog && {dialog}) then { + _errorCode = 5; + } else { + if (_elapsedTime >= _totalTime) then { + _errorCode = 0; + }; }; }; }; @@ -84,7 +102,13 @@ _ctrlPos set [1, ((0 + 29 * GVAR(settingProgressBarLocation)) * ((((safezoneW / //Only close dialog if it's the progressBar: if (!isNull (uiNamespace getVariable [QGVAR(ctrlProgressBar), controlNull])) then { - closeDialog 0; + if (_dialog) then { + closeDialog 0; + } else { + QGVAR(progressBarDisplay) cutText ["", "PLAIN"]; + // Remove key handler for non-dialog bar + [QGVAR(progressBarKeyHandler), "keydown"] call CBA_fnc_removeKeyHandler; + }; }; [_this select 1] call CBA_fnc_removePerFrameHandler; @@ -116,4 +140,4 @@ _ctrlPos set [1, ((0 + 29 * GVAR(settingProgressBarLocation)) * ((((safezoneW / }; }; }; -}, 0, [_args, _onFinish, _onFail, _condition, _player, CBA_missionTime, _totalTime, _exceptions, _localizedTitle]] call CBA_fnc_addPerFrameHandler; +}, 0, [_args, _onFinish, _onFail, _condition, _player, CBA_missionTime, _totalTime, _exceptions, _localizedTitle, _dialog]] call CBA_fnc_addPerFrameHandler;