2017-09-21 18:43:35 +00:00
|
|
|
/*
|
2018-04-19 19:01:26 +00:00
|
|
|
* Author: alganthe, mharis001
|
|
|
|
* Initializes the "Toggle NVGs" Zeus module display.
|
2017-09-21 18:43:35 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
2018-04-19 19:01:26 +00:00
|
|
|
* 0: toggleNvg controls group <CONTROL>
|
2017-09-21 18:43:35 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
2018-04-19 19:01:26 +00:00
|
|
|
* [CONTROL] call ace_zeus_fnc_ui_toggleNvg
|
2017-09-21 18:43:35 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
2018-04-19 19:01:26 +00:00
|
|
|
*/
|
2017-09-21 18:43:35 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
|
|
|
params ["_control"];
|
|
|
|
|
2018-04-19 19:01:26 +00:00
|
|
|
// Generic init
|
|
|
|
private _display = ctrlParent _control;
|
|
|
|
private _ctrlButtonOK = _display displayCtrl 1; // IDC_OK
|
|
|
|
private _logic = GETMVAR(BIS_fnc_initCuratorAttributes_target,objNull);
|
|
|
|
TRACE_1("Logic Object",_logic);
|
2017-09-21 18:43:35 +00:00
|
|
|
|
2018-04-19 19:01:26 +00:00
|
|
|
_control ctrlRemoveAllEventHandlers "SetFocus";
|
2017-09-21 18:43:35 +00:00
|
|
|
|
2018-04-19 19:01:26 +00:00
|
|
|
// Validate module target
|
2018-09-13 13:40:55 +00:00
|
|
|
private _unit = effectiveCommander attachedTo _logic;
|
2017-09-21 18:43:35 +00:00
|
|
|
|
|
|
|
scopeName "Main";
|
|
|
|
private _fnc_errorAndClose = {
|
|
|
|
params ["_msg"];
|
|
|
|
_display closeDisplay 0;
|
|
|
|
deleteVehicle _logic;
|
2017-09-27 00:36:36 +00:00
|
|
|
[_msg] call FUNC(showMessage);
|
2017-09-21 18:43:35 +00:00
|
|
|
breakOut "Main";
|
|
|
|
};
|
|
|
|
|
|
|
|
if !(isNull _unit) then {
|
|
|
|
switch (false) do {
|
|
|
|
case (_unit isKindOf "CAManBase"): {
|
|
|
|
[LSTRING(OnlyInfantry)] call _fnc_errorAndClose;
|
|
|
|
};
|
|
|
|
case (alive _unit): {
|
|
|
|
[LSTRING(OnlyAlive)] call _fnc_errorAndClose;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2018-04-19 19:01:26 +00:00
|
|
|
// Specific onLoad stuff
|
2018-09-13 13:40:55 +00:00
|
|
|
// Remove selected group option in not placed on unit and set default NVG status
|
|
|
|
if (isNull _unit) then {
|
|
|
|
(_display displayCtrl 92856) lbDelete 0;
|
|
|
|
} else {
|
2018-04-19 19:01:26 +00:00
|
|
|
(_display displayCtrl 92855) lbSetCurSel ([0, 1] select !(hmd _unit isEqualTo ""));
|
2017-09-21 18:43:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
private _fnc_onUnload = {
|
2018-04-19 19:01:26 +00:00
|
|
|
private _logic = GETMVAR(BIS_fnc_initCuratorAttributes_target,objNull);
|
2017-09-21 18:43:35 +00:00
|
|
|
if (isNull _logic) exitWith {};
|
|
|
|
|
2017-09-27 00:36:36 +00:00
|
|
|
deleteVehicle _logic;
|
2017-09-21 18:43:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
private _fnc_onConfirm = {
|
|
|
|
params [["_ctrlButtonOK", controlNull, [controlNull]]];
|
|
|
|
|
2018-04-19 19:01:26 +00:00
|
|
|
private _display = ctrlParent _ctrlButtonOK;
|
2017-09-21 18:43:35 +00:00
|
|
|
if (isNull _display) exitWith {};
|
|
|
|
|
2018-04-19 19:01:26 +00:00
|
|
|
private _logic = GETMVAR(BIS_fnc_initCuratorAttributes_target,objNull);
|
2017-09-21 18:43:35 +00:00
|
|
|
if (isNull _logic) exitWith {};
|
|
|
|
|
2018-04-19 19:01:26 +00:00
|
|
|
private _toggle = lbCurSel (_display displayCtrl 92855) > 0;
|
|
|
|
private _combo = _display displayCtrl 92856;
|
|
|
|
private _target = lbCurSel _combo;
|
|
|
|
if (lbSize _combo > 4) then {DEC(_target)};
|
2017-09-21 18:43:35 +00:00
|
|
|
|
2018-04-19 19:01:26 +00:00
|
|
|
[_logic, _toggle, _target] call FUNC(moduleToggleNvg);
|
2017-09-21 18:43:35 +00:00
|
|
|
};
|
|
|
|
|
2018-04-19 19:01:26 +00:00
|
|
|
_display displayAddEventHandler ["Unload", _fnc_onUnload];
|
|
|
|
_ctrlButtonOK ctrlAddEventHandler ["ButtonClick", _fnc_onConfirm];
|