ACE3/TO_MERGE/cse/gui/functions/fn_gui_loadingbar.sqf
Thomas Kooi db6f30fcc9 Added cse_gui source
Does not include the Icon pack. When using the UI it may throw up some missing .paa file errors. Replacements will need to be found if we want to use those.
2015-01-12 23:23:51 +01:00

46 lines
1.4 KiB
Plaintext

/**
* fn_gui_loadingbar.sqf
* @Descr: Displays a loading bar and halts script until loading bar has finished
* @Author: Glowbal
*
* @Arguments: [timeToWait NUMBER, condition CODE (Optional), onSuccess CODE (Optional), onFailure CODE (Optional), arguments ARRAY (Optional)]
* @Return: BOOl Returns true if loading bar has fully finished. Otherwise false
* @PublicAPI: true
*/
private ["_timeToWait","_cond","_onfailure","_onSuccess","_args","_dialog","_ctrl","_newStatus","_start","_return"];
_timeToWait = _this select 0;
_cond = [_this, 1, {true}, [{true}]] call BIS_fnc_Param;
_onSuccess = [_this, 2, {}, [{}]] call BIS_fnc_Param;
_onfailure = [_this, 3, {}, [{}]] call BIS_fnc_Param;
_args = [_this, 4, [], [[]]] call BIS_fnc_Param;
if (_timeToWait > 0) then {
disableSerialization;
1534 cutRsc ["cse_progressBar_Sample","plain"];
_dialog = uiNamespace getvariable "cse_progressBar_Sample";
_ctrl = _dialog displayCtrl 6;
_newStatus = 0;
_start = diag_tickTime;
while {(_newStatus <= 1.00 && (call _cond))} do {
uisleep 0.01;
_ctrl progressSetPosition _newStatus;
_newStatus = (diag_tickTime - _start) / _timeToWait;
};
1534 cutText ["","plain"];
_return = false;
if (_newStatus >= 1.00) then {
_return = true;
_args call _onSuccess;
} else {
_args call _onfailure;
};
} else {
if ((call _cond)) then {
_return = true;
_args call _onSuccess;
} else {
_args call _onfailure;
};
};
_return