Skip to content

Commit

Permalink
add options for showing time left and % done in progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
LinkIsGrim committed Sep 5, 2021
1 parent 2e6c025 commit 383b657
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
10 changes: 10 additions & 0 deletions addons/common/ACE_Settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ class ACE_Settings {
description = CSTRING(SettingProgressbarLocationDesc);
values[] = {ECSTRING(optionsmenu,Top), ECSTRING(optionsmenu,Bottom)};
};
class GVAR(settingProgressBarInfo) {
category = CSTRING(DisplayName);
value = 0;
typeName = "SCALAR";
force = 0;
isClientSettable = 1;
displayName = CSTRING(SettingProgressBarInfoName);
description = CSTRING(SettingProgressBarInfoDesc);
values[] = {CSTRING(None),CSTRING(SettingProgressbarInfoPercentage),CSTRING(SettingProgressbarInfoTime)};
}
class GVAR(displayTextColor) {
category = CSTRING(DisplayName);
value[] = {0,0,0,0.1};
Expand Down
16 changes: 13 additions & 3 deletions addons/common/functions/fnc_progressBar.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,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"];
(_this select 0) params ["_args", "_onFinish", "_onFail", "_condition", "_player", "_startTime", "_totalTime", "_exceptions", "_title"];

private _elapsedTime = CBA_missionTime - _startTime;
private _errorCode = -1;
Expand Down Expand Up @@ -95,6 +95,16 @@ _ctrlPos set [1, ((0 + 29 * GVAR(settingProgressBarLocation)) * ((((safezoneW /
};
} else {
//Update Progress Bar (ratio of elepased:total)
(uiNamespace getVariable QGVAR(ctrlProgressBar)) progressSetPosition (_elapsedTime / _totalTime);
private _ratio = _elapsedTime / _totalTime;
(uiNamespace getVariable QGVAR(ctrlProgressBar)) progressSetPosition _ratio;
switch (GVAR(settingProgressBarInfo)) do {
case 0: {};
case 1: {
(uiNamespace getVariable QGVAR(ctrlProgressBarTitle)) ctrlSetText (_title + format [" %1", floor (_ratio * 100)] + "%");
};
case 2: {
(uiNamespace getVariable QGVAR(ctrlProgressBarTitle)) ctrlSetText (_title + " " + format [localize LSTRING(TimeLeft), ceil (_totalTime - _elapsedTime)]);
};
};
};
}, 0, [_args, _onFinish, _onFail, _condition, _player, CBA_missionTime, _totalTime, _exceptions]] call CBA_fnc_addPerFrameHandler;
}, 0, [_args, _onFinish, _onFail, _condition, _player, CBA_missionTime, _totalTime, _exceptions, _localizedTitle]] call CBA_fnc_addPerFrameHandler;
18 changes: 18 additions & 0 deletions addons/common/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1456,5 +1456,23 @@
<Russian>Показывать действие в меню взаимодействия с собой.</Russian>
<Turkish>Kendi etkileşimim menüsünde animasyonları göster</Turkish>
</Key>
<Key ID="STR_ACE_Common_SettingProgressbarInfoName">
<English>Additional progress bar information</English>
</Key>
<Key ID="STR_ACE_Common_SettingProgressbarInfoDesc">
<English>Controls extra information shown in progress bar</English>
</Key>
<Key ID="STR_ACE_Common_SettingProgressbarInfoPercentage">
<English>Percentage</English>
</Key>
<Key ID="STR_ACE_Common_SettingProgressbarInfoTime">
<English>Time remaining</English>
</Key>
<Key ID="STR_ACE_Common_None">
<English>None</English>
</Key>
<Key ID="STR_ACE_Common_TimeLeft">
<English>Time left: %1s</English>
</Key>
</Package>
</Project>

0 comments on commit 383b657

Please sign in to comment.