Pylons - Separate settings for in-game and zeus (#6365)

* Modernize pylons

* Revert docs/wiki/featurex/fortify.md

* Bring back ACE settings with movedToSQF

* 🤦

* Move settings to separate file, Fix postInit logic problems

* Tabs -> spaces
This commit is contained in:
Ozan Eğitmen 2018-05-31 18:43:02 +03:00 committed by PabstMirror
parent a5a8c68831
commit a917d586cb
7 changed files with 145 additions and 102 deletions

View File

@ -1,46 +1,17 @@
class ACE_Settings { class ACE_Settings {
class GVAR(enabled) {
category = CSTRING(Category_Pylons);
displayName = CSTRING(Enabled);
description = CSTRING(Enabled_description);
value = 1;
typeName = "BOOL";
};
class GVAR(rearmNewPylons) { class GVAR(rearmNewPylons) {
category = CSTRING(Category_Pylons); movedToSQF = 1;
displayName = CSTRING(RearmNewPylons);
description = CSTRING(RearmNewPylons_description);
value = 0;
typeName = "BOOL";
}; };
class GVAR(searchDistance) { class GVAR(searchDistance) {
category = CSTRING(Category_Pylons); movedToSQF = 1;
displayName = CSTRING(SearchDistance);
description = CSTRING(SearchDistance_description);
value = 15;
typeName = "SCALAR";
sliderSettings[] = {0, 50, 15, 1};
}; };
class GVAR(timePerPylon) { class GVAR(timePerPylon) {
category = CSTRING(Category_Pylons); movedToSQF = 1;
displayName = CSTRING(TimePerPylon);
description = CSTRING(TimePerPylon_description);
value = 5;
typeName = "SCALAR";
sliderSettings[] = {0, 10, 5, 1};
}; };
class GVAR(requireEngineer) { class GVAR(requireEngineer) {
category = CSTRING(Category_Pylons); movedToSQF = 1;
displayName = CSTRING(RequireEngineer);
description = CSTRING(RequireEngineer_description);
value = 0;
typeName = "BOOL";
}; };
class GVAR(requireToolkit) { class GVAR(requireToolkit) {
category = CSTRING(Category_Pylons); movedToSQF = 1;
displayName = CSTRING(RequireToolkit);
description = CSTRING(RequireToolkit_description);
value = 1;
typeName = "BOOL";
}; };
}; };

View File

@ -1,57 +1,53 @@
#include "script_component.hpp" #include "script_component.hpp"
["ace_settingsInitialized", { private _filter = "isClass (_x >> 'Components' >> 'TransportPylonsComponent') && {(getNumber (_x >> 'scope')) > 0}";
if (!GVAR(enabled)) exitWith {}; GVAR(aircraftWithPylons) = (_filter configClasses (configFile >> "CfgVehicles")) apply {configName _x};
{
[_x, "init", {
params ["_aircraft"];
private _filter = "isClass (_x >> 'Components' >> 'TransportPylonsComponent') && {(getNumber (_x >> 'scope')) > 0}"; private _loadoutAction = [
GVAR(aircraftWithPylons) = (_filter configClasses (configFile >> "CfgVehicles")) apply {configName _x}; QGVAR(loadoutAction),
{ localize LSTRING(ConfigurePylons),
[_x, "init", { "",
params ["_aircraft"]; {[_target] call FUNC(showDialog)},
private _loadoutAction = [
QGVAR(loadoutAction),
localize LSTRING(ConfigurePylons),
"",
{[_target] call FUNC(showDialog)},
{
private _vehicles = nearestObjects [_target, ["Air", "LandVehicle", "Slingload_base_F", "ReammoBox_F"], GVAR(searchDistance) + 10];
private _filter = ["transportAmmo", QEGVAR(rearm,defaultSupply)] select (["ace_rearm"] call EFUNC(common,isModLoaded));
private _rearmVehicles = {(getNumber (configFile >> "CfgVehicles" >> typeOf _x >> _filter)) > 0} count _vehicles;
(_rearmVehicles > 0 && {[ace_player, _target] call FUNC(canConfigurePylons)})
}
] call EFUNC(interact_menu,createAction);
[_aircraft, 0, ["ACE_MainActions"], _loadoutAction] call EFUNC(interact_menu,addActionToObject);
}, false, [], true] call CBA_fnc_addClassEventHandler;
} forEach GVAR(aircraftWithPylons);
[QGVAR(setPylonLoadOutEvent), {
params ["_aircraft", "_pylonIndex", "_pylon", "_turret", "_weaponToRemove"];
TRACE_5("setPylonLoadOutEvent",_aircraft,_pylonIndex,_pylon,_turret,_weaponToRemove);
_aircraft setPylonLoadOut [_pylonIndex, _pylon, false, _turret];
if (_weaponToRemove != "") then {
{ {
if (_aircraft turretLocal _x) then { if (!GVAR(enabledFromAmmoTrucks)) exitWith {false};
TRACE_3("removing",_aircraft,_x,_weaponToRemove);
_aircraft removeWeaponTurret [_weaponToRemove, _x];
};
} forEach [[-1], [0]];
};
}] call CBA_fnc_addEventHandler;
[QGVAR(setAmmoOnPylonEvent), { private _vehicles = nearestObjects [_target, ["Air", "LandVehicle", "Slingload_base_F", "ReammoBox_F"], GVAR(searchDistance) + 10];
params ["_aircraft", "_pylonIndex", "_count"]; private _filter = ["transportAmmo", QEGVAR(rearm,defaultSupply)] select (["ace_rearm"] call EFUNC(common,isModLoaded));
_aircraft setAmmoOnPylon [_pylonIndex, _count]; private _rearmVehicles = {(getNumber (configFile >> "CfgVehicles" >> typeOf _x >> _filter)) > 0} count _vehicles;
}] call CBA_fnc_addEventHandler;
if (isServer) then { (_rearmVehicles > 0 && {[ace_player, _target] call FUNC(canConfigurePylons)})
GVAR(currentAircraftNamespace) = true call CBA_fnc_createNamespace; }
publicVariable QGVAR(currentAircraftNamespace); ] call EFUNC(interact_menu,createAction);
addMissionEventHandler ["HandleDisconnect", {call FUNC(handleDisconnect)}]; [_aircraft, 0, ["ACE_MainActions"], _loadoutAction] call EFUNC(interact_menu,addActionToObject);
}, false, [], true] call CBA_fnc_addClassEventHandler;
} forEach GVAR(aircraftWithPylons);
[QGVAR(setPylonLoadOutEvent), {
params ["_aircraft", "_pylonIndex", "_pylon", "_turret", "_weaponToRemove"];
TRACE_5("setPylonLoadOutEvent",_aircraft,_pylonIndex,_pylon,_turret,_weaponToRemove);
_aircraft setPylonLoadOut [_pylonIndex, _pylon, false, _turret];
if (_weaponToRemove != "") then {
{
if (_aircraft turretLocal _x) then {
TRACE_3("removing",_aircraft,_x,_weaponToRemove);
_aircraft removeWeaponTurret [_weaponToRemove, _x];
};
} forEach [[-1], [0]];
}; };
GVAR(searchDistanceSqr) = GVAR(searchDistance) ^ 2;
}] call CBA_fnc_addEventHandler; }] call CBA_fnc_addEventHandler;
[QGVAR(setAmmoOnPylonEvent), {
params ["_aircraft", "_pylonIndex", "_count"];
_aircraft setAmmoOnPylon [_pylonIndex, _count];
}] call CBA_fnc_addEventHandler;
if (isServer) then {
GVAR(currentAircraftNamespace) = true call CBA_fnc_createNamespace;
publicVariable QGVAR(currentAircraftNamespace);
addMissionEventHandler ["HandleDisconnect", {call FUNC(handleDisconnect)}];
};

View File

@ -6,4 +6,6 @@ PREP_RECOMPILE_START;
#include "XEH_PREP.hpp" #include "XEH_PREP.hpp"
PREP_RECOMPILE_END; PREP_RECOMPILE_END;
#include "initSettings.sqf"
ADDON = true; ADDON = true;

View File

@ -6,7 +6,7 @@ class CfgPatches {
units[] = {}; units[] = {};
weapons[] = {}; weapons[] = {};
requiredVersion = REQUIRED_VERSION; requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_interact_menu"}; requiredAddons[] = {"ace_interact_menu", "ace_zeus"};
author = ECSTRING(common,ACETeam); author = ECSTRING(common,ACETeam);
authors[] = {"654wak654"}; authors[] = {"654wak654"};
url = ECSTRING(main,URL); url = ECSTRING(main,URL);

View File

@ -18,7 +18,15 @@
params ["_aircraft", ["_isCurator", false]]; params ["_aircraft", ["_isCurator", false]];
if (!GVAR(enabled) || {!(typeOf _aircraft in GVAR(aircraftWithPylons))}) exitWith {}; 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);
};
private _currentUser = _aircraft getVariable [QGVAR(currentUser), objNull]; private _currentUser = _aircraft getVariable [QGVAR(currentUser), objNull];
if (!isNull _currentUser) exitWith { if (!isNull _currentUser) exitWith {

View File

@ -0,0 +1,66 @@
[
QGVAR(enabledFromAmmoTrucks),
"CHECKBOX",
[LSTRING(EnabledFromAmmoTrucks), LSTRING(EnabledFromAmmoTrucks_description)],
LSTRING(Category_Pylons),
[true],
true
] call CBA_Settings_fnc_init;
[
QGVAR(enabledForZeus),
"CHECKBOX",
[LSTRING(EnabledForZeus), LSTRING(EnabledForZeus_description)],
LSTRING(Category_Pylons),
[true],
true
] call CBA_Settings_fnc_init;
[
QGVAR(rearmNewPylons),
"CHECKBOX",
[LSTRING(RearmNewPylons), LSTRING(RearmNewPylons_description)],
LSTRING(Category_Pylons),
[false],
true
] call CBA_Settings_fnc_init;
[
QGVAR(requireEngineer),
"CHECKBOX",
[LSTRING(RequireEngineer), LSTRING(RequireEngineer_description)],
LSTRING(Category_Pylons),
[false],
true
] call CBA_Settings_fnc_init;
[
QGVAR(requireToolkit),
"CHECKBOX",
[LSTRING(RequireToolkit), LSTRING(RequireToolkit_description)],
LSTRING(Category_Pylons),
[true],
true
] call CBA_Settings_fnc_init;
[
QGVAR(searchDistance),
"SLIDER",
[LSTRING(SearchDistance), LSTRING(SearchDistance_description)],
LSTRING(Category_Pylons),
[5, 50, 15, 0],
true,
{
params ["_searchDistance"];
GVAR(searchDistanceSqr) = _searchDistance ^ 2;
}
] call CBA_Settings_fnc_init;
[
QGVAR(timePerPylon),
"SLIDER",
[LSTRING(TimePerPylon), LSTRING(TimePerPylon_description)],
LSTRING(Category_Pylons),
[1, 10, 5, 0],
true
] call CBA_Settings_fnc_init;

View File

@ -91,23 +91,23 @@
<Japanese>車両が遠すぎます</Japanese> <Japanese>車両が遠すぎます</Japanese>
<German>Fahrzeug zu weit entfernt</German> <German>Fahrzeug zu weit entfernt</German>
</Key> </Key>
<Key ID="STR_ACE_Pylons_Enabled"> <Key ID="STR_ACE_Pylons_EnabledForZeus">
<English>Enable Pylons Menu</English> <English>Enable Pylons Menu for Zeus</English>
<Japanese>パイロン メニューを有効化</Japanese>
<Italian>Abilita Menu Piloni</Italian>
<Chinese>啟用派龍架選單</Chinese>
<Chinesesimp>启用派龙架选单</Chinesesimp>
<Korean>파일런 메뉴 활성</Korean>
<German>Aktiviere das Menü für Außenlaststationen.</German>
</Key> </Key>
<Key ID="STR_ACE_Pylons_Enabled_description"> <Key ID="STR_ACE_Pylons_EnabledForZeus_description">
<English>Enable pylon configuration menu for aircraft.</English> <English>Enables use of the zeus module.</English>
<Japanese>航空機へのパイロン設定メニューを有効化します。</Japanese> </Key>
<Italian>Abilita il menù di configurazione piloni per aereo.</Italian> <Key ID="STR_ACE_Pylons_EnabledFromAmmoTrucks">
<Chinese>啟用後可透過派龍架選單來定義飛機的武裝配置。</Chinese> <English>Enable Pylons Menu from Ammo Trucks</English>
<Chinesesimp>启用后可透过派龙架选单来定义飞机的武装配置。</Chinesesimp> </Key>
<Korean>항공기의 파일런 설정 메뉴를 활성합니다.</Korean> <Key ID="STR_ACE_Pylons_EnabledFromAmmoTrucks_description">
<German>Aktiviert die Konfiguration der Außenlaststationen. für Fluggeräte.</German> <English>Enables use of pylons menu from ammo trucks.</English>
</Key>
<Key ID="STR_ACE_Pylons_AircraftDoesntHavePylons">
<English>This aircraft doesn't have pylons</English>
</Key>
<Key ID="STR_ACE_Pylons_ConfigurePylonsDisabledForZeus">
<English>Configure pylons module is disabled for zeus</English>
</Key> </Key>
<Key ID="STR_ACE_Pylons_RearmNewPylons"> <Key ID="STR_ACE_Pylons_RearmNewPylons">
<English>Rearm New Pylons</English> <English>Rearm New Pylons</English>