grey out scripted eject action if eject actions are hidden

This commit is contained in:
commy2 2019-05-03 17:47:40 +02:00
parent 58ece34149
commit 585e919b35
4 changed files with 38 additions and 37 deletions

View File

@ -9,9 +9,3 @@ class Extended_PreInit_EventHandlers {
init = QUOTE(call COMPILE_FILE(XEH_preInit));
};
};
class Extended_PostInit_EventHandlers {
class ADDON {
clientInit = QUOTE(call COMPILE_FILE(XEH_postInitClient));
};
};

View File

@ -1,29 +0,0 @@
#include "script_component.hpp"
if (!hasInterface) exitWith {};
private _cfgAction = configFile >> "CfgActions" >> "Eject";
GVAR(ejectActionParams) = [
[
"", // will be set with setUserActionText
{
params ["_vehicle", "_unit"];
private _preserveEngineOn = (_unit == driver _vehicle) && {isEngineOn _vehicle};
moveOut _unit;
if (_preserveEngineOn) then {
// vehicle is local to last driver, no need to care
_vehicle engineOn true;
};
},
nil,
getNumber (_cfgAction >> "priority"),
false,
true,
getText (_cfgAction >> "shortcut"),
'[_this, _target] call DFUNC(canShowEject)'
],
getText (_cfgAction >> "text"),
getText (_cfgAction >> "textDefault")
];
["Helicopter", "initPost", LINKFUNC(initEjectAction)] call CBA_fnc_addClassEventHandler;

View File

@ -6,4 +6,41 @@ PREP_RECOMPILE_START;
#include "XEH_PREP.hpp"
PREP_RECOMPILE_END;
if (hasInterface) exitWith {
["CBA_settingsInitialized", {
private _ejectAction = configFile >> "CfgActions" >> "Eject";
private _hideEjectAction = missionNamespace getVariable [QEGVAR(vehicles,hideEjectAction), false];
private _text = getText (_ejectAction >> "text");
if (_hideEjectAction) then {
_text = format ["<t color='#808080'>%1</t>", _text];
};
GVAR(ejectActionParams) = [
[
"", // will be set with setUserActionText
{
params ["_vehicle", "_unit"];
private _preserveEngineOn = (_unit == driver _vehicle) && {isEngineOn _vehicle};
moveOut _unit;
if (_preserveEngineOn) then {
// vehicle is local to last driver, no need to care
_vehicle engineOn true;
};
},
nil,
[getNumber (_ejectAction >> "priority"), -999] select _hideEjectAction,
false,
true,
getText (_ejectAction >> "shortcut"),
'[_this, _target] call DFUNC(canShowEject)'
],
_text,
getText (_ejectAction >> "textDefault")
];
["Helicopter", "InitPost", LINKFUNC(initEjectAction), nil, nil, true] call CBA_fnc_addClassEventHandler;
}] call CBA_fnc_addEventHandler;
};
ADDON = true;

View File

@ -1,9 +1,8 @@
[
QGVAR(keepEngineRunning),
"CHECKBOX",
[LSTRING(SettingKeepEngineRunningName), LSTRING(SettingKeepEngineRunningDesc)],
localize ELSTRING(common,ACEKeybindCategoryVehicles),
ELSTRING(common,ACEKeybindCategoryVehicles),
false, // default value
true // isGlobal
] call CBA_fnc_addSetting;