2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2017-09-21 18:43:35 +00:00
|
|
|
/*
|
2018-04-19 19:01:26 +00:00
|
|
|
* Author: alganthe, mharis001
|
|
|
|
* Initializes the "Toggle Flashlights" Zeus module display.
|
2017-09-21 18:43:35 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
2018-04-19 19:01:26 +00:00
|
|
|
* 0: toggleFlashlight 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_toggleFlashlight
|
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
|
|
|
|
|
|
|
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 flashlight status
|
|
|
|
if (isNull _unit) then {
|
|
|
|
(_display displayCtrl 56220) lbDelete 0;
|
|
|
|
} else {
|
2024-02-04 17:50:24 +00:00
|
|
|
(_display displayCtrl 56218) lbSetCurSel (parseNumber (_unit isFlashlightOn currentWeapon _unit));
|
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 56218) > 0;
|
|
|
|
private _addGear = lbCurSel (_display displayCtrl 56219) > 0;
|
|
|
|
private _combo = _display displayCtrl 56220;
|
|
|
|
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, _addGear, _target] call FUNC(moduleToggleFlashlight);
|
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];
|