Safety - Add optional flag to hide hint (#9086)

* Add optional flag to hide hint

* Update addons/safemode/functions/fnc_setWeaponSafety.sqf

* Update addons/safemode/functions/fnc_unlockSafety.sqf

Co-authored-by: PabstMirror <pabstmirror@gmail.com>

* Update addons/safemode/functions/fnc_lockSafety.sqf

Co-authored-by: PabstMirror <pabstmirror@gmail.com>

Co-authored-by: jonpas <jonpas33@gmail.com>
Co-authored-by: PabstMirror <pabstmirror@gmail.com>
This commit is contained in:
Cyruz 2022-12-03 19:57:16 +00:00 committed by GitHub
parent 5693edc96d
commit 7f5a8e4099
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 10 deletions

View File

@ -7,6 +7,7 @@
* 0: Unit <OBJECT> * 0: Unit <OBJECT>
* 1: Weapon <STRING> * 1: Weapon <STRING>
* 2: Muzzle <STRING> * 2: Muzzle <STRING>
* 3: Show hint <BOOL>
* *
* Return Value: * Return Value:
* None * None
@ -17,7 +18,7 @@
* Public: No * Public: No
*/ */
params ["_unit", "_weapon", "_muzzle"]; params ["_unit", "_weapon", "_muzzle", ["_hint", true, [true]]];
private _safedWeapons = _unit getVariable [QGVAR(safedWeapons), []]; private _safedWeapons = _unit getVariable [QGVAR(safedWeapons), []];
@ -75,6 +76,9 @@ if (_muzzle isEqualType "") then {
// play fire mode selector sound // play fire mode selector sound
[_unit, _weapon, _muzzle] call FUNC(playChangeFiremodeSound); [_unit, _weapon, _muzzle] call FUNC(playChangeFiremodeSound);
// show info box // show info box unless disabled
if (_hint) then {
private _picture = getText (configFile >> "CfgWeapons" >> _weapon >> "picture"); private _picture = getText (configFile >> "CfgWeapons" >> _weapon >> "picture");
[localize LSTRING(PutOnSafety), _picture] call EFUNC(common,displayTextPicture); [localize LSTRING(PutOnSafety), _picture] call EFUNC(common,displayTextPicture);
};

View File

@ -7,6 +7,7 @@
* 0: Unit <OBJECT> * 0: Unit <OBJECT>
* 1: Weapon <STRING> * 1: Weapon <STRING>
* 2: State <BOOL> * 2: State <BOOL>
* 3: Show hint <BOOL> (default: true)
* *
* Return Value: * Return Value:
* None * None
@ -20,7 +21,8 @@
params [ params [
["_unit", objNull, [objNull]], ["_unit", objNull, [objNull]],
["_weapon", "", [""]], ["_weapon", "", [""]],
["_state", true, [true]] ["_state", true, [true]],
["_hint", true, [true]]
]; ];
if (_weapon == "") exitWith {}; if (_weapon == "") exitWith {};
@ -32,5 +34,5 @@ _weapon = configName (configFile >> "CfgWeapons" >> _weapon);
private _muzzle = currentMuzzle _unit; private _muzzle = currentMuzzle _unit;
if (_state isNotEqualTo (_weapon in _safedWeapons)) then { if (_state isNotEqualTo (_weapon in _safedWeapons)) then {
[_unit, _weapon, _muzzle] call FUNC(lockSafety); [_unit, _weapon, _muzzle, _hint] call FUNC(lockSafety);
}; };

View File

@ -7,6 +7,7 @@
* 0: Unit <OBJECT> * 0: Unit <OBJECT>
* 1: Weapon <STRING> * 1: Weapon <STRING>
* 2: Muzzle <STRING> * 2: Muzzle <STRING>
* 3: Show hint <BOOL>
* *
* Return Value: * Return Value:
* None * None
@ -17,7 +18,7 @@
* Public: No * Public: No
*/ */
params ["_unit", "_weapon", "_muzzle"]; params ["_unit", "_weapon", "_muzzle", ["_hint", true, [true]]];
private _safedWeapons = _unit getVariable [QGVAR(safedWeapons), []]; private _safedWeapons = _unit getVariable [QGVAR(safedWeapons), []];
_safedWeapons deleteAt (_safedWeapons find _weapon); _safedWeapons deleteAt (_safedWeapons find _weapon);
@ -77,6 +78,8 @@ if (inputAction "nextWeapon" > 0) then {
// player hud // player hud
[true] call FUNC(setSafeModeVisual); [true] call FUNC(setSafeModeVisual);
// show info box // show info box unless disabled
if (_hint) then {
private _picture = getText (configFile >> "CfgWeapons" >> _weapon >> "picture"); private _picture = getText (configFile >> "CfgWeapons" >> _weapon >> "picture");
[localize LSTRING(TookOffSafety), _picture] call EFUNC(common,displayTextPicture); [localize LSTRING(TookOffSafety), _picture] call EFUNC(common,displayTextPicture);
};