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
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2018-04-19 19:01:26 +00:00
|
|
|
#define COMBO_ITEMS [[LSTRING(SelectedGroup), "\a3\ui_f_curator\data\displays\rscdisplaycurator\modegroups_ca.paa"], ["STR_WEST", "\a3\ui_f\data\map\diary\icons\playerwest_ca.paa"], ["STR_EAST", "\a3\ui_f\data\map\diary\icons\playereast_ca.paa"], ["STR_guerrila", "\a3\ui_f\data\map\diary\icons\playerguer_ca.paa"], ["STR_Civilian", "\a3\ui_f\data\map\diary\icons\playerciv_ca.paa"]]
|
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
|
2017-09-21 18:43:35 +00:00
|
|
|
private _unit = effectiveCommander (attachedTo _logic);
|
|
|
|
|
|
|
|
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
|
|
|
|
private _combo = _display displayCtrl 56220;
|
2017-09-21 18:43:35 +00:00
|
|
|
|
2018-04-19 19:01:26 +00:00
|
|
|
// Add target combo options (only add selected group option if placed on unit)
|
2017-09-21 18:43:35 +00:00
|
|
|
{
|
2018-04-19 19:01:26 +00:00
|
|
|
_x params ["_text", "_icon"];
|
|
|
|
_combo lbSetPicture [_combo lbAdd (localize _text), _icon];
|
|
|
|
} forEach (COMBO_ITEMS select [[0, 1] select (isNull _unit), 5]);
|
2017-09-21 18:43:35 +00:00
|
|
|
|
2018-04-19 19:01:26 +00:00
|
|
|
_combo lbSetCurSel 0;
|
2017-09-21 18:43:35 +00:00
|
|
|
|
2018-04-19 19:01:26 +00:00
|
|
|
// Set default flashlight status
|
|
|
|
if !(isNull _unit) then {
|
|
|
|
(_display displayCtrl 56218) lbSetCurSel ([0, 1] select (_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];
|