Skip to content

Commit 8391a92

Browse files
committed
Adds a parameter changedelay to change in-game wait time #20
1 parent 8363350 commit 8391a92

File tree

6 files changed

+93
-83
lines changed

6 files changed

+93
-83
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class XtdGearModels
6464
label = "Option A label";
6565
values[] = {"value1", "value2"};
6666
changeingame = 0; // 1 if value can be changed in game via ACE menu
67+
// changedelay = 2; If can changeingame, wait delay before change is effective (can be 0, 0.1, or more)
6768
// icon = "xxx"; If can changeingame, action group icon in ACE menu
6869
class value1
6970
{
@@ -73,6 +74,7 @@ class XtdGearModels
7374
// icon = "xxx"; If can changeingame, action icon in ACE menu
7475
// actionlabel = "xxx"; If can changeingame, action label in ACE menu
7576
// itemingame = "xxx"; If can changeingame, requires this item to be present in inventory. Item will be removed from inventory (added back if an other value is choosen)
77+
// changedelay = (inherited by default); If can changeingame, wait delay before change is effective
7678
};
7779
class value2
7880
{

addons/gearinfo/functions/fnc_getModelOptions.sqf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ READ(Number)
3636
private _optionLabel = [_optionDef1, _optionDef2, "label", _optionName] call _readText;
3737
private _optionIcon = [_optionDef1, _optionDef2, "icon", ""] call _readText;
3838
private _optionInGame = [_optionDef1, _optionDef2, "changeingame", 0] call _readNumber;
39+
private _optionDelay = [_optionDef1, _optionDef2, "changedelay", 2] call _readNumber;
3940
private _values = [];
4041
private _optionCenterImage = getNumber (_optionDef1 >> "centerImage");
4142
private _optionValues = getArray (_optionDef1 >> "values");
@@ -57,9 +58,10 @@ READ(Number)
5758
private _valueDesc = [_valueDef1, _valueDef2, "description", ""] call _readText;
5859
private _valueAction = [_valueDef1, _valueDef2, "actionLabel", format ["%1 %2", _optionLabel, _valueLabel]] call _readText;
5960
private _valueInGame = [_valueDef1, _valueDef2, "changeingame", _optionInGame] call _readNumber;
60-
private _itemInGame = [_valueDef1, _valueDef2, "itemingame", ""] call _readText;
61+
private _valueDelay = [_valueDef1, _valueDef2, "changedelay", _optionDelay] call _readNumber;
62+
private _itemInGame = [_valueDef1, _valueDef2, "itemingame", ""] call _readText;
6163

62-
_values pushBack [_valueName, _valueLabel, _valueImage, _valueIcon, _valueDesc, _valueAction, _valueInGame, _itemInGame];
64+
_values pushBack [_valueName, _valueLabel, _valueImage, _valueIcon, _valueDesc, _valueAction, _valueInGame, _itemInGame, _valueDelay];
6365

6466
} forEach _optionValues;
6567

