Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add failure code argument to fnc_progressBar #1177

Merged
merged 1 commit into from
Jul 7, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions addons/ui/fnc_progressBar.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ Arguments:
#1 - true: success, false: failure <BOOLEAN>
#2 - elapsed time, not more than _totalTime <NUMBER>
#3 - total time, same as _totalTime <NUMBER>
#4 - failure code <NUMBER>
0 - no failure
1 - user hit ESC key
2 - condition was false
3 - progressbar closed by new progressbar
Returns:
Nothing
Expand Down Expand Up @@ -75,7 +80,7 @@ if (!isNil QGVAR(ProgressBarParams)) then {
GVAR(ProgressBarParams) params ["_arguments", "", "", "_onFailure", "_startTime", "_totalTime"];
private _elapsedTime = (CBA_missionTime - _startTime) min _totalTime;

[_onFailure, [_arguments, false, _elapsedTime, _totalTime]] call CBA_fnc_execNextFrame;
[_onFailure, [_arguments, false, _elapsedTime, _totalTime, 3]] call CBA_fnc_execNextFrame;
Copy link
Contributor

@Dystopian Dystopian Jul 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these magic numbers should be macro

};

GVAR(ProgressBarParams) = [_arguments, _condition, _onSuccess, _onFailure, CBA_missionTime, _totalTime, _blockMouse, _blockKeys, _allowClose];
Expand All @@ -101,14 +106,14 @@ _ctrlScript ctrlAddEventHandler ["Draw", {
GVAR(ProgressBarParams) = nil;
{QGVAR(ProgressBar) cutText ["", "PLAIN"]} call CBA_fnc_execNextFrame; // game would crash if display is killed from Draw event
_blockInputDisplay closeDisplay 0;
[_onFailure, [_arguments, false, _elapsedTime, _totalTime]] call CBA_fnc_execNextFrame;
[_onFailure, [_arguments, false, _elapsedTime, _totalTime, 2]] call CBA_fnc_execNextFrame;
};

if (_elapsedTime >= _totalTime) exitWith {
GVAR(ProgressBarParams) = nil;
{QGVAR(ProgressBar) cutText ["", "PLAIN"]} call CBA_fnc_execNextFrame; // game would crash if display is killed from Draw event
_blockInputDisplay closeDisplay 0;
[_onSuccess, [_arguments, true, _elapsedTime, _totalTime]] call CBA_fnc_execNextFrame;
[_onSuccess, [_arguments, true, _elapsedTime, _totalTime, 0]] call CBA_fnc_execNextFrame;
};

private _ctrlBar = _display displayCtrl IDC_PROGRESSBAR_BAR;
Expand All @@ -135,7 +140,7 @@ if (_blockMouse) then {
GVAR(ProgressBarParams) = nil;
QGVAR(ProgressBar) cutText ["", "PLAIN"];
_blockInputDisplay closeDisplay 0;
[_onFailure, [_arguments, false, _elapsedTime, _totalTime]] call CBA_fnc_execNextFrame;
[_onFailure, [_arguments, false, _elapsedTime, _totalTime, 1]] call CBA_fnc_execNextFrame;

_blockKeys = false;
} else {
Expand Down