123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- params ["_progressVar","_progressCompleteVar", "_building", "_args", "_onFinish", "_onFail", ["_localizedTitle", ""], ["_condition", {true}], ["_exceptions", []]];
- private _player = ACE_player;
- closeDialog 0;
- createDialog "ace_common_ProgressBar_Dialog";
- (uiNamespace getVariable "ace_common_ctrlProgressBarTitle") ctrlSetText _localizedTitle;
- private _ctrlPos = ctrlPosition (uiNamespace getVariable "ace_common_ctrlProgressBarTitle");
- _ctrlPos set [1, ((0 + 29 * ace_common_settingProgressBarLocation) * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + (safezoneY + (safezoneH - (((safezoneW / safezoneH) min 1.2) / 1.2))/2))];
- (uiNamespace getVariable "ace_common_ctrlProgressBG") ctrlSetPosition _ctrlPos;
- (uiNamespace getVariable "ace_common_ctrlProgressBG") ctrlCommit 0;
- (uiNamespace getVariable "ace_common_ctrlProgressBar") ctrlSetPosition _ctrlPos;
- (uiNamespace getVariable "ace_common_ctrlProgressBar") ctrlCommit 0;
- (uiNamespace getVariable "ace_common_ctrlProgressBarTitle") ctrlSetPosition _ctrlPos;
- (uiNamespace getVariable "ace_common_ctrlProgressBarTitle") ctrlCommit 0;
- [{
- (_this select 0) params ["_progressVar", "_progressCompleteVar", "_args", "_onFinish", "_onFail", "_condition", "_player", "_building", "_exceptions"];
- private _progress = _building getVariable[_progressVar, -1];
- private _progressComplete = _building getVariable[_progressCompleteVar, 100];
- private _errorCode = -1;
-
- if (isNull (uiNamespace getVariable ["ace_common_ctrlProgressBar", controlNull])) then {
- _errorCode = 1;
- } else {
- if (ACE_player != _player || !alive _player) then {
- _errorCode = 2;
- } else {
- if !([_args, _progress, _errorCode] call _condition) then {
- _errorCode = 3;
- } else {
- if !([_player, objNull, _exceptions] call ace_common_fnc_canInteractWith) then {
- _errorCode = 4;
- } else {
- if (_progress >= _progressComplete) then {
- _errorCode = 0;
- };
- };
- };
- };
- };
- if (_errorCode != -1) then {
-
-
- if (!isNull (uiNamespace getVariable ["ace_common_ctrlProgressBar", controlNull])) then {
- closeDialog 0;
- };
- [_this select 1] call CBA_fnc_removePerFrameHandler;
- if (_errorCode == 0) then {
- if (_onFinish isEqualType "") then {
- [_onFinish, [_args, _errorCode]] call CBA_fnc_localEvent;
- } else {
- [_args, _errorCode] call _onFinish;
- };
- } else {
- if (_onFail isEqualType "") then {
- [_onFail, [_args, _progress, _errorCode]] call CBA_fnc_localEvent;
- } else {
- [_args, _progress, _errorCode] call _onFail;
- };
- };
- } else {
- private _progressResult = ((_progress / _progressComplete)) min 1;
- (uiNamespace getVariable "ace_common_ctrlProgressBar") progressSetPosition _progressResult;
- };
- }, 0, [_progressVar, _progressCompleteVar, _args, _onFinish, _onFail, _condition, _player, _building, _exceptions]] call CBA_fnc_addPerFrameHandler;
|