addons/ingame/functions/fnc_aceSelfActions.sqf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ private _loadout = getUnitLoadout _player;
3838
private _itemBack = "";
3939
{
4040
private _valueIndex = _foreachIndex;
41-
_x params ["_valueName", "", "", "_valueIcon", "", "_valueAction", "_valueInGame", "_itemInGame"];
41+
_x params ["_valueName", "", "", "_valueIcon", "", "_valueAction", "_valueInGame", "_itemInGame", "_valueDelay"];
4242

4343
if ( _valueInGame > 0 ) then {
4444

@@ -47,7 +47,7 @@ private _loadout = getUnitLoadout _player;
4747
_previewOptions set [_optionIndex, _valueName];
4848
private _previewConfig = [_classRoot, _model, _previewOptions] call EFUNC(gearinfo,findConfigName);
4949
if ( _previewConfig != "") then {
50-
_optionActions pushBack [_valueAction, _valueIcon, _previewConfig, _itemInGame];
50+
_optionActions pushBack [_valueAction, _valueIcon, _previewConfig, _itemInGame, _valueDelay];
5151
};
5252
} else {
5353
_itemBack = _itemInGame;

addons/ingame/functions/fnc_changeGear.sqf

Lines changed: 83 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -2,112 +2,118 @@
22
#include "script_component.hpp"
33

44
params ["", "", "_params"];
5-
_params params ["_player", "_layout", "_actionLabel", "_config"];
5+
_params params ["_player", "_layout", "_actionLabel", "_config", "", "", ["_delay", 2]];
66

77
private _callback = {
8-
params ["_args"];
9-
_args params ["_player", "_layout", "", "_config", "_giveBack", "_consume"];
8+
params ["_args"];
9+
_args params ["_player", "_layout", "", "_config", "_giveBack", "_consume"];
1010

11-
private _insignia = [_player] call BIS_fnc_getUnitInsignia;
12-
// setUnitLoadout will clear insignia, but BIS_fnc_setUnitInsignia does
13-
// not known about this and would ignore the next call
14-
[_player, ""] call BIS_fnc_setUnitInsignia;
11+
private _insignia = [_player] call BIS_fnc_getUnitInsignia;
12+
// setUnitLoadout will clear insignia, but BIS_fnc_setUnitInsignia does
13+
// not known about this and would ignore the next call
14+
[_player, ""] call BIS_fnc_setUnitInsignia;
1515

16-
private _loadout = getUnitLoadout _player;
16+
private _loadout = getUnitLoadout _player;
1717

18-
_layout params ["", "_loadoutIndex", "_loadoutSecondary"];
18+
_layout params ["", "_loadoutIndex", "_loadoutSecondary"];
1919

20-
if ( _loadoutSecondary == -1 ) then {
21-
_loadout set [_loadoutIndex, _config];
22-
} else {
23-
(_loadout select _loadoutIndex) set [_loadoutSecondary, _config];
24-
};
20+
if ( _loadoutSecondary == -1 ) then {
21+
_loadout set [_loadoutIndex, _config];
22+
} else {
23+
(_loadout select _loadoutIndex) set [_loadoutSecondary, _config];
24+
};
2525

26-
// setUnitLoadout causes NVGs to turn off.
27-
// Let's figure out if the player was using NVGs and set the
28-
// state again after setting the loadout.
29-
private _nvgState = currentVisionMode _player;
30-
31-
// setUnitLoadout causes TFAR backpacks to lose settings.
32-
// Before setting the player's loadout, let's grab their TFAR radio
33-
// settings so we can copy the settings to the "new" radio bag.
34-
// TFAR code snippets were adapted from TFAR_fnc_CopySettings.
35-
private _playerBag = (_loadout select 5) select 0;
36-
private _tfarSource = [];
37-
private _lrSettingsSource = [];
38-
39-
// Check if TFAR is active
40-
private _tfarIsActive = isClass (configFile >> "CfgPatches" >> "tfar_core");
41-
if (_tfarIsActive) then
26+
// setUnitLoadout causes NVGs to turn off.
27+
// Let's figure out if the player was using NVGs and set the
28+
// state again after setting the loadout.
29+
private _nvgState = currentVisionMode _player;
30+
31+
// setUnitLoadout causes TFAR backpacks to lose settings.
32+
// Before setting the player's loadout, let's grab their TFAR radio
33+
// settings so we can copy the settings to the "new" radio bag.
34+
// TFAR code snippets were adapted from TFAR_fnc_CopySettings.
35+
private _playerBag = (_loadout select 5) select 0;
36+
private _tfarSource = [];
37+
private _lrSettingsSource = [];
38+
39+
// Check if TFAR is active
40+
private _tfarIsActive = isClass (configFile >> "CfgPatches" >> "tfar_core");
41+
if (_tfarIsActive) then
42+
{
43+
// Check if player has backpack and backpack is TFAR radio
44+
if ([_playerBag] call TFAR_fnc_isLRRadio) then
4245
{
43-
// Check if player has backpack and backpack is TFAR radio
44-
if ([_playerBag] call TFAR_fnc_isLRRadio) then
45-
{
46-
// Get player backpack radio and settigns
47-
_tfarSource = _player call TFAR_fnc_backpackLr;
48-
_lrSettingsSource = _tfarSource call TFAR_fnc_getLrSettings;
49-
};
46+
// Get player backpack radio and settigns
47+
_tfarSource = _player call TFAR_fnc_backpackLr;
48+
_lrSettingsSource = _tfarSource call TFAR_fnc_getLrSettings;
5049
};
50+
};
5151

52-
_player setUnitLoadout _loadout;
52+
_player setUnitLoadout _loadout;
5353

54-
[_player] call EFUNC(gearinfo,applyTextureOptions);
54+
[_player] call EFUNC(gearinfo,applyTextureOptions);
5555

56-
[_player, _insignia] call BIS_fnc_setUnitInsignia;
56+
[_player, _insignia] call BIS_fnc_setUnitInsignia;
5757

58-
// Why would we make someone stand up?
59-
// What if they are laying down to avoid fire?
60-
/*
61-
if ( currentWeapon _player != "" ) then {
62-
_player playMoveNow "amovpercmstpslowwrfldnon";
63-
};
64-
*/
58+
// Why would we make someone stand up?
59+
// What if they are laying down to avoid fire?
60+
/*
61+
if ( currentWeapon _player != "" ) then {
62+
_player playMoveNow "amovpercmstpslowwrfldnon";
63+
};
64+
*/
6565

66-
if ( _consume != "" ) then {
67-
_player removeItem _consume;
68-
};
69-
if ( _giveBack != "" ) then {
70-
_player addItem _giveBack;
71-
};
66+
if ( _consume != "" ) then {
67+
_player removeItem _consume;
68+
};
69+
if ( _giveBack != "" ) then {
70+
_player addItem _giveBack;
71+
};
7272

73-
// Check if TFAR is active
74-
if (_tfarIsActive) then
75-
{
76-
// Check if player has backpack and backpack is TFAR radio
77-
private _newLoadout = getUnitLoadout _player;
78-
_playerBag = (_newLoadout select 5) select 0;
79-
80-
if ([_playerBag] call TFAR_fnc_isLRRadio) then
81-
{
82-
// Get player backpack radio and set settings
83-
private _tfarDestination = _player call TFAR_fnc_backpackLr;
84-
[_tfarDestination,[]+_lrSettingsSource] call TFAR_fnc_setLRSettings;
85-
};
86-
};
73+
// Check if TFAR is active
74+
if (_tfarIsActive) then
75+
{
76+
// Check if player has backpack and backpack is TFAR radio
77+
private _newLoadout = getUnitLoadout _player;
78+
_playerBag = (_newLoadout select 5) select 0;
8779

88-
// Check if player has NVGs. If they do and they were using them, turn back on.
89-
// We also need to make sure that whatever is in the NVG slot has NVG capabilities.
90-
private _nvgItem = hmd _player;
91-
private _hasNVGs = (_nvgItem != "");
92-
private _canNVG = "NVG" in (getArray (configFile >> "CfgWeapons" >> _nvgItem >> "visionMode"));
93-
if (_hasNVGs && {_canNVG && {_nvgState > 0}}) then
80+
if ([_playerBag] call TFAR_fnc_isLRRadio) then
9481
{
95-
_player action ["nvGoggles", _player];
82+
// Get player backpack radio and set settings
83+
private _tfarDestination = _player call TFAR_fnc_backpackLr;
84+
[_tfarDestination,[]+_lrSettingsSource] call TFAR_fnc_setLRSettings;
9685
};
86+
};
9787

88+
// Check if player has NVGs. If they do and they were using them, turn back on.
89+
// We also need to make sure that whatever is in the NVG slot has NVG capabilities.
90+
private _nvgItem = hmd _player;
91+
private _hasNVGs = (_nvgItem != "");
92+
private _canNVG = "NVG" in (getArray (configFile >> "CfgWeapons" >> _nvgItem >> "visionMode"));
93+
if (_hasNVGs && {_canNVG && {_nvgState > 0}}) then
94+
{
95+
_player action ["nvGoggles", _player];
9896
};
9997

98+
};
99+
100+
if ( _delay == 0 ) then {
101+
// Instant
102+
[_params] call _callback;
103+
}
104+
else {
100105
// ace_common_fnc_progressBar does not function while a player is in a vehicle.
101106
// To get around this, we will execute the progress bar only while on foot.
102107
// While in a vehicle, we will simply wait 2 seconds before swapping player items.
103108
private _isOnFoot = isNull objectParent _player;
104109
if (_isOnFoot) then
105110
{
106-
[2, _params, _callback, {}, _actionLabel + "..."] call ace_common_fnc_progressBar;
111+
[_delay, _params, _callback, {}, _actionLabel + "..."] call ace_common_fnc_progressBar;
107112
} else {
108113
[_params,_callback] spawn {
109114
params ["_params","_callback"];
110-
sleep 2;
115+
sleep _delay;
111116
[_params] call _callback;
112117
};
113-
};
118+
};
119+
};

addons/ingame/functions/fnc_generateActions.sqf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ private _actions = [];
2020
FUNC(changeGear),
2121
{true},
2222
{},
23-
[_player, _layout, _x select 0, _x select 2, _giveBack, _consume]
23+
[_player, _layout, _x select 0, _x select 2, _giveBack, _consume, _x select 4]
2424
] call ace_interact_menu_fnc_createAction, [], _target];
2525
};
2626
} forEach _optionActions;

addons/main/script_version.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#define MAJOR 0
2-
#define MINOR 6
2+
#define MINOR 7
33
#define PATCH 0
44
#define BUILD 0

0 commit comments

Comments
 (0)