mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Common - Add support for non-blocking progress bar (#9493)
* add support for non-blocking-progressbar * switch to cutRsc * Remove fade in/out * Update HintConfig.hpp * Add param to and cleanup header * Update addons/common/functions/fnc_progressBar.sqf Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> * remove key handler --------- Co-authored-by: Filip Maciejewski <veteran29@users.noreply.github.com> Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>
This commit is contained in:
parent
b53d760f4a
commit
3fcef89c97
@ -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);
|
||||
};
|
||||
|
||||
|
@ -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};);
|
||||
|
@ -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 <ARRAY>
|
||||
* 2: On Finish: Code called or STRING raised as event. <CODE, STRING>
|
||||
* 3: On Failure: Code called or STRING raised as event. <CODE, STRING>
|
||||
* 4: (Optional) Localized Title <STRING>
|
||||
* 5: Code to check each frame (Optional) <CODE>
|
||||
* 6: Exceptions for checking EFUNC(common,canInteractWith) (Optional)<ARRAY>
|
||||
* 4: Localized Title <STRING> (default: "")
|
||||
* 5: Code to check each frame <CODE> (default: {true})
|
||||
* 6: Exceptions for checking ace_common_fnc_canInteractWith <ARRAY> (default: [])
|
||||
* 7: Create progress bar as dialog, this blocks user input <BOOL> (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;
|
||||
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
|
||||
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;
|
||||
@ -70,6 +84,9 @@ _ctrlPos set [1, ((0 + 29 * GVAR(settingProgressBarLocation)) * ((((safezoneW /
|
||||
} else {
|
||||
if !([_player, objNull, _exceptions] call EFUNC(common,canInteractWith)) then {
|
||||
_errorCode = 4;
|
||||
} else {
|
||||
if (!_dialog && {dialog}) then {
|
||||
_errorCode = 5;
|
||||
} else {
|
||||
if (_elapsedTime >= _totalTime) then {
|
||||
_errorCode = 0;
|
||||
@ -78,13 +95,20 @@ _ctrlPos set [1, ((0 + 29 * GVAR(settingProgressBarLocation)) * ((((safezoneW /
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
if (_errorCode != -1) then {
|
||||
//Error or Success, close dialog and remove PFEH
|
||||
|
||||
//Only close dialog if it's the progressBar:
|
||||
if (!isNull (uiNamespace getVariable [QGVAR(ctrlProgressBar), controlNull])) then {
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user