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

Common - Add settings for additional progress bar information #8428

Merged
merged 9 commits into from
Oct 10, 2021
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)] + "%");
LinkIsGrim marked this conversation as resolved.
Show resolved Hide resolved
};
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>
LinkIsGrim marked this conversation as resolved.
Show resolved Hide resolved
</Key>
<Key ID="STR_ACE_Common_TimeLeft">
<English>Time left: %1s</English>
</Key>
</Package>
</Project>