2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2017-10-11 19:05:54 +00:00
|
|
|
/*
|
|
|
|
* Author: 654wak654
|
|
|
|
* Shows the aircraft loadout dialog for given aircraft.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Aircraft <OBJECT>
|
|
|
|
* 1: Is curator. Disables time and resource requirements. <BOOL> (default: false)
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [vehicle ace_player] call ace_pylons_fnc_showDialog
|
|
|
|
*
|
|
|
|
* Public: Yes
|
|
|
|
*/
|
|
|
|
|
|
|
|
params ["_aircraft", ["_isCurator", false]];
|
|
|
|
|
2019-02-11 20:19:19 +00:00
|
|
|
if (_isCurator && {!(["ace_zeus"] call EFUNC(common,isModLoaded))}) exitWith { WARNING("ace_zeus not loaded"); };
|
|
|
|
|
2018-05-31 15:43:02 +00:00
|
|
|
if !(typeOf _aircraft in GVAR(aircraftWithPylons)) exitWith {
|
|
|
|
if (_isCurator) then {
|
|
|
|
[LSTRING(AircraftDoesntHavePylons)] call EFUNC(zeus,showMessage);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
if (_isCurator && {!GVAR(enabledForZeus)}) exitWith {
|
|
|
|
[LSTRING(ConfigurePylonsDisabledForZeus)] call EFUNC(zeus,showMessage);
|
|
|
|
};
|
2017-10-11 19:05:54 +00:00
|
|
|
|
|
|
|
private _currentUser = _aircraft getVariable [QGVAR(currentUser), objNull];
|
|
|
|
if (!isNull _currentUser) exitWith {
|
|
|
|
[format [localize LSTRING(InUse), name _currentUser], false, 5] call EFUNC(common,displayText);
|
|
|
|
};
|
|
|
|
_aircraft setVariable [QGVAR(currentUser), ace_player, true];
|
|
|
|
GVAR(currentAircraftNamespace) setVariable [getPlayerUID ace_player, _aircraft, true];
|
|
|
|
|
|
|
|
GVAR(isCurator) = _isCurator;
|
|
|
|
GVAR(currentAircraft) = _aircraft;
|
|
|
|
|
|
|
|
createDialog QGVAR(DialogLoadout);
|
|
|
|
private _display = DISPLAY(ID_DIALOG);
|
|
|
|
_display displayAddEventHandler ["Unload", LINKFUNC(onButtonClose)];
|
|
|
|
|
|
|
|
if (GVAR(rearmNewPylons) || {_isCurator}) then {
|
|
|
|
ctrlShow [ID_TEXT_BANNER, false];
|
|
|
|
};
|
|
|
|
|
|
|
|
private _config = configFile >> "CfgVehicles" >> typeOf _aircraft;
|
|
|
|
private _pylonComponent = _config >> "Components" >> "TransportPylonsComponent";
|
|
|
|
|
|
|
|
ctrlSetText [ID_PICTURE_AIRCRAFT, getText (_pylonComponent >> "uiPicture")];
|
|
|
|
|
|
|
|
private _hasFRIES = getNumber (_config >> QEGVAR(fastroping,enabled));
|
|
|
|
if (["ace_fastroping"] call EFUNC(common,isModLoaded) && {_hasFRIES > 1}) then {
|
|
|
|
private _checkbox = _display displayCtrl ID_CHECKBOX_FRIES;
|
|
|
|
private _fries = _aircraft getVariable [QEGVAR(fastroping,FRIES), objNull];
|
|
|
|
_checkbox cbSetChecked (!isNull _fries);
|
|
|
|
_checkbox setVariable [QGVAR(originalState), !isNull _fries];
|
|
|
|
} else {
|
|
|
|
ctrlShow [ID_CHECKBOX_FRIES, false];
|
|
|
|
ctrlShow [ID_TEXT_FRIES, false];
|
|
|
|
};
|
|
|
|
|
|
|
|
GVAR(comboBoxes) = [];
|
|
|
|
{
|
2017-10-24 13:39:15 +00:00
|
|
|
private _combo = _display ctrlCreate [QGVAR(CtrlCombo), -1];
|
2017-10-11 19:05:54 +00:00
|
|
|
private _picturePos = ctrlPosition (_display displayCtrl ID_PICTURE_AIRCRAFT);
|
|
|
|
private _uiPos = getArray (_x >> "UIposition");
|
2017-10-24 16:22:02 +00:00
|
|
|
MAP(_uiPos,if (_x isEqualType 0) then {_x} else {call compile _x}); // Handle string positions
|
2017-10-11 19:05:54 +00:00
|
|
|
_combo ctrlSetPosition [
|
|
|
|
(_picturePos select 0) + (_uiPos select 0),
|
|
|
|
(_picturePos select 1) + (_uiPos select 1),
|
|
|
|
0.1 * safezoneW,
|
|
|
|
0.028 * safezoneH
|
|
|
|
];
|
|
|
|
_combo ctrlCommit 0;
|
|
|
|
|
|
|
|
_combo lbAdd localize LSTRING(Empty);
|
|
|
|
_combo lbSetData [0, ""];
|
|
|
|
|
|
|
|
private _mag = (getPylonMagazines _aircraft) select _forEachIndex;
|
|
|
|
private _mags = _aircraft getCompatiblePylonMagazines (_forEachIndex + 1);
|
2018-01-28 21:38:48 +00:00
|
|
|
private _userWhitelist = _aircraft getVariable [QGVAR(magazineWhitelist), _mags];
|
|
|
|
private _userBlacklist = _aircraft getVariable [QGVAR(magazineBlacklist), []];
|
2018-05-31 15:43:02 +00:00
|
|
|
|
2018-01-28 21:38:48 +00:00
|
|
|
_mags = _mags arrayIntersect _userWhitelist;
|
|
|
|
_mags = _mags - _userBlacklist;
|
2018-05-31 15:43:02 +00:00
|
|
|
|
2017-10-11 19:05:54 +00:00
|
|
|
private _index = 0;
|
|
|
|
{
|
|
|
|
_combo lbAdd getText (configFile >> "CfgMagazines" >> _x >> "displayName");
|
|
|
|
_combo lbSetData [_forEachIndex + 1, _x];
|
|
|
|
|
|
|
|
if (_x == _mag) then {
|
|
|
|
_index = _forEachIndex + 1;
|
|
|
|
};
|
|
|
|
} forEach _mags;
|
|
|
|
_combo lbSetCurSel _index;
|
|
|
|
_combo ctrlAddEventHandler ["LBSelChanged", LINKFUNC(onComboSelChange)];
|
|
|
|
// TODO: Allow pylon priority selection?
|
|
|
|
|
|
|
|
private _mirroredIndex = getNumber (_x >> "mirroredMissilePos");
|
|
|
|
|
|
|
|
private _button = controlNull;
|
|
|
|
if (count allTurrets [_aircraft, false] > 0) then {
|
|
|
|
_button = _display ctrlCreate ["ctrlButtonPictureKeepAspect", -1];
|
|
|
|
private _turret = [_aircraft, _forEachIndex] call EFUNC(common,getPylonTurret);
|
|
|
|
[_button, false, _turret] call FUNC(onButtonTurret);
|
|
|
|
_button ctrlAddEventHandler ["ButtonClick", {[_this select 0, true, []] call FUNC(onButtonTurret)}];
|
|
|
|
_button ctrlSetPosition [
|
|
|
|
(_picturePos select 0) + (_uiPos select 0) - (0.0165 * safezoneW),
|
|
|
|
(_picturePos select 1) + (_uiPos select 1),
|
|
|
|
0.0165 * safezoneW,
|
|
|
|
0.028 * safezoneH
|
|
|
|
];
|
|
|
|
_button ctrlCommit 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
GVAR(comboBoxes) pushBack [_combo, _mirroredIndex - 1, _button, _index];
|
|
|
|
} forEach ("true" configClasses (_pylonComponent >> "Pylons"));
|
|
|
|
|
|
|
|
GVAR(defaultLoadoutNames) = [];
|
|
|
|
{
|
|
|
|
lbAdd [ID_LIST_LOADOUTS, getText (_x >> "displayName")];
|
|
|
|
lbSetPicture [ID_LIST_LOADOUTS, _forEachIndex, "a3\data_f_jets\logos\jets_logo_small_ca.paa"];
|
|
|
|
|
|
|
|
GVAR(defaultLoadoutNames) pushBack getText (_x >> "displayName");
|
|
|
|
} forEach ("true" configClasses (_pylonComponent >> "Presets"));
|
|
|
|
|
|
|
|
{
|
|
|
|
if ((_x select 3) == typeOf _aircraft) then {
|
|
|
|
lbAdd [ID_LIST_LOADOUTS, _x select 0];
|
|
|
|
};
|
|
|
|
} forEach (profileNamespace getVariable [QGVAR(aircraftLoadouts), []]);
|
|
|
|
|
|
|
|
private _displayName = getText (_config >> "displayName");
|
|
|
|
ctrlSetText [ID_TEXT_LISTTITLE, format [localize LSTRING(LoadoutsFor), _displayName]];
|
|
|
|
|
|
|
|
private _list = _display displayCtrl ID_LIST_LOADOUTS;
|
|
|
|
_list ctrlAddEventHandler ["LBSelChanged", {
|
|
|
|
params ["_ctrl"];
|
|
|
|
|
|
|
|
ctrlSetText [ID_EDIT_LOADOUTNAME, _ctrl lbText (lbCurSel _ctrl)];
|
|
|
|
call FUNC(onNameChange);
|
|
|
|
}];
|
|
|
|
|
|
|
|
private _edit = _display displayCtrl ID_EDIT_LOADOUTNAME;
|
|
|
|
_edit ctrlAddEventHandler ["KeyUp", LINKFUNC(onNameChange)];
|
|
|
|
_edit ctrlAddEventHandler ["KeyDown", LINKFUNC(onNameChange)];
|
|
|
|
|
|
|
|
private _checkbox = _display displayCtrl ID_CHECKBOX_MIRROR;
|
|
|
|
_checkbox ctrlAddEventHandler ["CheckedChanged", {[(_this select 1) == 1] call FUNC(onPylonMirror)}];
|
2017-10-26 04:13:44 +00:00
|
|
|
|
|
|
|
if (!GVAR(isCurator)) then {
|
|
|
|
[{
|
|
|
|
isNull (GVAR(currentAircraft) getVariable [QGVAR(currentUser), objNull]) ||
|
|
|
|
{(ace_player distanceSqr GVAR(currentAircraft)) > GVAR(searchDistanceSqr)}
|
|
|
|
}, {
|
2018-02-10 01:17:57 +00:00
|
|
|
TRACE_3("disconnect/far",GVAR(currentAircraft),ace_player distance GVAR(currentAircraft),GVAR(currentAircraft) getVariable QGVAR(currentUser));
|
|
|
|
if ((ace_player distanceSqr GVAR(currentAircraft)) > GVAR(searchDistanceSqr)) then {
|
|
|
|
[localize LSTRING(TooFar), false, 5] call EFUNC(common,displayText);
|
|
|
|
};
|
2017-10-26 04:13:44 +00:00
|
|
|
call FUNC(onButtonClose);
|
|
|
|
}] call CBA_fnc_waitUntilAndExecute;
|
|
|
|
};
|